diff --git a/tools/qfcc/source/expr_unary.c b/tools/qfcc/source/expr_unary.c index 5103d4bac..f1ec48ca6 100644 --- a/tools/qfcc/source/expr_unary.c +++ b/tools/qfcc/source/expr_unary.c @@ -485,6 +485,12 @@ unary_expr (int op, const expr_t *e) // unary + is a no-op return e; } + if (op == '=') { + // unary = is a marker for special handling by the back-end + auto new = new_unary_expr (op, e); + new->expr.type = get_type (e); + return edag_add_expr (new); + } if (is_algebra (t)) { unary_type = algebra_u; } else if (is_enum (t)) { diff --git a/tools/qfcc/source/glsl-builtins.c b/tools/qfcc/source/glsl-builtins.c index 1053c5f47..969173d2c 100644 --- a/tools/qfcc/source/glsl-builtins.c +++ b/tools/qfcc/source/glsl-builtins.c @@ -849,17 +849,17 @@ SRC_LINE " gsamplerCAS=[__sampler(,Cube,,Array,Shadow)]) {" "\n" "gvec4 texture(gsampler sampler, gtex_coord P)" "\n" "= " SPV(OpImageSampleExplicitLod) "\n" - "[sampler, P, ImageOperands.Lod, 0];" "\n" + "[sampler, P, =ImageOperands.Lod, 0];" "\n" "float texture(gsamplerSh sampler, gshadow_coord P)" "\n" "= " SPV(OpImageSampleDrefExplicitLod) "\n" "[sampler, [gsamplerSh shadow_coord(P)], [gsamplerSh comp(P)]," "\n" - " ImageOperands.Lod, 0];" "\n" + " =ImageOperands.Lod, 0];" "\n" "float texture(gsamplerCAS sampler, vec4 P, float comp)" "\n" "= " SPV(OpImageSampleDrefExplicitLod) "[sampler, P, comp," "\n" - " ImageOperands.Lod, 0];" "\n" + " =ImageOperands.Lod, 0];" "\n" "gvec4 textureProj(gsampler sampler, gproj_coord P)" "\n" "= " SPV(OpImageSampleProjExplicitLod) "\n" - "[sampler, P, ImageOperands.Lod, 0];" "\n" + "[sampler, P, =ImageOperands.Lod, 0];" "\n" "};" "\n" "#undef __sampler" "\n" "#undef _sampler" "\n" @@ -890,21 +890,21 @@ SRC_LINE " gsamplerCAS=[__sampler(,Cube,,Array,Shadow)]) {" "\n" "gvec4 texture(gsampler sampler, gtex_coord P, float bias)" "\n" "= " SPV(OpImageSampleImplicitLod) "\n" - "[sampler, P, ImageOperands.Bias, bias];" "\n" + "[sampler, P, =ImageOperands.Bias, bias];" "\n" "gvec4 texture(gsampler sampler, gtex_coord P)" "\n" "= " SPV(OpImageSampleImplicitLod) "[sampler, P];" "\n" "float texture(gsamplerSh sampler, gshadow_coord P, float bias)" "\n" "= " SPV(OpImageSampleDrefImplicitLod) "\n" "[sampler, [gsamplerSh shadow_coord(P)], [gsamplerSh comp(P)]," "\n" - " ImageOperands.Bias, bias];" "\n" + " =ImageOperands.Bias, bias];" "\n" "float texture(gsamplerSh sampler, gshadow_coord P)" "\n" "= " SPV(OpImageSampleDrefImplicitLod) "\n" - "[sampler, [gsamplerSh shadow_coord(P)], [gsamplerSh comp(P)]];" "\n" + "[sampler, [gsamplerSh shadow_coord(P)], [gsamplerSh comp(P)]];""\n" "float texture(gsamplerCAS sampler, vec4 P, float comp)" "\n" "= " SPV(OpImageSampleDrefImplicitLod) "[sampler, P, comp];" "\n" "gvec4 textureProj(gsampler sampler, gproj_coord P, float bias)" "\n" "= " SPV(OpImageSampleProjImplicitLod) "\n" - "[sampler, P, ImageOperands.Bias, bias];" "\n" + "[sampler, P, =ImageOperands.Bias, bias];" "\n" "gvec4 textureProj(gsampler sampler, gproj_coord P)" "\n" "= " SPV(OpImageSampleProjImplicitLod) "[sampler, P];" "\n" "};" "\n" @@ -933,7 +933,7 @@ SRC_LINE " gsamplerMS=[_sampler(2D,MS,,)," "\n" " _sampler(2D,MS,Array,)]) {" "\n" "gvec4 texelFetch(gsampler sampler, gtex_coord P, int lod)" "\n" - "= " SPV(OpImageFetch) "[sampler, P, ImageOperands.Lod, lod];" "\n" + "= " SPV(OpImageFetch) "[sampler, P, =ImageOperands.Lod, lod];" "\n" "gvec4B texelFetch(gsamplerB sampler, int P)" "\n" "= " SPV(OpImageFetch) "[sampler, P];" "\n" "gvec4MS texelFetch(gsamplerMS sampler, ivec2 P, int sample)" "\n" @@ -964,7 +964,7 @@ SRC_LINE " gtextureMS=[_texture(2D,MS,,)," "\n" " _texture(2D,MS,Array,)]) {" "\n" "gvec4 texelFetch(gtexture texture, gtex_coord P, int lod)" "\n" - "= " SPV(OpImageFetch) "[texture, P, ImageOperands.Lod, lod];" "\n" + "= " SPV(OpImageFetch) "[texture, P, =ImageOperands.Lod, lod];" "\n" "gvec4B texelFetch(gtextureB texture, int P)" "\n" "= " SPV(OpImageFetch) "[texture, P];" "\n" "gvec4MS texelFetch(gtextureMS texture, ivec2 P, int sample)" "\n" diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index d3c4f30ce..efad7d82d 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -2132,6 +2132,7 @@ unary_expr | '~' cast_expr %prec UNARY { $$ = new_unary_expr ('~', $2); } | '&' cast_expr %prec UNARY { $$ = new_unary_expr ('&', $2); } | '*' cast_expr %prec UNARY { $$ = new_unary_expr ('.', $2); } + | '=' cast_expr %prec UNARY { $$ = new_unary_expr ('=', $2); } | SIZEOF unary_expr %prec UNARY { $$ = new_unary_expr ('S', $2); } | SIZEOF '(' typename ')' %prec HYPERUNARY { diff --git a/tools/qfcc/source/target_spirv.c b/tools/qfcc/source/target_spirv.c index dfe47585d..f8d4aee64 100644 --- a/tools/qfcc/source/target_spirv.c +++ b/tools/qfcc/source/target_spirv.c @@ -1080,6 +1080,14 @@ spirv_uexpr (const expr_t *e, spirvctx_t *ctx) if (e->expr.op == 'C') { return spirv_cast (e, ctx); } + if (e->expr.op == '=') { + auto val = e->expr.e1; + if (!is_integral_val (val)) { + error (val, "not a constant integer"); + return 0; + } + return expr_integral (val); + } auto op_name = convert_op (e->expr.op); if (!op_name) { if (e->expr.op > 32 && e->expr.op < 127) {