diff --git a/Data/Sys/Shaders/16bit.glsl b/Data/Sys/Shaders/16bit.glsl
index f7d8170ebe..edff1d5e3c 100644
--- a/Data/Sys/Shaders/16bit.glsl
+++ b/Data/Sys/Shaders/16bit.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/32bit.glsl b/Data/Sys/Shaders/32bit.glsl
index 1a9594f19c..ed8fb890c5 100644
--- a/Data/Sys/Shaders/32bit.glsl
+++ b/Data/Sys/Shaders/32bit.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/FXAA.glsl b/Data/Sys/Shaders/FXAA.glsl
index afcbe5e47d..60d072cdaa 100644
--- a/Data/Sys/Shaders/FXAA.glsl
+++ b/Data/Sys/Shaders/FXAA.glsl
@@ -12,7 +12,7 @@
// 0. You just DO WHAT THE FUCK YOU WANT TO.
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/README.txt b/Data/Sys/Shaders/README.txt
index 6913f9d099..acb7d22615 100644
--- a/Data/Sys/Shaders/README.txt
+++ b/Data/Sys/Shaders/README.txt
@@ -1,5 +1,5 @@
//dummy shader:
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
@@ -15,4 +15,4 @@ For best results, turn Wordwrap formatting on...
The shaders shown in the dropdown box in the video plugin configuration window are kept in the directory named User/Data/Shaders. They are linked in to the dolphin source from the repository at . See for more details on the way shaders work.
This file will hopefully hold more content in future...
-*/
\ No newline at end of file
+*/
diff --git a/Data/Sys/Shaders/acidmetal.glsl b/Data/Sys/Shaders/acidmetal.glsl
index b34626b709..6e976f0093 100644
--- a/Data/Sys/Shaders/acidmetal.glsl
+++ b/Data/Sys/Shaders/acidmetal.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/acidtrip.glsl b/Data/Sys/Shaders/acidtrip.glsl
index ff40955626..172e281b52 100644
--- a/Data/Sys/Shaders/acidtrip.glsl
+++ b/Data/Sys/Shaders/acidtrip.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/acidtrip2.glsl b/Data/Sys/Shaders/acidtrip2.glsl
index 0fbc3d5135..332de035f6 100644
--- a/Data/Sys/Shaders/acidtrip2.glsl
+++ b/Data/Sys/Shaders/acidtrip2.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/asciiart.glsl b/Data/Sys/Shaders/asciiart.glsl
index f9f5ab7788..089d216839 100644
--- a/Data/Sys/Shaders/asciiart.glsl
+++ b/Data/Sys/Shaders/asciiart.glsl
@@ -1,6 +1,6 @@
// textures
-uniform sampler2D samp8;
-uniform sampler2D samp9;
+SAMPLER_BINDING(8) uniform sampler2D samp8;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
const int char_width = 8;
const int char_height = 13;
diff --git a/Data/Sys/Shaders/auto_toon.glsl b/Data/Sys/Shaders/auto_toon.glsl
index a4efa8433a..8046ae2b1d 100644
--- a/Data/Sys/Shaders/auto_toon.glsl
+++ b/Data/Sys/Shaders/auto_toon.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/auto_toon2.glsl b/Data/Sys/Shaders/auto_toon2.glsl
index b2abceb9ad..574cce87c0 100644
--- a/Data/Sys/Shaders/auto_toon2.glsl
+++ b/Data/Sys/Shaders/auto_toon2.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/bad_bloom.glsl b/Data/Sys/Shaders/bad_bloom.glsl
index 4e0c96afa6..2aa2ff992e 100644
--- a/Data/Sys/Shaders/bad_bloom.glsl
+++ b/Data/Sys/Shaders/bad_bloom.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/brighten.glsl b/Data/Sys/Shaders/brighten.glsl
index 41cdd55672..75f3b684e6 100644
--- a/Data/Sys/Shaders/brighten.glsl
+++ b/Data/Sys/Shaders/brighten.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/chrismas.glsl b/Data/Sys/Shaders/chrismas.glsl
index c01536a332..158cf67e52 100644
--- a/Data/Sys/Shaders/chrismas.glsl
+++ b/Data/Sys/Shaders/chrismas.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/cool1.glsl b/Data/Sys/Shaders/cool1.glsl
index 6c1b7d5875..ef16147eda 100644
--- a/Data/Sys/Shaders/cool1.glsl
+++ b/Data/Sys/Shaders/cool1.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/darkerbrighter.glsl b/Data/Sys/Shaders/darkerbrighter.glsl
index 291ede4d3e..3c6045a887 100644
--- a/Data/Sys/Shaders/darkerbrighter.glsl
+++ b/Data/Sys/Shaders/darkerbrighter.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/emboss.glsl b/Data/Sys/Shaders/emboss.glsl
index 7b9b2212a4..325c4cd8a5 100644
--- a/Data/Sys/Shaders/emboss.glsl
+++ b/Data/Sys/Shaders/emboss.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/fire.glsl b/Data/Sys/Shaders/fire.glsl
index 106a4ef521..ea2595b047 100644
--- a/Data/Sys/Shaders/fire.glsl
+++ b/Data/Sys/Shaders/fire.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/fire2.glsl b/Data/Sys/Shaders/fire2.glsl
index f8f7e7a92b..2ca04ec529 100644
--- a/Data/Sys/Shaders/fire2.glsl
+++ b/Data/Sys/Shaders/fire2.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/firewater.glsl b/Data/Sys/Shaders/firewater.glsl
index b21e9db87d..20cf927bc9 100644
--- a/Data/Sys/Shaders/firewater.glsl
+++ b/Data/Sys/Shaders/firewater.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/grayscale.glsl b/Data/Sys/Shaders/grayscale.glsl
index 7a828f0a11..1c3658f00f 100644
--- a/Data/Sys/Shaders/grayscale.glsl
+++ b/Data/Sys/Shaders/grayscale.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/grayscale2.glsl b/Data/Sys/Shaders/grayscale2.glsl
index d9ef25a416..7e8f09e064 100644
--- a/Data/Sys/Shaders/grayscale2.glsl
+++ b/Data/Sys/Shaders/grayscale2.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/invert.glsl b/Data/Sys/Shaders/invert.glsl
index 67c5dee997..01e840c6e6 100644
--- a/Data/Sys/Shaders/invert.glsl
+++ b/Data/Sys/Shaders/invert.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/invert_blue.glsl b/Data/Sys/Shaders/invert_blue.glsl
index aa4eeea43a..081027ff75 100644
--- a/Data/Sys/Shaders/invert_blue.glsl
+++ b/Data/Sys/Shaders/invert_blue.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/invertedoutline.glsl b/Data/Sys/Shaders/invertedoutline.glsl
index 70363ddbbd..b5b29731b9 100644
--- a/Data/Sys/Shaders/invertedoutline.glsl
+++ b/Data/Sys/Shaders/invertedoutline.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/mad_world.glsl b/Data/Sys/Shaders/mad_world.glsl
index 63e46ecc39..1aff5223a2 100644
--- a/Data/Sys/Shaders/mad_world.glsl
+++ b/Data/Sys/Shaders/mad_world.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/nightvision.glsl b/Data/Sys/Shaders/nightvision.glsl
index 42f0fe441e..0756b81812 100644
--- a/Data/Sys/Shaders/nightvision.glsl
+++ b/Data/Sys/Shaders/nightvision.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/nightvision2.glsl b/Data/Sys/Shaders/nightvision2.glsl
index 3f5910c46b..cec3e82d72 100644
--- a/Data/Sys/Shaders/nightvision2.glsl
+++ b/Data/Sys/Shaders/nightvision2.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/nightvision2scanlines.glsl b/Data/Sys/Shaders/nightvision2scanlines.glsl
index f0b63687ad..7006429314 100644
--- a/Data/Sys/Shaders/nightvision2scanlines.glsl
+++ b/Data/Sys/Shaders/nightvision2scanlines.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/posterize.glsl b/Data/Sys/Shaders/posterize.glsl
index f09563014a..6b41c8332f 100644
--- a/Data/Sys/Shaders/posterize.glsl
+++ b/Data/Sys/Shaders/posterize.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/posterize2.glsl b/Data/Sys/Shaders/posterize2.glsl
index b2c47533a1..782bf32d9d 100644
--- a/Data/Sys/Shaders/posterize2.glsl
+++ b/Data/Sys/Shaders/posterize2.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/primarycolors.glsl b/Data/Sys/Shaders/primarycolors.glsl
index 29ae0ac200..ee62fc46f5 100644
--- a/Data/Sys/Shaders/primarycolors.glsl
+++ b/Data/Sys/Shaders/primarycolors.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/sepia.glsl b/Data/Sys/Shaders/sepia.glsl
index 83ac0b1e37..77d2414908 100644
--- a/Data/Sys/Shaders/sepia.glsl
+++ b/Data/Sys/Shaders/sepia.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/sketchy.glsl b/Data/Sys/Shaders/sketchy.glsl
index a91e404108..024593f719 100644
--- a/Data/Sys/Shaders/sketchy.glsl
+++ b/Data/Sys/Shaders/sketchy.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/spookey1.glsl b/Data/Sys/Shaders/spookey1.glsl
index 6a25d57e5e..249e2d06dc 100644
--- a/Data/Sys/Shaders/spookey1.glsl
+++ b/Data/Sys/Shaders/spookey1.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/spookey2.glsl b/Data/Sys/Shaders/spookey2.glsl
index 9a56bd21a1..34299ccc1d 100644
--- a/Data/Sys/Shaders/spookey2.glsl
+++ b/Data/Sys/Shaders/spookey2.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/stereoscopic.glsl b/Data/Sys/Shaders/stereoscopic.glsl
index f37a246e55..7c97313c8f 100644
--- a/Data/Sys/Shaders/stereoscopic.glsl
+++ b/Data/Sys/Shaders/stereoscopic.glsl
@@ -1,7 +1,7 @@
// Omega's 3D Stereoscopic filtering
// TODO: Need depth info!
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/stereoscopic2.glsl b/Data/Sys/Shaders/stereoscopic2.glsl
index f7370c7d5f..4fb8f5df11 100644
--- a/Data/Sys/Shaders/stereoscopic2.glsl
+++ b/Data/Sys/Shaders/stereoscopic2.glsl
@@ -1,7 +1,7 @@
// Omega's 3D Stereoscopic filtering (Amber/Blue)
// TODO: Need depth info!
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/sunset.glsl b/Data/Sys/Shaders/sunset.glsl
index 33201cf2ba..b2a793c84d 100644
--- a/Data/Sys/Shaders/sunset.glsl
+++ b/Data/Sys/Shaders/sunset.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/swap_RGB_BGR.glsl b/Data/Sys/Shaders/swap_RGB_BGR.glsl
index 011411700a..69c8461451 100644
--- a/Data/Sys/Shaders/swap_RGB_BGR.glsl
+++ b/Data/Sys/Shaders/swap_RGB_BGR.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/swap_RGB_BRG.glsl b/Data/Sys/Shaders/swap_RGB_BRG.glsl
index 82fe665b12..a9ec859b9f 100644
--- a/Data/Sys/Shaders/swap_RGB_BRG.glsl
+++ b/Data/Sys/Shaders/swap_RGB_BRG.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/swap_RGB_GBR.glsl b/Data/Sys/Shaders/swap_RGB_GBR.glsl
index 5884ccd0ab..bde5b51766 100644
--- a/Data/Sys/Shaders/swap_RGB_GBR.glsl
+++ b/Data/Sys/Shaders/swap_RGB_GBR.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/swap_RGB_GRB.glsl b/Data/Sys/Shaders/swap_RGB_GRB.glsl
index 26a4c14f8d..19cd3b0e41 100644
--- a/Data/Sys/Shaders/swap_RGB_GRB.glsl
+++ b/Data/Sys/Shaders/swap_RGB_GRB.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/swap_RGB_RBG.glsl b/Data/Sys/Shaders/swap_RGB_RBG.glsl
index 8e735a7337..c003436fff 100644
--- a/Data/Sys/Shaders/swap_RGB_RBG.glsl
+++ b/Data/Sys/Shaders/swap_RGB_RBG.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Data/Sys/Shaders/toxic.glsl b/Data/Sys/Shaders/toxic.glsl
index be3a0bb705..ab31e4c5f1 100644
--- a/Data/Sys/Shaders/toxic.glsl
+++ b/Data/Sys/Shaders/toxic.glsl
@@ -1,4 +1,4 @@
-uniform sampler2D samp9;
+SAMPLER_BINDING(9) uniform sampler2D samp9;
out vec4 ocol0;
in vec2 uv0;
diff --git a/Source/Core/VideoBackends/OGL/FramebufferManager.cpp b/Source/Core/VideoBackends/OGL/FramebufferManager.cpp
index cb21fc382f..62f112af2e 100644
--- a/Source/Core/VideoBackends/OGL/FramebufferManager.cpp
+++ b/Source/Core/VideoBackends/OGL/FramebufferManager.cpp
@@ -169,7 +169,7 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
{
// non-msaa, so just fetch the pixel
sampler =
- "uniform sampler2D samp9;\n"
+ "SAMPLER_BINDING(9) uniform sampler2D samp9;\n"
"vec4 sampleEFB(ivec2 pos) {\n"
" return texelFetch(samp9, pos, 0);\n"
"}\n";
@@ -180,7 +180,7 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
// This will lead to sample shading, but it's the only way to not loose
// the values of each sample.
sampler =
- "uniform sampler2DMS samp9;\n"
+ "SAMPLER_BINDING(9) uniform sampler2DMS samp9;\n"
"vec4 sampleEFB(ivec2 pos) {\n"
" return texelFetch(samp9, pos, gl_SampleID);\n"
"}\n";
@@ -191,7 +191,7 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
std::stringstream samples;
samples << m_msaaSamples;
sampler =
- "uniform sampler2DMS samp9;\n"
+ "SAMPLER_BINDING(9) uniform sampler2DMS samp9;\n"
"vec4 sampleEFB(ivec2 pos) {\n"
" vec4 color = vec4(0.0, 0.0, 0.0, 0.0);\n"
" for(int i=0; i<" + samples.str() + "; i++)\n"
diff --git a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp
index 99f3ad5485..768663f56a 100644
--- a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp
+++ b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp
@@ -61,12 +61,12 @@ static std::string GetGLSLVersionString()
void SHADER::SetProgramVariables()
{
- // glsl shader must be bind to set samplers
- Bind();
-
- // Bind UBO
+ // Bind UBO and texture samplers
if (!g_ActiveConfig.backend_info.bSupportsBindingLayout)
{
+ // glsl shader must be bind to set samplers if we don't support binding layout
+ Bind();
+
GLint PSBlock_id = glGetUniformBlockIndex(glprogid, "PSBlock");
GLint VSBlock_id = glGetUniformBlockIndex(glprogid, "VSBlock");
@@ -74,20 +74,19 @@ void SHADER::SetProgramVariables()
glUniformBlockBinding(glprogid, PSBlock_id, 1);
if (VSBlock_id != -1)
glUniformBlockBinding(glprogid, VSBlock_id, 2);
+
+ // Bind Texture Sampler
+ for (int a = 0; a <= 9; ++a)
+ {
+ char name[8];
+ snprintf(name, 8, "samp%d", a);
+
+ // Still need to get sampler locations since we aren't binding them statically in the shaders
+ int loc = glGetUniformLocation(glprogid, name);
+ if (loc != -1)
+ glUniform1i(loc, a);
+ }
}
-
- // Bind Texture Sampler
- for (int a = 0; a <= 9; ++a)
- {
- char name[8];
- snprintf(name, 8, "samp%d", a);
-
- // Still need to get sampler locations since we aren't binding them statically in the shaders
- int loc = glGetUniformLocation(glprogid, name);
- if (loc != -1)
- glUniform1i(loc, a);
- }
-
}
void SHADER::SetProgramBindings()
@@ -479,6 +478,7 @@ void ProgramShaderCache::CreateHeader ( void )
"%s\n" // 420pack
"%s\n" // msaa
"%s\n" // sample shading
+ "%s\n" // Sampler binding
// Precision defines for GLSL ES
"%s\n"
@@ -509,6 +509,7 @@ void ProgramShaderCache::CreateHeader ( void )
, (g_ActiveConfig.backend_info.bSupportsBindingLayout && v < GLSLES_310) ? "#extension GL_ARB_shading_language_420pack : enable" : ""
, (g_ogl_config.bSupportsMSAA && v < GLSL_150) ? "#extension GL_ARB_texture_multisample : enable" : ""
, (g_ogl_config.bSupportSampleShading) ? "#extension GL_ARB_sample_shading : enable" : ""
+ , g_ActiveConfig.backend_info.bSupportsBindingLayout ? "#define SAMPLER_BINDING(x) layout(binding = x)" : "#define SAMPLER_BINDING(x)"
, v>=GLSLES_300 ? "precision highp float;" : ""
, v>=GLSLES_300 ? "precision highp int;" : ""
diff --git a/Source/Core/VideoBackends/OGL/RasterFont.cpp b/Source/Core/VideoBackends/OGL/RasterFont.cpp
index d281f9a554..7d96e03ab8 100644
--- a/Source/Core/VideoBackends/OGL/RasterFont.cpp
+++ b/Source/Core/VideoBackends/OGL/RasterFont.cpp
@@ -124,7 +124,7 @@ static const char *s_vertexShaderSrc =
"}\n";
static const char *s_fragmentShaderSrc =
- "uniform sampler2D samp8;\n"
+ "SAMPLER_BINDING(8) uniform sampler2D samp8;\n"
"uniform vec4 color;\n"
"in vec2 uv0;\n"
"out vec4 ocol0;\n"
diff --git a/Source/Core/VideoBackends/OGL/TextureCache.cpp b/Source/Core/VideoBackends/OGL/TextureCache.cpp
index 198ffda169..8b38fca25c 100644
--- a/Source/Core/VideoBackends/OGL/TextureCache.cpp
+++ b/Source/Core/VideoBackends/OGL/TextureCache.cpp
@@ -346,7 +346,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
TextureCache::TextureCache()
{
const char *pColorMatrixProg =
- "uniform sampler2D samp9;\n"
+ "SAMPLER_BINDING(9) uniform sampler2D samp9;\n"
"uniform vec4 colmat[7];\n"
"in vec2 uv0;\n"
"out vec4 ocol0;\n"
@@ -358,7 +358,7 @@ TextureCache::TextureCache()
"}\n";
const char *pDepthMatrixProg =
- "uniform sampler2D samp9;\n"
+ "SAMPLER_BINDING(9) uniform sampler2D samp9;\n"
"uniform vec4 colmat[5];\n"
"in vec2 uv0;\n"
"out vec4 ocol0;\n"
@@ -372,7 +372,7 @@ TextureCache::TextureCache()
const char *VProgram =
"out vec2 uv0;\n"
- "uniform sampler2D samp9;\n"
+ "SAMPLER_BINDING(9) uniform sampler2D samp9;\n"
"uniform vec4 copy_position;\n" // left, top, right, bottom
"void main()\n"
"{\n"
diff --git a/Source/Core/VideoBackends/OGL/TextureConverter.cpp b/Source/Core/VideoBackends/OGL/TextureConverter.cpp
index 055a1e6d7c..7381969822 100644
--- a/Source/Core/VideoBackends/OGL/TextureConverter.cpp
+++ b/Source/Core/VideoBackends/OGL/TextureConverter.cpp
@@ -72,7 +72,7 @@ static void CreatePrograms()
const char *VProgramRgbToYuyv =
"out vec2 uv0;\n"
"uniform vec4 copy_position;\n" // left, top, right, bottom
- "uniform sampler2D samp9;\n"
+ "SAMPLER_BINDING(9) uniform sampler2D samp9;\n"
"void main()\n"
"{\n"
" vec2 rawpos = vec2(gl_VertexID&1, gl_VertexID&2);\n"
@@ -80,7 +80,7 @@ static void CreatePrograms()
" uv0 = mix(copy_position.xy, copy_position.zw, rawpos) / vec2(textureSize(samp9, 0));\n"
"}\n";
const char *FProgramRgbToYuyv =
- "uniform sampler2D samp9;\n"
+ "SAMPLER_BINDING(9) uniform sampler2D samp9;\n"
"in vec2 uv0;\n"
"out vec4 ocol0;\n"
"void main()\n"
@@ -111,7 +111,7 @@ static void CreatePrograms()
" gl_Position = vec4(rawpos*2.0-1.0, 0.0, 1.0);\n"
"}\n";
const char *FProgramYuyvToRgb =
- "uniform sampler2D samp9;\n"
+ "SAMPLER_BINDING(9) uniform sampler2D samp9;\n"
"in vec2 uv0;\n"
"out vec4 ocol0;\n"
"void main()\n"
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp
index 630d998e24..8e90713fd0 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/PixelShaderGen.cpp
@@ -204,7 +204,7 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
{
// Declare samplers
for (int i = 0; i < 8; ++i)
- out.Write("uniform sampler2D samp%d;\n", i);
+ out.Write("SAMPLER_BINDING(%d) uniform sampler2D samp%d;\n", i, i);
}
else // D3D
{
diff --git a/Source/Core/VideoCommon/TextureConversionShader.cpp b/Source/Core/VideoCommon/TextureConversionShader.cpp
index ad4dd6f1f6..76e49ce464 100644
--- a/Source/Core/VideoCommon/TextureConversionShader.cpp
+++ b/Source/Core/VideoCommon/TextureConversionShader.cpp
@@ -70,7 +70,7 @@ static void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType)
if (ApiType == API_OPENGL)
{
WRITE(p, "#define samp0 samp9\n");
- WRITE(p, "uniform sampler2D samp0;\n");
+ WRITE(p, "SAMPLER_BINDING(9) uniform sampler2D samp0;\n");
WRITE(p, " out vec4 ocol0;\n");
WRITE(p, "void main()\n");