diff --git a/src/core/gpu_hw_shadergen.cpp b/src/core/gpu_hw_shadergen.cpp index b6fa26f29..d35e53368 100644 --- a/src/core/gpu_hw_shadergen.cpp +++ b/src/core/gpu_hw_shadergen.cpp @@ -1052,7 +1052,7 @@ float4 LoadVRAM(int2 coords) { #if MULTISAMPLING float4 value = LOAD_TEXTURE_MS(samp0, coords, 0u); - for (uint sample_index = 1u; sample_index < MULTISAMPLES; sample_index++) + FOR_UNROLL (uint sample_index = 1u; sample_index < MULTISAMPLES; sample_index++) value += LOAD_TEXTURE_MS(samp0, coords, sample_index); value /= float(MULTISAMPLES); return value; @@ -1156,7 +1156,7 @@ float4 LoadVRAM(int2 coords) { #if MULTISAMPLING float4 value = LOAD_TEXTURE_MS(samp0, coords, 0u); - for (uint sample_index = 1u; sample_index < MULTISAMPLES; sample_index++) + FOR_UNROLL (uint sample_index = 1u; sample_index < MULTISAMPLES; sample_index++) value += LOAD_TEXTURE_MS(samp0, coords, sample_index); value /= float(MULTISAMPLES); return value; diff --git a/src/core/shader_cache_version.h b/src/core/shader_cache_version.h index 6a7a3d817..f867c0411 100644 --- a/src/core/shader_cache_version.h +++ b/src/core/shader_cache_version.h @@ -1,4 +1,4 @@ #pragma once #include "types.h" -static constexpr u32 SHADER_CACHE_VERSION = 5; \ No newline at end of file +static constexpr u32 SHADER_CACHE_VERSION = 6; \ No newline at end of file diff --git a/src/core/shadergen.cpp b/src/core/shadergen.cpp index b5f09542d..176795167 100644 --- a/src/core/shadergen.cpp +++ b/src/core/shadergen.cpp @@ -173,6 +173,10 @@ void ShaderGen::WriteHeader(std::stringstream& ss) ss << "#define CONSTANT const\n"; ss << "#define GLOBAL\n"; + ss << "#define FOR_UNROLL for\n"; + ss << "#define FOR_LOOP for\n"; + ss << "#define IF_BRANCH if\n"; + ss << "#define IF_FLATTEN if\n"; ss << "#define VECTOR_EQ(a, b) ((a) == (b))\n"; ss << "#define VECTOR_NEQ(a, b) ((a) != (b))\n"; ss << "#define VECTOR_COMP_EQ(a, b) equal((a), (b))\n"; @@ -214,6 +218,10 @@ void ShaderGen::WriteHeader(std::stringstream& ss) ss << "#define mat4 float4x4\n"; ss << "#define CONSTANT static const\n"; ss << "#define GLOBAL static\n"; + ss << "#define FOR_UNROLL [unroll] for\n"; + ss << "#define FOR_LOOP [loop] for\n"; + ss << "#define IF_BRANCH [branch] if\n"; + ss << "#define IF_FLATTEN [flatten] if\n"; ss << "#define VECTOR_EQ(a, b) (all((a) == (b)))\n"; ss << "#define VECTOR_NEQ(a, b) (any((a) != (b)))\n"; ss << "#define VECTOR_COMP_EQ(a, b) ((a) == (b))\n";