summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/ShaderGenCommon.cpp
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2021-11-18 13:08:23 -0500
committerGitHub <noreply@github.com>2021-11-18 13:08:23 -0500
commit6f4bbac528682389e34a1a4985820ee5137619c7 (patch)
tree9f07e21fa1da14c7485fddac611a2618888afcf0 /Source/Core/VideoCommon/ShaderGenCommon.cpp
parent8b57aad8edd82ccc414775d22e96d896bcac6176 (diff)
parent95b99410443e7ae47df1f3e9436e275c80dd3678 (diff)
Merge pull request #9956 from Pokechu22/non-power-of-2-wrap-2
VideoCommon: Manually handle texture wrapping and sampling
Diffstat (limited to 'Source/Core/VideoCommon/ShaderGenCommon.cpp')
-rw-r--r--Source/Core/VideoCommon/ShaderGenCommon.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/ShaderGenCommon.cpp b/Source/Core/VideoCommon/ShaderGenCommon.cpp
index c5cd3ef30d..34921f9116 100644
--- a/Source/Core/VideoCommon/ShaderGenCommon.cpp
+++ b/Source/Core/VideoCommon/ShaderGenCommon.cpp
@@ -39,6 +39,9 @@ ShaderHostConfig ShaderHostConfig::GetCurrent()
bits.backend_logic_op = g_ActiveConfig.backend_info.bSupportsLogicOp;
bits.backend_palette_conversion = g_ActiveConfig.backend_info.bSupportsPaletteConversion;
bits.enable_validation_layer = g_ActiveConfig.bEnableValidationLayer;
+ bits.manual_texture_sampling = !g_ActiveConfig.bFastTextureSampling;
+ bits.manual_texture_sampling_custom_texture_sizes =
+ g_ActiveConfig.ManualTextureSamplingWithHiResTextures();
return bits;
}
@@ -105,6 +108,30 @@ void WriteIsNanHeader(ShaderCode& out, APIType api_type)
}
}
+void WriteBitfieldExtractHeader(ShaderCode& out, APIType api_type,
+ const ShaderHostConfig& host_config)
+{
+ // ==============================================
+ // BitfieldExtract for APIs which don't have it
+ // ==============================================
+ if (!host_config.backend_bitfield)
+ {
+ out.Write("uint bitfieldExtract(uint val, int off, int size) {{\n"
+ " // This built-in function is only supported in OpenGL 4.0+ and ES 3.1+\n"
+ " // Microsoft's HLSL compiler automatically optimises this to a bitfield extract "
+ "instruction.\n"
+ " uint mask = uint((1 << size) - 1);\n"
+ " return uint(val >> off) & mask;\n"
+ "}}\n\n");
+ out.Write("int bitfieldExtract(int val, int off, int size) {{\n"
+ " // This built-in function is only supported in OpenGL 4.0+ and ES 3.1+\n"
+ " // Microsoft's HLSL compiler automatically optimises this to a bitfield extract "
+ "instruction.\n"
+ " return ((val << (32 - size - off)) >> (32 - size));\n"
+ "}}\n\n");
+ }
+}
+
static void DefineOutputMember(ShaderCode& object, APIType api_type, std::string_view qualifier,
std::string_view type, std::string_view name, int var_index,
std::string_view semantic = {}, int semantic_index = -1)