|
|
@@ -2716,7 +2716,8 @@ void CompilerHLSL::emit_texture_op(const Instruction &i)
|
|
|
|
|
|
// The IR can give us more components than we need, so chop them off as needed.
|
|
|
string coord_expr;
|
|
|
- if (coord_components != expression_type(coord).vecsize)
|
|
|
+ auto &coord_type = expression_type(coord);
|
|
|
+ if (coord_components != coord_type.vecsize)
|
|
|
coord_expr = to_enclosed_expression(coord) + swizzle(coord_components, expression_type(coord).vecsize);
|
|
|
else
|
|
|
coord_expr = to_expression(coord);
|
|
|
@@ -2726,9 +2727,8 @@ void CompilerHLSL::emit_texture_op(const Instruction &i)
|
|
|
|
|
|
if (hlsl_options.shader_model < 40 && lod)
|
|
|
{
|
|
|
- auto &coordtype = expression_type(coord);
|
|
|
string coord_filler;
|
|
|
- for (uint32_t size = coordtype.vecsize; size < 3; ++size)
|
|
|
+ for (uint32_t size = coord_components; size < 3; ++size)
|
|
|
{
|
|
|
coord_filler += ", 0.0";
|
|
|
}
|
|
|
@@ -2737,9 +2737,8 @@ void CompilerHLSL::emit_texture_op(const Instruction &i)
|
|
|
|
|
|
if (hlsl_options.shader_model < 40 && bias)
|
|
|
{
|
|
|
- auto &coordtype = expression_type(coord);
|
|
|
string coord_filler;
|
|
|
- for (uint32_t size = coordtype.vecsize; size < 3; ++size)
|
|
|
+ for (uint32_t size = coord_components; size < 3; ++size)
|
|
|
{
|
|
|
coord_filler += ", 0.0";
|
|
|
}
|
|
|
@@ -2748,10 +2747,9 @@ void CompilerHLSL::emit_texture_op(const Instruction &i)
|
|
|
|
|
|
if (op == OpImageFetch)
|
|
|
{
|
|
|
- auto &coordtype = expression_type(coord);
|
|
|
if (imgtype.image.dim != DimBuffer && !imgtype.image.ms)
|
|
|
coord_expr =
|
|
|
- join("int", coordtype.vecsize + 1, "(", coord_expr, ", ", lod ? to_expression(lod) : string("0"), ")");
|
|
|
+ join("int", coord_components + 1, "(", coord_expr, ", ", lod ? to_expression(lod) : string("0"), ")");
|
|
|
}
|
|
|
else
|
|
|
expr += ", ";
|
|
|
@@ -3030,7 +3028,7 @@ string CompilerHLSL::bitcast_glsl_op(const SPIRType &out_type, const SPIRType &i
|
|
|
if (!requires_explicit_fp16_packing)
|
|
|
{
|
|
|
requires_explicit_fp16_packing = true;
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
}
|
|
|
return "SPIRV_Cross_unpackFloat2x16";
|
|
|
}
|
|
|
@@ -3039,7 +3037,7 @@ string CompilerHLSL::bitcast_glsl_op(const SPIRType &out_type, const SPIRType &i
|
|
|
if (!requires_explicit_fp16_packing)
|
|
|
{
|
|
|
requires_explicit_fp16_packing = true;
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
}
|
|
|
return "SPIRV_Cross_packFloat2x16";
|
|
|
}
|
|
|
@@ -3101,7 +3099,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop,
|
|
|
if (!requires_fp16_packing)
|
|
|
{
|
|
|
requires_fp16_packing = true;
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
}
|
|
|
emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packHalf2x16");
|
|
|
break;
|
|
|
@@ -3110,7 +3108,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop,
|
|
|
if (!requires_fp16_packing)
|
|
|
{
|
|
|
requires_fp16_packing = true;
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
}
|
|
|
emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackHalf2x16");
|
|
|
break;
|
|
|
@@ -3119,7 +3117,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop,
|
|
|
if (!requires_snorm8_packing)
|
|
|
{
|
|
|
requires_snorm8_packing = true;
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
}
|
|
|
emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packSnorm4x8");
|
|
|
break;
|
|
|
@@ -3128,7 +3126,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop,
|
|
|
if (!requires_snorm8_packing)
|
|
|
{
|
|
|
requires_snorm8_packing = true;
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
}
|
|
|
emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackSnorm4x8");
|
|
|
break;
|
|
|
@@ -3137,7 +3135,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop,
|
|
|
if (!requires_unorm8_packing)
|
|
|
{
|
|
|
requires_unorm8_packing = true;
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
}
|
|
|
emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packUnorm4x8");
|
|
|
break;
|
|
|
@@ -3146,7 +3144,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop,
|
|
|
if (!requires_unorm8_packing)
|
|
|
{
|
|
|
requires_unorm8_packing = true;
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
}
|
|
|
emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackUnorm4x8");
|
|
|
break;
|
|
|
@@ -3155,7 +3153,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop,
|
|
|
if (!requires_snorm16_packing)
|
|
|
{
|
|
|
requires_snorm16_packing = true;
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
}
|
|
|
emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packSnorm2x16");
|
|
|
break;
|
|
|
@@ -3164,7 +3162,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop,
|
|
|
if (!requires_snorm16_packing)
|
|
|
{
|
|
|
requires_snorm16_packing = true;
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
}
|
|
|
emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackSnorm2x16");
|
|
|
break;
|
|
|
@@ -3173,7 +3171,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop,
|
|
|
if (!requires_unorm16_packing)
|
|
|
{
|
|
|
requires_unorm16_packing = true;
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
}
|
|
|
emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packUnorm2x16");
|
|
|
break;
|
|
|
@@ -3182,7 +3180,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop,
|
|
|
if (!requires_unorm16_packing)
|
|
|
{
|
|
|
requires_unorm16_packing = true;
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
}
|
|
|
emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackUnorm2x16");
|
|
|
break;
|
|
|
@@ -3211,7 +3209,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop,
|
|
|
if (!requires_inverse_2x2)
|
|
|
{
|
|
|
requires_inverse_2x2 = true;
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
}
|
|
|
}
|
|
|
else if (type.vecsize == 3 && type.columns == 3)
|
|
|
@@ -3219,7 +3217,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop,
|
|
|
if (!requires_inverse_3x3)
|
|
|
{
|
|
|
requires_inverse_3x3 = true;
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
}
|
|
|
}
|
|
|
else if (type.vecsize == 4 && type.columns == 4)
|
|
|
@@ -3227,7 +3225,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop,
|
|
|
if (!requires_inverse_4x4)
|
|
|
{
|
|
|
requires_inverse_4x4 = true;
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
}
|
|
|
}
|
|
|
emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_Inverse");
|
|
|
@@ -3949,7 +3947,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
|
|
|
if (!requires_op_fmod)
|
|
|
{
|
|
|
requires_op_fmod = true;
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
}
|
|
|
CompilerGLSL::emit_instruction(instruction);
|
|
|
break;
|
|
|
@@ -4464,7 +4462,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
|
|
|
if (!requires_bitfield_insert)
|
|
|
{
|
|
|
requires_bitfield_insert = true;
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
}
|
|
|
|
|
|
auto expr = join("SPIRV_Cross_bitfieldInsert(", to_expression(ops[2]), ", ", to_expression(ops[3]), ", ",
|
|
|
@@ -4485,7 +4483,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
|
|
|
if (!requires_bitfield_extract)
|
|
|
{
|
|
|
requires_bitfield_extract = true;
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
}
|
|
|
|
|
|
if (opcode == OpBitFieldSExtract)
|
|
|
@@ -4562,7 +4560,7 @@ void CompilerHLSL::require_texture_query_variant(const SPIRType &type)
|
|
|
uint64_t mask = 1ull << bit;
|
|
|
if ((required_textureSizeVariants & mask) == 0)
|
|
|
{
|
|
|
- force_recompile = true;
|
|
|
+ force_recompile();
|
|
|
required_textureSizeVariants |= mask;
|
|
|
}
|
|
|
}
|
|
|
@@ -4675,7 +4673,7 @@ string CompilerHLSL::compile()
|
|
|
emit_hlsl_entry_point();
|
|
|
|
|
|
pass_count++;
|
|
|
- } while (force_recompile);
|
|
|
+ } while (is_forcing_recompilation());
|
|
|
|
|
|
// Entry point in HLSL is always main() for the time being.
|
|
|
get_entry_point().name = "main";
|