diff options
author | Aaron Siegel <asiegel@on1.com> | 2022-09-15 21:33:09 +0300 |
---|---|---|
committer | Aaron Siegel <asiegel@on1.com> | 2022-09-15 21:33:09 +0300 |
commit | 7b4c470f16053d1f00df668e8aba64b8a59d092f (patch) | |
tree | 21fd3714d4ae2d411920a8da9ce73205ea2391b4 | |
parent | 6d3518e23849326415129d275d2df40fe3fc6b64 (diff) |
GLSL: Account for ES sampler1D to sampler2D promotion in textureSize.
-rw-r--r-- | spirv_glsl.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index 5d87cea5..a8129641 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -12597,12 +12597,12 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) uint32_t result_type = ops[0]; uint32_t id = ops[1]; uint32_t img = ops[2]; + auto &type = expression_type(img); + auto &imgtype = get<SPIRType>(type.self); std::string fname = "textureSize"; if (is_legacy_desktop()) { - auto &type = expression_type(img); - auto &imgtype = get<SPIRType>(type.self); fname = legacy_tex_op(fname, imgtype, img); } else if (is_legacy_es()) @@ -12610,6 +12610,11 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) auto expr = join(fname, "(", convert_separate_image_to_expression(img), ", ", bitcast_expression(SPIRType::Int, ops[3]), ")"); + + // ES needs to emulate 1D images as 2D. + if (type.image.dim == Dim1D && options.es) + expr = join(expr, ".x"); + auto &restype = get<SPIRType>(ops[0]); expr = bitcast_expression(restype, SPIRType::Int, expr); emit_op(result_type, id, expr, true); |