diff --git a/gapis/api/gles/api/other.api b/gapis/api/gles/api/other.api index 69c1f00cb8..65682d1a9c 100644 --- a/gapis/api/gles/api/other.api +++ b/gapis/api/gles/api/other.api @@ -113,6 +113,10 @@ sub GLboolean GetCapability(GLenum capability, GLuint index) { switch (capability) { @if(Version.GLES20) case GL_BLEND: { + i := as!DrawBufferIndex(index) + if !(i in ctx.Pixel.Blend) { + glErrorInvalidValue!DrawBufferIndex(i) + } } @if(Version.GLES20) case GL_CULL_FACE, diff --git a/gapis/api/gles/api/state_queries.api b/gapis/api/gles/api/state_queries.api index f8c69e825e..8a646356aa 100644 --- a/gapis/api/gles/api/state_queries.api +++ b/gapis/api/gles/api/state_queries.api @@ -191,6 +191,13 @@ sub GLboolean IsEnabledi(GLenum capability, GLuint index) { return GetCapability(capability, index) } +sub ref!BlendState getBlendStateOrInvalidValue(ref!Context ctx, DrawBufferIndex index) { + if !(index in ctx.Pixel.Blend) { + glErrorInvalidValue!DrawBufferIndex(index) + } + return ctx.Pixel.Blend[index] +} + sub void GetStateVariable!T(GLenum name, bool isIndexed, GLuint index, T* v) { ctx := GetContext() switch (name) { @@ -244,8 +251,8 @@ sub void GetStateVariable!T(GLenum name, bool isIndexed, GLuint index, T* v) { } @if(Version.GLES20) case GL_BLEND: { - i := as!DrawBufferIndex(index) // SPEC: Man page does not mention indexing. - v[0] = as!T(ctx.Pixel.Blend[i].Enabled) + // SPEC: Man page does not mention indexing. + v[0] = as!T(getBlendStateOrInvalidValue(ctx, as!DrawBufferIndex(index)).Enabled) } @if(Version.GLES20) case GL_BLEND_COLOR: { @@ -257,33 +264,33 @@ sub void GetStateVariable!T(GLenum name, bool isIndexed, GLuint index, T* v) { } @if(Version.GLES20) case GL_BLEND_DST_ALPHA: { - i := as!DrawBufferIndex(index) // SPEC: Man page does not mention indexing. - v[0] = as!T(ctx.Pixel.Blend[i].DstAlpha) + // SPEC: Man page does not mention indexing. + v[0] = as!T(getBlendStateOrInvalidValue(ctx, as!DrawBufferIndex(index)).DstAlpha) } @if(Version.GLES20) case GL_BLEND_DST_RGB: { - i := as!DrawBufferIndex(index) // SPEC: Man page does not mention indexing. - v[0] = as!T(ctx.Pixel.Blend[i].DstRgb) + // SPEC: Man page does not mention indexing. + v[0] = as!T(getBlendStateOrInvalidValue(ctx, as!DrawBufferIndex(index)).DstRgb) } @if(Version.GLES20) case GL_BLEND_EQUATION_ALPHA: { - i := as!DrawBufferIndex(index) // SPEC: Man page does not mention indexing. - v[0] = as!T(ctx.Pixel.Blend[i].EquationAlpha) + // SPEC: Man page does not mention indexing. + v[0] = as!T(getBlendStateOrInvalidValue(ctx, as!DrawBufferIndex(index)).EquationAlpha) } @if(Version.GLES20) case GL_BLEND_EQUATION_RGB: { - i := as!DrawBufferIndex(index) // SPEC: Man page does not mention indexing. - v[0] = as!T(ctx.Pixel.Blend[i].EquationRgb) + // SPEC: Man page does not mention indexing. + v[0] = as!T(getBlendStateOrInvalidValue(ctx, as!DrawBufferIndex(index)).EquationRgb) } @if(Version.GLES20) case GL_BLEND_SRC_ALPHA: { - i := as!DrawBufferIndex(index) // SPEC: Man page does not mention indexing. - v[0] = as!T(ctx.Pixel.Blend[i].SrcAlpha) + // SPEC: Man page does not mention indexing. + v[0] = as!T(getBlendStateOrInvalidValue(ctx, as!DrawBufferIndex(index)).SrcAlpha) } @if(Version.GLES20) case GL_BLEND_SRC_RGB: { - i := as!DrawBufferIndex(index) // SPEC: Man page does not mention indexing. - v[0] = as!T(ctx.Pixel.Blend[i].SrcRgb) + // SPEC: Man page does not mention indexing. + v[0] = as!T(getBlendStateOrInvalidValue(ctx, as!DrawBufferIndex(index)).SrcRgb) } @if(Version.GLES20) case GL_BLUE_BITS: { diff --git a/gapis/api/gles/tweaker.go b/gapis/api/gles/tweaker.go index d9992316bb..105fad51ba 100644 --- a/gapis/api/gles/tweaker.go +++ b/gapis/api/gles/tweaker.go @@ -68,7 +68,7 @@ func (t *tweaker) getCapability(ctx context.Context, name GLenum) bool { i := GLuint(0) // capability index. res, err := subGetCapability(ctx, a, t.dID, o, s, GetState(s), a.thread, nil, name, i) if err != nil { - panic(err) + return false } return res != 0 }