mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +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;
|
void sendBuffers(const UniformInfo *info, love::graphics::Buffer **buffers, int count) override;
|
||||||
bool hasUniform(const std::string &name) const override;
|
bool hasUniform(const std::string &name) const override;
|
||||||
ptrdiff_t getHandle() const override { return 0; }
|
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);
|
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();
|
std::string msgs = logger.getAllMessages();
|
||||||
// printf("spirv length: %ld, messages:\n%s\n", spirv.size(), msgs.c_str());
|
// printf("spirv length: %ld, messages:\n%s\n", spirv.size(), msgs.c_str());
|
||||||
|
|
||||||
// Compile to GLSL, ready to give to GL driver.
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// printf("GLSL INPUT SOURCE:\n\n%s\n\n", pixel->getSource().c_str());
|
// 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);
|
int binding = msl.get_decoration(resource.id, spv::DecorationBinding);
|
||||||
const SPIRType &type = msl.get_type(resource.base_type_id);
|
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);
|
auto it = uniforms.find(resource.name);
|
||||||
if (it != uniforms.end())
|
if (it != uniforms.end())
|
||||||
{
|
{
|
||||||
@@ -240,6 +233,10 @@ Shader::Shader(id<MTLDevice> device, love::graphics::ShaderStage *vertex, love::
|
|||||||
}
|
}
|
||||||
|
|
||||||
uniforms[u.name] = u;
|
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)
|
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.dataSize = membersize;
|
||||||
u.count = std::max<size_t>(1, membertype.array.size());
|
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)
|
switch (membertype.basetype)
|
||||||
{
|
{
|
||||||
case SPIRType::Int:
|
case SPIRType::Int:
|
||||||
@@ -317,6 +307,16 @@ Shader::Shader(id<MTLDevice> device, love::graphics::ShaderStage *vertex, love::
|
|||||||
default:
|
default:
|
||||||
break;
|
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
|
// 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
|
bool Shader::hasUniform(const std::string &name) const
|
||||||
{
|
{
|
||||||
return uniforms.find(name) != uniforms.end();
|
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->setEnvTarget(EShTargetSpv, EShTargetSpv_1_5);
|
||||||
glslangShader->setAutoMapLocations(true);
|
glslangShader->setAutoMapLocations(true);
|
||||||
glslangShader->setAutoMapBindings(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();
|
glslangShader->setEnvInputVulkanRulesRelaxed();
|
||||||
|
|
||||||
const char *csrc = source.c_str();
|
const char *csrc = source.c_str();
|
||||||
|
|||||||
Reference in New Issue
Block a user