Merge pull request #471 from Sonicadvance1/sampler_binding
Support Sampler binding in the shader.
This commit is contained in:
commit
5646ffdacd
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//dummy shader:
|
||||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
uniform sampler2D samp9;
|
||||
SAMPLER_BINDING(9) uniform sampler2D samp9;
|
||||
|
||||
out vec4 ocol0;
|
||||
in vec2 uv0;
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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,7 +74,6 @@ 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)
|
||||
|
@ -87,7 +86,7 @@ void SHADER::SetProgramVariables()
|
|||
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;" : ""
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue