summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend/spirv/emit_context.cpp
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-04-06 07:56:15 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:26 +0200
commit1f3eb601acdcdfa4c119cffbf36b5792147b893f (patch)
tree1a8dcc5e4ce11e9090dd6d7a8b4e8aaa130ff67b /src/shader_recompiler/backend/spirv/emit_context.cpp
parentshader: Address feedback (diff)
downloadyuzu-1f3eb601acdcdfa4c119cffbf36b5792147b893f.tar
yuzu-1f3eb601acdcdfa4c119cffbf36b5792147b893f.tar.gz
yuzu-1f3eb601acdcdfa4c119cffbf36b5792147b893f.tar.bz2
yuzu-1f3eb601acdcdfa4c119cffbf36b5792147b893f.tar.lz
yuzu-1f3eb601acdcdfa4c119cffbf36b5792147b893f.tar.xz
yuzu-1f3eb601acdcdfa4c119cffbf36b5792147b893f.tar.zst
yuzu-1f3eb601acdcdfa4c119cffbf36b5792147b893f.zip
Diffstat (limited to '')
-rw-r--r--src/shader_recompiler/backend/spirv/emit_context.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp
index 2d39ea373..d01633628 100644
--- a/src/shader_recompiler/backend/spirv/emit_context.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_context.cpp
@@ -46,6 +46,8 @@ Id ImageType(EmitContext& ctx, const TextureDescriptor& desc) {
return ctx.TypeImage(type, spv::Dim::Cube, true, false, false, 1, format);
case TextureType::ShadowArrayCube:
return ctx.TypeImage(type, spv::Dim::Cube, true, true, false, 1, format);
+ case TextureType::Buffer:
+ break;
}
throw InvalidArgument("Invalid texture type {}", desc.type);
}
@@ -129,6 +131,7 @@ EmitContext::EmitContext(const Profile& profile_, IR::Program& program, u32& bin
DefineConstantBuffers(program.info, binding);
DefineStorageBuffers(program.info, binding);
DefineTextures(program.info, binding);
+ DefineTextureBuffers(program.info, binding);
DefineAttributeMemAccess(program.info);
DefineLabels(program);
}
@@ -541,6 +544,32 @@ void EmitContext::DefineTextures(const Info& info, u32& binding) {
}
}
+void EmitContext::DefineTextureBuffers(const Info& info, u32& binding) {
+ if (info.texture_buffer_descriptors.empty()) {
+ return;
+ }
+ const spv::ImageFormat format{spv::ImageFormat::Unknown};
+ image_buffer_type = TypeImage(F32[1], spv::Dim::Buffer, 0U, false, false, 1, format);
+ sampled_texture_buffer_type = TypeSampledImage(image_buffer_type);
+
+ const Id type{TypePointer(spv::StorageClass::UniformConstant, sampled_texture_buffer_type)};
+ texture_buffers.reserve(info.texture_buffer_descriptors.size());
+ for (const TextureBufferDescriptor& desc : info.texture_buffer_descriptors) {
+ if (desc.count != 1) {
+ throw NotImplementedException("Array of texture buffers");
+ }
+ const Id id{AddGlobalVariable(type, spv::StorageClass::UniformConstant)};
+ Decorate(id, spv::Decoration::Binding, binding);
+ Decorate(id, spv::Decoration::DescriptorSet, 0U);
+ Name(id, fmt::format("texbuf{}_{:02x}", desc.cbuf_index, desc.cbuf_offset));
+ texture_buffers.insert(texture_buffers.end(), desc.count, id);
+ if (profile.supported_spirv >= 0x00010400) {
+ interfaces.push_back(id);
+ }
+ binding += desc.count;
+ }
+}
+
void EmitContext::DefineLabels(IR::Program& program) {
for (IR::Block* const block : program.blocks) {
block->SetDefinition(OpLabel());