diff --git a/src/core/fullscreenui.cpp b/src/core/fullscreenui.cpp index 80c15758d..acc928db5 100644 --- a/src/core/fullscreenui.cpp +++ b/src/core/fullscreenui.cpp @@ -1093,8 +1093,6 @@ bool FullscreenUI::LoadBackgroundShader(const std::string& path, Error* error) plconfig.blend = GPUPipeline::BlendState::GetNoBlendingState(); plconfig.geometry_shader = nullptr; plconfig.depth_format = GPUTexture::Format::Unknown; - plconfig.samples = 1; - plconfig.per_sample_shading = false; plconfig.render_pass_flags = GPUPipeline::NoRenderPassFlags; plconfig.layout = GPUPipeline::Layout::SingleTextureAndPushConstants; plconfig.SetTargetFormats(g_gpu_device->HasMainSwapChain() ? g_gpu_device->GetMainSwapChain()->GetFormat() : diff --git a/src/core/fullscreenui_widgets.cpp b/src/core/fullscreenui_widgets.cpp index 9b9bc3398..cacbd019a 100644 --- a/src/core/fullscreenui_widgets.cpp +++ b/src/core/fullscreenui_widgets.cpp @@ -782,8 +782,6 @@ bool FullscreenUI::CompileTransitionPipelines(Error* error) plconfig.depth = GPUPipeline::DepthState::GetNoTestsState(); plconfig.blend = GPUPipeline::BlendState::GetNoBlendingState(); plconfig.SetTargetFormats(swap_chain ? swap_chain->GetFormat() : GPUTexture::Format::RGBA8); - plconfig.samples = 1; - plconfig.per_sample_shading = false; plconfig.render_pass_flags = GPUPipeline::NoRenderPassFlags; plconfig.vertex_shader = vs.get(); plconfig.geometry_shader = nullptr; diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 3b58d2ae2..b1e644063 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -1355,11 +1355,9 @@ bool GPU_HW::CompilePipelines(Error* error) GPUPipeline::GraphicsConfig plconfig = {}; plconfig.layout = GPUPipeline::Layout::SingleTextureAndUBO; plconfig.input_layout.vertex_stride = sizeof(BatchVertex); - plconfig.rasterization = GPUPipeline::RasterizationState::GetNoCullState(); + plconfig.rasterization = GPUPipeline::RasterizationState::GetNoCullState(m_multisamples, per_sample_shading); plconfig.primitive = GPUPipeline::Primitive::Triangles; plconfig.geometry_shader = nullptr; - plconfig.samples = m_multisamples; - plconfig.per_sample_shading = per_sample_shading; plconfig.depth = GPUPipeline::DepthState::GetNoTestsState(); // [depth_test][transparency_mode][render_mode][texture_mode][dithering][interlacing][check_mask] @@ -1585,7 +1583,7 @@ bool GPU_HW::CompilePipelines(Error* error) SetScreenQuadInputLayout(plconfig); plconfig.vertex_shader = m_screen_quad_vertex_shader.get(); plconfig.layout = GPUPipeline::Layout::SingleTextureAndPushConstants; - plconfig.per_sample_shading = false; + plconfig.rasterization = GPUPipeline::RasterizationState::GetNoCullState(m_multisamples, false); plconfig.blend = GPUPipeline::BlendState::GetNoBlendingState(); plconfig.color_formats[1] = needs_rov_depth ? VRAM_DS_COLOR_FORMAT : GPUTexture::Format::Unknown; @@ -1729,8 +1727,7 @@ bool GPU_HW::CompilePipelines(Error* error) plconfig.render_pass_flags = GPUPipeline::NoRenderPassFlags; plconfig.depth = GPUPipeline::DepthState::GetNoTestsState(); plconfig.blend = GPUPipeline::BlendState::GetNoBlendingState(); - plconfig.samples = m_multisamples; - plconfig.per_sample_shading = true; + plconfig.rasterization = GPUPipeline::RasterizationState::GetNoCullState(m_multisamples, true); plconfig.SetTargetFormats(VRAM_DS_COLOR_FORMAT); if (!(m_copy_depth_pipeline = g_gpu_device->CreatePipeline(plconfig, error))) return false; @@ -1743,7 +1740,7 @@ bool GPU_HW::CompilePipelines(Error* error) SetScreenQuadInputLayout(plconfig); plconfig.vertex_shader = m_screen_quad_vertex_shader.get(); plconfig.fragment_shader = fs.get(); - plconfig.per_sample_shading = false; + plconfig.rasterization = GPUPipeline::RasterizationState::GetNoCullState(m_multisamples, false); if (!m_use_rov_for_shader_blend) { plconfig.SetTargetFormats(VRAM_RT_FORMAT, depth_buffer_format); @@ -1791,8 +1788,6 @@ bool GPU_HW::CompileResolutionDependentPipelines(Error* error) plconfig.rasterization = GPUPipeline::RasterizationState::GetNoCullState(); plconfig.primitive = GPUPipeline::Primitive::Triangles; plconfig.geometry_shader = nullptr; - plconfig.samples = 1; - plconfig.per_sample_shading = false; plconfig.render_pass_flags = GPUPipeline::NoRenderPassFlags; plconfig.depth = GPUPipeline::DepthState::GetNoTestsState(); plconfig.blend = GPUPipeline::BlendState::GetNoBlendingState(); @@ -1871,8 +1866,6 @@ bool GPU_HW::CompileDownsamplePipelines(Error* error) plconfig.rasterization = GPUPipeline::RasterizationState::GetNoCullState(); plconfig.primitive = GPUPipeline::Primitive::Triangles; plconfig.geometry_shader = nullptr; - plconfig.samples = 1; - plconfig.per_sample_shading = false; plconfig.depth = GPUPipeline::DepthState::GetNoTestsState(); plconfig.blend = GPUPipeline::BlendState::GetNoBlendingState(); plconfig.vertex_shader = m_fullscreen_quad_vertex_shader.get(); diff --git a/src/core/gpu_hw_texture_cache.cpp b/src/core/gpu_hw_texture_cache.cpp index f03bbd97a..608196d23 100644 --- a/src/core/gpu_hw_texture_cache.cpp +++ b/src/core/gpu_hw_texture_cache.cpp @@ -871,8 +871,6 @@ bool GPUTextureCache::CompilePipelines(Error* error) plconfig.blend = GPUPipeline::BlendState::GetNoBlendingState(); plconfig.primitive = GPUPipeline::Primitive::Triangles; plconfig.geometry_shader = nullptr; - plconfig.samples = 1; - plconfig.per_sample_shading = false; plconfig.render_pass_flags = GPUPipeline::NoRenderPassFlags; plconfig.SetTargetFormats(REPLACEMENT_TEXTURE_FORMAT); diff --git a/src/core/gpu_presenter.cpp b/src/core/gpu_presenter.cpp index 5958ec358..53b8e1ae7 100644 --- a/src/core/gpu_presenter.cpp +++ b/src/core/gpu_presenter.cpp @@ -105,8 +105,6 @@ bool GPUPresenter::CompileDisplayPipelines(bool display, bool deinterlace, bool plconfig.blend = GPUPipeline::BlendState::GetNoBlendingState(); plconfig.geometry_shader = nullptr; plconfig.depth_format = GPUTexture::Format::Unknown; - plconfig.samples = 1; - plconfig.per_sample_shading = false; plconfig.render_pass_flags = GPUPipeline::NoRenderPassFlags; if (display) diff --git a/src/core/shader_cache_version.h b/src/core/shader_cache_version.h index b998eb6ea..0a5e8b89a 100644 --- a/src/core/shader_cache_version.h +++ b/src/core/shader_cache_version.h @@ -5,4 +5,4 @@ #include "common/types.h" -inline constexpr u32 SHADER_CACHE_VERSION = 35; +inline constexpr u32 SHADER_CACHE_VERSION = 36; diff --git a/src/util/d3d11_device.h b/src/util/d3d11_device.h index 8656424aa..5772168fc 100644 --- a/src/util/d3d11_device.h +++ b/src/util/d3d11_device.h @@ -132,7 +132,7 @@ private: { size_t operator()(const BlendStateMapKey& key) const; }; - using RasterizationStateMap = std::unordered_map>; + using RasterizationStateMap = std::unordered_map>; using DepthStateMap = std::unordered_map>; using BlendStateMap = std::unordered_map, BlendStateMapHash>; using InputLayoutMap = diff --git a/src/util/d3d12_pipeline.cpp b/src/util/d3d12_pipeline.cpp index 8a1a83153..9bd948492 100644 --- a/src/util/d3d12_pipeline.cpp +++ b/src/util/d3d12_pipeline.cpp @@ -109,8 +109,7 @@ std::string D3D12Pipeline::GetPipelineName(const GraphicsConfig& config) hash.Update(shader->GetBytecodeData(), shader->GetBytecodeSize()); hash.Update(&config.color_formats, sizeof(config.color_formats)); hash.Update(&config.depth_format, sizeof(config.depth_format)); - hash.Update(&config.samples, sizeof(config.samples)); - hash.Update(&config.per_sample_shading, sizeof(config.per_sample_shading)); + hash.Update(&config.render_pass_flags, sizeof(config.render_pass_flags)); u8 digest[SHA1Digest::DIGEST_SIZE]; hash.Final(digest); @@ -238,8 +237,8 @@ std::unique_ptr D3D12Device::CreatePipeline(const GPUPipeline::Grap gpb.SetRasterizationState(D3D12_FILL_MODE_SOLID, cull_mapping[static_cast(config.rasterization.cull_mode.GetValue())], false); - if (config.samples > 1) - gpb.SetMultisamples(config.samples); + if (config.rasterization.multisamples > 1) + gpb.SetMultisamples(config.rasterization.multisamples); gpb.SetDepthState(config.depth.depth_test != GPUPipeline::DepthFunc::Always || config.depth.depth_write, config.depth.depth_write, compare_mapping[static_cast(config.depth.depth_test.GetValue())]); gpb.SetNoStencilState(); diff --git a/src/util/gpu_device.cpp b/src/util/gpu_device.cpp index fe313c3d5..848b2c643 100644 --- a/src/util/gpu_device.cpp +++ b/src/util/gpu_device.cpp @@ -121,10 +121,13 @@ bool GPUPipeline::InputLayout::operator!=(const InputLayout& rhs) const sizeof(VertexAttribute) * rhs.vertex_attributes.size()) != 0); } -GPUPipeline::RasterizationState GPUPipeline::RasterizationState::GetNoCullState() +GPUPipeline::RasterizationState GPUPipeline::RasterizationState::GetNoCullState(u8 multisamples /* = 1 */, + bool per_sample_shading /* = false */) { RasterizationState ret = {}; ret.cull_mode = CullMode::None; + ret.multisamples = multisamples; + ret.per_sample_shading = per_sample_shading; return ret; } @@ -1310,7 +1313,10 @@ void GPUDevice::SetDriverType(GPUDriverType type) { m_driver_type = type; -#define NTENTRY(n) {GPUDriverType::n, #n} +#define NTENTRY(n) \ + { \ + GPUDriverType::n, #n \ + } static constexpr const std::pair name_table[] = { NTENTRY(Unknown), NTENTRY(AMDProprietary), diff --git a/src/util/gpu_device.h b/src/util/gpu_device.h index 5eecbeca4..c590bd611 100644 --- a/src/util/gpu_device.h +++ b/src/util/gpu_device.h @@ -370,12 +370,13 @@ public: MaxCount }; - // TODO: purge this? union RasterizationState { - u8 key; + u16 key; - BitField cull_mode; + BitField cull_mode; + BitField multisamples; + BitField per_sample_shading; // clang-format off ALWAYS_INLINE bool operator==(const RasterizationState& rhs) const { return key == rhs.key; } @@ -383,7 +384,7 @@ public: ALWAYS_INLINE bool operator<(const RasterizationState& rhs) const { return key < rhs.key; } // clang-format on - static RasterizationState GetNoCullState(); + static RasterizationState GetNoCullState(u8 multisamples = 1, bool per_sample_shading = false); }; union DepthState @@ -447,23 +448,20 @@ public: struct GraphicsConfig { - Layout layout; - - Primitive primitive; InputLayout input_layout; - - RasterizationState rasterization; - DepthState depth; - BlendState blend; - GPUShader* vertex_shader; GPUShader* geometry_shader; GPUShader* fragment_shader; + BlendState blend; + RasterizationState rasterization; + DepthState depth; + + Layout layout; + Primitive primitive; + GPUTexture::Format color_formats[4]; GPUTexture::Format depth_format; - u8 samples; - bool per_sample_shading; RenderPassFlag render_pass_flags; void SetTargetFormats(GPUTexture::Format color_format, diff --git a/src/util/imgui_manager.cpp b/src/util/imgui_manager.cpp index a75892ec2..395919881 100644 --- a/src/util/imgui_manager.cpp +++ b/src/util/imgui_manager.cpp @@ -406,8 +406,6 @@ bool ImGuiManager::CompilePipelines(Error* error) plconfig.blend = GPUPipeline::BlendState::GetAlphaBlendingState(); plconfig.blend.write_mask = 0x7; plconfig.SetTargetFormats(s_state.window_format); - plconfig.samples = 1; - plconfig.per_sample_shading = false; plconfig.render_pass_flags = GPUPipeline::NoRenderPassFlags; plconfig.vertex_shader = imgui_vs.get(); plconfig.geometry_shader = nullptr; diff --git a/src/util/metal_device.mm b/src/util/metal_device.mm index 201b77cd0..e350784a1 100644 --- a/src/util/metal_device.mm +++ b/src/util/metal_device.mm @@ -872,7 +872,7 @@ std::unique_ptr MetalDevice::CreatePipeline(const GPUPipeline::Grap // General const MTLPrimitiveType primitive = primitives[static_cast(config.primitive)]; - desc.rasterSampleCount = config.samples; + desc.rasterSampleCount = config.rasterization.multisamples; // Metal-specific stuff desc.vertexBuffers[0].mutability = MTLMutabilityImmutable; diff --git a/src/util/postprocessing_shader_fx.cpp b/src/util/postprocessing_shader_fx.cpp index 5e914f20f..9528bdbb4 100644 --- a/src/util/postprocessing_shader_fx.cpp +++ b/src/util/postprocessing_shader_fx.cpp @@ -1482,8 +1482,6 @@ bool PostProcessing::ReShadeFXShader::CompilePipeline(GPUTexture::Format format, plconfig.rasterization = GPUPipeline::RasterizationState::GetNoCullState(); plconfig.depth = GPUPipeline::DepthState::GetNoTestsState(); plconfig.blend = GPUPipeline::BlendState::GetNoBlendingState(); - plconfig.samples = 1; - plconfig.per_sample_shading = false; plconfig.render_pass_flags = GPUPipeline::NoRenderPassFlags; GPUPipeline::ComputeConfig cplconfig; diff --git a/src/util/postprocessing_shader_glsl.cpp b/src/util/postprocessing_shader_glsl.cpp index c83011d49..4783882ac 100644 --- a/src/util/postprocessing_shader_glsl.cpp +++ b/src/util/postprocessing_shader_glsl.cpp @@ -137,8 +137,6 @@ bool PostProcessing::GLSLShader::CompilePipeline(GPUTexture::Format format, u32 plconfig.rasterization = GPUPipeline::RasterizationState::GetNoCullState(); plconfig.depth = GPUPipeline::DepthState::GetNoTestsState(); plconfig.blend = GPUPipeline::BlendState::GetNoBlendingState(); - plconfig.samples = 1; - plconfig.per_sample_shading = false; plconfig.render_pass_flags = GPUPipeline::NoRenderPassFlags; plconfig.vertex_shader = vs.get(); plconfig.fragment_shader = fs.get(); diff --git a/src/util/postprocessing_shader_slang.cpp b/src/util/postprocessing_shader_slang.cpp index b366aa9ee..7cfd341a2 100644 --- a/src/util/postprocessing_shader_slang.cpp +++ b/src/util/postprocessing_shader_slang.cpp @@ -1482,8 +1482,6 @@ bool PostProcessing::SlangShader::CompilePass(Pass& pass, Error* error) plconfig.rasterization = GPUPipeline::RasterizationState::GetNoCullState(); plconfig.depth = GPUPipeline::DepthState::GetNoTestsState(); plconfig.blend = GPUPipeline::BlendState::GetNoBlendingState(); - plconfig.samples = 1; - plconfig.per_sample_shading = false; plconfig.render_pass_flags = GPUPipeline::NoRenderPassFlags; plconfig.vertex_shader = vs.get(); plconfig.fragment_shader = fs.get(); @@ -1779,8 +1777,6 @@ std::unique_ptr PostProcessing::SlangShader::CreateBlitPipeline(GPU plconfig.rasterization = GPUPipeline::RasterizationState::GetNoCullState(); plconfig.depth = GPUPipeline::DepthState::GetNoTestsState(); plconfig.blend = GPUPipeline::BlendState::GetNoBlendingState(); - plconfig.samples = 1; - plconfig.per_sample_shading = false; plconfig.render_pass_flags = GPUPipeline::NoRenderPassFlags; plconfig.vertex_shader = vs.get(); plconfig.fragment_shader = fs.get(); diff --git a/src/util/vulkan_device.cpp b/src/util/vulkan_device.cpp index b54e6eb84..ba0fa3b1b 100644 --- a/src/util/vulkan_device.cpp +++ b/src/util/vulkan_device.cpp @@ -1214,7 +1214,7 @@ VkRenderPass VulkanDevice::GetRenderPass(const GPUPipeline::GraphicsConfig& conf key.stencil_store_op = stencil ? VK_ATTACHMENT_STORE_OP_STORE : VK_ATTACHMENT_STORE_OP_DONT_CARE; } - key.samples = static_cast(config.samples); + key.samples = config.rasterization.multisamples; key.feedback_loop = config.render_pass_flags; const auto it = m_render_pass_cache.find(key); diff --git a/src/util/vulkan_pipeline.cpp b/src/util/vulkan_pipeline.cpp index b0f74bd4c..73f2f1bca 100644 --- a/src/util/vulkan_pipeline.cpp +++ b/src/util/vulkan_pipeline.cpp @@ -215,8 +215,8 @@ std::unique_ptr VulkanDevice::CreatePipeline(const GPUPipeline::Gra gpb.SetRasterizationState(VK_POLYGON_MODE_FILL, cull_mapping[static_cast(config.rasterization.cull_mode.GetValue())], VK_FRONT_FACE_CLOCKWISE); - if (config.samples > 1) - gpb.SetMultisamples(config.samples, config.per_sample_shading); + if (config.rasterization.multisamples > 1) + gpb.SetMultisamples(config.rasterization.multisamples, config.rasterization.per_sample_shading); gpb.SetDepthState(config.depth.depth_test != GPUPipeline::DepthFunc::Always || config.depth.depth_write, config.depth.depth_write, compare_mapping[static_cast(config.depth.depth_test.GetValue())]); gpb.SetNoStencilState();