mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
metal: work on storage buffers
This commit is contained in:
@@ -964,6 +964,16 @@ void Graphics::applyShaderUniforms(id<MTLRenderCommandEncoder> renderEncoder, lo
|
|||||||
if (sampindex != LOVE_UINT8_MAX)
|
if (sampindex != LOVE_UINT8_MAX)
|
||||||
setSampler(renderEncoder, bindings, ShaderStage::STAGE_PIXEL, sampindex, sampler);
|
setSampler(renderEncoder, bindings, ShaderStage::STAGE_PIXEL, sampindex, sampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const Shader::BufferBinding &b : s->getBufferBindings())
|
||||||
|
{
|
||||||
|
uint8 index = b.stages[ShaderStage::STAGE_VERTEX];
|
||||||
|
if (index != LOVE_UINT8_MAX)
|
||||||
|
setBuffer(renderEncoder, bindings, ShaderStage::STAGE_VERTEX, index, b.buffer, 0);
|
||||||
|
index = b.stages[ShaderStage::STAGE_PIXEL];
|
||||||
|
if (index != LOVE_UINT8_MAX)
|
||||||
|
setBuffer(renderEncoder, bindings, ShaderStage::STAGE_PIXEL, index, b.buffer, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setVertexBuffers(id<MTLRenderCommandEncoder> encoder, const BufferBindings *buffers, Graphics::RenderEncoderBindings &bindings)
|
static void setVertexBuffers(id<MTLRenderCommandEncoder> encoder, const BufferBindings *buffers, Graphics::RenderEncoderBindings &bindings)
|
||||||
|
|||||||
@@ -684,6 +684,35 @@ void Shader::compileFromGLSLang(id<MTLDevice> device, const glslang::TProgram &p
|
|||||||
b.samplerStages[stageindex] = (uint8) samplerbinding;
|
b.samplerStages[stageindex] = (uint8) samplerbinding;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto &resource : resources.storage_buffers)
|
||||||
|
{
|
||||||
|
auto it = uniforms.find(resource.name);
|
||||||
|
if (it == uniforms.end())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
UniformInfo &u = it->second;
|
||||||
|
|
||||||
|
uint32 bufferbinding = msl.get_automatic_msl_resource_binding(resource.id);
|
||||||
|
if (bufferbinding == (uint32)-1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (int i = 0; i < u.count; i++)
|
||||||
|
{
|
||||||
|
if (u.ints[i] == -1)
|
||||||
|
{
|
||||||
|
u.ints[i] = (int)bufferBindings.size();
|
||||||
|
BufferBinding b = {};
|
||||||
|
|
||||||
|
for (uint8 &stagebinding : b.stages)
|
||||||
|
stagebinding = LOVE_UINT8_MAX;
|
||||||
|
|
||||||
|
bufferBindings.push_back(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
bufferBindings[u.ints[i]].stages[stageindex] = (uint8) bufferbinding;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception &e)
|
catch (std::exception &e)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user