summaryrefslogtreecommitdiff
path: root/src/video_core/renderer_vulkan
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2020-06-04 23:03:49 -0300
committerGravatar ReinUsesLisp2020-06-05 00:24:51 -0300
commit5b2b6d594c6cfa77c3fb92faee63ad524bfe7204 (patch)
tree807efa01ce6b050f9660ab50a15d355d0be05bd5 /src/video_core/renderer_vulkan
parentshader/track: Move bindless tracking to a separate function (diff)
downloadyuzu-5b2b6d594c6cfa77c3fb92faee63ad524bfe7204.tar.gz
yuzu-5b2b6d594c6cfa77c3fb92faee63ad524bfe7204.tar.xz
yuzu-5b2b6d594c6cfa77c3fb92faee63ad524bfe7204.zip
shader/texture: Join separate image and sampler pairs offline
Games using D3D idioms can join images and samplers when a shader executes, instead of baking them into a combined sampler image. This is also possible on Vulkan. One approach to this solution would be to use separate samplers on Vulkan and leave this unimplemented on OpenGL, but we can't do this because there's no consistent way of determining which constant buffer holds a sampler and which one an image. We could in theory find the first bit and if it's in the TIC area, it's an image; but this falls apart when an image or sampler handle use an index of zero. The used approach is to track for a LOP.OR operation (this is done at an IR level, not at an ISA level), track again the constant buffers used as source and store this pair. Then, outside of shader execution, join the sample and image pair with a bitwise or operation. This approach won't work on games that truly use separate samplers in a meaningful way. For example, pooling textures in a 2D array and determining at runtime what sampler to use. This invalidates OpenGL's disk shader cache :) - Used mostly by D3D ports to Switch
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
index a3d992ed3..42a20530d 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
@@ -117,6 +117,17 @@ template <typename Engine, typename Entry>
117Tegra::Texture::FullTextureInfo GetTextureInfo(const Engine& engine, const Entry& entry, 117Tegra::Texture::FullTextureInfo GetTextureInfo(const Engine& engine, const Entry& entry,
118 std::size_t stage, std::size_t index = 0) { 118 std::size_t stage, std::size_t index = 0) {
119 const auto stage_type = static_cast<Tegra::Engines::ShaderType>(stage); 119 const auto stage_type = static_cast<Tegra::Engines::ShaderType>(stage);
120 if constexpr (std::is_same_v<Entry, SamplerEntry>) {
121 if (entry.is_separated) {
122 const u32 buffer_1 = entry.buffer;
123 const u32 buffer_2 = entry.secondary_buffer;
124 const u32 offset_1 = entry.offset;
125 const u32 offset_2 = entry.secondary_offset;
126 const u32 handle_1 = engine.AccessConstBuffer32(stage_type, buffer_1, offset_1);
127 const u32 handle_2 = engine.AccessConstBuffer32(stage_type, buffer_2, offset_2);
128 return engine.GetTextureInfo(handle_1 | handle_2);
129 }
130 }
120 if (entry.is_bindless) { 131 if (entry.is_bindless) {
121 const auto tex_handle = engine.AccessConstBuffer32(stage_type, entry.buffer, entry.offset); 132 const auto tex_handle = engine.AccessConstBuffer32(stage_type, entry.buffer, entry.offset);
122 return engine.GetTextureInfo(tex_handle); 133 return engine.GetTextureInfo(tex_handle);