Browse Source

Add more validations

pull/294/head
MaranBr 3 months ago
parent
commit
f1c6e0d74c
  1. 1
      src/video_core/renderer_vulkan/vk_graphics_pipeline.h
  2. 27
      src/video_core/renderer_vulkan/vk_rasterizer.cpp

1
src/video_core/renderer_vulkan/vk_graphics_pipeline.h

@ -81,6 +81,7 @@ public:
const GraphicsPipelineCacheKey& key, std::array<vk::ShaderModule, NUM_STAGES> stages,
const std::array<const Shader::Info*, NUM_STAGES>& infos);
bool HasDynamicVertexInput() const noexcept { return key.state.dynamic_vertex_input; }
GraphicsPipeline& operator=(GraphicsPipeline&&) noexcept = delete;
GraphicsPipeline(GraphicsPipeline&&) noexcept = delete;

27
src/video_core/renderer_vulkan/vk_rasterizer.cpp

@ -1000,9 +1000,11 @@ void RasterizerVulkan::UpdateDynamicStates() {
}
}
if (device.IsExtVertexInputDynamicStateSupported() && dynamic_state > 2) {
if (auto* gp = pipeline_cache.CurrentGraphicsPipeline(); gp && gp->HasDynamicVertexInput()) {
UpdateVertexInput(regs);
}
}
}
void RasterizerVulkan::HandleTransformFeedback() {
static std::once_flag warn_unsupported;
@ -1029,23 +1031,23 @@ void RasterizerVulkan::UpdateViewportsState(Tegra::Engines::Maxwell3D::Regs& reg
if (!regs.viewport_scale_offset_enabled) {
float x = static_cast<float>(regs.surface_clip.x);
float y = static_cast<float>(regs.surface_clip.y);
float width = static_cast<float>(regs.surface_clip.width);
float height = static_cast<float>(regs.surface_clip.height);
const bool lower_left = regs.window_origin.mode != Maxwell::WindowOrigin::Mode::UpperLeft;
if (lower_left) {
// Vulkan viewport space is top-left; emulate lower-left with negative height.
float width = std::max(1.0f, static_cast<float>(regs.surface_clip.width));
float height = std::max(1.0f, static_cast<float>(regs.surface_clip.height));
if (regs.window_origin.mode != Maxwell::WindowOrigin::Mode::UpperLeft) {
y += height;
height = -height;
}
VkViewport viewport{
.x = x,
.y = y,
.width = width != 0.0f ? width : 1.0f,
.height = height != 0.0f ? height : 1.0f,
.width = width,
.height = height,
.minDepth = 0.0f,
.maxDepth = 1.0f,
};
scheduler.Record([viewport](vk::CommandBuffer cmdbuf) { cmdbuf.SetViewport(0, viewport); });
scheduler.Record([viewport](vk::CommandBuffer cmdbuf) {
cmdbuf.SetViewport(0, viewport);
});
return;
}
const bool is_rescaling{texture_cache.IsRescaling()};
@ -1074,10 +1076,9 @@ void RasterizerVulkan::UpdateScissorsState(Tegra::Engines::Maxwell3D::Regs& regs
if (!regs.viewport_scale_offset_enabled) {
u32 x = regs.surface_clip.x;
u32 y = regs.surface_clip.y;
u32 width = static_cast<u32>(regs.surface_clip.width) ? static_cast<u32>(regs.surface_clip.width) : 1u;
u32 height = static_cast<u32>(regs.surface_clip.height) ? static_cast<u32>(regs.surface_clip.height) : 1u;
u32 width = std::max(1u, static_cast<u32>(regs.surface_clip.width));
u32 height = std::max(1u, static_cast<u32>(regs.surface_clip.height));
if (regs.window_origin.mode != Maxwell::WindowOrigin::Mode::UpperLeft) {
// Vulkan scissor is top-left; convert from lower-left coordinates.
y = regs.surface_clip.height - (y + height);
}
VkRect2D scissor{};
@ -1085,7 +1086,9 @@ void RasterizerVulkan::UpdateScissorsState(Tegra::Engines::Maxwell3D::Regs& regs
scissor.offset.y = static_cast<int32_t>(y);
scissor.extent.width = width;
scissor.extent.height = height;
scheduler.Record([scissor](vk::CommandBuffer cmdbuf) { cmdbuf.SetScissor(0, scissor); });
scheduler.Record([scissor](vk::CommandBuffer cmdbuf) {
cmdbuf.SetScissor(0, scissor);
});
return;
}
u32 up_scale = 1;

Loading…
Cancel
Save