Merge remote-tracking branch 'origin/12.0-development' into vulkan

This commit is contained in:
niki
2022-08-28 03:43:08 +02:00
12 changed files with 165 additions and 72 deletions
+27 -3
View File
@@ -46,6 +46,7 @@ static bool isBuffer(Shader::UniformType utype)
Shader::Shader(StrongRef<love::graphics::ShaderStage> stages[SHADERSTAGE_MAX_ENUM])
: love::graphics::Shader(stages)
, program(0)
, splitUniformsPerDraw(false)
, builtinUniforms()
, builtinUniformInfo()
{
@@ -486,6 +487,11 @@ bool Shader::loadVolatile()
{
OpenGL::TempDebugGroup debuggroup("Shader load");
// love::graphics::Shader sets up the shader code-side of this.
auto gfx = Module::getInstance<love::graphics::Graphics>(Module::M_GRAPHICS);
if (gfx != nullptr)
splitUniformsPerDraw = gfx->getCapabilities().features[Graphics::FEATURE_PIXEL_SHADER_HIGHP];
// zero out active texture list
textureUnits.clear();
textureUnits.push_back(TextureUnit());
@@ -1014,9 +1020,27 @@ void Shader::updateBuiltinUniforms(love::graphics::Graphics *gfx, int viewportW,
data.constantColor = gfx->getColor();
gammaCorrectColor(data.constantColor);
GLint location = builtinUniforms[BUILTIN_UNIFORMS_PER_DRAW];
if (location >= 0)
glUniform4fv(location, 13, (const GLfloat *) &data);
// This branch is to avoid always declaring the whole array as highp in the
// vertex shader and mediump in the pixel shader for love's default shaders,
// on systems that don't support highp in pixel shaders. The default shaders
// use the transform matrices in vertex shaders and screen size params in
// pixel shaders. If there's a single array containing both and each shader
// stage declares a different precision, that's a compile error.
if (splitUniformsPerDraw)
{
GLint location = builtinUniforms[BUILTIN_UNIFORMS_PER_DRAW];
if (location >= 0)
glUniform4fv(location, 12, (const GLfloat *) &data);
GLint location2 = builtinUniforms[BUILTIN_UNIFORMS_PER_DRAW_2];
if (location2 >= 0)
glUniform4fv(location2, 1, (const GLfloat *) &data.screenSizeParams);
}
else
{
GLint location = builtinUniforms[BUILTIN_UNIFORMS_PER_DRAW];
if (location >= 0)
glUniform4fv(location, 13, (const GLfloat *) &data);
}
}
int Shader::getUniformTypeComponents(GLenum type) const
+2
View File
@@ -112,6 +112,8 @@ private:
// volatile
GLuint program;
bool splitUniformsPerDraw;
// Location values for any built-in uniform variables.
GLint builtinUniforms[BUILTIN_MAX_ENUM];
UniformInfo *builtinUniformInfo[BUILTIN_MAX_ENUM];