push constants
This commit is contained in:
@@ -120,7 +120,7 @@ void metalBindUniform(gnCommandBufferHandle buffer, gnUniform uniform, uint32_t
|
||||
if (map.set == set && map.binding == uniform->uniform->bindings[i].binding) {
|
||||
[encoder setVertexBuffer:info.buffer->buffer->buffer
|
||||
offset:info.offset
|
||||
atIndex:1
|
||||
atIndex:map.metalBindingIndex
|
||||
];
|
||||
break;
|
||||
}
|
||||
@@ -140,5 +140,5 @@ void metalBindUniform(gnCommandBufferHandle buffer, gnUniform uniform, uint32_t
|
||||
|
||||
void metalBindVertexBytes(gnCommandBufferHandle buffer, gnPushConstantLayout layout, void* data) {
|
||||
id<MTLRenderCommandEncoder> encoder = (id<MTLRenderCommandEncoder>)buffer->commandBuffer->encoder;
|
||||
// [encoder setVertexBytes:data length:layout.size atIndex:0]; // TODO: fix this
|
||||
[encoder setVertexBytes:data length:layout.size atIndex:buffer->commandBuffer->boundGraphcisPipeline->graphicsPipeline->vertexShaderMaps.pushConstantIndex]; // TODO: fix this
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ GN_ARRAY_LIST(metalBindingMap);
|
||||
|
||||
typedef struct metalBindingMaps {
|
||||
metalBindingMapArrayList uniformBufferMaps;
|
||||
uint32_t pushConstantIndex;
|
||||
metalBindingMapArrayList textureMaps;
|
||||
} metalBindingMaps;
|
||||
|
||||
|
@@ -83,14 +83,16 @@ gnReturnCode createMetalShaderModule(gnShaderModule module, gnDevice device, gnS
|
||||
|
||||
spvc_compiler_create_shader_resources(compiler, &resources);
|
||||
|
||||
spvc_resources_get_resource_list_for_type(resources, SPVC_RESOURCE_TYPE_PUSH_CONSTANT, &list, &count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
// TODO: get the buffer index
|
||||
}
|
||||
|
||||
module->shaderModule->maps.uniformBufferMaps = loadUniformBufferInformation(resources, compiler, shaderModuleInfo.stage);
|
||||
module->shaderModule->maps.textureMaps = loadTextureBindingInformation(resources, compiler);
|
||||
|
||||
spvc_resources_get_resource_list_for_type(resources, SPVC_RESOURCE_TYPE_PUSH_CONSTANT, &list, &count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
spvc_compiler_unset_decoration(compiler, list[i].id, SpvDecorationBinding);
|
||||
module->shaderModule->maps.pushConstantIndex = module->shaderModule->maps.uniformBufferMaps.data[module->shaderModule->maps.uniformBufferMaps.count - 1].metalBindingIndex + 1;
|
||||
spvc_compiler_set_decoration(compiler, list[i].id, SpvDecorationBinding, module->shaderModule->maps.pushConstantIndex);
|
||||
}
|
||||
|
||||
spvc_compiler_create_compiler_options(compiler, &options);
|
||||
spvc_compiler_options_set_uint(options, SPVC_COMPILER_OPTION_MSL_VERSION, 200);
|
||||
spvc_compiler_options_set_bool(options, SPVC_COMPILER_OPTION_MSL_ENABLE_DECORATION_BINDING, true);
|
||||
|
Reference in New Issue
Block a user