mirror of
https://github.com/InoriRus/Kyty.git
synced 2026-08-28 05:06:40 +00:00
one step closer to run games
This commit is contained in:
@@ -225,6 +225,35 @@ int KYTY_SYSV_ABI GraphicsUpdatePsShader(uint32_t* cmd, uint64_t size, const uin
|
||||
return OK;
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI GraphicsUpdatePsShader350(uint32_t* cmd, uint64_t size, const uint32_t* ps_regs)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(ps_regs == nullptr);
|
||||
EXIT_NOT_IMPLEMENTED(size < 12 + 1);
|
||||
|
||||
printf("\t cmd_buffer = %016" PRIx64 "\n", reinterpret_cast<uint64_t>(cmd));
|
||||
printf("\t size = %" PRIu64 "\n", size);
|
||||
|
||||
printf("\t ps_regs.m_spiShaderPgmLoPs = %08" PRIx32 "\n", ps_regs[0]);
|
||||
printf("\t ps_regs.m_spiShaderPgmHiPs = %08" PRIx32 "\n", ps_regs[1]);
|
||||
printf("\t ps_regs.m_spiShaderPgmRsrc1Ps = %08" PRIx32 "\n", ps_regs[2]);
|
||||
printf("\t ps_regs.m_spiShaderPgmRsrc2Ps = %08" PRIx32 "\n", ps_regs[3]);
|
||||
printf("\t ps_regs.m_spiShaderZFormat = %08" PRIx32 "\n", ps_regs[4]);
|
||||
printf("\t ps_regs.m_spiShaderColFormat = %08" PRIx32 "\n", ps_regs[5]);
|
||||
printf("\t ps_regs.m_spiPsInputEna = %08" PRIx32 "\n", ps_regs[6]);
|
||||
printf("\t ps_regs.m_spiPsInputAddr = %08" PRIx32 "\n", ps_regs[7]);
|
||||
printf("\t ps_regs.m_spiPsInControl = %08" PRIx32 "\n", ps_regs[8]);
|
||||
printf("\t ps_regs.m_spiBarycCntl = %08" PRIx32 "\n", ps_regs[9]);
|
||||
printf("\t ps_regs.m_dbShaderControl = %08" PRIx32 "\n", ps_regs[10]);
|
||||
printf("\t ps_regs.m_cbShaderMask = %08" PRIx32 "\n", ps_regs[11]);
|
||||
|
||||
cmd[0] = KYTY_PM4(size, Pm4::IT_NOP, Pm4::R_PS_UPDATE);
|
||||
memcpy(&cmd[1], ps_regs, 12 * 4);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI GraphicsSetCsShaderWithModifier(uint32_t* cmd, uint64_t size, const uint32_t* cs_regs, uint32_t shader_modifier)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,6 @@
|
||||
#include "Kyty/Core/String.h"
|
||||
#include "Kyty/Core/Threads.h"
|
||||
|
||||
#include "Emulator/Config.h"
|
||||
#include "Emulator/Graphics/AsyncJob.h"
|
||||
#include "Emulator/Graphics/GraphicContext.h"
|
||||
#include "Emulator/Graphics/Graphics.h"
|
||||
@@ -17,6 +16,8 @@
|
||||
#include "Emulator/Graphics/Window.h"
|
||||
#include "Emulator/Profiler.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#ifdef KYTY_EMU_ENABLED
|
||||
|
||||
#define KYTY_HW_CTX_PARSER_ARGS \
|
||||
@@ -67,6 +68,7 @@ public:
|
||||
void WriteAtEndOfPipe64(uint32_t cache_policy, uint32_t event_write_dest, uint32_t eop_event_type, uint32_t cache_action,
|
||||
uint32_t event_index, uint32_t event_write_source, void* dst_gpu_addr, uint64_t value,
|
||||
uint32_t interrupt_selector);
|
||||
void Flip();
|
||||
void Flip(void* dst_gpu_addr, uint32_t value);
|
||||
void FlipWithInterrupt(uint32_t eop_event_type, uint32_t cache_action, void* dst_gpu_addr, uint32_t value);
|
||||
void WriteBack();
|
||||
@@ -106,6 +108,9 @@ public:
|
||||
[[nodiscard]] const FlipInfo& GetFlip() const { return m_flip; }
|
||||
void SetFlip(const FlipInfo& flip) { m_flip = flip; }
|
||||
|
||||
[[nodiscard]] uint64_t GetSumbitId() const { return m_sumbit_id; }
|
||||
void SetSumbitId(uint64_t sumbit_id) { m_sumbit_id = sumbit_id; }
|
||||
|
||||
private:
|
||||
static constexpr int VK_BUFFERS_NUM = 4;
|
||||
|
||||
@@ -133,6 +138,7 @@ private:
|
||||
uint32_t m_const_ram[0x3000] = {0};
|
||||
|
||||
FlipInfo m_flip;
|
||||
uint64_t m_sumbit_id = 0;
|
||||
};
|
||||
|
||||
class GraphicsRing
|
||||
@@ -660,6 +666,7 @@ void GraphicsRing::Submit(uint32_t* cmd_draw_buffer, uint32_t num_draw_dw, uint3
|
||||
m_idle_cond_var.Wait(&m_mutex);
|
||||
}
|
||||
m_done = false;
|
||||
|
||||
m_cp->Reset();
|
||||
}
|
||||
|
||||
@@ -714,6 +721,7 @@ GraphicsRing::CmdBatch GraphicsRing::GetCmdBatch()
|
||||
{
|
||||
m_idle = true;
|
||||
m_idle_cond_var.Signal();
|
||||
|
||||
m_cond_var.Wait(&m_mutex);
|
||||
}
|
||||
|
||||
@@ -732,6 +740,8 @@ void GraphicsRing::ThreadBatchRun(void* data)
|
||||
{
|
||||
EXIT_IF(data == nullptr);
|
||||
|
||||
static std::atomic_uint64_t seq = 0;
|
||||
|
||||
auto* ring = static_cast<GraphicsRing*>(data);
|
||||
auto* cp = ring->m_cp;
|
||||
|
||||
@@ -745,6 +755,7 @@ void GraphicsRing::ThreadBatchRun(void* data)
|
||||
cp->BufferInit();
|
||||
cp->ResetDeCe();
|
||||
cp->SetFlip(buf.flip);
|
||||
cp->SetSumbitId(++seq);
|
||||
|
||||
ring->m_job1.Execute([cp, buf](void* /*unused*/) { cp->Run(buf.draw_buffer.data, buf.draw_buffer.num_dw); });
|
||||
ring->m_job2.Execute([cp, buf](void* /*unused*/) { cp->Run(buf.const_buffer.data, buf.const_buffer.num_dw); });
|
||||
@@ -968,7 +979,8 @@ void CommandProcessor::DrawIndex(uint32_t index_count, const void* index_addr, u
|
||||
|
||||
EXIT_IF(m_current_buffer < 0 || m_current_buffer >= VK_BUFFERS_NUM);
|
||||
|
||||
GraphicsRenderDrawIndex(m_buffer[m_current_buffer], &m_ctx, &m_ucfg, m_index_type_and_size, index_count, index_addr, flags, type);
|
||||
GraphicsRenderDrawIndex(m_sumbit_id, m_buffer[m_current_buffer], &m_ctx, &m_ucfg, m_index_type_and_size, index_count, index_addr, flags,
|
||||
type);
|
||||
}
|
||||
|
||||
void CommandProcessor::DispatchDirect(uint32_t thread_group_x, uint32_t thread_group_y, uint32_t thread_group_z, uint32_t mode)
|
||||
@@ -977,7 +989,7 @@ void CommandProcessor::DispatchDirect(uint32_t thread_group_x, uint32_t thread_g
|
||||
|
||||
EXIT_IF(m_current_buffer < 0 || m_current_buffer >= VK_BUFFERS_NUM);
|
||||
|
||||
GraphicsRenderDispatchDirect(m_buffer[m_current_buffer], &m_ctx, thread_group_x, thread_group_y, thread_group_z, mode);
|
||||
GraphicsRenderDispatchDirect(m_sumbit_id, m_buffer[m_current_buffer], &m_ctx, thread_group_x, thread_group_y, thread_group_z, mode);
|
||||
}
|
||||
|
||||
void CommandProcessor::DrawIndexAuto(uint32_t index_count, uint32_t flags)
|
||||
@@ -986,7 +998,7 @@ void CommandProcessor::DrawIndexAuto(uint32_t index_count, uint32_t flags)
|
||||
|
||||
EXIT_IF(m_current_buffer < 0 || m_current_buffer >= VK_BUFFERS_NUM);
|
||||
|
||||
GraphicsRenderDrawIndexAuto(m_buffer[m_current_buffer], &m_ctx, &m_ucfg, index_count, flags);
|
||||
GraphicsRenderDrawIndexAuto(m_sumbit_id, m_buffer[m_current_buffer], &m_ctx, &m_ucfg, index_count, flags);
|
||||
}
|
||||
|
||||
void CommandProcessor::ClearGds(uint64_t dw_offset, uint32_t dw_num, uint32_t clear_value)
|
||||
@@ -1035,10 +1047,11 @@ void CommandProcessor::WriteAtEndOfPipe32(uint32_t cache_policy, uint32_t event_
|
||||
|
||||
if (event_write_source == 0x00000002 && eop_event_type == 0x0000002f && cache_action == 0x00000000 && event_index == 0x00000006)
|
||||
{
|
||||
GraphicsRenderWriteAtEndOfPipe(m_buffer[m_current_buffer], static_cast<uint32_t*>(dst_gpu_addr), value);
|
||||
GraphicsRenderWriteAtEndOfPipe32(m_sumbit_id, m_buffer[m_current_buffer], static_cast<uint32_t*>(dst_gpu_addr), value);
|
||||
} else if (event_write_source == 0x00000001 && eop_event_type == 0x0000002f && cache_action == 0x00000000 && event_index == 0x00000006)
|
||||
{
|
||||
GraphicsRenderWriteAtEndOfPipeGds(m_buffer[m_current_buffer], static_cast<uint32_t*>(dst_gpu_addr), value & 0xffffu, value >> 16u);
|
||||
GraphicsRenderWriteAtEndOfPipeGds32(m_sumbit_id, m_buffer[m_current_buffer], static_cast<uint32_t*>(dst_gpu_addr), value & 0xffffu,
|
||||
value >> 16u);
|
||||
} else
|
||||
{
|
||||
EXIT("unknown event type\n");
|
||||
@@ -1067,31 +1080,43 @@ void CommandProcessor::WriteAtEndOfPipe64(uint32_t cache_policy, uint32_t event_
|
||||
EXIT_NOT_IMPLEMENTED(cache_policy != 0x00000000);
|
||||
EXIT_NOT_IMPLEMENTED(event_write_dest != 0x00000000);
|
||||
|
||||
if (eop_event_type == 0x04 && cache_action == 0x00 && event_index == 0x05 && event_write_source == 0x02 &&
|
||||
(interrupt_selector == 0x00 || interrupt_selector == 0x03))
|
||||
bool with_interrupt = false;
|
||||
bool source64 = (event_write_source == 0x02);
|
||||
bool source32 = (event_write_source == 0x01);
|
||||
bool source_counter = (event_write_source == 0x04);
|
||||
|
||||
switch (interrupt_selector)
|
||||
{
|
||||
GraphicsRenderWriteAtEndOfPipe(m_buffer[m_current_buffer], static_cast<uint64_t*>(dst_gpu_addr), value);
|
||||
} else if (eop_event_type == 0x04 && cache_action == 0x00 && event_index == 0x05 && event_write_source == 0x01 &&
|
||||
(interrupt_selector == 0x00 || interrupt_selector == 0x03))
|
||||
case 0x00:
|
||||
case 0x03: with_interrupt = false; break;
|
||||
case 0x02: with_interrupt = true; break;
|
||||
default: EXIT("unknown interrupt_selector\n");
|
||||
}
|
||||
|
||||
if (eop_event_type == 0x04 && cache_action == 0x00 && event_index == 0x05 && source64 && !with_interrupt)
|
||||
{
|
||||
GraphicsRenderWriteAtEndOfPipe(m_buffer[m_current_buffer], static_cast<uint32_t*>(dst_gpu_addr), value);
|
||||
GraphicsRenderWriteAtEndOfPipe64(m_sumbit_id, m_buffer[m_current_buffer], static_cast<uint64_t*>(dst_gpu_addr), value);
|
||||
} else if (eop_event_type == 0x04 && cache_action == 0x00 && event_index == 0x05 && source32 && !with_interrupt)
|
||||
{
|
||||
GraphicsRenderWriteAtEndOfPipe32(m_sumbit_id, m_buffer[m_current_buffer], static_cast<uint32_t*>(dst_gpu_addr), value);
|
||||
} else if (((eop_event_type == 0x04 && event_index == 0x05) || (eop_event_type == 0x28 && event_index == 0x05) ||
|
||||
(eop_event_type == 0x2f && event_index == 0x06)) &&
|
||||
cache_action == 0x38 && event_write_source == 0x02 && (interrupt_selector == 0x00 || interrupt_selector == 0x03))
|
||||
cache_action == 0x38 && source64 && !with_interrupt)
|
||||
{
|
||||
GraphicsRenderWriteAtEndOfPipeWithWriteBack(m_buffer[m_current_buffer], static_cast<uint64_t*>(dst_gpu_addr), value);
|
||||
} else if (eop_event_type == 0x04 && cache_action == 0x00 && event_index == 0x05 && event_write_source == 0x04 &&
|
||||
(interrupt_selector == 0x00 || interrupt_selector == 0x03))
|
||||
GraphicsRenderWriteAtEndOfPipeWithWriteBack64(m_sumbit_id, m_buffer[m_current_buffer], static_cast<uint64_t*>(dst_gpu_addr), value);
|
||||
} else if (eop_event_type == 0x04 && cache_action == 0x00 && event_index == 0x05 && source_counter && !with_interrupt)
|
||||
{
|
||||
GraphicsRenderWriteAtEndOfPipeClockCounter(m_buffer[m_current_buffer], static_cast<uint64_t*>(dst_gpu_addr));
|
||||
} else if ((eop_event_type == 0x04 && event_index == 0x05) && cache_action == 0x00 && event_write_source == 0x02 &&
|
||||
interrupt_selector == 0x02)
|
||||
GraphicsRenderWriteAtEndOfPipeClockCounter(m_sumbit_id, m_buffer[m_current_buffer], static_cast<uint64_t*>(dst_gpu_addr));
|
||||
} else if ((eop_event_type == 0x04 && event_index == 0x05) && cache_action == 0x00 && source64 && with_interrupt)
|
||||
{
|
||||
GraphicsRenderWriteAtEndOfPipeWithInterrupt(m_buffer[m_current_buffer], static_cast<uint64_t*>(dst_gpu_addr), value);
|
||||
} else if ((eop_event_type == 0x04 && event_index == 0x05) && cache_action == 0x3b && event_write_source == 0x02 &&
|
||||
interrupt_selector == 0x02)
|
||||
GraphicsRenderWriteAtEndOfPipeWithInterrupt64(m_sumbit_id, m_buffer[m_current_buffer], static_cast<uint64_t*>(dst_gpu_addr), value);
|
||||
} else if ((eop_event_type == 0x04 && event_index == 0x05) && cache_action == 0x00 && source32 && with_interrupt)
|
||||
{
|
||||
GraphicsRenderWriteAtEndOfPipeWithInterruptWriteBack(m_buffer[m_current_buffer], static_cast<uint64_t*>(dst_gpu_addr), value);
|
||||
GraphicsRenderWriteAtEndOfPipeWithInterrupt32(m_sumbit_id, m_buffer[m_current_buffer], static_cast<uint32_t*>(dst_gpu_addr), value);
|
||||
} else if ((eop_event_type == 0x04 && event_index == 0x05) && cache_action == 0x3b && source64 && with_interrupt)
|
||||
{
|
||||
GraphicsRenderWriteAtEndOfPipeWithInterruptWriteBack64(m_sumbit_id, m_buffer[m_current_buffer],
|
||||
static_cast<uint64_t*>(dst_gpu_addr), value);
|
||||
} else
|
||||
{
|
||||
EXIT("unknown event type\n");
|
||||
@@ -1147,6 +1172,18 @@ void CommandProcessor::TriggerEvent(uint32_t event_type, uint32_t event_index)
|
||||
}
|
||||
}
|
||||
|
||||
void CommandProcessor::Flip()
|
||||
{
|
||||
Core::LockGuard lock(m_mutex);
|
||||
|
||||
EXIT_IF(m_current_buffer < 0 || m_current_buffer >= VK_BUFFERS_NUM);
|
||||
|
||||
printf("CommandProcessor::Flip()\n");
|
||||
|
||||
GraphicsRenderWriteAtEndOfPipeOnlyFlip(m_sumbit_id, m_buffer[m_current_buffer], m_flip.handle, m_flip.index, m_flip.flip_mode,
|
||||
m_flip.flip_arg);
|
||||
}
|
||||
|
||||
void CommandProcessor::Flip(void* dst_gpu_addr, uint32_t value)
|
||||
{
|
||||
Core::LockGuard lock(m_mutex);
|
||||
@@ -1157,8 +1194,8 @@ void CommandProcessor::Flip(void* dst_gpu_addr, uint32_t value)
|
||||
printf("\t dst_gpu_addr = 0x%016" PRIx64 "\n", reinterpret_cast<uint64_t>(dst_gpu_addr));
|
||||
printf("\t value = 0x%08" PRIx32 "\n", value);
|
||||
|
||||
GraphicsRenderWriteAtEndOfPipeWithFlip(m_buffer[m_current_buffer], static_cast<uint32_t*>(dst_gpu_addr), value, m_flip.handle,
|
||||
m_flip.index, m_flip.flip_mode, m_flip.flip_arg);
|
||||
GraphicsRenderWriteAtEndOfPipeWithFlip32(m_sumbit_id, m_buffer[m_current_buffer], static_cast<uint32_t*>(dst_gpu_addr), value,
|
||||
m_flip.handle, m_flip.index, m_flip.flip_mode, m_flip.flip_arg);
|
||||
}
|
||||
|
||||
void CommandProcessor::FlipWithInterrupt(uint32_t eop_event_type, uint32_t cache_action, void* dst_gpu_addr, uint32_t value)
|
||||
@@ -1175,8 +1212,9 @@ void CommandProcessor::FlipWithInterrupt(uint32_t eop_event_type, uint32_t cache
|
||||
|
||||
if (eop_event_type == 0x00000004 && cache_action == 0x00000038)
|
||||
{
|
||||
GraphicsRenderWriteAtEndOfPipeWithInterruptWriteBackFlip(m_buffer[m_current_buffer], static_cast<uint32_t*>(dst_gpu_addr), value,
|
||||
m_flip.handle, m_flip.index, m_flip.flip_mode, m_flip.flip_arg);
|
||||
GraphicsRenderWriteAtEndOfPipeWithInterruptWriteBackFlip32(m_sumbit_id, m_buffer[m_current_buffer],
|
||||
static_cast<uint32_t*>(dst_gpu_addr), value, m_flip.handle, m_flip.index,
|
||||
m_flip.flip_mode, m_flip.flip_arg);
|
||||
} else
|
||||
{
|
||||
EXIT("unknown event type\n");
|
||||
@@ -1308,13 +1346,13 @@ KYTY_HW_CTX_PARSER(hw_ctx_set_depth_render_target)
|
||||
z.stencil_info.tile_mode_index = KYTY_PM4_GET(buffer[1], DB_STENCIL_INFO, TILE_MODE_INDEX);
|
||||
z.stencil_info.tile_stencil_disable = KYTY_PM4_GET(buffer[1], DB_STENCIL_INFO, TILE_STENCIL_DISABLE);
|
||||
|
||||
if (Config::IsNeo())
|
||||
{
|
||||
EXIT_NOT_IMPLEMENTED((buffer[2] & 0xffu) != 0);
|
||||
EXIT_NOT_IMPLEMENTED((buffer[3] & 0xffu) != 0);
|
||||
EXIT_NOT_IMPLEMENTED((buffer[4] & 0xffu) != 0);
|
||||
EXIT_NOT_IMPLEMENTED((buffer[5] & 0xffu) != 0);
|
||||
}
|
||||
// if (Config::IsNeo())
|
||||
// {
|
||||
// EXIT_NOT_IMPLEMENTED((buffer[2] & 0xffu) != 0);
|
||||
// EXIT_NOT_IMPLEMENTED((buffer[3] & 0xffu) != 0);
|
||||
// EXIT_NOT_IMPLEMENTED((buffer[4] & 0xffu) != 0);
|
||||
// EXIT_NOT_IMPLEMENTED((buffer[5] & 0xffu) != 0);
|
||||
// }
|
||||
|
||||
z.z_read_base_addr = static_cast<uint64_t>(buffer[2]) << 8u;
|
||||
z.stencil_read_base_addr = static_cast<uint64_t>(buffer[3]) << 8u;
|
||||
@@ -1479,6 +1517,65 @@ KYTY_HW_CTX_PARSER(hw_ctx_set_line_control)
|
||||
return 1;
|
||||
}
|
||||
|
||||
KYTY_HW_CTX_PARSER(hw_ctx_set_scan_mode_control)
|
||||
{
|
||||
EXIT_NOT_IMPLEMENTED(cmd_id != 0xc0016900);
|
||||
EXIT_NOT_IMPLEMENTED(cmd_offset != Pm4::PA_SC_MODE_CNTL_0);
|
||||
|
||||
HW::ScanModeControl r;
|
||||
|
||||
r.msaa_enable = KYTY_PM4_GET(buffer[0], PA_SC_MODE_CNTL_0, MSAA_ENABLE) != 0;
|
||||
r.vport_scissor_enable = KYTY_PM4_GET(buffer[0], PA_SC_MODE_CNTL_0, VPORT_SCISSOR_ENABLE) != 0;
|
||||
r.line_stipple_enable = KYTY_PM4_GET(buffer[0], PA_SC_MODE_CNTL_0, LINE_STIPPLE_ENABLE) != 0;
|
||||
|
||||
cp->GetCtx()->SetScanModeControl(r);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
KYTY_HW_CTX_PARSER(hw_ctx_set_aa_config)
|
||||
{
|
||||
EXIT_NOT_IMPLEMENTED(cmd_id != 0xc0016900);
|
||||
EXIT_NOT_IMPLEMENTED(cmd_offset != Pm4::PA_SC_AA_CONFIG);
|
||||
|
||||
HW::AaConfig r;
|
||||
|
||||
r.msaa_num_samples = KYTY_PM4_GET(buffer[0], PA_SC_AA_CONFIG, MSAA_NUM_SAMPLES);
|
||||
r.aa_mask_centroid_dtmn = KYTY_PM4_GET(buffer[0], PA_SC_AA_CONFIG, AA_MASK_CENTROID_DTMN) != 0;
|
||||
r.max_sample_dist = KYTY_PM4_GET(buffer[0], PA_SC_AA_CONFIG, MAX_SAMPLE_DIST);
|
||||
r.msaa_exposed_samples = KYTY_PM4_GET(buffer[0], PA_SC_AA_CONFIG, MSAA_EXPOSED_SAMPLES);
|
||||
|
||||
cp->GetCtx()->SetAaConfig(r);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
KYTY_HW_CTX_PARSER(hw_ctx_set_aa_sample_control)
|
||||
{
|
||||
EXIT_NOT_IMPLEMENTED(cmd_id != 0xc0106900);
|
||||
EXIT_NOT_IMPLEMENTED(cmd_offset != Pm4::PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y0_0);
|
||||
|
||||
uint32_t count = 1;
|
||||
|
||||
if (dw >= 20 && buffer[16] == 0xc0026900 && buffer[17] == Pm4::PA_SC_CENTROID_PRIORITY_0)
|
||||
{
|
||||
count = 20;
|
||||
|
||||
HW::AaSampleControl r;
|
||||
|
||||
memcpy(r.locations, buffer, 16 * 4);
|
||||
|
||||
r.centroid_priority = static_cast<uint64_t>(buffer[18]) | (static_cast<uint64_t>(buffer[19]) << 32u);
|
||||
|
||||
cp->GetCtx()->SetAaSampleControl(r);
|
||||
} else
|
||||
{
|
||||
KYTY_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
KYTY_HW_CTX_PARSER(hw_ctx_set_depth_control)
|
||||
{
|
||||
EXIT_NOT_IMPLEMENTED(cmd_id != 0xC0016900);
|
||||
@@ -2478,11 +2575,12 @@ KYTY_CP_OP_PARSER(cp_op_acquire_mem)
|
||||
{
|
||||
case 0x02c40040:
|
||||
case 0x02c43fc0:
|
||||
case 0x02c47fc0:
|
||||
{
|
||||
// target_mask: 0x00000040 (rt0), 0x00003fc0 (all rt)
|
||||
// target_mask: 0x00000040 (rt0), 0x00003fc0 (all rt), 0x00007fc0 (all rt and depth)
|
||||
// extended_action: 0x02000000 (FlushAndInvalidateCbCache)
|
||||
// action: 0x38 (WriteBackAndInvalidateL1andL2)
|
||||
EXIT_IF(target_mask != 0x00000040 && target_mask != 0x00003FC0);
|
||||
EXIT_IF(target_mask != 0x00000040 && target_mask != 0x00003FC0 && target_mask != 0x00007FC0);
|
||||
EXIT_IF(extended_action != 0x02000000);
|
||||
EXIT_IF(action != 0x38);
|
||||
EXIT_NOT_IMPLEMENTED(size_lo == 0);
|
||||
@@ -2624,6 +2722,11 @@ KYTY_CP_OP_PARSER(cp_op_marker)
|
||||
case 0x0: cp->SetEmbeddedDataMarker(buffer + 1, len_dw, align); break;
|
||||
case 0x4: cp->SetUserDataMarker(HW::UserSgprType::Vsharp); break;
|
||||
case 0xd: cp->SetUserDataMarker(HW::UserSgprType::Region); break;
|
||||
case 0x777:
|
||||
{
|
||||
cp->Flip();
|
||||
break;
|
||||
}
|
||||
case 0x778:
|
||||
{
|
||||
auto* addr = reinterpret_cast<void*>(buffer[1] | (static_cast<uint64_t>(buffer[2]) << 32u));
|
||||
@@ -2730,28 +2833,31 @@ static void graphics_init_jmp_tables()
|
||||
func = nullptr;
|
||||
}
|
||||
|
||||
g_hw_ctx_func[Pm4::DB_RENDER_CONTROL] = hw_ctx_set_render_control;
|
||||
g_hw_ctx_func[Pm4::DB_STENCIL_CLEAR] = hw_ctx_set_stencil_clear;
|
||||
g_hw_ctx_func[Pm4::DB_DEPTH_CLEAR] = hw_ctx_set_depth_clear;
|
||||
g_hw_ctx_func[Pm4::PA_SC_SCREEN_SCISSOR_TL] = hw_ctx_set_screen_scissor;
|
||||
g_hw_ctx_func[Pm4::DB_Z_INFO] = hw_ctx_set_depth_render_target;
|
||||
g_hw_ctx_func[Pm4::DB_STENCIL_INFO] = hw_ctx_set_stencil_info;
|
||||
g_hw_ctx_func[0x08d] = hw_ctx_hardware_screen_offset;
|
||||
g_hw_ctx_func[0x08e] = hw_ctx_set_render_target_mask;
|
||||
g_hw_ctx_func[Pm4::PA_SC_GENERIC_SCISSOR_TL] = hw_ctx_set_generic_scissor;
|
||||
g_hw_ctx_func[Pm4::CB_BLEND_RED] = hw_ctx_set_blend_color;
|
||||
g_hw_ctx_func[Pm4::DB_STENCIL_CONTROL] = hw_ctx_set_stencil_control;
|
||||
g_hw_ctx_func[Pm4::DB_STENCILREFMASK] = hw_ctx_set_stencil_mask;
|
||||
g_hw_ctx_func[Pm4::SPI_PS_INPUT_CNTL_0] = hw_ctx_set_ps_input;
|
||||
g_hw_ctx_func[Pm4::DB_DEPTH_CONTROL] = hw_ctx_set_depth_control;
|
||||
g_hw_ctx_func[Pm4::DB_EQAA] = hw_ctx_set_eqaa_control;
|
||||
g_hw_ctx_func[Pm4::CB_COLOR_CONTROL] = hw_ctx_set_color_control;
|
||||
g_hw_ctx_func[0x204] = hw_ctx_set_clip_control;
|
||||
g_hw_ctx_func[Pm4::PA_SU_SC_MODE_CNTL] = hw_ctx_set_mode_control;
|
||||
g_hw_ctx_func[0x206] = hw_ctx_set_viewport_transform_control;
|
||||
g_hw_ctx_func[Pm4::PA_SU_LINE_CNTL] = hw_ctx_set_line_control;
|
||||
g_hw_ctx_func[Pm4::VGT_SHADER_STAGES_EN] = hw_ctx_set_shader_stages;
|
||||
g_hw_ctx_func[0x2fa] = hw_ctx_set_guard_bands;
|
||||
g_hw_ctx_func[Pm4::DB_RENDER_CONTROL] = hw_ctx_set_render_control;
|
||||
g_hw_ctx_func[Pm4::DB_STENCIL_CLEAR] = hw_ctx_set_stencil_clear;
|
||||
g_hw_ctx_func[Pm4::DB_DEPTH_CLEAR] = hw_ctx_set_depth_clear;
|
||||
g_hw_ctx_func[Pm4::PA_SC_SCREEN_SCISSOR_TL] = hw_ctx_set_screen_scissor;
|
||||
g_hw_ctx_func[Pm4::DB_Z_INFO] = hw_ctx_set_depth_render_target;
|
||||
g_hw_ctx_func[Pm4::DB_STENCIL_INFO] = hw_ctx_set_stencil_info;
|
||||
g_hw_ctx_func[0x08d] = hw_ctx_hardware_screen_offset;
|
||||
g_hw_ctx_func[0x08e] = hw_ctx_set_render_target_mask;
|
||||
g_hw_ctx_func[Pm4::PA_SC_GENERIC_SCISSOR_TL] = hw_ctx_set_generic_scissor;
|
||||
g_hw_ctx_func[Pm4::CB_BLEND_RED] = hw_ctx_set_blend_color;
|
||||
g_hw_ctx_func[Pm4::DB_STENCIL_CONTROL] = hw_ctx_set_stencil_control;
|
||||
g_hw_ctx_func[Pm4::DB_STENCILREFMASK] = hw_ctx_set_stencil_mask;
|
||||
g_hw_ctx_func[Pm4::SPI_PS_INPUT_CNTL_0] = hw_ctx_set_ps_input;
|
||||
g_hw_ctx_func[Pm4::DB_DEPTH_CONTROL] = hw_ctx_set_depth_control;
|
||||
g_hw_ctx_func[Pm4::DB_EQAA] = hw_ctx_set_eqaa_control;
|
||||
g_hw_ctx_func[Pm4::CB_COLOR_CONTROL] = hw_ctx_set_color_control;
|
||||
g_hw_ctx_func[0x204] = hw_ctx_set_clip_control;
|
||||
g_hw_ctx_func[Pm4::PA_SU_SC_MODE_CNTL] = hw_ctx_set_mode_control;
|
||||
g_hw_ctx_func[0x206] = hw_ctx_set_viewport_transform_control;
|
||||
g_hw_ctx_func[Pm4::PA_SU_LINE_CNTL] = hw_ctx_set_line_control;
|
||||
g_hw_ctx_func[Pm4::PA_SC_MODE_CNTL_0] = hw_ctx_set_scan_mode_control;
|
||||
g_hw_ctx_func[Pm4::PA_SC_AA_CONFIG] = hw_ctx_set_aa_config;
|
||||
g_hw_ctx_func[Pm4::PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y0_0] = hw_ctx_set_aa_sample_control;
|
||||
g_hw_ctx_func[Pm4::VGT_SHADER_STAGES_EN] = hw_ctx_set_shader_stages;
|
||||
g_hw_ctx_func[0x2fa] = hw_ctx_set_guard_bands;
|
||||
|
||||
for (uint32_t slot = 0; slot < 8; slot++)
|
||||
{
|
||||
|
||||
@@ -159,6 +159,12 @@ bool DepthStencilBufferObject::Equal(const uint64_t* other) const
|
||||
params[PARAM_HEIGHT] == other[PARAM_HEIGHT] && params[PARAM_HTILE] == other[PARAM_HTILE]);
|
||||
}
|
||||
|
||||
// bool DepthStencilBufferObject::Reuse(const uint64_t* other) const
|
||||
//{
|
||||
// return (params[PARAM_FORMAT] == other[PARAM_FORMAT] && params[PARAM_WIDTH] <= other[PARAM_WIDTH] &&
|
||||
// params[PARAM_HEIGHT] <= other[PARAM_HEIGHT] && params[PARAM_HTILE] == other[PARAM_HTILE]);
|
||||
//}
|
||||
|
||||
GpuObject::create_func_t DepthStencilBufferObject::GetCreateFunc() const
|
||||
{
|
||||
return create_func;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -54,16 +54,19 @@ public:
|
||||
virtual ~LabelManager() { KYTY_NOT_IMPLEMENTED; }
|
||||
KYTY_CLASS_NO_COPY(LabelManager);
|
||||
|
||||
Label* Create(GraphicContext* ctx, uint64_t* dst_gpu_addr, uint64_t value, LabelGpuObject::callback_t callback_1,
|
||||
LabelGpuObject::callback_t callback_2, const uint64_t* args);
|
||||
Label* Create(GraphicContext* ctx, uint32_t* dst_gpu_addr, uint32_t value, LabelGpuObject::callback_t callback_1,
|
||||
LabelGpuObject::callback_t callback_2, const uint64_t* args);
|
||||
Label* Create64(GraphicContext* ctx, uint64_t* dst_gpu_addr, uint64_t value, LabelGpuObject::callback_t callback_1,
|
||||
LabelGpuObject::callback_t callback_2, const uint64_t* args);
|
||||
Label* Create32(GraphicContext* ctx, uint32_t* dst_gpu_addr, uint32_t value, LabelGpuObject::callback_t callback_1,
|
||||
LabelGpuObject::callback_t callback_2, const uint64_t* args);
|
||||
void Delete(Label* label);
|
||||
void Set(CommandBuffer* buffer, Label* label);
|
||||
|
||||
private:
|
||||
static void ThreadRun(void* data);
|
||||
|
||||
bool Remove(Label* label);
|
||||
static void Destroy(Label* label);
|
||||
|
||||
Core::Mutex m_mutex;
|
||||
Core::CondVar m_cond_var;
|
||||
Vector<Label*> m_labels;
|
||||
@@ -104,18 +107,24 @@ void LabelManager::ThreadRun(void* data)
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& label: deleted_labels)
|
||||
{
|
||||
manager->Delete(label);
|
||||
}
|
||||
|
||||
if (active_count == 0)
|
||||
{
|
||||
manager->m_cond_var.Wait(&manager->m_mutex);
|
||||
}
|
||||
|
||||
for (auto& label: deleted_labels)
|
||||
{
|
||||
bool removed = manager->Remove(label);
|
||||
EXIT_NOT_IMPLEMENTED(!removed);
|
||||
}
|
||||
|
||||
manager->m_mutex.Unlock();
|
||||
|
||||
for (auto& label: deleted_labels)
|
||||
{
|
||||
Destroy(label);
|
||||
}
|
||||
|
||||
for (auto& label: fired_labels)
|
||||
{
|
||||
bool write = true;
|
||||
@@ -151,11 +160,11 @@ void LabelManager::ThreadRun(void* data)
|
||||
}
|
||||
}
|
||||
|
||||
Label* LabelManager::Create(GraphicContext* ctx, uint64_t* dst_gpu_addr, uint64_t value, LabelGpuObject::callback_t callback_1,
|
||||
LabelGpuObject::callback_t callback_2, const uint64_t* args)
|
||||
Label* LabelManager::Create64(GraphicContext* ctx, uint64_t* dst_gpu_addr, uint64_t value, LabelGpuObject::callback_t callback_1,
|
||||
LabelGpuObject::callback_t callback_2, const uint64_t* args)
|
||||
{
|
||||
EXIT_IF(ctx == nullptr);
|
||||
EXIT_IF(dst_gpu_addr == nullptr);
|
||||
EXIT_IF(args == nullptr);
|
||||
|
||||
Core::LockGuard lock(m_mutex);
|
||||
|
||||
@@ -190,11 +199,10 @@ Label* LabelManager::Create(GraphicContext* ctx, uint64_t* dst_gpu_addr, uint64_
|
||||
return label;
|
||||
}
|
||||
|
||||
Label* LabelManager::Create(GraphicContext* ctx, uint32_t* dst_gpu_addr, uint32_t value, LabelGpuObject::callback_t callback_1,
|
||||
LabelGpuObject::callback_t callback_2, const uint64_t* args)
|
||||
Label* LabelManager::Create32(GraphicContext* ctx, uint32_t* dst_gpu_addr, uint32_t value, LabelGpuObject::callback_t callback_1,
|
||||
LabelGpuObject::callback_t callback_2, const uint64_t* args)
|
||||
{
|
||||
EXIT_IF(ctx == nullptr);
|
||||
EXIT_IF(dst_gpu_addr == nullptr);
|
||||
EXIT_IF(args == nullptr);
|
||||
|
||||
Core::LockGuard lock(m_mutex);
|
||||
@@ -229,7 +237,7 @@ Label* LabelManager::Create(GraphicContext* ctx, uint32_t* dst_gpu_addr, uint32_
|
||||
return label;
|
||||
}
|
||||
|
||||
void LabelManager::Delete(Label* label)
|
||||
bool LabelManager::Remove(Label* label)
|
||||
{
|
||||
EXIT_IF(label == nullptr);
|
||||
EXIT_IF(label->event == nullptr);
|
||||
@@ -246,18 +254,35 @@ void LabelManager::Delete(Label* label)
|
||||
if (label->status == LabelStatus::Active)
|
||||
{
|
||||
label->status = LabelStatus::ActiveDeleted;
|
||||
} else
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
m_labels.RemoveAt(index);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void LabelManager::Destroy(Label* label)
|
||||
{
|
||||
EXIT_IF(label == nullptr);
|
||||
EXIT_IF(label->event == nullptr);
|
||||
EXIT_IF(label->device == nullptr);
|
||||
EXIT_IF(label->buffer == nullptr);
|
||||
|
||||
// All submitted commands that refer to event must have completed execution
|
||||
label->buffer->CommandProcessorWait();
|
||||
|
||||
vkDestroyEvent(label->device, label->event, nullptr);
|
||||
|
||||
delete label;
|
||||
}
|
||||
|
||||
void LabelManager::Delete(Label* label)
|
||||
{
|
||||
if (Remove(label))
|
||||
{
|
||||
m_labels.RemoveAt(index);
|
||||
|
||||
EXIT_IF(label->buffer == nullptr);
|
||||
|
||||
// All submitted commands that refer to event must have completed execution
|
||||
label->buffer->CommandProcessorWait();
|
||||
|
||||
vkDestroyEvent(label->device, label->event, nullptr);
|
||||
|
||||
delete label;
|
||||
Destroy(label);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,20 +325,20 @@ void LabelInit()
|
||||
g_label_manager = new LabelManager;
|
||||
}
|
||||
|
||||
Label* LabelCreate(GraphicContext* ctx, uint64_t* dst_gpu_addr, uint64_t value, LabelGpuObject::callback_t callback_1,
|
||||
LabelGpuObject::callback_t callback_2, const uint64_t* args)
|
||||
Label* LabelCreate64(GraphicContext* ctx, uint64_t* dst_gpu_addr, uint64_t value, LabelGpuObject::callback_t callback_1,
|
||||
LabelGpuObject::callback_t callback_2, const uint64_t* args)
|
||||
{
|
||||
EXIT_IF(g_label_manager == nullptr);
|
||||
|
||||
return g_label_manager->Create(ctx, dst_gpu_addr, value, callback_1, callback_2, args);
|
||||
return g_label_manager->Create64(ctx, dst_gpu_addr, value, callback_1, callback_2, args);
|
||||
}
|
||||
|
||||
Label* LabelCreate(GraphicContext* ctx, uint32_t* dst_gpu_addr, uint32_t value, LabelGpuObject::callback_t callback_1,
|
||||
LabelGpuObject::callback_t callback_2, const uint64_t* args)
|
||||
Label* LabelCreate32(GraphicContext* ctx, uint32_t* dst_gpu_addr, uint32_t value, LabelGpuObject::callback_t callback_1,
|
||||
LabelGpuObject::callback_t callback_2, const uint64_t* args)
|
||||
{
|
||||
EXIT_IF(g_label_manager == nullptr);
|
||||
|
||||
return g_label_manager->Create(ctx, dst_gpu_addr, value, callback_1, callback_2, args);
|
||||
return g_label_manager->Create32(ctx, dst_gpu_addr, value, callback_1, callback_2, args);
|
||||
}
|
||||
|
||||
void LabelDelete(Label* label)
|
||||
@@ -343,10 +368,10 @@ static void* create_func(GraphicContext* ctx, const uint64_t* params, const uint
|
||||
auto callback_1 = reinterpret_cast<LabelGpuObject::callback_t>(params[LabelGpuObject::PARAM_CALLBACK_1]);
|
||||
auto callback_2 = reinterpret_cast<LabelGpuObject::callback_t>(params[LabelGpuObject::PARAM_CALLBACK_2]);
|
||||
|
||||
auto* label_obj = (*size == 8 ? LabelCreate(ctx, reinterpret_cast<uint64_t*>(*vaddr), value, callback_1, callback_2,
|
||||
params + LabelGpuObject::PARAM_ARG_1)
|
||||
: (*size == 4 ? LabelCreate(ctx, reinterpret_cast<uint32_t*>(*vaddr), static_cast<uint32_t>(value),
|
||||
callback_1, callback_2, params + LabelGpuObject::PARAM_ARG_1)
|
||||
auto* label_obj = (*size == 8 ? LabelCreate64(ctx, reinterpret_cast<uint64_t*>(*vaddr), value, callback_1, callback_2,
|
||||
params + LabelGpuObject::PARAM_ARG_1)
|
||||
: (*size == 4 ? LabelCreate32(ctx, reinterpret_cast<uint32_t*>(*vaddr), static_cast<uint32_t>(value),
|
||||
callback_1, callback_2, params + LabelGpuObject::PARAM_ARG_1)
|
||||
: nullptr));
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(label_obj == nullptr);
|
||||
|
||||
@@ -354,7 +354,7 @@ String ShaderCode::DbgDump() const
|
||||
String ret;
|
||||
for (const auto& inst: m_instructions)
|
||||
{
|
||||
if (m_labels.Contains(inst.pc, [](auto label, auto pc) { return label.dst == pc; }))
|
||||
if (m_labels.Contains(inst.pc, [](auto label, auto pc) { return label.GetDst() == pc; }))
|
||||
{
|
||||
ret += String::FromPrintf("label_%04" PRIx32 ":\n", inst.pc);
|
||||
}
|
||||
@@ -363,6 +363,51 @@ String ShaderCode::DbgDump() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ShaderCode::IsDiscardInstruction(uint32_t index) const
|
||||
{
|
||||
if (!(index == 0 || index + 1 >= m_instructions.Size()))
|
||||
{
|
||||
const auto& prev_inst = m_instructions.At(index - 1);
|
||||
const auto& inst = m_instructions.At(index);
|
||||
const auto& next_inst = m_instructions.At(index + 1);
|
||||
|
||||
return (inst.type == ShaderInstructionType::Exp && inst.format == ShaderInstructionFormat::Mrt0OffOffComprVmDone &&
|
||||
prev_inst.type == ShaderInstructionType::SMovB64 && prev_inst.format == ShaderInstructionFormat::Sdst2Ssrc02 &&
|
||||
prev_inst.dst.type == ShaderOperandType::ExecLo && prev_inst.src[0].type == ShaderOperandType::IntegerInlineConstant &&
|
||||
prev_inst.src[0].constant.i == 0 && next_inst.type == ShaderInstructionType::SEndpgm);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ShaderCode::IsDiscardBlock(uint32_t pc) const
|
||||
{
|
||||
auto inst_count = m_instructions.Size();
|
||||
for (uint32_t index = 0; index < inst_count; index++)
|
||||
{
|
||||
const auto& inst = m_instructions.At(index);
|
||||
if (inst.pc == pc)
|
||||
{
|
||||
for (uint32_t i = index; i < inst_count; i++)
|
||||
{
|
||||
const auto& inst = m_instructions.At(i);
|
||||
|
||||
if (inst.type == ShaderInstructionType::SEndpgm || inst.type == ShaderInstructionType::SCbranchExecz ||
|
||||
inst.type == ShaderInstructionType::SCbranchScc0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsDiscardInstruction(i))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static ShaderOperand operand_parse(uint32_t code)
|
||||
{
|
||||
ShaderOperand ret;
|
||||
@@ -555,7 +600,7 @@ KYTY_SHADER_PARSER(shader_parse_sopp)
|
||||
|
||||
if (inst.type == ShaderInstructionType::SCbranchScc0 || inst.type == ShaderInstructionType::SCbranchExecz)
|
||||
{
|
||||
dst->GetLabels().Add(ShaderLabel({inst.pc + 4 + inst.src[0].constant.i, inst.pc}));
|
||||
dst->GetLabels().Add(ShaderLabel(inst));
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -1782,7 +1827,7 @@ KYTY_SHADER_PARSER(shader_parse)
|
||||
}
|
||||
|
||||
if ((instruction == 0xBF810000 && (type == ShaderType::Vertex || type == ShaderType::Pixel || type == ShaderType::Compute) &&
|
||||
!dst->GetLabels().Contains(4 * static_cast<uint32_t>(ptr - src), [](auto label, auto pc) { return label.dst == pc; })) ||
|
||||
!dst->GetLabels().Contains(4 * static_cast<uint32_t>(ptr - src), [](auto label, auto pc) { return label.GetDst() == pc; })) ||
|
||||
(instruction == 0xBE802000 && type == ShaderType::Fetch))
|
||||
{
|
||||
break;
|
||||
|
||||
@@ -2036,17 +2036,24 @@ KYTY_RECOMPILER_FUNC(Recompile_Exp_Mrt0OffOffComprVmDone)
|
||||
{
|
||||
EXIT_NOT_IMPLEMENTED(index == 0 || index + 1 >= code.GetInstructions().Size());
|
||||
|
||||
const auto& prev_inst = code.GetInstructions().At(index - 1);
|
||||
const auto& inst = code.GetInstructions().At(index);
|
||||
const auto& next_inst = code.GetInstructions().At(index + 1);
|
||||
|
||||
if (!(prev_inst.type == ShaderInstructionType::SMovB64 && prev_inst.format == ShaderInstructionFormat::Sdst2Ssrc02 &&
|
||||
prev_inst.dst.type == ShaderOperandType::ExecLo && prev_inst.src[0].type == ShaderOperandType::IntegerInlineConstant &&
|
||||
prev_inst.src[0].constant.i == 0 && next_inst.type == ShaderInstructionType::SEndpgm))
|
||||
if (!code.IsDiscardInstruction(index))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// const auto& prev_inst = code.GetInstructions().At(index - 1);
|
||||
// const auto& inst = code.GetInstructions().At(index);
|
||||
// const auto& next_inst = code.GetInstructions().At(index + 1);
|
||||
//
|
||||
// if (!(prev_inst.type == ShaderInstructionType::SMovB64 && prev_inst.format == ShaderInstructionFormat::Sdst2Ssrc02 &&
|
||||
// prev_inst.dst.type == ShaderOperandType::ExecLo && prev_inst.src[0].type == ShaderOperandType::IntegerInlineConstant &&
|
||||
// prev_inst.src[0].constant.i == 0 && next_inst.type == ShaderInstructionType::SEndpgm))
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
const auto& inst = code.GetInstructions().At(index);
|
||||
|
||||
const auto* info = spirv->GetPsInputInfo();
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(info == nullptr || !info->ps_pixel_kill_enable);
|
||||
@@ -3188,7 +3195,7 @@ KYTY_RECOMPILER_FUNC(Recompile_SCbranchExecz_Label)
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(!operand_is_constant(inst.src[0]));
|
||||
|
||||
String label = String::FromPrintf("label_%04" PRIx32 "_%04" PRIx32, inst.pc + 4 + inst.src[0].constant.i, inst.pc);
|
||||
String label = ShaderLabel(inst).ToString();
|
||||
|
||||
static const char32_t* text = UR"(
|
||||
%execz_u_<index> = OpLoad %uint %execz
|
||||
@@ -3209,17 +3216,30 @@ KYTY_RECOMPILER_FUNC(Recompile_SCbranchScc0_Label)
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(!operand_is_constant(inst.src[0]));
|
||||
|
||||
String label = String::FromPrintf("label_%04" PRIx32 "_%04" PRIx32, inst.pc + 4 + inst.src[0].constant.i, inst.pc);
|
||||
auto label = ShaderLabel(inst);
|
||||
String label_str = label.ToString();
|
||||
|
||||
static const char32_t* text = UR"(
|
||||
// TODO(): analyze control flow graph
|
||||
bool discard = code.IsDiscardBlock(label.GetDst());
|
||||
|
||||
static const char32_t* text_variant_a = UR"(
|
||||
%scc_u_<index> = OpLoad %uint %scc
|
||||
%scc_b_<index> = OpIEqual %bool %scc_u_<index> %uint_0
|
||||
OpSelectionMerge %<label> None
|
||||
OpBranchConditional %scc_b_<index> %<label> %t230_<index>
|
||||
%t230_<index> = OpLabel
|
||||
)";
|
||||
static const char32_t* text_variant_b = UR"(
|
||||
%scc_u_<index> = OpLoad %uint %scc
|
||||
%scc_b_<index> = OpIEqual %bool %scc_u_<index> %uint_0
|
||||
OpSelectionMerge %t230_<index> None
|
||||
OpBranchConditional %scc_b_<index> %<label> %t230_<index>
|
||||
%t230_<index> = OpLabel
|
||||
)";
|
||||
|
||||
*dst_source += String(text).ReplaceStr(U"<index>", String::FromPrintf("%u", index)).ReplaceStr(U"<label>", label);
|
||||
*dst_source += String(discard ? text_variant_b : text_variant_a)
|
||||
.ReplaceStr(U"<index>", String::FromPrintf("%u", index))
|
||||
.ReplaceStr(U"<label>", label_str);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -6158,7 +6178,7 @@ void Spirv::WriteInstructions()
|
||||
for (uint32_t i = labels.Size(); i > 0; i--)
|
||||
{
|
||||
auto label = labels.At(i - 1);
|
||||
if (index > 0 && label.dst == inst.pc)
|
||||
if (index > 0 && label.GetDst() == inst.pc)
|
||||
{
|
||||
static const char32_t* text = UR"(
|
||||
<branch>
|
||||
@@ -6170,7 +6190,7 @@ void Spirv::WriteInstructions()
|
||||
|
||||
m_source += String(text)
|
||||
.ReplaceStr(U"<branch>", (skip_branch ? U"" : U"OpBranch %<label>"))
|
||||
.ReplaceStr(U"<label>", String::FromPrintf("label_%04" PRIx32 "_%04" PRIx32, label.dst, label.src));
|
||||
.ReplaceStr(U"<label>", label.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -452,27 +452,21 @@ void TileConvertTiledToLinear(void* dst, const void* src, TileMode mode, uint32_
|
||||
}
|
||||
}
|
||||
|
||||
void TileGetDepthSize(uint32_t width, uint32_t height, uint32_t z_format, uint32_t stencil_format, bool htile, bool neo,
|
||||
uint32_t* stencil_size, uint32_t* htile_size, uint32_t* depth_size, uint32_t* pitch)
|
||||
bool TileGetDepthSize(uint32_t width, uint32_t height, uint32_t pitch, uint32_t z_format, uint32_t stencil_format, bool htile, bool neo,
|
||||
TileSizeAlign* stencil_size, TileSizeAlign* htile_size, TileSizeAlign* depth_size)
|
||||
{
|
||||
struct SizeAlign
|
||||
{
|
||||
uint32_t size;
|
||||
uint32_t align;
|
||||
};
|
||||
|
||||
struct DepthInfo
|
||||
{
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t z_format;
|
||||
uint32_t stencil_format;
|
||||
bool tile;
|
||||
bool neo;
|
||||
uint32_t pitch;
|
||||
SizeAlign stencil;
|
||||
SizeAlign htile;
|
||||
SizeAlign depth;
|
||||
uint32_t width = 0;
|
||||
uint32_t height = 0;
|
||||
uint32_t z_format = 0;
|
||||
uint32_t stencil_format = 0;
|
||||
bool tile = false;
|
||||
bool neo = false;
|
||||
uint32_t pitch = 0;
|
||||
TileSizeAlign stencil = {};
|
||||
TileSizeAlign htile = {};
|
||||
TileSizeAlign depth = {};
|
||||
};
|
||||
|
||||
static const DepthInfo infos_base[] = {
|
||||
@@ -513,6 +507,8 @@ void TileGetDepthSize(uint32_t width, uint32_t height, uint32_t z_format, uint32
|
||||
{3840, 2160, 3, 0, false, true, 3840, {0, 0}, {0, 0}, {33423360, 65536}},
|
||||
{1920, 1080, 3, 0, true, true, 1920, {0, 0}, {196608, 4096}, {8847360, 65536}},
|
||||
{1920, 1080, 3, 0, false, true, 1920, {0, 0}, {0, 0}, {8847360, 65536}},
|
||||
{1920, 1080, 3, 0, true, true, 2048, {0, 0}, {196608, 4096}, {9437184, 65536}},
|
||||
{1920, 1080, 3, 0, false, true, 2048, {0, 0}, {0, 0}, {9437184, 65536}},
|
||||
{1280, 720, 3, 0, true, true, 1280, {0, 0}, {131072, 4096}, {3932160, 65536}},
|
||||
{1280, 720, 3, 0, false, true, 1280, {0, 0}, {0, 0}, {3932160, 65536}},
|
||||
{3840, 2160, 1, 0, true, true, 3840, {0, 0}, {655360, 4096}, {16711680, 65536}},
|
||||
@@ -544,187 +540,184 @@ void TileGetDepthSize(uint32_t width, uint32_t height, uint32_t z_format, uint32
|
||||
EXIT_IF(depth_size == nullptr);
|
||||
EXIT_IF(htile_size == nullptr);
|
||||
EXIT_IF(stencil_size == nullptr);
|
||||
EXIT_IF(pitch == nullptr);
|
||||
|
||||
if (neo)
|
||||
{
|
||||
for (const auto& i: infos_neo)
|
||||
{
|
||||
if (i.width == width && i.height == height && i.tile == htile && i.z_format == z_format && i.stencil_format == stencil_format)
|
||||
if (i.width == width && i.height == height && i.pitch == pitch && i.tile == htile && i.z_format == z_format &&
|
||||
i.stencil_format == stencil_format)
|
||||
{
|
||||
*depth_size = i.depth.size;
|
||||
*htile_size = i.htile.size;
|
||||
*stencil_size = i.stencil.size;
|
||||
*pitch = i.pitch;
|
||||
return;
|
||||
*depth_size = i.depth;
|
||||
*htile_size = i.htile;
|
||||
*stencil_size = i.stencil;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
for (const auto& i: infos_base)
|
||||
{
|
||||
if (i.width == width && i.height == height && i.tile == htile && i.z_format == z_format && i.stencil_format == stencil_format)
|
||||
if (i.width == width && i.height == height && i.pitch == pitch && i.tile == htile && i.z_format == z_format &&
|
||||
i.stencil_format == stencil_format)
|
||||
{
|
||||
*depth_size = i.depth.size;
|
||||
*htile_size = i.htile.size;
|
||||
*stencil_size = i.stencil.size;
|
||||
*pitch = i.pitch;
|
||||
return;
|
||||
*depth_size = i.depth;
|
||||
*htile_size = i.htile;
|
||||
*stencil_size = i.stencil;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
*depth_size = 0;
|
||||
*htile_size = 0;
|
||||
*stencil_size = 0;
|
||||
*depth_size = TileSizeAlign();
|
||||
*htile_size = TileSizeAlign();
|
||||
*stencil_size = TileSizeAlign();
|
||||
return false;
|
||||
}
|
||||
|
||||
void TileGetVideoOutSize(uint32_t width, uint32_t height, bool tile, bool neo, uint32_t* size, uint32_t* pitch)
|
||||
void TileGetVideoOutSize(uint32_t width, uint32_t height, uint32_t pitch, bool tile, bool neo, TileSizeAlign* size)
|
||||
{
|
||||
EXIT_IF(size == nullptr);
|
||||
EXIT_IF(pitch == nullptr);
|
||||
|
||||
uint32_t ret_size = 0;
|
||||
uint32_t ret_pitch = 0;
|
||||
uint32_t ret_align = 0;
|
||||
|
||||
if (width == 3840 && height == 2160 && tile && !neo)
|
||||
if (pitch == 3840)
|
||||
{
|
||||
ret_size = 33423360;
|
||||
ret_pitch = 3840;
|
||||
}
|
||||
if (width == 3840 && height == 2160 && tile && neo)
|
||||
{
|
||||
ret_size = 33423360;
|
||||
ret_pitch = 3840;
|
||||
}
|
||||
if (width == 3840 && height == 2160 && !tile && !neo)
|
||||
{
|
||||
ret_size = 33177600;
|
||||
ret_pitch = 3840;
|
||||
}
|
||||
if (width == 3840 && height == 2160 && !tile && neo)
|
||||
{
|
||||
ret_size = 33177600;
|
||||
ret_pitch = 3840;
|
||||
if (width == 3840 && height == 2160 && tile && !neo)
|
||||
{
|
||||
ret_size = 33423360;
|
||||
ret_align = 32768;
|
||||
}
|
||||
if (width == 3840 && height == 2160 && tile && neo)
|
||||
{
|
||||
ret_size = 33423360;
|
||||
ret_align = 65536;
|
||||
}
|
||||
if (width == 3840 && height == 2160 && !tile && !neo)
|
||||
{
|
||||
ret_size = 33177600;
|
||||
ret_align = 256;
|
||||
}
|
||||
if (width == 3840 && height == 2160 && !tile && neo)
|
||||
{
|
||||
ret_size = 33177600;
|
||||
ret_align = 256;
|
||||
}
|
||||
}
|
||||
|
||||
if (width == 1920 && height == 1080 && tile && !neo)
|
||||
if (pitch == 1920)
|
||||
{
|
||||
ret_size = 8355840;
|
||||
ret_pitch = 1920;
|
||||
}
|
||||
if (width == 1920 && height == 1080 && tile && neo)
|
||||
{
|
||||
ret_size = 8847360;
|
||||
ret_pitch = 1920;
|
||||
}
|
||||
if (width == 1920 && height == 1080 && !tile && !neo)
|
||||
{
|
||||
ret_size = 8294400;
|
||||
ret_pitch = 1920;
|
||||
}
|
||||
if (width == 1920 && height == 1080 && !tile && neo)
|
||||
{
|
||||
ret_size = 8294400;
|
||||
ret_pitch = 1920;
|
||||
if (width == 1920 && height == 1080 && tile && !neo)
|
||||
{
|
||||
ret_size = 8355840;
|
||||
ret_align = 32768;
|
||||
}
|
||||
if (width == 1920 && height == 1080 && tile && neo)
|
||||
{
|
||||
ret_size = 8847360;
|
||||
ret_align = 65536;
|
||||
}
|
||||
if (width == 1920 && height == 1080 && !tile && !neo)
|
||||
{
|
||||
ret_size = 8294400;
|
||||
ret_align = 256;
|
||||
}
|
||||
if (width == 1920 && height == 1080 && !tile && neo)
|
||||
{
|
||||
ret_size = 8294400;
|
||||
ret_align = 256;
|
||||
}
|
||||
}
|
||||
|
||||
if (width == 1280 && height == 720 && tile && !neo)
|
||||
if (pitch == 1280)
|
||||
{
|
||||
ret_size = 3932160;
|
||||
ret_pitch = 1280;
|
||||
}
|
||||
if (width == 1280 && height == 720 && tile && neo)
|
||||
{
|
||||
ret_size = 3932160;
|
||||
ret_pitch = 1280;
|
||||
}
|
||||
if (width == 1280 && height == 720 && !tile && !neo)
|
||||
{
|
||||
ret_size = 3686400;
|
||||
ret_pitch = 1280;
|
||||
}
|
||||
if (width == 1280 && height == 720 && !tile && neo)
|
||||
{
|
||||
ret_size = 3686400;
|
||||
ret_pitch = 1280;
|
||||
if (width == 1280 && height == 720 && tile && !neo)
|
||||
{
|
||||
ret_size = 3932160;
|
||||
ret_align = 32768;
|
||||
}
|
||||
if (width == 1280 && height == 720 && tile && neo)
|
||||
{
|
||||
ret_size = 3932160;
|
||||
ret_align = 65536;
|
||||
}
|
||||
if (width == 1280 && height == 720 && !tile && !neo)
|
||||
{
|
||||
ret_size = 3686400;
|
||||
ret_align = 256;
|
||||
}
|
||||
if (width == 1280 && height == 720 && !tile && neo)
|
||||
{
|
||||
ret_size = 3686400;
|
||||
ret_align = 256;
|
||||
}
|
||||
}
|
||||
|
||||
*size = ret_size;
|
||||
*pitch = ret_pitch;
|
||||
size->size = ret_size;
|
||||
size->align = ret_align;
|
||||
}
|
||||
|
||||
void TileGetTextureSize(uint32_t dfmt, uint32_t nfmt, uint32_t width, uint32_t height, uint32_t pitch, uint32_t levels, uint32_t tile,
|
||||
bool neo, uint32_t* total_size, uint32_t* level_sizes, uint32_t* padded_width, uint32_t* padded_height)
|
||||
bool neo, TileSizeAlign* total_size, uint32_t* level_sizes, uint32_t* padded_width, uint32_t* padded_height)
|
||||
{
|
||||
KYTY_PROFILER_FUNCTION();
|
||||
|
||||
struct Padded
|
||||
{
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t width = 0;
|
||||
uint32_t height = 0;
|
||||
};
|
||||
|
||||
struct TextureInfo
|
||||
{
|
||||
uint32_t dfmt;
|
||||
uint32_t nfmt;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t levels;
|
||||
uint32_t tile;
|
||||
bool neo;
|
||||
uint32_t size[16];
|
||||
Padded padded[16];
|
||||
uint32_t dfmt = 0;
|
||||
uint32_t nfmt = 0;
|
||||
uint32_t width = 0;
|
||||
uint32_t height = 0;
|
||||
uint32_t pitch = 0;
|
||||
uint32_t levels = 0;
|
||||
uint32_t tile = 0;
|
||||
bool neo = false;
|
||||
TileSizeAlign size[16];
|
||||
Padded padded[16];
|
||||
};
|
||||
|
||||
static const TextureInfo infos[] = {
|
||||
// clang-format off
|
||||
|
||||
// kDataFormatB8G8R8A8UnormSrgb, 512, 512, kTileModeDisplay_LinearAligned
|
||||
{ 10, 9, 512, 512, 10, 8, false, {1048576, 262144, 65536, 16384, 4096, 1024, 512, 256, 256, 256, },
|
||||
{ {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, } },
|
||||
{ 10, 9, 512, 512, 10, 8, true, {1048576, 262144, 65536, 16384, 4096, 1024, 512, 256, 256, 256, },
|
||||
{ {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, } },
|
||||
// kDataFormatB8G8R8A8UnormSrgb, 512, 512, kTileModeThin_1dThin
|
||||
{ 10, 9, 512, 512, 10, 13, false, {1048576, 262144, 65536, 16384, 4096, 1024, 256, 256, 256, 256, },
|
||||
{ {512, 512}, {256, 256}, {128, 128}, {64, 64}, {32, 32}, {16, 16}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, } },
|
||||
{ 10, 9, 512, 512, 10, 13, true, {1048576, 262144, 65536, 16384, 4096, 1024, 256, 256, 256, 256, },
|
||||
{ {512, 512}, {256, 256}, {128, 128}, {64, 64}, {32, 32}, {16, 16}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, } },
|
||||
// kDataFormatBc3UnormSrgb, 512, 512, kTileModeDisplay_LinearAligned
|
||||
{ 37, 9, 512, 512, 10, 8, false, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
||||
{ {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, } },
|
||||
{ 37, 9, 512, 512, 10, 8, true, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
||||
{ {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, } },
|
||||
// kDataFormatBc3UnormSrgb, 512, 512, kTileModeThin_1dThin
|
||||
{ 37, 9, 512, 512, 10, 13, false, {262144, 65536, 16384, 4096, 1024, 1024, 1024, 1024, 1024, 1024, },
|
||||
{ {128, 128}, {64, 64}, {32, 32}, {16, 16}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, } },
|
||||
{ 37, 9, 512, 512, 10, 13, true, {262144, 65536, 16384, 4096, 1024, 1024, 1024, 1024, 1024, 1024, },
|
||||
{ {128, 128}, {64, 64}, {32, 32}, {16, 16}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, } },
|
||||
// kDataFormatB8G8R8A8Unorm, 512, 512, kTileModeThin_1dThin
|
||||
{ 10, 0, 512, 512, 10, 13, false, {1048576, 262144, 65536, 16384, 4096, 1024, 256, 256, 256, 256, },
|
||||
{ {512, 512}, {256, 256}, {128, 128}, {64, 64}, {32, 32}, {16, 16}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, } },
|
||||
{ 10, 0, 512, 512, 10, 13, true, {1048576, 262144, 65536, 16384, 4096, 1024, 256, 256, 256, 256, },
|
||||
{ {512, 512}, {256, 256}, {128, 128}, {64, 64}, {32, 32}, {16, 16}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, } },
|
||||
// kDataFormatB8G8R8A8Unorm, 512, 768, kTileModeThin_1dThin
|
||||
{ 10, 0, 512, 768, 10, 13, false, {1572864, 1048576, 131072, 32768, 8192, 2048, 512, 256, 256, 256, },
|
||||
{ {512, 768}, {256, 512}, {128, 256}, {64, 128}, {32, 64}, {16, 32}, {8, 16}, {8, 8}, {8, 8}, {8, 8}, } },
|
||||
{ 10, 0, 512, 768, 10, 13, true, {1572864, 1048576, 131072, 32768, 8192, 2048, 512, 256, 256, 256, },
|
||||
{ {512, 768}, {256, 512}, {128, 256}, {64, 128}, {32, 64}, {16, 32}, {8, 16}, {8, 8}, {8, 8}, {8, 8}, } },
|
||||
// kDataFormatB8G8R8A8Unorm, 256, 256, kTileModeThin_2dThin
|
||||
{ 10, 0, 256, 256, 9, 14, false, {262144, 65536, 16384, 4096, 1024, 256, 256, 256, 256, },
|
||||
{ {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, } },
|
||||
{ 10, 0, 256, 256, 9, 14, true, {262144, 65536, 16384, 4096, 1024, 256, 256, 256, 256, },
|
||||
{ {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, } },
|
||||
// kDataFormatR32Float, 1920, 1080, kTileModeDepth_2dThin_256
|
||||
{ 4, 7, 1920, 1080, 11, 2, false, {8355840, 12615680, 1048576, 262144, 65536, 16384, 2048, 1024, 1024, 1024, 1024, },
|
||||
{ {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, } },
|
||||
{ 4, 7, 1920, 1080, 11, 2, true, {8847360, 12124160, 1048576, 262144, 65536, 16384, 2048, 1024, 1024, 1024, 1024, },
|
||||
{ {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, } },
|
||||
// kDataFormatR8Unorm, 2048, 2048, kTileModeDisplay_LinearAligned
|
||||
{ 1, 0, 2048, 2048, 12, 8, false, {4194304, 1048576, 262144, 65536, 16384, 4096, 2048, 1024, 512, 256, 256, 256, },
|
||||
{ {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, } },
|
||||
{ 1, 0, 2048, 2048, 12, 8, true, {4194304, 1048576, 262144, 65536, 16384, 4096, 2048, 1024, 512, 256, 256, 256, },
|
||||
{ {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, } },
|
||||
// kDataFormatB8G8R8A8UnormSrgb, 512, 512, 0, 0, kTileModeDisplay_LinearAligned
|
||||
{ 10, 9, 512, 512, 512, 10, 8, false, {{1048576, 256}, {262144, 256}, {65536, 256}, {16384, 256}, {4096, 256}, {1024, 256}, {512, 256}, {256, 256}, {256, 256}, {256, 256}, }, { {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, } },
|
||||
{ 10, 9, 512, 512, 512, 10, 8, true, {{1048576, 256}, {262144, 256}, {65536, 256}, {16384, 256}, {4096, 256}, {1024, 256}, {512, 256}, {256, 256}, {256, 256}, {256, 256}, }, { {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, } },
|
||||
// kDataFormatB8G8R8A8UnormSrgb, 512, 512, 0, 0, kTileModeThin_1dThin
|
||||
{ 10, 9, 512, 512, 512, 10, 13, false, {{1048576, 256}, {262144, 256}, {65536, 256}, {16384, 256}, {4096, 256}, {1024, 256}, {256, 256}, {256, 256}, {256, 256}, {256, 256}, }, { {512, 512}, {256, 256}, {128, 128}, {64, 64}, {32, 32}, {16, 16}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, } },
|
||||
{ 10, 9, 512, 512, 512, 10, 13, true, {{1048576, 256}, {262144, 256}, {65536, 256}, {16384, 256}, {4096, 256}, {1024, 256}, {256, 256}, {256, 256}, {256, 256}, {256, 256}, }, { {512, 512}, {256, 256}, {128, 128}, {64, 64}, {32, 32}, {16, 16}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, } },
|
||||
// kDataFormatBc3UnormSrgb, 512, 512, 0, 0, kTileModeThin_1dThin
|
||||
{ 37, 9, 512, 512, 512, 10, 13, false, {{262144, 256}, {65536, 256}, {16384, 256}, {4096, 256}, {1024, 256}, {1024, 256}, {1024, 256}, {1024, 256}, {1024, 256}, {1024, 256}, }, { {128, 128}, {64, 64}, {32, 32}, {16, 16}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, } },
|
||||
{ 37, 9, 512, 512, 512, 10, 13, true, {{262144, 256}, {65536, 256}, {16384, 256}, {4096, 256}, {1024, 256}, {1024, 256}, {1024, 256}, {1024, 256}, {1024, 256}, {1024, 256}, }, { {128, 128}, {64, 64}, {32, 32}, {16, 16}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, } },
|
||||
// kDataFormatB8G8R8A8Unorm, 512, 512, 0, 0, kTileModeThin_1dThin
|
||||
{ 10, 0, 512, 512, 512, 10, 13, false, {{1048576, 256}, {262144, 256}, {65536, 256}, {16384, 256}, {4096, 256}, {1024, 256}, {256, 256}, {256, 256}, {256, 256}, {256, 256}, }, { {512, 512}, {256, 256}, {128, 128}, {64, 64}, {32, 32}, {16, 16}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, } },
|
||||
{ 10, 0, 512, 512, 512, 10, 13, true, {{1048576, 256}, {262144, 256}, {65536, 256}, {16384, 256}, {4096, 256}, {1024, 256}, {256, 256}, {256, 256}, {256, 256}, {256, 256}, }, { {512, 512}, {256, 256}, {128, 128}, {64, 64}, {32, 32}, {16, 16}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, } },
|
||||
// kDataFormatB8G8R8A8Unorm, 512, 768, 0, 0, kTileModeThin_1dThin
|
||||
{ 10, 0, 512, 768, 512, 10, 13, false, {{1572864, 256}, {1048576, 256}, {131072, 256}, {32768, 256}, {8192, 256}, {2048, 256}, {512, 256}, {256, 256}, {256, 256}, {256, 256}, }, { {512, 768}, {256, 512}, {128, 256}, {64, 128}, {32, 64}, {16, 32}, {8, 16}, {8, 8}, {8, 8}, {8, 8}, } },
|
||||
{ 10, 0, 512, 768, 512, 10, 13, true, {{1572864, 256}, {1048576, 256}, {131072, 256}, {32768, 256}, {8192, 256}, {2048, 256}, {512, 256}, {256, 256}, {256, 256}, {256, 256}, }, { {512, 768}, {256, 512}, {128, 256}, {64, 128}, {32, 64}, {16, 32}, {8, 16}, {8, 8}, {8, 8}, {8, 8}, } },
|
||||
// kDataFormatB8G8R8A8Unorm, 256, 256, 0, 0, kTileModeThin_2dThin
|
||||
{ 10, 0, 256, 256, 256, 9, 14, false, {{262144, 32768}, {65536, 32768}, {16384, 32768}, {4096, 32768}, {1024, 32768}, {256, 32768}, {256, 32768}, {256, 32768}, {256, 32768}, }, { {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, } },
|
||||
{ 10, 0, 256, 256, 256, 9, 14, true, {{262144, 65536}, {65536, 65536}, {16384, 65536}, {4096, 65536}, {1024, 65536}, {256, 65536}, {256, 65536}, {256, 65536}, {256, 65536}, }, { {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, } },
|
||||
// kDataFormatB8G8R8A8Unorm, 1920, 1080, 1920, 1, kTileModeDisplay_2dThin
|
||||
{ 10, 0, 1920, 1080, 1920, 1, 10, false, {{8355840, 32768}, }, { {0, 0}, } },
|
||||
{ 10, 0, 1920, 1080, 1920, 1, 10, true, {{8847360, 65536}, }, { {0, 0}, } },
|
||||
// kDataFormatB8G8R8A8Unorm, 3840, 2160, 3840, 1, kTileModeDisplay_2dThin
|
||||
{ 10, 0, 3840, 2160, 3840, 1, 10, false, {{33423360, 32768}, }, { {0, 0}, } },
|
||||
{ 10, 0, 3840, 2160, 3840, 1, 10, true, {{33423360, 65536}, }, { {0, 0}, } },
|
||||
// kDataFormatR32Float, 1920, 1080, 1920, 1, kTileModeDepth_2dThin_256
|
||||
{ 4, 7, 1920, 1080, 1920, 1, 2, false, {{8355840, 32768}, }, { {0, 0}, } },
|
||||
{ 4, 7, 1920, 1080, 1920, 1, 2, true, {{8847360, 65536}, }, { {0, 0}, } },
|
||||
// kDataFormatR8Unorm, 2048, 2048, 0, 0, kTileModeDisplay_LinearAligned
|
||||
{ 1, 0, 2048, 2048, 2048, 12, 8, false, {{4194304, 256}, {1048576, 256}, {262144, 256}, {65536, 256}, {16384, 256}, {4096, 256}, {2048, 256}, {1024, 256}, {512, 256}, {256, 256}, {256, 256}, {256, 256}, }, { {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, } },
|
||||
{ 1, 0, 2048, 2048, 2048, 12, 8, true, {{4194304, 256}, {1048576, 256}, {262144, 256}, {65536, 256}, {16384, 256}, {4096, 256}, {2048, 256}, {1024, 256}, {512, 256}, {256, 256}, {256, 256}, {256, 256}, }, { {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, } },
|
||||
// kDataFormatB8G8R8A8Unorm, 1, 1, 64, 0, kTileModeDisplay_LinearAligned
|
||||
{ 10, 0, 1, 1, 64, 1, 8, false, {{256, 256}, }, { {0, 0}, } },
|
||||
{ 10, 0, 1, 1, 64, 1, 8, true, {{256, 256}, }, { {0, 0}, } },
|
||||
|
||||
// clang-format on
|
||||
};
|
||||
@@ -733,18 +726,19 @@ void TileGetTextureSize(uint32_t dfmt, uint32_t nfmt, uint32_t width, uint32_t h
|
||||
|
||||
for (const auto& i: infos)
|
||||
{
|
||||
if (i.dfmt == dfmt && i.nfmt == nfmt && i.width == width && i.width == pitch && i.height == height && i.levels >= levels &&
|
||||
if (i.dfmt == dfmt && i.nfmt == nfmt && i.width == width && i.pitch == pitch && i.height == height && i.levels >= levels &&
|
||||
i.tile == tile && i.neo == neo)
|
||||
{
|
||||
for (uint32_t l = 0; l < levels; l++)
|
||||
{
|
||||
if (total_size != nullptr)
|
||||
{
|
||||
*total_size += i.size[l];
|
||||
total_size->size += i.size[l].size;
|
||||
total_size->align = i.size[l].align;
|
||||
}
|
||||
if (level_sizes != nullptr)
|
||||
{
|
||||
level_sizes[l] = i.size[l];
|
||||
level_sizes[l] = i.size[l].size;
|
||||
}
|
||||
if (padded_width != nullptr)
|
||||
{
|
||||
@@ -759,12 +753,13 @@ void TileGetTextureSize(uint32_t dfmt, uint32_t nfmt, uint32_t width, uint32_t h
|
||||
}
|
||||
}
|
||||
|
||||
if (tile == 8 && levels == 1 && dfmt == 10 && nfmt == 9)
|
||||
if (tile == 8 && levels == 1 && ((dfmt == 10 && nfmt == 9) || (dfmt == 10 && nfmt == 0)))
|
||||
{
|
||||
uint32_t size = pitch * height * 4;
|
||||
if (total_size != nullptr)
|
||||
{
|
||||
*total_size = size;
|
||||
total_size->size = size;
|
||||
total_size->align = 256;
|
||||
}
|
||||
if (level_sizes != nullptr)
|
||||
{
|
||||
|
||||
@@ -248,6 +248,8 @@ void UtilBlitImage(CommandBuffer* buffer, VulkanImage* src_image, VulkanSwapchai
|
||||
|
||||
void VulkanCreateBuffer(GraphicContext* gctx, uint64_t size, VulkanBuffer* buffer)
|
||||
{
|
||||
KYTY_PROFILER_FUNCTION();
|
||||
|
||||
EXIT_IF(gctx == nullptr);
|
||||
EXIT_IF(buffer == nullptr);
|
||||
EXIT_IF(buffer->buffer != nullptr);
|
||||
@@ -272,6 +274,8 @@ void VulkanCreateBuffer(GraphicContext* gctx, uint64_t size, VulkanBuffer* buffe
|
||||
|
||||
void VulkanDeleteBuffer(GraphicContext* gctx, VulkanBuffer* buffer)
|
||||
{
|
||||
KYTY_PROFILER_FUNCTION();
|
||||
|
||||
EXIT_IF(buffer == nullptr);
|
||||
EXIT_IF(gctx == nullptr);
|
||||
|
||||
|
||||
@@ -189,27 +189,28 @@ private:
|
||||
|
||||
static VideoOutContext* g_video_out_context = nullptr;
|
||||
|
||||
static void calc_buffer_size(const VideoOutBufferAttribute* attribute, uint64_t* size, uint64_t* pitch)
|
||||
static void calc_buffer_size(const VideoOutBufferAttribute* attribute, uint64_t* out_size, uint64_t* out_align, uint64_t* out_pitch)
|
||||
{
|
||||
EXIT_IF(size == nullptr);
|
||||
EXIT_IF(pitch == nullptr);
|
||||
EXIT_IF(out_size == nullptr);
|
||||
EXIT_IF(out_pitch == nullptr);
|
||||
|
||||
bool tile = attribute->tilingMode == 0;
|
||||
bool neo = Config::IsNeo();
|
||||
uint32_t width = attribute->width;
|
||||
uint32_t height = attribute->height;
|
||||
uint32_t pitch = attribute->pitchInPixel;
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(attribute->width != attribute->pitchInPixel);
|
||||
// EXIT_NOT_IMPLEMENTED(attribute->width != attribute->pitchInPixel);
|
||||
EXIT_NOT_IMPLEMENTED(attribute->option != 0);
|
||||
EXIT_NOT_IMPLEMENTED(attribute->aspectRatio != 0);
|
||||
EXIT_NOT_IMPLEMENTED(attribute->pixelFormat != 0x80000000);
|
||||
|
||||
uint32_t size32 = 0;
|
||||
uint32_t pitch32 = 0;
|
||||
Graphics::TileGetVideoOutSize(width, height, tile, neo, &size32, &pitch32);
|
||||
Graphics::TileSizeAlign size32 {};
|
||||
Graphics::TileGetVideoOutSize(width, height, pitch, tile, neo, &size32);
|
||||
|
||||
*size = size32;
|
||||
*pitch = pitch32;
|
||||
*out_size = size32.size;
|
||||
*out_align = size32.align;
|
||||
*out_pitch = pitch;
|
||||
}
|
||||
|
||||
void VideoOutInit(uint32_t width, uint32_t height)
|
||||
@@ -535,7 +536,7 @@ void VideoOutEndVblank()
|
||||
{
|
||||
EXIT_IF(g_video_out_context == nullptr);
|
||||
|
||||
// g_video_out_context->VblankEnd();
|
||||
g_video_out_context->VblankEnd();
|
||||
}
|
||||
|
||||
KYTY_SYSV_ABI int VideoOutOpen(int user_id, int bus_type, int index, const void* param)
|
||||
@@ -821,8 +822,9 @@ KYTY_SYSV_ABI int VideoOutRegisterBuffers(int handle, int start_index, void* con
|
||||
EXIT_NOT_IMPLEMENTED(attribute->option != 0);
|
||||
|
||||
uint64_t buffer_size = 0;
|
||||
uint64_t buffer_align = 0;
|
||||
uint64_t buffer_pitch = 0;
|
||||
calc_buffer_size(attribute, &buffer_size, &buffer_pitch);
|
||||
calc_buffer_size(attribute, &buffer_size, &buffer_align, &buffer_pitch);
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(buffer_size == 0);
|
||||
EXIT_NOT_IMPLEMENTED(buffer_pitch == 0);
|
||||
@@ -841,12 +843,14 @@ KYTY_SYSV_ABI int VideoOutRegisterBuffers(int handle, int start_index, void* con
|
||||
return VIDEO_OUT_ERROR_SLOT_OCCUPIED;
|
||||
}
|
||||
|
||||
EXIT_NOT_IMPLEMENTED((reinterpret_cast<uint64_t>(addresses[i]) & (buffer_align - 1u)) != 0);
|
||||
|
||||
ctx->buffers[i + start_index].set_id = set_index;
|
||||
ctx->buffers[i + start_index].buffer = addresses[i];
|
||||
ctx->buffers[i + start_index].buffer_size = buffer_size;
|
||||
ctx->buffers[i + start_index].buffer_pitch = buffer_pitch;
|
||||
ctx->buffers[i + start_index].buffer_vulkan = static_cast<Graphics::VideoOutVulkanImage*>(Graphics::GpuMemoryCreateObject(
|
||||
g_video_out_context->GetGraphicCtx(), nullptr, reinterpret_cast<uint64_t>(addresses[i]), buffer_size, vulkan_buffer_info));
|
||||
0, g_video_out_context->GetGraphicCtx(), nullptr, reinterpret_cast<uint64_t>(addresses[i]), buffer_size, vulkan_buffer_info));
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(ctx->buffers[i + start_index].buffer_vulkan == nullptr);
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
namespace Kyty::Libs::Graphics {
|
||||
|
||||
constexpr float FPS_AVERAGE_FRAMES = 5.0f;
|
||||
constexpr float FPS_UPDATE_TIME = 0.25f;
|
||||
|
||||
struct EventKeyboard
|
||||
{
|
||||
@@ -183,6 +184,8 @@ struct GameApi
|
||||
double m_current_fps = {0.0};
|
||||
int m_max_updates_per_frame = {4};
|
||||
double m_update_fixed_time = 1.0 / 60.0;
|
||||
int m_fps_frames_num = {0};
|
||||
double m_fps_start_time = {0};
|
||||
};
|
||||
|
||||
struct GameApiPrivateStruct
|
||||
@@ -274,8 +277,22 @@ static void CalcFrameTime(GameApi* game, double game_time_s)
|
||||
|
||||
game->m_frame_num++;
|
||||
|
||||
game->m_current_fps = (1.0f / (game->m_current_time_seconds - game->m_previous_time_seconds)) * (1.0f / FPS_AVERAGE_FRAMES) +
|
||||
game->m_current_fps * (1.0f - (1.0f / FPS_AVERAGE_FRAMES));
|
||||
int fps_model = 1;
|
||||
|
||||
if (fps_model == 1)
|
||||
{
|
||||
game->m_fps_frames_num++;
|
||||
if (game->m_current_time_seconds - game->m_fps_start_time > FPS_UPDATE_TIME)
|
||||
{
|
||||
game->m_current_fps = static_cast<double>(game->m_fps_frames_num) / (game->m_current_time_seconds - game->m_fps_start_time);
|
||||
game->m_fps_frames_num = 0;
|
||||
game->m_fps_start_time = game->m_current_time_seconds;
|
||||
}
|
||||
} else
|
||||
{
|
||||
game->m_current_fps = (1.0f / (game->m_current_time_seconds - game->m_previous_time_seconds)) * (1.0f / FPS_AVERAGE_FRAMES) +
|
||||
game->m_current_fps * (1.0f - (1.0f / FPS_AVERAGE_FRAMES));
|
||||
}
|
||||
}
|
||||
|
||||
static bool Init(GameApi* /*game*/)
|
||||
|
||||
Reference in New Issue
Block a user