metal: more work on shader uniforms

This commit is contained in:
Alex Szpakowski
2021-03-27 17:37:53 -03:00
parent 5f888be64a
commit da6fd95a64
3 changed files with 24 additions and 15 deletions
+19 -14
View File
@@ -172,7 +172,6 @@ Shader::Shader(id<MTLDevice> device, love::graphics::ShaderStage *vertex, love::
std::string msgs = logger.getAllMessages();
// printf("spirv length: %ld, messages:\n%s\n", spirv.size(), msgs.c_str());
// Compile to GLSL, ready to give to GL driver.
try
{
// printf("GLSL INPUT SOURCE:\n\n%s\n\n", pixel->getSource().c_str());
@@ -191,12 +190,6 @@ Shader::Shader(id<MTLDevice> device, love::graphics::ShaderStage *vertex, love::
int binding = msl.get_decoration(resource.id, spv::DecorationBinding);
const SPIRType &type = msl.get_type(resource.base_type_id);
BuiltinUniform builtin = BUILTIN_MAX_ENUM;
if (getConstant(resource.name.c_str(), builtin))
{
// TODO
}
auto it = uniforms.find(resource.name);
if (it != uniforms.end())
{
@@ -240,6 +233,10 @@ Shader::Shader(id<MTLDevice> device, love::graphics::ShaderStage *vertex, love::
}
uniforms[u.name] = u;
BuiltinUniform builtin = BUILTIN_MAX_ENUM;
if (getConstant(resource.name.c_str(), builtin))
builtinUniformInfo[builtin] = &uniforms[u.name];
}
for (const auto &resource : resources.uniform_buffers)
@@ -281,13 +278,6 @@ Shader::Shader(id<MTLDevice> device, love::graphics::ShaderStage *vertex, love::
u.dataSize = membersize;
u.count = std::max<size_t>(1, membertype.array.size());
BuiltinUniform builtin = BUILTIN_MAX_ENUM;
if (getConstant(u.name.c_str(), builtin))
{
if (builtin == BUILTIN_UNIFORMS_PER_DRAW)
builtinUniformDataOffset = offset;
}
switch (membertype.basetype)
{
case SPIRType::Int:
@@ -317,6 +307,16 @@ Shader::Shader(id<MTLDevice> device, love::graphics::ShaderStage *vertex, love::
default:
break;
}
uniforms[u.name] = u;
BuiltinUniform builtin = BUILTIN_MAX_ENUM;
if (getConstant(u.name.c_str(), builtin))
{
if (builtin == BUILTIN_UNIFORMS_PER_DRAW)
builtinUniformDataOffset = offset;
builtinUniformInfo[builtin] = &uniforms[u.name];
}
}
}
@@ -477,6 +477,11 @@ void Shader::sendBuffers(const UniformInfo *info, love::graphics::Buffer **buffe
// TODO
}
void Shader::setVideoTextures(love::graphics::Texture *ytexture, love::graphics::Texture *cbtexture, love::graphics::Texture *crtexture)
{
// TODO
}
bool Shader::hasUniform(const std::string &name) const
{
return uniforms.find(name) != uniforms.end();