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

Gles fixes #1546

Merged
merged 3 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
10 changes: 7 additions & 3 deletions gapil/resolver/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ func index(rv *resolver, in *ast.Index) semantic.Expression {
rv.with(semantic.Uint64Type, func() {
index = expression(rv, in.Index)
})
if bop, ok := index.(*semantic.BinaryOp); ok && bop.Operator == ast.OpSlice {
rv.errorf(in, "cannot slice static arrays")
return semantic.Invalid{}
}

it := index.ExpressionType()
if isNumber(semantic.Underlying(it)) {
if v, ok := index.(semantic.Uint64Value); ok && uint32(v) >= at.Size {
Expand Down Expand Up @@ -332,9 +337,8 @@ func index(rv *resolver, in *ast.Index) semantic.Expression {
rv.mappings.add(in, out)
return out
}
if n, ok := index.(semantic.Uint64Value); ok && n == 0 {
// pointer[0]
// TODO: clean up the magical 0 index on pointers
if n, ok := index.(semantic.Uint64Value); ok {
// pointer[n]
r := &semantic.BinaryOp{LHS: n, Operator: ast.OpSlice, RHS: n + 1}
slice := &semantic.PointerRange{AST: in, Pointer: object, Type: at.Slice, Range: r}
out := &semantic.SliceIndex{AST: in, Slice: slice, Type: at.Slice, Index: n}
Expand Down
5 changes: 5 additions & 0 deletions gapil/resolver/resolve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ cmd void foo() { a := A(1,2,3) a[2] = 2 }`,
source: `type u32[3] A
cmd void foo() { a := A(1,2,3) i := a[3] }`,
errors: err("array index 3 is out of bounds for u32[3]"),
}, {
name: "StaticArray sliced. Error: cannot slice static arrays",
source: `type u32[3] A
cmd void foo() { a := A(1,2,3) i := a[1:2] }`,
errors: err("cannot slice static arrays"),
},
} {
test.check(ctx)
Expand Down
12 changes: 8 additions & 4 deletions gapis/api/gles/api/textures_and_samplers.api
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,10 @@ sub void TexParameterv!T(GLenum target, GLenum pname, T params) {
@if(Version.GLES32)
case GL_TEXTURE_BORDER_COLOR: {
// TODO: Handle - has different behaviour based on the I suffix.
t.BorderColor[0] = as!GLfloat(params[0])
t.BorderColor[1] = as!GLfloat(params[1])
t.BorderColor[2] = as!GLfloat(params[2])
t.BorderColor[3] = as!GLfloat(params[3])
}
@if(Extension.GL_EXT_texture_filter_anisotropic)
case GL_TEXTURE_MAX_ANISOTROPY_EXT: {
Expand Down Expand Up @@ -1805,8 +1809,8 @@ sub void TexParameterIuiv(GLenum target, GLenum pname, const GLuint* params) {
@doc("https://www.khronos.org/opengles/sdk/docs/man32/html/glTexParameter.xhtml", Version.GLES32)
cmd void glTexParameterf(GLenum target, GLenum parameter, GLfloat value) {
if parameter == GL_TEXTURE_BORDER_COLOR { glErrorInvalidEnum(parameter) } // not scalar
params := Vec1f(value)
TexParameterv!Vec1f(target, parameter, params)
params := Vec4f(value, 0, 0, 0)
TexParameterv!Vec4f(target, parameter, params)
}

@if(Version.GLES10)
Expand All @@ -1825,8 +1829,8 @@ cmd void glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) {
@doc("https://www.khronos.org/opengles/sdk/docs/man32/html/glTexParameter.xhtml", Version.GLES32)
cmd void glTexParameteri(GLenum target, GLenum parameter, GLint value) {
if parameter == GL_TEXTURE_BORDER_COLOR { glErrorInvalidEnum(parameter) } // not scalar
params := Vec1i(value)
TexParameterv!Vec1i(target, parameter, params)
params := Vec4i(value, 0, 0, 0)
TexParameterv!Vec4i(target, parameter, params)
}

@if(Version.GLES10)
Expand Down