mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 13:56:59 +01:00
renderer: remove dynamic draw state from pipeline keys
This commit is contained in:
@@ -74,20 +74,6 @@ void PipelineCacheLog(fmt::format_string<Args...> format, Args&&... args) {
|
|||||||
Log::Flush();
|
Log::Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NormalizeStaticParamsForDynamicState(PipelineStaticParameters& static_params) {
|
|
||||||
static_params.viewport_scale[0] = 0.5f;
|
|
||||||
static_params.viewport_scale[1] = 0.5f;
|
|
||||||
static_params.viewport_scale[2] = 1.0f;
|
|
||||||
static_params.viewport_offset[0] = 0.5f;
|
|
||||||
static_params.viewport_offset[1] = 0.5f;
|
|
||||||
static_params.viewport_offset[2] = 0.0f;
|
|
||||||
|
|
||||||
static_params.scissor_ltrb[0] = 0;
|
|
||||||
static_params.scissor_ltrb[1] = 0;
|
|
||||||
static_params.scissor_ltrb[2] = 1;
|
|
||||||
static_params.scissor_ltrb[3] = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ReadShaderGuestMemory(void*, uint64_t address, uint32_t* value) {
|
bool ReadShaderGuestMemory(void*, uint64_t address, uint32_t* value) {
|
||||||
return value != nullptr &&
|
return value != nullptr &&
|
||||||
Libs::LibKernel::Memory::TryReadGpuCleanBacking(address, value, sizeof(*value));
|
Libs::LibKernel::Memory::TryReadGpuCleanBacking(address, value, sizeof(*value));
|
||||||
@@ -690,10 +676,7 @@ PipelineCache::GraphicsPipeline& PipelineCache::CreateGraphicsPipeline(
|
|||||||
if (static_params.sample_shading_enable && !m_graphics.sample_rate_shading_enabled) {
|
if (static_params.sample_shading_enable && !m_graphics.sample_rate_shading_enabled) {
|
||||||
EXIT("Pipeline: sample-rate shading is required but unsupported by the host\n");
|
EXIT("Pipeline: sample-rate shading is required but unsupported by the host\n");
|
||||||
}
|
}
|
||||||
static_params.with_depth = with_depth;
|
static_params.with_depth = with_depth;
|
||||||
static_params.depth_test_enable = depth.depth_test_enable;
|
|
||||||
static_params.depth_write_enable = (depth.depth_write_enable && !depth.depth_clear_enable);
|
|
||||||
static_params.depth_compare_op = depth.depth_compare_op;
|
|
||||||
static_params.depth_bounds_test_enable = depth.depth_bounds_test_enable;
|
static_params.depth_bounds_test_enable = depth.depth_bounds_test_enable;
|
||||||
static_params.depth_min_bounds = depth.depth_min_bounds;
|
static_params.depth_min_bounds = depth.depth_min_bounds;
|
||||||
static_params.depth_max_bounds = depth.depth_max_bounds;
|
static_params.depth_max_bounds = depth.depth_max_bounds;
|
||||||
@@ -721,8 +704,6 @@ PipelineCache::GraphicsPipeline& PipelineCache::CreateGraphicsPipeline(
|
|||||||
static_params.blend_enable[i] = bc.enable;
|
static_params.blend_enable[i] = bc.enable;
|
||||||
static_params.blend_bypass[i] = rt.info.blend_bypass;
|
static_params.blend_bypass[i] = rt.info.blend_bypass;
|
||||||
}
|
}
|
||||||
NormalizeStaticParamsForDynamicState(static_params);
|
|
||||||
|
|
||||||
GraphicsPipelineKey key {};
|
GraphicsPipelineKey key {};
|
||||||
key.rendering = rendering;
|
key.rendering = rendering;
|
||||||
key.vs_shader_id = p.vs_shader_id;
|
key.vs_shader_id = p.vs_shader_id;
|
||||||
|
|||||||
@@ -32,19 +32,13 @@ struct ComputeShaderInfo;
|
|||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
|
||||||
struct PipelineStaticParameters {
|
struct PipelineStaticParameters {
|
||||||
float viewport_scale[3] = {};
|
|
||||||
float viewport_offset[3] = {};
|
|
||||||
bool negative_one_to_one = false;
|
bool negative_one_to_one = false;
|
||||||
bool depth_clip_enable = true;
|
bool depth_clip_enable = true;
|
||||||
int scissor_ltrb[4] = {0};
|
|
||||||
vk::PrimitiveTopology topology = vk::PrimitiveTopology::ePointList;
|
vk::PrimitiveTopology topology = vk::PrimitiveTopology::ePointList;
|
||||||
bool primitive_restart_enable = false;
|
bool primitive_restart_enable = false;
|
||||||
uint32_t samples = 1;
|
uint32_t samples = 1;
|
||||||
bool sample_shading_enable = false;
|
bool sample_shading_enable = false;
|
||||||
bool with_depth = false;
|
bool with_depth = false;
|
||||||
bool depth_test_enable = false;
|
|
||||||
bool depth_write_enable = false;
|
|
||||||
vk::CompareOp depth_compare_op = vk::CompareOp::eNever;
|
|
||||||
bool depth_bounds_test_enable = false;
|
bool depth_bounds_test_enable = false;
|
||||||
float depth_min_bounds = 0.0f;
|
float depth_min_bounds = 0.0f;
|
||||||
float depth_max_bounds = 0.0f;
|
float depth_max_bounds = 0.0f;
|
||||||
@@ -74,14 +68,7 @@ struct PipelineStaticParameters {
|
|||||||
static_assert(std::is_trivially_copyable_v<PipelineStaticParameters>);
|
static_assert(std::is_trivially_copyable_v<PipelineStaticParameters>);
|
||||||
static_assert(std::is_standard_layout_v<PipelineStaticParameters>);
|
static_assert(std::is_standard_layout_v<PipelineStaticParameters>);
|
||||||
static_assert(alignof(PipelineStaticParameters) == 1);
|
static_assert(alignof(PipelineStaticParameters) == 1);
|
||||||
static_assert(sizeof(PipelineStaticParameters) ==
|
static_assert(sizeof(PipelineStaticParameters) == 166);
|
||||||
sizeof(float[3]) + sizeof(float[3]) + sizeof(bool) * 2 + sizeof(int[4]) +
|
|
||||||
sizeof(vk::PrimitiveTopology) + sizeof(bool) + sizeof(uint32_t) +
|
|
||||||
sizeof(bool) * 4 + sizeof(vk::CompareOp) + sizeof(bool) + sizeof(float) * 2 +
|
|
||||||
sizeof(bool) + sizeof(PipelineStencilStaticState) * 2 + sizeof(uint32_t) +
|
|
||||||
sizeof(uint32_t[RENDER_COLOR_ATTACHMENTS_MAX]) + sizeof(bool) * 3 +
|
|
||||||
sizeof(uint8_t[RENDER_COLOR_ATTACHMENTS_MAX]) * 6 +
|
|
||||||
sizeof(bool[RENDER_COLOR_ATTACHMENTS_MAX]) * 3);
|
|
||||||
|
|
||||||
struct PipelineRenderingState {
|
struct PipelineRenderingState {
|
||||||
std::array<vk::Format, RENDER_COLOR_ATTACHMENTS_MAX> color_formats {};
|
std::array<vk::Format, RENDER_COLOR_ATTACHMENTS_MAX> color_formats {};
|
||||||
|
|||||||
@@ -650,20 +650,6 @@ void CreatePipelineInternal(
|
|||||||
input_assembly.primitiveRestartEnable =
|
input_assembly.primitiveRestartEnable =
|
||||||
static_params.primitive_restart_enable ? VK_TRUE : VK_FALSE;
|
static_params.primitive_restart_enable ? VK_TRUE : VK_FALSE;
|
||||||
|
|
||||||
vk::Viewport viewport {};
|
|
||||||
viewport.x = static_params.viewport_offset[0] - static_params.viewport_scale[0];
|
|
||||||
viewport.y = static_params.viewport_offset[1] - static_params.viewport_scale[1];
|
|
||||||
viewport.width = static_params.viewport_scale[0] * 2.0f;
|
|
||||||
viewport.height = static_params.viewport_scale[1] * 2.0f;
|
|
||||||
viewport.minDepth = static_params.viewport_offset[2];
|
|
||||||
viewport.maxDepth = static_params.viewport_scale[2] + static_params.viewport_offset[2];
|
|
||||||
|
|
||||||
vk::Rect2D scissor {};
|
|
||||||
scissor.offset = {static_params.scissor_ltrb[0], static_params.scissor_ltrb[1]};
|
|
||||||
scissor.extent = {
|
|
||||||
static_cast<uint32_t>(static_params.scissor_ltrb[2] - static_params.scissor_ltrb[0]),
|
|
||||||
static_cast<uint32_t>(static_params.scissor_ltrb[3] - static_params.scissor_ltrb[1])};
|
|
||||||
|
|
||||||
vk::PipelineViewportDepthClipControlCreateInfoEXT depth_clip_control {};
|
vk::PipelineViewportDepthClipControlCreateInfoEXT depth_clip_control {};
|
||||||
depth_clip_control.sType = vk::StructureType::ePipelineViewportDepthClipControlCreateInfoEXT;
|
depth_clip_control.sType = vk::StructureType::ePipelineViewportDepthClipControlCreateInfoEXT;
|
||||||
depth_clip_control.pNext = nullptr;
|
depth_clip_control.pNext = nullptr;
|
||||||
@@ -674,9 +660,9 @@ void CreatePipelineInternal(
|
|||||||
viewport_state.pNext = &depth_clip_control;
|
viewport_state.pNext = &depth_clip_control;
|
||||||
viewport_state.flags = {};
|
viewport_state.flags = {};
|
||||||
viewport_state.viewportCount = 1;
|
viewport_state.viewportCount = 1;
|
||||||
viewport_state.pViewports = &viewport;
|
viewport_state.pViewports = nullptr;
|
||||||
viewport_state.scissorCount = 1;
|
viewport_state.scissorCount = 1;
|
||||||
viewport_state.pScissors = &scissor;
|
viewport_state.pScissors = nullptr;
|
||||||
|
|
||||||
vk::CullModeFlags cull_mode = vk::CullModeFlagBits::eNone;
|
vk::CullModeFlags cull_mode = vk::CullModeFlagBits::eNone;
|
||||||
if (static_params.cull_back) {
|
if (static_params.cull_back) {
|
||||||
@@ -839,9 +825,6 @@ void CreatePipelineInternal(
|
|||||||
depth_stencil_info.sType = vk::StructureType::ePipelineDepthStencilStateCreateInfo;
|
depth_stencil_info.sType = vk::StructureType::ePipelineDepthStencilStateCreateInfo;
|
||||||
depth_stencil_info.pNext = nullptr;
|
depth_stencil_info.pNext = nullptr;
|
||||||
depth_stencil_info.flags = {};
|
depth_stencil_info.flags = {};
|
||||||
depth_stencil_info.depthTestEnable = (static_params.depth_test_enable ? VK_TRUE : VK_FALSE);
|
|
||||||
depth_stencil_info.depthWriteEnable = (static_params.depth_write_enable ? VK_TRUE : VK_FALSE);
|
|
||||||
depth_stencil_info.depthCompareOp = static_params.depth_compare_op;
|
|
||||||
depth_stencil_info.depthBoundsTestEnable =
|
depth_stencil_info.depthBoundsTestEnable =
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
VK_FALSE; // MoltenVK lacks the depthBounds feature; depth-bounds testing is disabled
|
VK_FALSE; // MoltenVK lacks the depthBounds feature; depth-bounds testing is disabled
|
||||||
@@ -864,6 +847,9 @@ void CreatePipelineInternal(
|
|||||||
vk::DynamicState::eViewport,
|
vk::DynamicState::eViewport,
|
||||||
vk::DynamicState::eScissor,
|
vk::DynamicState::eScissor,
|
||||||
vk::DynamicState::eLineWidth,
|
vk::DynamicState::eLineWidth,
|
||||||
|
vk::DynamicState::eDepthTestEnable,
|
||||||
|
vk::DynamicState::eDepthWriteEnable,
|
||||||
|
vk::DynamicState::eDepthCompareOp,
|
||||||
vk::DynamicState::eDepthBiasEnable,
|
vk::DynamicState::eDepthBiasEnable,
|
||||||
vk::DynamicState::eDepthBias,
|
vk::DynamicState::eDepthBias,
|
||||||
vk::DynamicState::eStencilCompareMask,
|
vk::DynamicState::eStencilCompareMask,
|
||||||
@@ -925,14 +911,11 @@ void CreatePipelineInternal(
|
|||||||
if (graphics_debug_dump_enabled()) {
|
if (graphics_debug_dump_enabled()) {
|
||||||
LOGF("PipelineTrace: vkCreateGraphicsPipelines begin VS=%" PRIu64 " PS=%" PRIu64
|
LOGF("PipelineTrace: vkCreateGraphicsPipelines begin VS=%" PRIu64 " PS=%" PRIu64
|
||||||
" topology=%" PRIu32 " color_mask=0x%08" PRIx32
|
" topology=%" PRIu32 " color_mask=0x%08" PRIx32
|
||||||
" depth=%s blend=%s dyn_states=%" PRIu32 " viewport=%f,%f %fx%f"
|
" depth=%s blend=%s dyn_states=%" PRIu32 "\n",
|
||||||
" scissor=%d,%d %ux%u\n",
|
|
||||||
pipeline.vs_shader_id, pipeline.ps_shader_id,
|
pipeline.vs_shader_id, pipeline.ps_shader_id,
|
||||||
static_cast<uint32_t>(static_params.topology),
|
static_cast<uint32_t>(static_params.topology), static_params.color_mask[0],
|
||||||
static_params.color_mask[0], (static_params.with_depth ? "true" : "false"),
|
(static_params.with_depth ? "true" : "false"),
|
||||||
(static_params.blend_enable[0] ? "true" : "false"), dynamic_states_count, viewport.x,
|
(static_params.blend_enable[0] ? "true" : "false"), dynamic_states_count);
|
||||||
viewport.y, viewport.width, viewport.height, scissor.offset.x, scissor.offset.y,
|
|
||||||
scissor.extent.width, scissor.extent.height);
|
|
||||||
}
|
}
|
||||||
result = graphics.device.createGraphicsPipelines(driver_cache, 1, &pipeline_info, nullptr,
|
result = graphics.device.createGraphicsPipelines(driver_cache, 1, &pipeline_info, nullptr,
|
||||||
&pipeline.pipeline);
|
&pipeline.pipeline);
|
||||||
|
|||||||
@@ -376,6 +376,10 @@ static void SetGraphicsDynamicParams(const CommandBuffer& buffer, vk::CommandBuf
|
|||||||
const auto& blend = ctx.GetBlendColor();
|
const auto& blend = ctx.GetBlendColor();
|
||||||
const std::array blend_constants {blend.red, blend.green, blend.blue, blend.alpha};
|
const std::array blend_constants {blend.red, blend.green, blend.blue, blend.alpha};
|
||||||
vk_buffer.setBlendConstants(blend_constants.data());
|
vk_buffer.setBlendConstants(blend_constants.data());
|
||||||
|
vk_buffer.setDepthTestEnable(depth.depth_test_enable ? VK_TRUE : VK_FALSE);
|
||||||
|
vk_buffer.setDepthWriteEnable(
|
||||||
|
depth.depth_write_enable && !depth.depth_clear_enable ? VK_TRUE : VK_FALSE);
|
||||||
|
vk_buffer.setDepthCompareOp(depth.depth_compare_op);
|
||||||
|
|
||||||
const auto& mode = ctx.GetModeControl();
|
const auto& mode = ctx.GetModeControl();
|
||||||
const auto& poly_offset = ctx.GetPolyOffset();
|
const auto& poly_offset = ctx.GetPolyOffset();
|
||||||
|
|||||||
Reference in New Issue
Block a user