summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_vulkan
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-03-24 05:33:45 +0100
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:24 +0200
commit68a9505d8a1d00c6ba2739bc0af3069cf87b9b84 (patch)
treeb9a78497cd8af1d73a7eda34cd0df08b3dc324e6 /src/video_core/renderer_vulkan
parentshader: Fix use-after-free bug in object_pool (diff)
downloadyuzu-68a9505d8a1d00c6ba2739bc0af3069cf87b9b84.tar
yuzu-68a9505d8a1d00c6ba2739bc0af3069cf87b9b84.tar.gz
yuzu-68a9505d8a1d00c6ba2739bc0af3069cf87b9b84.tar.bz2
yuzu-68a9505d8a1d00c6ba2739bc0af3069cf87b9b84.tar.lz
yuzu-68a9505d8a1d00c6ba2739bc0af3069cf87b9b84.tar.xz
yuzu-68a9505d8a1d00c6ba2739bc0af3069cf87b9b84.tar.zst
yuzu-68a9505d8a1d00c6ba2739bc0af3069cf87b9b84.zip
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r--src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp3
-rw-r--r--src/video_core/renderer_vulkan/vk_pipeline_cache.cpp33
-rw-r--r--src/video_core/renderer_vulkan/vk_pipeline_cache.h4
3 files changed, 37 insertions, 3 deletions
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
index a2ec418b1..a87ed1976 100644
--- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
+++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
@@ -181,6 +181,9 @@ void GraphicsPipeline::Configure(bool is_indexed) {
PushImageDescriptors(stage_infos[stage], samplers.data(), image_view_ids.data(),
*texture_cache, *update_descriptor_queue, index);
}
+ if (!descriptor_set_layout) {
+ return;
+ }
const VkDescriptorSet descriptor_set{descriptor_allocator.Commit()};
update_descriptor_queue->Send(*descriptor_update_template, descriptor_set);
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
index bdbc8dd1e..504b8c9d6 100644
--- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
@@ -437,7 +437,7 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, Tegra::GPU& gpu_,
buffer_cache{buffer_cache_}, texture_cache{texture_cache_} {
const auto& float_control{device.FloatControlProperties()};
const VkDriverIdKHR driver_id{device.GetDriverID()};
- profile = Shader::Profile{
+ base_profile = Shader::Profile{
.unified_descriptor_binding = true,
.support_vertex_instance_id = false,
.support_float_controls = true,
@@ -458,6 +458,7 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, Tegra::GPU& gpu_,
.support_vote = true,
.warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyBiggerThanGuest(),
.has_broken_spirv_clamp = driver_id == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS_KHR,
+ .generic_input_types{},
};
}
@@ -589,6 +590,7 @@ GraphicsPipeline PipelineCache::CreateGraphicsPipeline(ShaderPools& pools,
Shader::Environment& env{*envs[env_index]};
++env_index;
+ const Shader::Profile profile{MakeProfile(key, env.ShaderStage())};
const std::vector<u32> code{EmitSPIRV(profile, env, program, binding)};
modules[stage_index] = BuildShader(device, code);
}
@@ -645,9 +647,36 @@ ComputePipeline PipelineCache::CreateComputePipeline(ShaderPools& pools,
Shader::Maxwell::Flow::CFG cfg{env, pools.flow_block, env.StartAddress()};
Shader::IR::Program program{TranslateProgram(pools.inst, pools.block, env, cfg)};
u32 binding{0};
- std::vector<u32> code{EmitSPIRV(profile, env, program, binding)};
+ std::vector<u32> code{EmitSPIRV(base_profile, env, program, binding)};
return ComputePipeline{device, descriptor_pool, update_descriptor_queue, program.info,
BuildShader(device, code)};
}
+static Shader::AttributeType CastAttributeType(const FixedPipelineState::VertexAttribute& attr) {
+ switch (attr.Type()) {
+ case Maxwell::VertexAttribute::Type::SignedNorm:
+ case Maxwell::VertexAttribute::Type::UnsignedNorm:
+ case Maxwell::VertexAttribute::Type::UnsignedScaled:
+ case Maxwell::VertexAttribute::Type::SignedScaled:
+ case Maxwell::VertexAttribute::Type::Float:
+ return Shader::AttributeType::Float;
+ case Maxwell::VertexAttribute::Type::SignedInt:
+ return Shader::AttributeType::SignedInt;
+ case Maxwell::VertexAttribute::Type::UnsignedInt:
+ return Shader::AttributeType::UnsignedInt;
+ }
+ return Shader::AttributeType::Float;
+}
+
+Shader::Profile PipelineCache::MakeProfile(const GraphicsPipelineCacheKey& key,
+ Shader::Stage stage) {
+ Shader::Profile profile{base_profile};
+ if (stage == Shader::Stage::VertexB) {
+ profile.convert_depth_mode = key.state.ndc_minus_one_to_one != 0;
+ std::ranges::transform(key.state.attributes, profile.generic_input_types.begin(),
+ &CastAttributeType);
+ }
+ return profile;
+}
+
} // namespace Vulkan
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.h b/src/video_core/renderer_vulkan/vk_pipeline_cache.h
index d481f56f9..e09d78063 100644
--- a/src/video_core/renderer_vulkan/vk_pipeline_cache.h
+++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.h
@@ -156,6 +156,8 @@ private:
ComputePipeline CreateComputePipeline(ShaderPools& pools, const ComputePipelineCacheKey& key,
Shader::Environment& env) const;
+ Shader::Profile MakeProfile(const GraphicsPipelineCacheKey& key, Shader::Stage stage);
+
Tegra::GPU& gpu;
Tegra::Engines::Maxwell3D& maxwell3d;
Tegra::Engines::KeplerCompute& kepler_compute;
@@ -176,7 +178,7 @@ private:
ShaderPools main_pools;
- Shader::Profile profile;
+ Shader::Profile base_profile;
std::string pipeline_cache_filename;
};