summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_vulkan/vk_pipeline_cache.cpp4
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.cpp6
-rw-r--r--src/video_core/renderer_vulkan/vk_shader_decompiler.cpp30
-rw-r--r--src/video_core/renderer_vulkan/vk_shader_decompiler.h3
4 files changed, 26 insertions, 17 deletions
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
index a5c7b7945..65a1c6245 100644
--- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
@@ -312,7 +312,9 @@ VKPipelineCache::DecompileShaders(const GraphicsPipelineCacheKey& key) {
312 ASSERT(point_size != 0.0f); 312 ASSERT(point_size != 0.0f);
313 } 313 }
314 for (std::size_t i = 0; i < Maxwell::NumVertexAttributes; ++i) { 314 for (std::size_t i = 0; i < Maxwell::NumVertexAttributes; ++i) {
315 specialization.attribute_types[i] = fixed_state.vertex_input.attributes[i].Type(); 315 const auto& attribute = fixed_state.vertex_input.attributes[i];
316 specialization.enabled_attributes[i] = attribute.enabled.Value() != 0;
317 specialization.attribute_types[i] = attribute.Type();
316 } 318 }
317 specialization.ndc_minus_one_to_one = fixed_state.rasterizer.ndc_minus_one_to_one; 319 specialization.ndc_minus_one_to_one = fixed_state.rasterizer.ndc_minus_one_to_one;
318 320
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
index be5b77fae..a3d992ed3 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
@@ -877,14 +877,10 @@ void RasterizerVulkan::SetupVertexArrays(FixedPipelineState::VertexInput& vertex
877 877
878 for (std::size_t index = 0; index < Maxwell::NumVertexAttributes; ++index) { 878 for (std::size_t index = 0; index < Maxwell::NumVertexAttributes; ++index) {
879 const auto& attrib = regs.vertex_attrib_format[index]; 879 const auto& attrib = regs.vertex_attrib_format[index];
880 if (!attrib.IsValid()) { 880 if (attrib.IsConstant()) {
881 vertex_input.SetAttribute(index, false, 0, 0, {}, {}); 881 vertex_input.SetAttribute(index, false, 0, 0, {}, {});
882 continue; 882 continue;
883 } 883 }
884
885 [[maybe_unused]] const auto& buffer = regs.vertex_array[attrib.buffer];
886 ASSERT(buffer.IsEnabled());
887
888 vertex_input.SetAttribute(index, true, attrib.buffer, attrib.offset, attrib.type.Value(), 884 vertex_input.SetAttribute(index, true, attrib.buffer, attrib.offset, attrib.type.Value(),
889 attrib.size.Value()); 885 attrib.size.Value());
890 } 886 }
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
index 6f6dedd82..a13e8baa7 100644
--- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
+++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
@@ -741,8 +741,10 @@ private:
741 if (!IsGenericAttribute(index)) { 741 if (!IsGenericAttribute(index)) {
742 continue; 742 continue;
743 } 743 }
744
745 const u32 location = GetGenericAttributeLocation(index); 744 const u32 location = GetGenericAttributeLocation(index);
745 if (!IsAttributeEnabled(location)) {
746 continue;
747 }
746 const auto type_descriptor = GetAttributeType(location); 748 const auto type_descriptor = GetAttributeType(location);
747 Id type; 749 Id type;
748 if (IsInputAttributeArray()) { 750 if (IsInputAttributeArray()) {
@@ -986,6 +988,10 @@ private:
986 return stage == ShaderType::TesselationControl; 988 return stage == ShaderType::TesselationControl;
987 } 989 }
988 990
991 bool IsAttributeEnabled(u32 location) const {
992 return stage != ShaderType::Vertex || specialization.enabled_attributes[location];
993 }
994
989 u32 GetNumInputVertices() const { 995 u32 GetNumInputVertices() const {
990 switch (stage) { 996 switch (stage) {
991 case ShaderType::Geometry: 997 case ShaderType::Geometry:
@@ -1201,16 +1207,20 @@ private:
1201 UNIMPLEMENTED_MSG("Unmanaged FrontFacing element={}", element); 1207 UNIMPLEMENTED_MSG("Unmanaged FrontFacing element={}", element);
1202 return {v_float_zero, Type::Float}; 1208 return {v_float_zero, Type::Float};
1203 default: 1209 default:
1204 if (IsGenericAttribute(attribute)) { 1210 if (!IsGenericAttribute(attribute)) {
1205 const u32 location = GetGenericAttributeLocation(attribute); 1211 break;
1206 const auto type_descriptor = GetAttributeType(location);
1207 const Type type = type_descriptor.type;
1208 const Id attribute_id = input_attributes.at(attribute);
1209 const std::vector elements = {element};
1210 const Id pointer = ArrayPass(type_descriptor.scalar, attribute_id, elements);
1211 return {OpLoad(GetTypeDefinition(type), pointer), type};
1212 } 1212 }
1213 break; 1213 const u32 location = GetGenericAttributeLocation(attribute);
1214 if (!IsAttributeEnabled(location)) {
1215 // Disabled attributes (also known as constant attributes) always return zero.
1216 return {v_float_zero, Type::Float};
1217 }
1218 const auto type_descriptor = GetAttributeType(location);
1219 const Type type = type_descriptor.type;
1220 const Id attribute_id = input_attributes.at(attribute);
1221 const std::vector elements = {element};
1222 const Id pointer = ArrayPass(type_descriptor.scalar, attribute_id, elements);
1223 return {OpLoad(GetTypeDefinition(type), pointer), type};
1214 } 1224 }
1215 UNIMPLEMENTED_MSG("Unhandled input attribute: {}", static_cast<u32>(attribute)); 1225 UNIMPLEMENTED_MSG("Unhandled input attribute: {}", static_cast<u32>(attribute));
1216 return {v_float_zero, Type::Float}; 1226 return {v_float_zero, Type::Float};
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.h b/src/video_core/renderer_vulkan/vk_shader_decompiler.h
index f4c05ac3c..b7af26388 100644
--- a/src/video_core/renderer_vulkan/vk_shader_decompiler.h
+++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.h
@@ -88,7 +88,8 @@ struct Specialization final {
88 u32 shared_memory_size{}; 88 u32 shared_memory_size{};
89 89
90 // Graphics specific 90 // Graphics specific
91 std::optional<float> point_size{}; 91 std::optional<float> point_size;
92 std::bitset<Maxwell::NumVertexAttributes> enabled_attributes;
92 std::array<Maxwell::VertexAttribute::Type, Maxwell::NumVertexAttributes> attribute_types{}; 93 std::array<Maxwell::VertexAttribute::Type, Maxwell::NumVertexAttributes> attribute_types{};
93 bool ndc_minus_one_to_one{}; 94 bool ndc_minus_one_to_one{};
94}; 95};