Bug 1170855 - Part 6: Implement Sampler binding tracking. r=jgilbert

This commit is contained in:
Dan Glastonbury 2015-06-09 10:18:19 +10:00
parent 4226f9eb5f
commit d020e96d87
5 changed files with 14 additions and 3 deletions

View File

@ -36,6 +36,12 @@ WebGL2Context::DeleteSampler(WebGLSampler* sampler)
if (!sampler || sampler->IsDeleted())
return;
for (int n = 0; n < mGLMaxTextureUnits; n++) {
if (mBoundSamplers[n] == sampler) {
mBoundSamplers[n] = nullptr;
}
}
sampler->RequestDelete();
}
@ -74,6 +80,8 @@ WebGL2Context::BindSampler(GLuint unit, WebGLSampler* sampler)
return ErrorInvalidOperation("bindSampler: binding deleted sampler");
WebGLContextUnchecked::BindSampler(unit, sampler);
mBoundSamplers[unit] = sampler;
}
void

View File

@ -109,9 +109,7 @@ WebGL2Context::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
return WebGLObjectAsJSValue(cx, mBoundReadFramebuffer.get(), rv);
case LOCAL_GL_SAMPLER_BINDING:
// TODO: Implement bound sampler tracking
//return WebGLObjectAsJSValue(cx, mBoundSamplers[mActiveTexture].get(), rv);
return JS::NullValue();
return WebGLObjectAsJSValue(cx, mBoundSamplers[mActiveTexture].get(), rv);
case LOCAL_GL_TEXTURE_BINDING_2D_ARRAY:
// TODO: Implement gl.TEXTURE_2D_ARRAY

View File

@ -325,6 +325,7 @@ WebGLContext::DestroyResourcesAndContext()
mBound2DTextures.Clear();
mBoundCubeMapTextures.Clear();
mBound3DTextures.Clear();
mBoundSamplers.Clear();
mBoundArrayBuffer = nullptr;
mBoundCopyReadBuffer = nullptr;
mBoundCopyWriteBuffer = nullptr;
@ -1949,6 +1950,7 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(WebGLContext,
mBound2DTextures,
mBoundCubeMapTextures,
mBound3DTextures,
mBoundSamplers,
mBoundArrayBuffer,
mBoundCopyReadBuffer,
mBoundCopyWriteBuffer,

View File

@ -1435,6 +1435,7 @@ protected:
nsTArray<WebGLRefPtr<WebGLTexture> > mBound2DTextures;
nsTArray<WebGLRefPtr<WebGLTexture> > mBoundCubeMapTextures;
nsTArray<WebGLRefPtr<WebGLTexture> > mBound3DTextures;
nsTArray<WebGLRefPtr<WebGLSampler> > mBoundSamplers;
void ResolveTexturesForDraw() const;

View File

@ -1755,6 +1755,7 @@ WebGLContext::InitAndValidateGL()
mBound2DTextures.Clear();
mBoundCubeMapTextures.Clear();
mBound3DTextures.Clear();
mBoundSamplers.Clear();
mBoundArrayBuffer = nullptr;
mBoundTransformFeedbackBuffer = nullptr;
@ -1798,6 +1799,7 @@ WebGLContext::InitAndValidateGL()
mBound2DTextures.SetLength(mGLMaxTextureUnits);
mBoundCubeMapTextures.SetLength(mGLMaxTextureUnits);
mBound3DTextures.SetLength(mGLMaxTextureUnits);
mBoundSamplers.SetLength(mGLMaxTextureUnits);
if (MinCapabilityMode()) {
mGLMaxTextureSize = MINVALUE_GL_MAX_TEXTURE_SIZE;