mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Metal: Use reference, so we're not copying every frame
This commit is contained in:
parent
74907876d3
commit
2123368dca
1 changed files with 8 additions and 8 deletions
|
|
@ -1091,13 +1091,13 @@ void MDUniformSet::bind_uniforms_direct(MDShader *p_shader, MDCommandBuffer::Ren
|
||||||
|
|
||||||
for (uint32_t i = 0; i < MIN(uniforms.size(), set.uniforms.size()); i++) {
|
for (uint32_t i = 0; i < MIN(uniforms.size(), set.uniforms.size()); i++) {
|
||||||
RDD::BoundUniform const &uniform = uniforms[i];
|
RDD::BoundUniform const &uniform = uniforms[i];
|
||||||
UniformInfo ui = set.uniforms[i];
|
const UniformInfo &ui = set.uniforms[i];
|
||||||
|
|
||||||
static const RDC::ShaderStage stage_usages[2] = { RDC::ShaderStage::SHADER_STAGE_VERTEX, RDC::ShaderStage::SHADER_STAGE_FRAGMENT };
|
static const RDC::ShaderStage stage_usages[2] = { RDC::ShaderStage::SHADER_STAGE_VERTEX, RDC::ShaderStage::SHADER_STAGE_FRAGMENT };
|
||||||
for (const RDC::ShaderStage stage : stage_usages) {
|
for (const RDC::ShaderStage stage : stage_usages) {
|
||||||
ShaderStageUsage const stage_usage = ShaderStageUsage(1 << stage);
|
ShaderStageUsage const stage_usage = ShaderStageUsage(1 << stage);
|
||||||
|
|
||||||
BindingInfo *bi = ui.bindings.getptr(stage);
|
const BindingInfo *bi = ui.bindings.getptr(stage);
|
||||||
if (bi == nullptr) {
|
if (bi == nullptr) {
|
||||||
// No binding for this stage.
|
// No binding for this stage.
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -1131,7 +1131,7 @@ void MDUniformSet::bind_uniforms_direct(MDShader *p_shader, MDCommandBuffer::Ren
|
||||||
samplers[j] = sampler;
|
samplers[j] = sampler;
|
||||||
textures[j] = texture;
|
textures[j] = texture;
|
||||||
}
|
}
|
||||||
BindingInfo *sbi = ui.bindings_secondary.getptr(stage);
|
const BindingInfo *sbi = ui.bindings_secondary.getptr(stage);
|
||||||
if (sbi) {
|
if (sbi) {
|
||||||
if (stage == RDD::SHADER_STAGE_VERTEX) {
|
if (stage == RDD::SHADER_STAGE_VERTEX) {
|
||||||
[enc setVertexSamplerStates:samplers withRange:NSMakeRange(sbi->index, count)];
|
[enc setVertexSamplerStates:samplers withRange:NSMakeRange(sbi->index, count)];
|
||||||
|
|
@ -1177,7 +1177,7 @@ void MDUniformSet::bind_uniforms_direct(MDShader *p_shader, MDCommandBuffer::Ren
|
||||||
[enc setFragmentTexture:obj atIndex:bi->index];
|
[enc setFragmentTexture:obj atIndex:bi->index];
|
||||||
}
|
}
|
||||||
|
|
||||||
BindingInfo *sbi = ui.bindings_secondary.getptr(stage);
|
const BindingInfo *sbi = ui.bindings_secondary.getptr(stage);
|
||||||
if (sbi) {
|
if (sbi) {
|
||||||
id<MTLTexture> tex = obj.parentTexture ? obj.parentTexture : obj;
|
id<MTLTexture> tex = obj.parentTexture ? obj.parentTexture : obj;
|
||||||
id<MTLBuffer> buf = tex.buffer;
|
id<MTLBuffer> buf = tex.buffer;
|
||||||
|
|
@ -1293,12 +1293,12 @@ void MDUniformSet::bind_uniforms_direct(MDShader *p_shader, MDCommandBuffer::Com
|
||||||
|
|
||||||
for (uint32_t i = 0; i < uniforms.size(); i++) {
|
for (uint32_t i = 0; i < uniforms.size(); i++) {
|
||||||
RDD::BoundUniform const &uniform = uniforms[i];
|
RDD::BoundUniform const &uniform = uniforms[i];
|
||||||
UniformInfo ui = set.uniforms[i];
|
const UniformInfo &ui = set.uniforms[i];
|
||||||
|
|
||||||
const RDC::ShaderStage stage = RDC::ShaderStage::SHADER_STAGE_COMPUTE;
|
const RDC::ShaderStage stage = RDC::ShaderStage::SHADER_STAGE_COMPUTE;
|
||||||
const ShaderStageUsage stage_usage = ShaderStageUsage(1 << stage);
|
const ShaderStageUsage stage_usage = ShaderStageUsage(1 << stage);
|
||||||
|
|
||||||
BindingInfo *bi = ui.bindings.getptr(stage);
|
const BindingInfo *bi = ui.bindings.getptr(stage);
|
||||||
if (bi == nullptr) {
|
if (bi == nullptr) {
|
||||||
// No binding for this stage.
|
// No binding for this stage.
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -1328,7 +1328,7 @@ void MDUniformSet::bind_uniforms_direct(MDShader *p_shader, MDCommandBuffer::Com
|
||||||
samplers[j] = sampler;
|
samplers[j] = sampler;
|
||||||
textures[j] = texture;
|
textures[j] = texture;
|
||||||
}
|
}
|
||||||
BindingInfo *sbi = ui.bindings_secondary.getptr(stage);
|
const BindingInfo *sbi = ui.bindings_secondary.getptr(stage);
|
||||||
if (sbi) {
|
if (sbi) {
|
||||||
[enc setSamplerStates:samplers withRange:NSMakeRange(sbi->index, count)];
|
[enc setSamplerStates:samplers withRange:NSMakeRange(sbi->index, count)];
|
||||||
}
|
}
|
||||||
|
|
@ -1354,7 +1354,7 @@ void MDUniformSet::bind_uniforms_direct(MDShader *p_shader, MDCommandBuffer::Com
|
||||||
id<MTLTexture> obj = rid::get(uniform.ids[0]);
|
id<MTLTexture> obj = rid::get(uniform.ids[0]);
|
||||||
[enc setTexture:obj atIndex:bi->index];
|
[enc setTexture:obj atIndex:bi->index];
|
||||||
|
|
||||||
BindingInfo *sbi = ui.bindings_secondary.getptr(stage);
|
const BindingInfo *sbi = ui.bindings_secondary.getptr(stage);
|
||||||
if (sbi) {
|
if (sbi) {
|
||||||
id<MTLTexture> tex = obj.parentTexture ? obj.parentTexture : obj;
|
id<MTLTexture> tex = obj.parentTexture ? obj.parentTexture : obj;
|
||||||
id<MTLBuffer> buf = tex.buffer;
|
id<MTLBuffer> buf = tex.buffer;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue