summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/spirv
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/backend/spirv')
-rw-r--r--src/shader_recompiler/backend/spirv/emit_context.cpp54
-rw-r--r--src/shader_recompiler/backend/spirv/emit_context.h2
2 files changed, 28 insertions, 28 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp
index d01633628..b738e00cc 100644
--- a/src/shader_recompiler/backend/spirv/emit_context.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_context.cpp
@@ -130,8 +130,8 @@ EmitContext::EmitContext(const Profile& profile_, IR::Program& program, u32& bin
130 DefineSharedMemory(program); 130 DefineSharedMemory(program);
131 DefineConstantBuffers(program.info, binding); 131 DefineConstantBuffers(program.info, binding);
132 DefineStorageBuffers(program.info, binding); 132 DefineStorageBuffers(program.info, binding);
133 DefineTextures(program.info, binding);
134 DefineTextureBuffers(program.info, binding); 133 DefineTextureBuffers(program.info, binding);
134 DefineTextures(program.info, binding);
135 DefineAttributeMemAccess(program.info); 135 DefineAttributeMemAccess(program.info);
136 DefineLabels(program); 136 DefineLabels(program);
137} 137}
@@ -516,6 +516,32 @@ void EmitContext::DefineStorageBuffers(const Info& info, u32& binding) {
516 } 516 }
517} 517}
518 518
519void EmitContext::DefineTextureBuffers(const Info& info, u32& binding) {
520 if (info.texture_buffer_descriptors.empty()) {
521 return;
522 }
523 const spv::ImageFormat format{spv::ImageFormat::Unknown};
524 image_buffer_type = TypeImage(F32[1], spv::Dim::Buffer, 0U, false, false, 1, format);
525 sampled_texture_buffer_type = TypeSampledImage(image_buffer_type);
526
527 const Id type{TypePointer(spv::StorageClass::UniformConstant, sampled_texture_buffer_type)};
528 texture_buffers.reserve(info.texture_buffer_descriptors.size());
529 for (const TextureBufferDescriptor& desc : info.texture_buffer_descriptors) {
530 if (desc.count != 1) {
531 throw NotImplementedException("Array of texture buffers");
532 }
533 const Id id{AddGlobalVariable(type, spv::StorageClass::UniformConstant)};
534 Decorate(id, spv::Decoration::Binding, binding);
535 Decorate(id, spv::Decoration::DescriptorSet, 0U);
536 Name(id, fmt::format("texbuf{}_{:02x}", desc.cbuf_index, desc.cbuf_offset));
537 texture_buffers.insert(texture_buffers.end(), desc.count, id);
538 if (profile.supported_spirv >= 0x00010400) {
539 interfaces.push_back(id);
540 }
541 binding += desc.count;
542 }
543}
544
519void EmitContext::DefineTextures(const Info& info, u32& binding) { 545void EmitContext::DefineTextures(const Info& info, u32& binding) {
520 textures.reserve(info.texture_descriptors.size()); 546 textures.reserve(info.texture_descriptors.size());
521 for (const TextureDescriptor& desc : info.texture_descriptors) { 547 for (const TextureDescriptor& desc : info.texture_descriptors) {
@@ -544,32 +570,6 @@ void EmitContext::DefineTextures(const Info& info, u32& binding) {
544 } 570 }
545} 571}
546 572
547void EmitContext::DefineTextureBuffers(const Info& info, u32& binding) {
548 if (info.texture_buffer_descriptors.empty()) {
549 return;
550 }
551 const spv::ImageFormat format{spv::ImageFormat::Unknown};
552 image_buffer_type = TypeImage(F32[1], spv::Dim::Buffer, 0U, false, false, 1, format);
553 sampled_texture_buffer_type = TypeSampledImage(image_buffer_type);
554
555 const Id type{TypePointer(spv::StorageClass::UniformConstant, sampled_texture_buffer_type)};
556 texture_buffers.reserve(info.texture_buffer_descriptors.size());
557 for (const TextureBufferDescriptor& desc : info.texture_buffer_descriptors) {
558 if (desc.count != 1) {
559 throw NotImplementedException("Array of texture buffers");
560 }
561 const Id id{AddGlobalVariable(type, spv::StorageClass::UniformConstant)};
562 Decorate(id, spv::Decoration::Binding, binding);
563 Decorate(id, spv::Decoration::DescriptorSet, 0U);
564 Name(id, fmt::format("texbuf{}_{:02x}", desc.cbuf_index, desc.cbuf_offset));
565 texture_buffers.insert(texture_buffers.end(), desc.count, id);
566 if (profile.supported_spirv >= 0x00010400) {
567 interfaces.push_back(id);
568 }
569 binding += desc.count;
570 }
571}
572
573void EmitContext::DefineLabels(IR::Program& program) { 573void EmitContext::DefineLabels(IR::Program& program) {
574 for (IR::Block* const block : program.blocks) { 574 for (IR::Block* const block : program.blocks) {
575 block->SetDefinition(OpLabel()); 575 block->SetDefinition(OpLabel());
diff --git a/src/shader_recompiler/backend/spirv/emit_context.h b/src/shader_recompiler/backend/spirv/emit_context.h
index 2a10e94e5..f1ac4430c 100644
--- a/src/shader_recompiler/backend/spirv/emit_context.h
+++ b/src/shader_recompiler/backend/spirv/emit_context.h
@@ -154,8 +154,8 @@ private:
154 void DefineSharedMemory(const IR::Program& program); 154 void DefineSharedMemory(const IR::Program& program);
155 void DefineConstantBuffers(const Info& info, u32& binding); 155 void DefineConstantBuffers(const Info& info, u32& binding);
156 void DefineStorageBuffers(const Info& info, u32& binding); 156 void DefineStorageBuffers(const Info& info, u32& binding);
157 void DefineTextures(const Info& info, u32& binding);
158 void DefineTextureBuffers(const Info& info, u32& binding); 157 void DefineTextureBuffers(const Info& info, u32& binding);
158 void DefineTextures(const Info& info, u32& binding);
159 void DefineAttributeMemAccess(const Info& info); 159 void DefineAttributeMemAccess(const Info& info);
160 void DefineLabels(IR::Program& program); 160 void DefineLabels(IR::Program& program);
161 161