diff --git a/gapil/resolver/expression.go b/gapil/resolver/expression.go index 583278ccfb..8d6dd0d2fa 100644 --- a/gapil/resolver/expression.go +++ b/gapil/resolver/expression.go @@ -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 { @@ -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} diff --git a/gapil/resolver/resolve_test.go b/gapil/resolver/resolve_test.go index 1adf9086fd..c7fdd304f2 100644 --- a/gapil/resolver/resolve_test.go +++ b/gapil/resolver/resolve_test.go @@ -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) diff --git a/gapis/api/gles/api/textures_and_samplers.api b/gapis/api/gles/api/textures_and_samplers.api index f31b6e0233..6324a061fa 100644 --- a/gapis/api/gles/api/textures_and_samplers.api +++ b/gapis/api/gles/api/textures_and_samplers.api @@ -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: { @@ -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) @@ -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)