mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
2fdb3f6084
- Bug 1048721 - Implement WebGL2Sync. r=jgilbert (b15a0a106) - Bug 1156626 - Add ES3 buffer binding values to strong type. r=jgilbert (2495c6e3b) - Bug 1144889 - Do proper sRGB detection. - r=kamidphish (db7956d1c) - Bug 1159117 - Enable support for legacy formats. r=jgilbert (8a1cc3f16) - Bug 974832 - Implement necessary GL features to provide timer queries. r=dglastonbury (eaed796c8) - Bug 974832 - Add support for WebGL's EXT_disjoint_timer_query. r=dglastonbury, r=smaug (35f1a540c) - Bug 974832 - Add tests for WebGL's EXT_disjoint_timer_query. r=dglastonbury (a7201f461) - Bug 1167504 - Part 9: Remove BindableName - Queries. r=jgilbert (c5e304f55) - Bug 1168845 - Update WebGL interface names to follow the spec. r=smaug, r=dglastonbury (494859b27) - Bug 1150310 - Return context cached value for stencil* queries. r=jgilbert (f5afa0562) - Bug 1150310 - Only check stencil LSB 8bit value. r=jgilbert (fa9506d8b) - Bug 1167504 - Part 10: Remove WebGLBindableName.h. r=jgilbert (dc1fee18e) - Bug 1048745 - Non square UniformMatrix. r=jgilbert (0dac5c36b) - Bug 1048745 - Uniform with GLuint. r=jgilbert (41de94bc1) - Bug 1048745 - Uniform array with Uint32Array. r=jgilbert, r=smaug (0fa503e7e) - Bug 1048745 - Query GL for glGetUniformuiv function. r=jgilbert (8086c9053) - Bug 1145501 - Extend validation of BufferData usage. r=jgilbert (5f57241fc) - Bug 1155470 - Fix queries. r=jgilbert (ccf7dad00) - Bug 1153386 - All the GLES3 uniform types. r=jgilbert (2b223ed42) - Bug 1048747 - Cleanup how uniform interface blocks are handled. r=jgilbert (6ac86d50e) - Bug 1048724 - Sort out Transform Feedback Varyings. r=jgilbert (bcdd6dfdf) - Bug 1167504 - Part 12: Return new buffer binding points from getParameter. r=jgilbert (3d01ff848) - Bug 1170855 - Part 1: Extract WebGL 2 specific pnames. r=jgilbert (935a74b45) - Bug 1170855 - Part 2: Be consistent when handling pnames from extensions. r=jgilbert (06522e47b) - Bug 1170855 - Part 3: Cleanup and better comments. r=jgilbert (3e422adf8) - Bug 1170855 - Part 4: Pour in the WebGL 2 pnames. r=jgilbert (2119d2f3d) - Bug 1170855 - Part 5: Correctly load glGetInteger64v. r=jgilbert (3e44d32e3) - Bug 1009734 - Wait until draw to warn about texture completeness. - r=kamidphish (d7dc3eaa8) - Bug 1170855 - Part 6: Implement Sampler binding tracking. r=jgilbert (6f1a1e713) - Bug 1170855 - Part 7: Implement MAX_CLIENT_WAIT_TIMEOUT_WEBGL. r=jgilbert, r=smaug (7ca761b1f) - Bug 1170855 - Part 8: MAX_SERVER_WAIT_TIMEOUT is unsigned. r=jgilbert (16939ba9f) - Bug 1170855 - Part 9: MAX_VARYING_COMPONENTS workaround. r=jgilbert (2cc7e870c) - Bug 1170855 - Part A: Don't error on MAX_ELEMENT_INDEX. r=jgilbert (acefb1580) - Bug 1170855 - Part B: READ_BUFFER requires emulation for default FB. r=jgilbert (795bb5793) - Bug 1170855 - Part C: Move _WEBGL GLenums from GLConsts.h to WebGLContext.h. r=jgilbert (3eada1f47) - Bug 1182950 - Fix compile error in non-unified build. r=botond (018bb21ea)
218 lines
7.1 KiB
C++
218 lines
7.1 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef WEBGL_PROGRAM_H_
|
|
#define WEBGL_PROGRAM_H_
|
|
|
|
#include <map>
|
|
#include "mozilla/CheckedInt.h"
|
|
#include "mozilla/LinkedList.h"
|
|
#include "mozilla/dom/WebGL2RenderingContextBinding.h"
|
|
#include "nsString.h"
|
|
#include "nsWrapperCache.h"
|
|
#include <set>
|
|
#include <vector>
|
|
#include "WebGLObjectModel.h"
|
|
#include "WebGLShader.h"
|
|
|
|
namespace mozilla {
|
|
|
|
class WebGLActiveInfo;
|
|
class WebGLProgram;
|
|
class WebGLUniformLocation;
|
|
|
|
namespace webgl {
|
|
|
|
struct UniformBlockInfo final
|
|
: public RefCounted<UniformBlockInfo>
|
|
{
|
|
MOZ_DECLARE_REFCOUNTED_TYPENAME(UniformBlockInfo);
|
|
|
|
const nsCString mBaseUserName;
|
|
const nsCString mBaseMappedName;
|
|
|
|
UniformBlockInfo(const nsACString& baseUserName,
|
|
const nsACString& baseMappedName)
|
|
: mBaseUserName(baseUserName)
|
|
, mBaseMappedName(baseMappedName)
|
|
{}
|
|
};
|
|
|
|
struct LinkedProgramInfo final
|
|
: public RefCounted<LinkedProgramInfo>
|
|
, public SupportsWeakPtr<LinkedProgramInfo>
|
|
{
|
|
MOZ_DECLARE_REFCOUNTED_TYPENAME(LinkedProgramInfo)
|
|
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(LinkedProgramInfo)
|
|
|
|
WebGLProgram* const prog;
|
|
std::vector<nsRefPtr<WebGLActiveInfo>> activeAttribs;
|
|
std::vector<nsRefPtr<WebGLActiveInfo>> activeUniforms;
|
|
|
|
// Needed for Get{Attrib,Uniform}Location. The keys for these are non-mapped
|
|
// user-facing `GLActiveInfo::name`s, without any final "[0]".
|
|
std::map<nsCString, const WebGLActiveInfo*> attribMap;
|
|
std::map<nsCString, const WebGLActiveInfo*> uniformMap;
|
|
std::map<nsCString, const nsCString>* fragDataMap;
|
|
|
|
std::vector<RefPtr<UniformBlockInfo>> uniformBlocks;
|
|
|
|
// Needed for draw call validation.
|
|
std::set<GLuint> activeAttribLocs;
|
|
|
|
explicit LinkedProgramInfo(WebGLProgram* aProg);
|
|
|
|
bool FindAttrib(const nsCString& baseUserName,
|
|
const WebGLActiveInfo** const out_activeInfo) const
|
|
{
|
|
auto itr = attribMap.find(baseUserName);
|
|
if (itr == attribMap.end())
|
|
return false;
|
|
|
|
*out_activeInfo = itr->second;
|
|
return true;
|
|
}
|
|
|
|
bool FindUniform(const nsCString& baseUserName,
|
|
const WebGLActiveInfo** const out_activeInfo) const
|
|
{
|
|
auto itr = uniformMap.find(baseUserName);
|
|
if (itr == uniformMap.end())
|
|
return false;
|
|
|
|
*out_activeInfo = itr->second;
|
|
return true;
|
|
}
|
|
|
|
bool FindUniformBlock(const nsCString& baseUserName,
|
|
RefPtr<const UniformBlockInfo>* const out_info) const
|
|
{
|
|
const size_t count = uniformBlocks.size();
|
|
for (size_t i = 0; i < count; i++) {
|
|
if (baseUserName == uniformBlocks[i]->mBaseUserName) {
|
|
*out_info = uniformBlocks[i].get();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool FindFragData(const nsCString& baseUserName,
|
|
nsCString* const out_baseMappedName) const
|
|
{
|
|
if (!fragDataMap) {
|
|
*out_baseMappedName = baseUserName;
|
|
return true;
|
|
}
|
|
|
|
MOZ_CRASH("Not implemented.");
|
|
}
|
|
|
|
bool HasActiveAttrib(GLuint loc) const {
|
|
auto itr = activeAttribLocs.find(loc);
|
|
return itr != activeAttribLocs.end();
|
|
}
|
|
};
|
|
|
|
} // namespace webgl
|
|
|
|
class WebGLShader;
|
|
|
|
typedef nsDataHashtable<nsCStringHashKey, nsCString> CStringMap;
|
|
|
|
class WebGLProgram final
|
|
: public nsWrapperCache
|
|
, public WebGLRefCountedObject<WebGLProgram>
|
|
, public LinkedListElement<WebGLProgram>
|
|
, public WebGLContextBoundObject
|
|
{
|
|
public:
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLProgram)
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLProgram)
|
|
|
|
explicit WebGLProgram(WebGLContext* webgl);
|
|
|
|
void Delete();
|
|
|
|
// GL funcs
|
|
void AttachShader(WebGLShader* shader);
|
|
void BindAttribLocation(GLuint index, const nsAString& name);
|
|
void DetachShader(WebGLShader* shader);
|
|
already_AddRefed<WebGLActiveInfo> GetActiveAttrib(GLuint index) const;
|
|
already_AddRefed<WebGLActiveInfo> GetActiveUniform(GLuint index) const;
|
|
void GetAttachedShaders(nsTArray<nsRefPtr<WebGLShader>>* const out) const;
|
|
GLint GetAttribLocation(const nsAString& name) const;
|
|
GLint GetFragDataLocation(const nsAString& name) const;
|
|
void GetProgramInfoLog(nsAString* const out) const;
|
|
JS::Value GetProgramParameter(GLenum pname) const;
|
|
GLuint GetUniformBlockIndex(const nsAString& name) const;
|
|
void GetActiveUniformBlockName(GLuint uniformBlockIndex, nsAString& name) const;
|
|
void GetActiveUniformBlockParam(GLuint uniformBlockIndex, GLenum pname,
|
|
Nullable<dom::OwningUnsignedLongOrUint32ArrayOrBoolean>& retval) const;
|
|
void GetActiveUniformBlockActiveUniforms(JSContext* cx, GLuint uniformBlockIndex,
|
|
Nullable<dom::OwningUnsignedLongOrUint32ArrayOrBoolean>& retval,
|
|
ErrorResult& rv) const;
|
|
already_AddRefed<WebGLUniformLocation> GetUniformLocation(const nsAString& name) const;
|
|
void UniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformBlockBinding) const;
|
|
|
|
bool LinkProgram();
|
|
bool UseProgram() const;
|
|
void ValidateProgram() const;
|
|
|
|
////////////////
|
|
|
|
bool FindAttribUserNameByMappedName(const nsACString& mappedName,
|
|
nsDependentCString* const out_userName) const;
|
|
bool FindUniformByMappedName(const nsACString& mappedName,
|
|
nsCString* const out_userName,
|
|
bool* const out_isArray) const;
|
|
bool FindUniformBlockByMappedName(const nsACString& mappedName,
|
|
nsCString* const out_userName,
|
|
bool* const out_isArray) const;
|
|
|
|
void TransformFeedbackVaryings(const dom::Sequence<nsString>& varyings,
|
|
GLenum bufferMode);
|
|
already_AddRefed<WebGLActiveInfo> GetTransformFeedbackVarying(GLuint index);
|
|
|
|
bool IsLinked() const { return mMostRecentLinkInfo; }
|
|
|
|
const webgl::LinkedProgramInfo* LinkInfo() const {
|
|
return mMostRecentLinkInfo.get();
|
|
}
|
|
|
|
WebGLContext* GetParentObject() const {
|
|
return Context();
|
|
}
|
|
|
|
virtual JSObject* WrapObject(JSContext* js, JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
private:
|
|
~WebGLProgram() {
|
|
DeleteOnce();
|
|
}
|
|
|
|
bool LinkAndUpdate();
|
|
|
|
public:
|
|
const GLuint mGLName;
|
|
|
|
private:
|
|
WebGLRefPtr<WebGLShader> mVertShader;
|
|
WebGLRefPtr<WebGLShader> mFragShader;
|
|
std::map<nsCString, GLuint> mBoundAttribLocs;
|
|
std::vector<nsCString> mTransformFeedbackVaryings;
|
|
GLenum mTransformFeedbackBufferMode;
|
|
nsCString mLinkLog;
|
|
RefPtr<const webgl::LinkedProgramInfo> mMostRecentLinkInfo;
|
|
// Storage for transform feedback varyings before link.
|
|
// (Work around for bug seen on nVidia drivers.)
|
|
std::vector<std::string> mTempMappedVaryings;
|
|
};
|
|
|
|
} // namespace mozilla
|
|
|
|
#endif // WEBGL_PROGRAM_H_
|