PS5 graphics (#42)

This commit is contained in:
InoriRus
2022-07-26 17:15:08 +03:00
parent 6f9200d009
commit d256e8e4b0
13 changed files with 3040 additions and 1716 deletions
File diff suppressed because it is too large Load Diff
+67 -49
View File
@@ -138,9 +138,10 @@ public:
KYTY_CLASS_NO_COPY(PipelineCache);
VulkanPipeline* CreatePipeline(VulkanFramebuffer* framebuffer, RenderColorInfo* color, RenderDepthInfo* depth,
const ShaderVertexInputInfo* vs_input_info, HW::HardwareContext* ctx,
const ShaderVertexInputInfo* vs_input_info, HW::Context* ctx, HW::Shader* sh_ctx,
const ShaderPixelInputInfo* ps_input_info, VkPrimitiveTopology topology);
VulkanPipeline* CreatePipeline(const ShaderComputeInputInfo* input_info, const HW::ComputeShaderInfo* cs_regs);
VulkanPipeline* CreatePipeline(const ShaderComputeInputInfo* input_info, const HW::ComputeShaderInfo* cs_regs,
const HW::ShaderRegisters* sh_regs);
void DeletePipeline(VulkanPipeline* pipeline);
void DeletePipelines(VulkanFramebuffer* framebuffer);
void DeleteAllPipelines();
@@ -468,10 +469,14 @@ static void uc_print(const char* func, const HW::UserConfig& uc)
printf("\t GetPrimType() = 0x%08" PRIx32 "\n", uc.GetPrimType());
}
// void uc_check(const UserConfig& uc)
//{
// EXIT_NOT_IMPLEMENTED(uc.GetPrimType() != 4);
//}
static void uc_check(const HW::UserConfig& /*uc*/) {}
static void sh_print(const char* func, const HW::Shader& /*uc*/)
{
printf("%s\n", func);
}
static void sh_check(const HW::Shader& /*uc*/) {}
static Core::StringList rt_print(const char* func, const HW::RenderTarget& rt)
{
@@ -679,14 +684,14 @@ static void clip_print(const char* func, const HW::ClipControl& c)
{
printf("%s\n", func);
printf("\t user_clip_planes = 0x%08" PRIx32 "\n", c.user_clip_planes);
printf("\t user_clip_plane_mode = 0x%08" PRIx32 "\n", c.user_clip_plane_mode);
printf("\t clip_space = 0x%08" PRIx32 "\n", c.clip_space);
printf("\t vertex_kill_mode = 0x%08" PRIx32 "\n", c.vertex_kill_mode);
printf("\t min_z_clip_enable = 0x%08" PRIx32 "\n", c.min_z_clip_enable);
printf("\t max_z_clip_enable = 0x%08" PRIx32 "\n", c.max_z_clip_enable);
printf("\t user_clip_planes = 0x%02" PRIx8 "\n", c.user_clip_planes);
printf("\t user_clip_plane_mode = 0x%02" PRIx8 "\n", c.user_clip_plane_mode);
printf("\t dx_clip_space = %s\n", c.dx_clip_space ? "true" : "false");
printf("\t vertex_kill_any = %s\n", c.vertex_kill_any ? "true" : "false");
printf("\t min_z_clip_disable = %s\n", c.min_z_clip_disable ? "true" : "false");
printf("\t max_z_clip_disable = %s\n", c.max_z_clip_disable ? "true" : "false");
printf("\t user_clip_plane_negate_y = %s\n", c.user_clip_plane_negate_y ? "true" : "false");
printf("\t clip_enable = %s\n", c.clip_enable ? "true" : "false");
printf("\t clip_disable = %s\n", c.clip_disable ? "true" : "false");
printf("\t user_clip_plane_cull_only = %s\n", c.user_clip_plane_cull_only ? "true" : "false");
printf("\t cull_on_clipping_error_disable = %s\n", c.cull_on_clipping_error_disable ? "true" : "false");
printf("\t linear_attribute_clip_enable = %s\n", c.linear_attribute_clip_enable ? "true" : "false");
@@ -697,12 +702,12 @@ static void clip_check(const HW::ClipControl& c)
{
EXIT_NOT_IMPLEMENTED(c.user_clip_planes != 0);
EXIT_NOT_IMPLEMENTED(c.user_clip_plane_mode != 0);
EXIT_NOT_IMPLEMENTED(c.clip_space != 0);
EXIT_NOT_IMPLEMENTED(c.vertex_kill_mode != 0);
EXIT_NOT_IMPLEMENTED(c.min_z_clip_enable != 0);
EXIT_NOT_IMPLEMENTED(c.max_z_clip_enable != 0);
EXIT_NOT_IMPLEMENTED(c.dx_clip_space != false);
EXIT_NOT_IMPLEMENTED(c.vertex_kill_any != false);
EXIT_NOT_IMPLEMENTED(c.min_z_clip_disable != false);
EXIT_NOT_IMPLEMENTED(c.max_z_clip_disable != false);
EXIT_NOT_IMPLEMENTED(c.user_clip_plane_negate_y != false);
EXIT_NOT_IMPLEMENTED(c.clip_enable != false);
EXIT_NOT_IMPLEMENTED(c.clip_disable != false);
EXIT_NOT_IMPLEMENTED(c.user_clip_plane_cull_only != false);
EXIT_NOT_IMPLEMENTED(c.cull_on_clipping_error_disable != false);
EXIT_NOT_IMPLEMENTED(c.linear_attribute_clip_enable != false);
@@ -986,7 +991,7 @@ static void vp_check(const HW::ScreenViewport& vp, const HW::ScanModeControl& sm
EXIT_NOT_IMPLEMENTED(vp.viewports[0].viewport_scissor_window_offset_enable != false);
}
static void hw_check(const HW::HardwareContext& hw)
static void hw_check(const HW::Context& hw)
{
const auto& rt = hw.GetRenderTarget(0);
const auto& bc = hw.GetBlendControl(0);
@@ -1021,7 +1026,7 @@ static void hw_check(const HW::HardwareContext& hw)
// EXIT_NOT_IMPLEMENTED(hw.GetStencilClearValue() != 0);
}
static void hw_print(const HW::HardwareContext& hw)
static void hw_print(const HW::Context& hw)
{
const auto& rt = hw.GetRenderTarget(0);
const auto& bc = hw.GetBlendControl(0);
@@ -1042,7 +1047,7 @@ static void hw_print(const HW::HardwareContext& hw)
if (Kyty::Log::GetDirection() != Kyty::Log::Direction::Silent)
{
printf("HardwareContext\n");
printf("Context\n");
printf("\t GetRenderTargetMask() = 0x%08" PRIx32 "\n", hw.GetRenderTargetMask());
printf("\t GetDepthClearValue() = %f\n", hw.GetDepthClearValue());
printf("\t GetStencilClearValue() = %" PRIu8 "\n", hw.GetStencilClearValue());
@@ -2345,7 +2350,7 @@ VulkanPipeline* PipelineCache::Find(const Pipeline& p) const
}
VulkanPipeline* PipelineCache::CreatePipeline(VulkanFramebuffer* framebuffer, RenderColorInfo* color, RenderDepthInfo* depth,
const ShaderVertexInputInfo* vs_input_info, HW::HardwareContext* ctx,
const ShaderVertexInputInfo* vs_input_info, HW::Context* ctx, HW::Shader* sh_ctx,
const ShaderPixelInputInfo* ps_input_info, VkPrimitiveTopology topology)
{
KYTY_PROFILER_BLOCK("PipelineCache::CreatePipeline(Gfx)", profiler::colors::DeepOrangeA200);
@@ -2356,8 +2361,9 @@ VulkanPipeline* PipelineCache::CreatePipeline(VulkanFramebuffer* framebuffer, Re
Core::LockGuard lock(m_mutex);
const auto& vs_regs = ctx->GetVs();
const auto& ps_regs = ctx->GetPs();
const auto& vs_regs = sh_ctx->GetVs();
const auto& ps_regs = sh_ctx->GetPs();
const auto& sh_regs = ctx->GetShaderRegisters();
const HW::BlendColor& bclr = ctx->GetBlendColor();
const HW::ScreenViewport& vp = ctx->GetScreenViewport();
const auto& bc = ctx->GetBlendControl(0);
@@ -2445,8 +2451,8 @@ VulkanPipeline* PipelineCache::CreatePipeline(VulkanFramebuffer* framebuffer, Re
return found;
}
auto vs_code = ShaderParseVS(&vs_regs);
auto ps_code = ShaderParsePS(&ps_regs);
auto vs_code = ShaderParseVS(&vs_regs, &sh_regs);
auto ps_code = ShaderParsePS(&ps_regs, &sh_regs);
auto vs_shader = ShaderRecompileVS(vs_code, vs_input_info);
auto ps_shader = ShaderRecompilePS(ps_code, ps_input_info);
@@ -2497,11 +2503,13 @@ VulkanPipeline* PipelineCache::CreatePipeline(VulkanFramebuffer* framebuffer, Re
return p.pipeline;
}
VulkanPipeline* PipelineCache::CreatePipeline(const ShaderComputeInputInfo* input_info, const HW::ComputeShaderInfo* cs_regs)
VulkanPipeline* PipelineCache::CreatePipeline(const ShaderComputeInputInfo* input_info, const HW::ComputeShaderInfo* cs_regs,
const HW::ShaderRegisters* sh_regs)
{
KYTY_PROFILER_BLOCK("PipelineCache::CreatePipeline(Compute)", profiler::colors::RedA100);
EXIT_IF(cs_regs == nullptr);
EXIT_IF(sh_regs == nullptr);
Core::LockGuard lock(m_mutex);
@@ -2530,7 +2538,7 @@ VulkanPipeline* PipelineCache::CreatePipeline(const ShaderComputeInputInfo* inpu
return found;
}
auto cs_code = ShaderParseCS(cs_regs);
auto cs_code = ShaderParseCS(cs_regs, sh_regs);
auto cs_shader = ShaderRecompileCS(cs_code, input_info);
EXIT_IF(cs_shader.IsEmpty());
@@ -3612,7 +3620,7 @@ void GraphicsRenderDepthStencilBarrier(CommandBuffer* buffer, uint64_t vaddr, ui
}
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void FindRenderDepthInfo(uint64_t submit_id, CommandBuffer* /*buffer*/, const HW::HardwareContext& hw, RenderDepthInfo* r)
static void FindRenderDepthInfo(uint64_t submit_id, CommandBuffer* /*buffer*/, const HW::Context& hw, RenderDepthInfo* r)
{
KYTY_PROFILER_FUNCTION();
@@ -3772,7 +3780,7 @@ static void FindRenderDepthInfo(uint64_t submit_id, CommandBuffer* /*buffer*/, c
}
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void FindRenderColorInfo(uint64_t submit_id, CommandBuffer* buffer, const HW::HardwareContext& hw, RenderColorInfo* r)
static void FindRenderColorInfo(uint64_t submit_id, CommandBuffer* buffer, const HW::Context& hw, RenderColorInfo* r)
{
KYTY_PROFILER_FUNCTION();
@@ -4313,7 +4321,7 @@ static void SetDynamicParams(VkCommandBuffer vk_buffer, VulkanPipeline* pipeline
}
}
void GraphicsRenderDrawIndex(uint64_t submit_id, CommandBuffer* buffer, HW::HardwareContext* ctx, HW::UserConfig* ucfg,
void GraphicsRenderDrawIndex(uint64_t submit_id, CommandBuffer* buffer, HW::Context* ctx, HW::UserConfig* ucfg, HW::Shader* sh_ctx,
uint32_t index_type_and_size, uint32_t index_count, const void* index_addr, uint32_t flags, uint32_t type)
{
KYTY_PROFILER_FUNCTION();
@@ -4326,17 +4334,21 @@ void GraphicsRenderDrawIndex(uint64_t submit_id, CommandBuffer* buffer, HW::Hard
Core::LockGuard lock(g_render_ctx->GetMutex());
if (const auto& vs = ctx->GetVs(); !vs.vs_embedded && ShaderIsDisabled(vs.vs_regs.GetGpuAddress()))
if (const auto& vs = sh_ctx->GetVs(); !vs.vs_embedded && ShaderIsDisabled(vs.vs_regs.GetGpuAddress()))
{
return;
}
if (const auto& ps = ctx->GetPs(); !ps.ps_embedded && ShaderIsDisabled(ps.ps_regs.data_addr))
if (const auto& ps = sh_ctx->GetPs(); !ps.ps_embedded && ShaderIsDisabled(ps.ps_regs.data_addr))
{
return;
}
sh_print("GraphicsRenderDrawIndex():Shader:", *sh_ctx);
sh_check(*sh_ctx);
uc_print("GraphicsRenderDrawIndex():UserConfig:", *ucfg);
uc_check(*ucfg);
hw_print(*ctx);
hw_check(*ctx);
@@ -4394,12 +4406,12 @@ void GraphicsRenderDrawIndex(uint64_t submit_id, CommandBuffer* buffer, HW::Hard
auto* vk_buffer = buffer->GetPool()->buffers[buffer->GetIndex()];
ShaderVertexInputInfo vs_input_info;
ShaderGetInputInfoVS(&ctx->GetVs(), &vs_input_info);
ShaderGetInputInfoVS(&sh_ctx->GetVs(), &ctx->GetShaderRegisters(), &vs_input_info);
ShaderPixelInputInfo ps_input_info;
ShaderGetInputInfoPS(&ctx->GetPs(), &vs_input_info, &ps_input_info);
ShaderGetInputInfoPS(&sh_ctx->GetPs(), &ctx->GetShaderRegisters(), &vs_input_info, &ps_input_info);
auto* pipeline = g_render_ctx->GetPipelineCache()->CreatePipeline(framebuffer, &color_info, &depth_info, &vs_input_info, ctx,
auto* pipeline = g_render_ctx->GetPipelineCache()->CreatePipeline(framebuffer, &color_info, &depth_info, &vs_input_info, ctx, sh_ctx,
&ps_input_info, topology);
// EXIT_NOT_IMPLEMENTED(vs_input_info.buffers_num > 1);
@@ -4459,7 +4471,7 @@ void GraphicsRenderDrawIndex(uint64_t submit_id, CommandBuffer* buffer, HW::Hard
}
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
void GraphicsRenderDrawIndexAuto(uint64_t submit_id, CommandBuffer* buffer, HW::HardwareContext* ctx, HW::UserConfig* ucfg,
void GraphicsRenderDrawIndexAuto(uint64_t submit_id, CommandBuffer* buffer, HW::Context* ctx, HW::UserConfig* ucfg, HW::Shader* sh_ctx,
uint32_t index_count, uint32_t flags)
{
KYTY_PROFILER_FUNCTION();
@@ -4470,17 +4482,21 @@ void GraphicsRenderDrawIndexAuto(uint64_t submit_id, CommandBuffer* buffer, HW::
Core::LockGuard lock(g_render_ctx->GetMutex());
if (const auto& vs = ctx->GetVs(); !vs.vs_embedded && ShaderIsDisabled(vs.vs_regs.GetGpuAddress()))
if (const auto& vs = sh_ctx->GetVs(); !vs.vs_embedded && ShaderIsDisabled(vs.vs_regs.GetGpuAddress()))
{
return;
}
if (const auto& ps = ctx->GetPs(); !ps.ps_embedded && ShaderIsDisabled(ps.ps_regs.data_addr))
if (const auto& ps = sh_ctx->GetPs(); !ps.ps_embedded && ShaderIsDisabled(ps.ps_regs.data_addr))
{
return;
}
sh_print("GraphicsRenderDrawIndexAuto():Shader:", *sh_ctx);
sh_check(*sh_ctx);
uc_print("GraphicsRenderDrawIndexAuto():UserConfig:", *ucfg);
uc_check(*ucfg);
hw_print(*ctx);
hw_check(*ctx);
@@ -4515,16 +4531,17 @@ void GraphicsRenderDrawIndexAuto(uint64_t submit_id, CommandBuffer* buffer, HW::
default: EXIT("unknown primitive type: %u\n", ucfg->GetPrimType());
}
const auto& vertex_shader_info = ctx->GetVs();
const auto& pixel_shader_info = ctx->GetPs();
const auto& vertex_shader_info = sh_ctx->GetVs();
const auto& pixel_shader_info = sh_ctx->GetPs();
const auto& shader_regs = ctx->GetShaderRegisters();
ShaderVertexInputInfo vs_input_info;
ShaderGetInputInfoVS(&vertex_shader_info, &vs_input_info);
ShaderGetInputInfoVS(&vertex_shader_info, &shader_regs, &vs_input_info);
ShaderPixelInputInfo ps_input_info;
ShaderGetInputInfoPS(&pixel_shader_info, &vs_input_info, &ps_input_info);
ShaderGetInputInfoPS(&pixel_shader_info, &shader_regs, &vs_input_info, &ps_input_info);
auto* pipeline = g_render_ctx->GetPipelineCache()->CreatePipeline(framebuffer, &color_info, &depth_info, &vs_input_info, ctx,
auto* pipeline = g_render_ctx->GetPipelineCache()->CreatePipeline(framebuffer, &color_info, &depth_info, &vs_input_info, ctx, sh_ctx,
&ps_input_info, topology);
// EXIT_NOT_IMPLEMENTED(vs_input_info.buffers_num > 1);
@@ -4578,7 +4595,7 @@ void GraphicsRenderDrawIndexAuto(uint64_t submit_id, CommandBuffer* buffer, HW::
InvalidateMemoryObject(depth_info);
}
void GraphicsRenderDispatchDirect(uint64_t submit_id, CommandBuffer* buffer, HW::HardwareContext* ctx, uint32_t thread_group_x,
void GraphicsRenderDispatchDirect(uint64_t submit_id, CommandBuffer* buffer, HW::Context* ctx, HW::Shader* sh_ctx, uint32_t thread_group_x,
uint32_t thread_group_y, uint32_t thread_group_z, uint32_t mode)
{
EXIT_IF(ctx == nullptr);
@@ -4588,21 +4605,22 @@ void GraphicsRenderDispatchDirect(uint64_t submit_id, CommandBuffer* buffer, HW:
Core::LockGuard lock(g_render_ctx->GetMutex());
if (ShaderIsDisabled(ctx->GetCs().cs_regs.data_addr))
if (ShaderIsDisabled(sh_ctx->GetCs().cs_regs.data_addr))
{
return;
}
EXIT_NOT_IMPLEMENTED(mode != 0);
const auto& cs_regs = ctx->GetCs();
const auto& cs_regs = sh_ctx->GetCs();
const auto& sh_regs = ctx->GetShaderRegisters();
ShaderComputeInputInfo input_info;
ShaderGetInputInfoCS(&cs_regs, &input_info);
ShaderGetInputInfoCS(&cs_regs, &sh_regs, &input_info);
auto* vk_buffer = buffer->GetPool()->buffers[buffer->GetIndex()];
auto* pipeline = g_render_ctx->GetPipelineCache()->CreatePipeline(&input_info, &ctx->GetCs());
auto* pipeline = g_render_ctx->GetPipelineCache()->CreatePipeline(&input_info, &sh_ctx->GetCs(), &ctx->GetShaderRegisters());
vkCmdBindPipeline(vk_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->pipeline);
File diff suppressed because it is too large Load Diff
+41 -24
View File
@@ -7,9 +7,9 @@
namespace Kyty::Libs::Graphics::Pm4 {
static const char* g_names[256] = {};
static const char* g_r_names[64] = {};
static bool g_names_initialized = false;
static const char* g_names[256] = {};
static const char* g_r_names[Pm4::R_NUM] = {};
static bool g_names_initialized = false;
static void init_names()
{
@@ -25,26 +25,31 @@ static void init_names()
n = "<unknown>";
}
g_r_names[R_ZERO] = "R_ZERO";
g_r_names[R_VS] = "R_VS";
g_r_names[R_PS] = "R_PS";
g_r_names[R_DRAW_INDEX] = "R_DRAW_INDEX";
g_r_names[R_DRAW_INDEX_AUTO] = "R_DRAW_INDEX_AUTO";
g_r_names[R_DRAW_RESET] = "R_DRAW_RESET";
g_r_names[R_WAIT_FLIP_DONE] = "R_WAIT_FLIP_DONE";
g_r_names[R_CS] = "R_CS";
g_r_names[R_DISPATCH_DIRECT] = "R_DISPATCH_DIRECT";
g_r_names[R_DISPATCH_RESET] = "R_DISPATCH_RESET";
g_r_names[R_DISPATCH_WAIT_MEM] = "R_DISPATCH_WAIT_MEM";
g_r_names[R_PUSH_MARKER] = "R_PUSH_MARKER";
g_r_names[R_POP_MARKER] = "R_POP_MARKER";
g_r_names[R_VS_EMBEDDED] = "R_VS_EMBEDDED";
g_r_names[R_PS_EMBEDDED] = "R_PS_EMBEDDED";
g_r_names[R_VS_UPDATE] = "R_VS_UPDATE";
g_r_names[R_PS_UPDATE] = "R_PS_UPDATE";
g_r_names[R_CX_REGS] = "R_CX_REGS";
g_r_names[R_SH_REGS] = "R_SH_REGS";
g_r_names[R_UC_REGS] = "R_UC_REGS";
g_r_names[R_ZERO] = "R_ZERO";
g_r_names[R_VS] = "R_VS";
g_r_names[R_PS] = "R_PS";
g_r_names[R_DRAW_INDEX] = "R_DRAW_INDEX";
g_r_names[R_DRAW_INDEX_AUTO] = "R_DRAW_INDEX_AUTO";
g_r_names[R_DRAW_RESET] = "R_DRAW_RESET";
g_r_names[R_WAIT_FLIP_DONE] = "R_WAIT_FLIP_DONE";
g_r_names[R_CS] = "R_CS";
g_r_names[R_DISPATCH_DIRECT] = "R_DISPATCH_DIRECT";
g_r_names[R_DISPATCH_RESET] = "R_DISPATCH_RESET";
g_r_names[R_WAIT_MEM_32] = "R_WAIT_MEM_32";
g_r_names[R_PUSH_MARKER] = "R_PUSH_MARKER";
g_r_names[R_POP_MARKER] = "R_POP_MARKER";
g_r_names[R_VS_EMBEDDED] = "R_VS_EMBEDDED";
g_r_names[R_PS_EMBEDDED] = "R_PS_EMBEDDED";
g_r_names[R_VS_UPDATE] = "R_VS_UPDATE";
g_r_names[R_PS_UPDATE] = "R_PS_UPDATE";
g_r_names[R_CX_REGS_INDIRECT] = "R_CX_REGS_INDIRECT";
g_r_names[R_SH_REGS_INDIRECT] = "R_SH_REGS_INDIRECT";
g_r_names[R_UC_REGS_INDIRECT] = "R_UC_REGS_INDIRECT";
g_r_names[R_ACQUIRE_MEM] = "R_ACQUIRE_MEM";
g_r_names[R_WRITE_DATA] = "R_WRITE_DATA";
g_r_names[R_WAIT_MEM_64] = "R_WAIT_MEM_64";
g_r_names[R_FLIP] = "R_FLIP";
g_r_names[R_RELEASE_MEM] = "R_RELEASE_MEM";
g_names[IT_NOP] = "IT_NOP";
g_names[IT_SET_BASE] = "IT_SET_BASE";
@@ -131,7 +136,7 @@ void DumpPm4PacketStream(Core::File* file, uint32_t* cmd_buffer, uint32_t start_
bool sh_gx = (cmd_id & 0x2u) == 0;
len = ((cmd_id >> 16u) & 0x3fffu) + 1;
uint8_t op = ((cmd_id >> 8u) & 0xffu);
auto r = ((cmd_id >> 2u) & 0x3fu);
auto r = KYTY_PM4_R(cmd_id);
file->Printf("%s %s(OP:0x%02" PRIx8 ") SH:%s CNT:%u\n", g_names[op], (op == IT_NOP ? g_r_names[r] : ""), op,
sh_gx ? "GX" : "CX", len);
@@ -140,6 +145,18 @@ void DumpPm4PacketStream(Core::File* file, uint32_t* cmd_buffer, uint32_t start_
{
file->Printf(" | 0x%08" PRIx32 " | \n", cmd[i]);
}
if (op == IT_NOP && (r == R_CX_REGS_INDIRECT || r == R_SH_REGS_INDIRECT || r == R_UC_REGS_INDIRECT) && len == 3)
{
auto* indirect_buffer = reinterpret_cast<uint32_t*>(cmd[1] | (static_cast<uint64_t>(cmd[2]) << 32u));
uint32_t indirect_num_dw = cmd[0];
for (uint32_t i = 0; i < indirect_num_dw; i++, indirect_buffer += 2)
{
file->Printf(" | | offset = 0x%08" PRIx32 ", value = 0x%08" PRIx32 "\n", indirect_buffer[0],
indirect_buffer[1]);
}
}
} else
{
file->Printf("?????\n");
+90 -52
View File
@@ -2088,7 +2088,7 @@ KYTY_SHADER_PARSER(shader_parse)
return ptr - src;
}
static void vs_print(const char* func, const HW::VsStageRegisters& vs)
static void vs_print(const char* func, const HW::VsStageRegisters& vs, const HW::ShaderRegisters& sh)
{
printf("%s\n", func);
@@ -2098,12 +2098,23 @@ static void vs_print(const char* func, const HW::VsStageRegisters& vs)
printf("\t GetInputComponentsCount() = 0x%08" PRIx32 "\n", vs.GetInputComponentsCount());
printf("\t GetUnknown1() = 0x%08" PRIx32 "\n", vs.GetUnknown1());
printf("\t GetUnknown2() = 0x%08" PRIx32 "\n", vs.GetUnknown2());
printf("\t m_spiVsOutConfig = 0x%08" PRIx32 "\n", vs.m_spiVsOutConfig);
printf("\t m_spiShaderPosFormat = 0x%08" PRIx32 "\n", vs.m_spiShaderPosFormat);
printf("\t m_paClVsOutCntl = 0x%08" PRIx32 "\n", vs.m_paClVsOutCntl);
printf("\t m_spiVsOutConfig = 0x%08" PRIx32 "\n", sh.m_spiVsOutConfig);
printf("\t m_spiShaderPosFormat = 0x%08" PRIx32 "\n", sh.m_spiShaderPosFormat);
printf("\t m_paClVsOutCntl = 0x%08" PRIx32 "\n", sh.m_paClVsOutCntl);
printf("\t m_spiShaderIdxFormat = 0x%08" PRIx32 "\n", sh.m_spiShaderIdxFormat);
printf("\t m_geNggSubgrpCntl = 0x%08" PRIx32 "\n", sh.m_geNggSubgrpCntl);
printf("\t m_vgtGsInstanceCnt = 0x%08" PRIx32 "\n", sh.m_vgtGsInstanceCnt);
printf("\t GetEsVertsPerSubgrp() = 0x%08" PRIx32 "\n", sh.GetEsVertsPerSubgrp());
printf("\t GetGsPrimsPerSubgrp() = 0x%08" PRIx32 "\n", sh.GetGsPrimsPerSubgrp());
printf("\t GetGsInstPrimsInSubgrp() = 0x%08" PRIx32 "\n", sh.GetGsInstPrimsInSubgrp());
printf("\t m_geMaxOutputPerSubgroup = 0x%08" PRIx32 "\n", sh.m_geMaxOutputPerSubgroup);
printf("\t m_vgtEsgsRingItemsize = 0x%08" PRIx32 "\n", sh.m_vgtEsgsRingItemsize);
printf("\t m_vgtGsMaxVertOut = 0x%08" PRIx32 "\n", sh.m_vgtGsMaxVertOut);
printf("\t m_vgtGsOutPrimType = 0x%08" PRIx32 "\n", sh.m_vgtGsOutPrimType);
}
static void ps_print(const char* func, const HW::PsStageRegisters& ps)
static void ps_print(const char* func, const HW::PsStageRegisters& ps, const HW::ShaderRegisters& sh)
{
printf("%s\n", func);
@@ -2112,26 +2123,28 @@ static void ps_print(const char* func, const HW::PsStageRegisters& ps)
// printf("\t m_spiShaderPgmRsrc2Ps = 0x%08" PRIx32 "\n", ps.m_spiShaderPgmRsrc2Ps);
// printf("\t GetTargetOutputMode(0) = 0x%08" PRIx32 "\n", ps.GetTargetOutputMode(0));
printf("\t data_addr = 0x%016" PRIx64 "\n", ps.data_addr);
printf("\t conservative_z_export_value = 0x%08" PRIx32 "\n", ps.conservative_z_export_value);
printf("\t shader_z_behavior = 0x%08" PRIx32 "\n", ps.shader_z_behavior);
printf("\t shader_kill_enable = %s\n", ps.shader_kill_enable ? "true" : "false");
printf("\t shader_z_export_enable = %s\n", ps.shader_z_export_enable ? "true" : "false");
printf("\t shader_execute_on_noop = %s\n", ps.shader_execute_on_noop ? "true" : "false");
printf("\t conservative_z_export_value = 0x%08" PRIx32 "\n", sh.db_shader_control.conservative_z_export_value);
printf("\t shader_z_behavior = 0x%08" PRIx32 "\n", sh.db_shader_control.shader_z_behavior);
printf("\t shader_kill_enable = %s\n", sh.db_shader_control.shader_kill_enable ? "true" : "false");
printf("\t shader_z_export_enable = %s\n", sh.db_shader_control.shader_z_export_enable ? "true" : "false");
printf("\t shader_execute_on_noop = %s\n", sh.db_shader_control.shader_execute_on_noop ? "true" : "false");
printf("\t vgprs = 0x%02" PRIx8 "\n", ps.vgprs);
printf("\t sgprs = 0x%02" PRIx8 "\n", ps.sgprs);
printf("\t scratch_en = 0x%02" PRIx8 "\n", ps.scratch_en);
printf("\t user_sgpr = 0x%02" PRIx8 "\n", ps.user_sgpr);
printf("\t wave_cnt_en = 0x%02" PRIx8 "\n", ps.wave_cnt_en);
printf("\t shader_z_format = 0x%08" PRIx32 "\n", ps.shader_z_format);
printf("\t target_output_mode[0] = 0x%02" PRIx8 "\n", ps.target_output_mode[0]);
printf("\t ps_input_ena = 0x%08" PRIx32 "\n", ps.ps_input_ena);
printf("\t ps_input_addr = 0x%08" PRIx32 "\n", ps.ps_input_addr);
printf("\t ps_in_control = 0x%08" PRIx32 "\n", ps.ps_in_control);
printf("\t baryc_cntl = 0x%08" PRIx32 "\n", ps.baryc_cntl);
printf("\t m_cbShaderMask = 0x%08" PRIx32 "\n", ps.m_cbShaderMask);
printf("\t shader_z_format = 0x%08" PRIx32 "\n", sh.shader_z_format);
printf("\t target_output_mode[0] = 0x%02" PRIx8 "\n", sh.target_output_mode[0]);
printf("\t ps_input_ena = 0x%08" PRIx32 "\n", sh.ps_input_ena);
printf("\t ps_input_addr = 0x%08" PRIx32 "\n", sh.ps_input_addr);
printf("\t ps_in_control = 0x%08" PRIx32 "\n", sh.ps_in_control);
printf("\t baryc_cntl = 0x%08" PRIx32 "\n", sh.baryc_cntl);
printf("\t m_cbShaderMask = 0x%08" PRIx32 "\n", sh.m_cbShaderMask);
printf("\t m_paScShaderControl = 0x%08" PRIx32 "\n", sh.m_paScShaderControl);
}
static void cs_print(const char* func, const HW::CsStageRegisters& cs)
static void cs_print(const char* func, const HW::CsStageRegisters& cs, const HW::ShaderRegisters& /*sh*/)
{
printf("%s\n", func);
@@ -2183,7 +2196,7 @@ static void bi_print(const char* func, const ShaderBinaryInfo& bi)
printf("\t crc32 = 0x%08" PRIx32 "\n", bi.crc32);
}
static void vs_check(const HW::VsStageRegisters& vs)
static void vs_check(const HW::VsStageRegisters& vs, const HW::ShaderRegisters& sh)
{
EXIT_NOT_IMPLEMENTED(vs.GetStreamoutEnabled() != false);
// EXIT_NOT_IMPLEMENTED(vs.GetSgprCount() != 0x00000000);
@@ -2191,17 +2204,28 @@ static void vs_check(const HW::VsStageRegisters& vs)
// EXIT_NOT_IMPLEMENTED(vs.GetUnknown1() != 0x002c0000);
// EXIT_NOT_IMPLEMENTED(vs.GetUnknown2() != 0x00000000);
// EXIT_NOT_IMPLEMENTED(vs.m_spiVsOutConfig != 0x00000000);
EXIT_NOT_IMPLEMENTED(vs.m_spiShaderPosFormat != 0x00000004);
EXIT_NOT_IMPLEMENTED(vs.m_paClVsOutCntl != 0x00000000);
EXIT_NOT_IMPLEMENTED(sh.m_spiShaderPosFormat != 0x00000004);
EXIT_NOT_IMPLEMENTED(sh.m_paClVsOutCntl != 0x00000000);
EXIT_NOT_IMPLEMENTED(sh.m_spiShaderIdxFormat != 0x00000000 && sh.m_spiShaderIdxFormat != 0x00000001);
EXIT_NOT_IMPLEMENTED(sh.m_geNggSubgrpCntl != 0x00000000 && sh.m_geNggSubgrpCntl != 0x00000001);
EXIT_NOT_IMPLEMENTED(sh.m_vgtGsInstanceCnt != 0x00000000);
EXIT_NOT_IMPLEMENTED(sh.GetEsVertsPerSubgrp() != 0x00000000);
EXIT_NOT_IMPLEMENTED(sh.GetGsPrimsPerSubgrp() != 0x00000000);
EXIT_NOT_IMPLEMENTED(sh.GetGsInstPrimsInSubgrp() != 0x00000000);
EXIT_NOT_IMPLEMENTED(sh.m_geMaxOutputPerSubgroup != 0x00000000);
EXIT_NOT_IMPLEMENTED(sh.m_vgtEsgsRingItemsize != 0x00000000);
EXIT_NOT_IMPLEMENTED(sh.m_vgtGsMaxVertOut != 0x00000000);
EXIT_NOT_IMPLEMENTED(sh.m_vgtGsOutPrimType != 0x00000000);
}
static void ps_check(const HW::PsStageRegisters& ps)
static void ps_check(const HW::PsStageRegisters& ps, const HW::ShaderRegisters& sh)
{
EXIT_NOT_IMPLEMENTED(ps.target_output_mode[0] != 4 && ps.target_output_mode[0] != 9);
EXIT_NOT_IMPLEMENTED(ps.conservative_z_export_value != 0x00000000);
EXIT_NOT_IMPLEMENTED(ps.shader_z_behavior != 0x00000001 && ps.shader_z_behavior != 0x00000000);
EXIT_NOT_IMPLEMENTED(sh.target_output_mode[0] != 4 && sh.target_output_mode[0] != 9);
EXIT_NOT_IMPLEMENTED(sh.db_shader_control.conservative_z_export_value != 0x00000000);
EXIT_NOT_IMPLEMENTED(sh.db_shader_control.shader_z_behavior != 0x00000001 && sh.db_shader_control.shader_z_behavior != 0x00000000);
// EXIT_NOT_IMPLEMENTED(ps.shader_kill_enable != false);
EXIT_NOT_IMPLEMENTED(ps.shader_z_export_enable != false);
EXIT_NOT_IMPLEMENTED(sh.db_shader_control.shader_z_export_enable != false);
// EXIT_NOT_IMPLEMENTED(ps.shader_execute_on_noop != false);
// EXIT_NOT_IMPLEMENTED(ps.m_spiShaderPgmRsrc1Ps != 0x002c0000);
// EXIT_NOT_IMPLEMENTED(ps.m_spiShaderPgmRsrc2Ps != 0x00000000);
@@ -2210,15 +2234,18 @@ static void ps_check(const HW::PsStageRegisters& ps)
EXIT_NOT_IMPLEMENTED(ps.scratch_en != 0);
// EXIT_NOT_IMPLEMENTED(ps.user_sgpr != 0 && ps.user_sgpr != 4 && ps.user_sgpr != 12);
EXIT_NOT_IMPLEMENTED(ps.wave_cnt_en != 0);
EXIT_NOT_IMPLEMENTED(ps.shader_z_format != 0x00000000);
EXIT_NOT_IMPLEMENTED(ps.ps_input_ena != 0x00000002 && ps.ps_input_ena != 0x00000302);
EXIT_NOT_IMPLEMENTED(ps.ps_input_addr != 0x00000002 && ps.ps_input_addr != 0x00000302);
EXIT_NOT_IMPLEMENTED(sh.shader_z_format != 0x00000000);
EXIT_NOT_IMPLEMENTED(sh.ps_input_ena != 0x00000002 && sh.ps_input_ena != 0x00000302);
EXIT_NOT_IMPLEMENTED(sh.ps_input_addr != 0x00000002 && sh.ps_input_addr != 0x00000302);
// EXIT_NOT_IMPLEMENTED(ps.m_spiPsInControl != 0x00000000);
EXIT_NOT_IMPLEMENTED(ps.baryc_cntl != 0x00000000);
EXIT_NOT_IMPLEMENTED(ps.m_cbShaderMask != 0x0000000f);
EXIT_NOT_IMPLEMENTED(sh.baryc_cntl != 0x00000000);
EXIT_NOT_IMPLEMENTED(sh.m_cbShaderMask != 0x0000000f);
EXIT_NOT_IMPLEMENTED(sh.db_shader_control.other_bits != 0x00000000);
EXIT_NOT_IMPLEMENTED(sh.m_paScShaderControl != 0x00000000);
}
static void cs_check(const HW::CsStageRegisters& cs)
static void cs_check(const HW::CsStageRegisters& cs, const HW::ShaderRegisters& /*sh*/)
{
// EXIT_NOT_IMPLEMENTED(cs.num_thread_x != 0x00000040);
// EXIT_NOT_IMPLEMENTED(cs.num_thread_y != 0x00000001);
@@ -2713,13 +2740,13 @@ void ShaderCalcBindingIndices(ShaderBindResources* bind)
EXIT_IF((bind->push_constant_size % 16) != 0);
}
void ShaderGetInputInfoVS(const HW::VertexShaderInfo* regs, ShaderVertexInputInfo* info)
void ShaderGetInputInfoVS(const HW::VertexShaderInfo* regs, const HW::ShaderRegisters* sh, ShaderVertexInputInfo* info)
{
KYTY_PROFILER_FUNCTION();
EXIT_IF(info == nullptr || regs == nullptr);
info->export_count = static_cast<int>(1 + ((regs->vs_regs.m_spiVsOutConfig >> 1u) & 0x1Fu));
info->export_count = static_cast<int>(sh->GetExportCount());
info->bind.push_constant_offset = 0;
info->bind.push_constant_size = 0;
info->bind.descriptor_set_slot = 0;
@@ -2800,28 +2827,30 @@ void ShaderGetInputInfoVS(const HW::VertexShaderInfo* regs, ShaderVertexInputInf
}
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
void ShaderGetInputInfoPS(const HW::PixelShaderInfo* regs, const ShaderVertexInputInfo* vs_info, ShaderPixelInputInfo* ps_info)
void ShaderGetInputInfoPS(const HW::PixelShaderInfo* regs, const HW::ShaderRegisters* sh, const ShaderVertexInputInfo* vs_info,
ShaderPixelInputInfo* ps_info)
{
KYTY_PROFILER_FUNCTION();
EXIT_IF(vs_info == nullptr);
EXIT_IF(ps_info == nullptr);
EXIT_IF(regs == nullptr);
EXIT_IF(sh == nullptr);
if (regs->ps_embedded)
{
return;
}
ps_info->input_num = regs->ps_regs.ps_in_control;
ps_info->ps_pos_xy = (regs->ps_regs.ps_input_ena == 0x00000302 && regs->ps_regs.ps_input_addr == 0x00000302);
ps_info->ps_pixel_kill_enable = regs->ps_regs.shader_kill_enable;
ps_info->ps_early_z = (regs->ps_regs.shader_z_behavior == 1);
ps_info->ps_execute_on_noop = regs->ps_regs.shader_execute_on_noop;
ps_info->input_num = sh->ps_in_control;
ps_info->ps_pos_xy = (sh->ps_input_ena == 0x00000302 && sh->ps_input_addr == 0x00000302);
ps_info->ps_pixel_kill_enable = sh->db_shader_control.shader_kill_enable;
ps_info->ps_early_z = (sh->db_shader_control.shader_z_behavior == 1);
ps_info->ps_execute_on_noop = sh->db_shader_control.shader_execute_on_noop;
for (uint32_t i = 0; i < ps_info->input_num; i++)
{
ps_info->interpolator_settings[i] = regs->ps_interpolator_settings[i];
ps_info->interpolator_settings[i] = sh->ps_interpolator_settings[i];
}
ps_info->bind.descriptor_set_slot = (vs_info->bind.storage_buffers.buffers_num > 0 ? 1 : 0);
@@ -2830,7 +2859,7 @@ void ShaderGetInputInfoPS(const HW::PixelShaderInfo* regs, const ShaderVertexInp
for (int i = 0; i < 8; i++)
{
ps_info->target_output_mode[i] = regs->ps_regs.target_output_mode[i];
ps_info->target_output_mode[i] = sh->target_output_mode[i];
}
const auto* src = reinterpret_cast<const uint32_t*>(regs->ps_regs.data_addr);
@@ -2894,7 +2923,7 @@ void ShaderGetInputInfoPS(const HW::PixelShaderInfo* regs, const ShaderVertexInp
}
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
void ShaderGetInputInfoCS(const HW::ComputeShaderInfo* regs, ShaderComputeInputInfo* info)
void ShaderGetInputInfoCS(const HW::ComputeShaderInfo* regs, const HW::ShaderRegisters* /*sh*/, ShaderComputeInputInfo* info)
{
EXIT_IF(info == nullptr);
EXIT_IF(regs == nullptr);
@@ -3355,10 +3384,13 @@ private:
String m_file_name;
};
ShaderCode ShaderParseVS(const HW::VertexShaderInfo* regs)
ShaderCode ShaderParseVS(const HW::VertexShaderInfo* regs, const HW::ShaderRegisters* sh)
{
KYTY_PROFILER_FUNCTION(profiler::colors::Amber300);
EXIT_IF(regs == nullptr);
EXIT_IF(sh == nullptr);
ShaderCode code;
code.SetType(ShaderType::Vertex);
@@ -3372,8 +3404,8 @@ ShaderCode ShaderParseVS(const HW::VertexShaderInfo* regs)
EXIT_NOT_IMPLEMENTED(src == nullptr);
vs_print("ShaderParseVS()", regs->vs_regs);
vs_check(regs->vs_regs);
vs_print("ShaderParseVS()", regs->vs_regs, *sh);
vs_check(regs->vs_regs, *sh);
const auto* header = GetBinaryInfo(src);
@@ -3434,10 +3466,13 @@ Vector<uint32_t> ShaderRecompileVS(const ShaderCode& code, const ShaderVertexInp
return ret;
}
ShaderCode ShaderParsePS(const HW::PixelShaderInfo* regs)
ShaderCode ShaderParsePS(const HW::PixelShaderInfo* regs, const HW::ShaderRegisters* sh)
{
KYTY_PROFILER_FUNCTION(profiler::colors::Blue300);
EXIT_IF(regs == nullptr);
EXIT_IF(sh == nullptr);
ShaderCode code;
code.SetType(ShaderType::Pixel);
@@ -3451,8 +3486,8 @@ ShaderCode ShaderParsePS(const HW::PixelShaderInfo* regs)
EXIT_NOT_IMPLEMENTED(src == nullptr);
ps_print("ShaderParsePS()", regs->ps_regs);
ps_check(regs->ps_regs);
ps_print("ShaderParsePS()", regs->ps_regs, *sh);
ps_check(regs->ps_regs, *sh);
EXIT_NOT_IMPLEMENTED(regs->ps_regs.user_sgpr > regs->ps_user_sgpr.count);
@@ -3520,16 +3555,19 @@ Vector<uint32_t> ShaderRecompilePS(const ShaderCode& code, const ShaderPixelInpu
return ret;
}
ShaderCode ShaderParseCS(const HW::ComputeShaderInfo* regs)
ShaderCode ShaderParseCS(const HW::ComputeShaderInfo* regs, const HW::ShaderRegisters* sh)
{
KYTY_PROFILER_FUNCTION(profiler::colors::CyanA700);
EXIT_IF(regs == nullptr);
EXIT_IF(sh == nullptr);
const auto* src = reinterpret_cast<const uint32_t*>(regs->cs_regs.data_addr);
EXIT_NOT_IMPLEMENTED(src == nullptr);
cs_print("ShaderParseCS()", regs->cs_regs);
cs_check(regs->cs_regs);
cs_print("ShaderParseCS()", regs->cs_regs, *sh);
cs_check(regs->cs_regs, *sh);
EXIT_NOT_IMPLEMENTED(regs->cs_regs.user_sgpr > regs->cs_user_sgpr.count);