From 7b4c470f16053d1f00df668e8aba64b8a59d092f Mon Sep 17 00:00:00 2001 From: Aaron Siegel Date: Thu, 15 Sep 2022 11:33:09 -0700 Subject: GLSL: Account for ES sampler1D to sampler2D promotion in textureSize. --- spirv_glsl.cpp | 9 +++++++-- 1 file 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(type.self); std::string fname = "textureSize"; if (is_legacy_desktop()) { - auto &type = expression_type(img); - auto &imgtype = get(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(ops[0]); expr = bitcast_expression(restype, SPIRType::Int, expr); emit_op(result_type, id, expr, true); -- cgit v1.2.3