Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't crash GAPIS if we open a OpenGL ES 1.X trace #1549

Merged
merged 2 commits into from
Jan 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions gapis/api/gles/api/other.api
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
35 changes: 21 additions & 14 deletions gapis/api/gles/api/state_queries.api
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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: {
Expand All @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion gapis/api/gles/tweaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down