mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
metal: vertex attribute reflection is slightly better
This commit is contained in:
@@ -272,9 +272,9 @@ void setPointSize() {
|
||||
)";
|
||||
|
||||
static const char vertex_main[] = R"(
|
||||
LOVE_IO_LOCATION(0) attribute vec4 VertexPosition;
|
||||
LOVE_IO_LOCATION(1) attribute vec4 VertexTexCoord;
|
||||
LOVE_IO_LOCATION(2) attribute vec4 VertexColor;
|
||||
attribute vec4 VertexPosition;
|
||||
attribute vec4 VertexTexCoord;
|
||||
attribute vec4 VertexColor;
|
||||
|
||||
varying vec4 VaryingTexCoord;
|
||||
varying vec4 VaryingColor;
|
||||
|
||||
@@ -322,8 +322,42 @@ Shader::Shader(id<MTLDevice> device, love::graphics::ShaderStage *vertex, love::
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &resource : resources.storage_buffers)
|
||||
{
|
||||
auto it = uniforms.find(resource.name);
|
||||
if (it != uniforms.end())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
if (i == ShaderStage::STAGE_VERTEX)
|
||||
{
|
||||
int nextattributeindex = ATTRIB_MAX_ENUM;
|
||||
|
||||
for (const auto &var : interfacevars)
|
||||
{
|
||||
spv::StorageClass storage = msl.get_storage_class(var);
|
||||
const std::string &name = msl.get_name(var);
|
||||
|
||||
if (storage == spv::StorageClassInput)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
BuiltinVertexAttribute builtinattribute;
|
||||
if (graphics::getConstant(name.c_str(), builtinattribute))
|
||||
index = (int) builtinattribute;
|
||||
else
|
||||
index = nextattributeindex++;
|
||||
|
||||
msl.set_decoration(var, spv::DecorationLocation, index);
|
||||
|
||||
attributes[name] = msl.get_decoration(var, spv::DecorationLocation);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &varying : resources.stage_outputs)
|
||||
{
|
||||
// printf("vertex shader output %s: %d\n", inp.name.c_str(), msl.get_decoration(inp.id, spv::DecorationLocation));
|
||||
@@ -373,16 +407,6 @@ Shader::Shader(id<MTLDevice> device, love::graphics::ShaderStage *vertex, love::
|
||||
}
|
||||
|
||||
functions[i] = [library newFunctionWithName:library.functionNames[0]];
|
||||
|
||||
for (const auto &var : interfacevars)
|
||||
{
|
||||
spv::StorageClass storage = msl.get_storage_class(var);
|
||||
const std::string &name = msl.get_name(var);
|
||||
// printf("var: %s\n", name.c_str());
|
||||
|
||||
if (i == ShaderStage::STAGE_VERTEX && storage == spv::StorageClassInput)
|
||||
attributes[name] = msl.get_decoration(var, spv::DecorationLocation);
|
||||
}
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user