mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
metal: more work on shader uniforms
This commit is contained in:
@@ -81,7 +81,7 @@ public:
|
||||
void sendBuffers(const UniformInfo *info, love::graphics::Buffer **buffers, int count) override;
|
||||
bool hasUniform(const std::string &name) const override;
|
||||
ptrdiff_t getHandle() const override { return 0; }
|
||||
void setVideoTextures(love::graphics::Texture *ytexture, love::graphics::Texture *cbtexture, love::graphics::Texture *crtexture) override {}
|
||||
void setVideoTextures(love::graphics::Texture *ytexture, love::graphics::Texture *cbtexture, love::graphics::Texture *crtexture) override;
|
||||
|
||||
id<MTLRenderPipelineState> getCachedRenderPipeline(const RenderPipelineKey &key);
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -159,6 +159,10 @@ ShaderStage::ShaderStage(love::graphics::Graphics *gfx, StageType stage, const s
|
||||
glslangShader->setEnvTarget(EShTargetSpv, EShTargetSpv_1_5);
|
||||
glslangShader->setAutoMapLocations(true);
|
||||
glslangShader->setAutoMapBindings(true);
|
||||
|
||||
// Needed for local uniforms to work (they will be converted into a uniform
|
||||
// block).
|
||||
// https://github.com/KhronosGroup/GLSL/blob/master/extensions/ext/GL_EXT_vulkan_glsl_relaxed.txt
|
||||
glslangShader->setEnvInputVulkanRulesRelaxed();
|
||||
|
||||
const char *csrc = source.c_str();
|
||||
|
||||
Reference in New Issue
Block a user