mirror of
https://github.com/InoriRus/Kyty.git
synced 2026-08-28 05:06:40 +00:00
implement more APIs
This commit is contained in:
@@ -530,9 +530,9 @@ static void rt_check(const HW::RenderTarget& rt)
|
||||
// EXIT_NOT_IMPLEMENTED(rt.dcc_max_uncompressed_block_size != 0x00000002);
|
||||
EXIT_NOT_IMPLEMENTED(rt.dcc.max_compressed_block_size != 0x00000000);
|
||||
EXIT_NOT_IMPLEMENTED(rt.dcc.min_compressed_block_size != 0x00000000);
|
||||
EXIT_NOT_IMPLEMENTED(rt.dcc.color_transform != 0x00000000);
|
||||
// EXIT_NOT_IMPLEMENTED(rt.dcc.color_transform != 0x00000000);
|
||||
EXIT_NOT_IMPLEMENTED(rt.dcc.enable_overwrite_combiner != false);
|
||||
EXIT_NOT_IMPLEMENTED(rt.dcc.force_independent_blocks != false);
|
||||
// EXIT_NOT_IMPLEMENTED(rt.dcc.force_independent_blocks != false);
|
||||
EXIT_NOT_IMPLEMENTED(rt.cmask.addr != 0x0000000000000000);
|
||||
EXIT_NOT_IMPLEMENTED(rt.cmask_slice.slice_minus1 != 0x00000000);
|
||||
EXIT_NOT_IMPLEMENTED(rt.fmask.addr != 0x0000000000000000);
|
||||
@@ -733,7 +733,7 @@ static void mc_print(const char* func, const HW::ModeControl& c)
|
||||
|
||||
static void mc_check(const HW::ModeControl& c)
|
||||
{
|
||||
EXIT_NOT_IMPLEMENTED(c.cull_front != false);
|
||||
// EXIT_NOT_IMPLEMENTED(c.cull_front != false);
|
||||
// EXIT_NOT_IMPLEMENTED(c.cull_back != false);
|
||||
EXIT_NOT_IMPLEMENTED(c.face != false);
|
||||
EXIT_NOT_IMPLEMENTED(c.poly_mode != 0);
|
||||
@@ -771,10 +771,10 @@ static void bc_check(const HW::BlendControl& c, const HW::BlendColor& color, con
|
||||
// EXIT_NOT_IMPLEMENTED(c.color_srcblend != 0);
|
||||
EXIT_NOT_IMPLEMENTED(c.color_comb_fcn != 0);
|
||||
// EXIT_NOT_IMPLEMENTED(c.color_destblend != 0);
|
||||
EXIT_NOT_IMPLEMENTED(c.alpha_srcblend != 0);
|
||||
// EXIT_NOT_IMPLEMENTED(c.alpha_srcblend != 0);
|
||||
EXIT_NOT_IMPLEMENTED(c.alpha_comb_fcn != 0);
|
||||
EXIT_NOT_IMPLEMENTED(c.alpha_destblend != 0);
|
||||
EXIT_NOT_IMPLEMENTED(c.separate_alpha_blend != false);
|
||||
// EXIT_NOT_IMPLEMENTED(c.alpha_destblend != 0);
|
||||
// EXIT_NOT_IMPLEMENTED(c.separate_alpha_blend != false);
|
||||
// EXIT_NOT_IMPLEMENTED(c.enable != false);
|
||||
EXIT_NOT_IMPLEMENTED(color.red != 0.0f);
|
||||
EXIT_NOT_IMPLEMENTED(color.green != 0.0f);
|
||||
@@ -2863,7 +2863,7 @@ VulkanDescriptorSet* DescriptorCache::GetDescriptor(Stage stage, VulkanBuffer**
|
||||
gds_buffer_info[i].range = VK_WHOLE_SIZE;
|
||||
}
|
||||
|
||||
int binding_num = 0;
|
||||
uint32_t binding_num = 0;
|
||||
|
||||
constexpr uint32_t B_MAX = 5;
|
||||
|
||||
@@ -3321,6 +3321,23 @@ void GraphicsRenderRenderTextureBarrier(CommandBuffer* buffer, uint64_t vaddr, u
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsRenderDepthStencilBarrier(CommandBuffer* buffer, uint64_t vaddr, uint64_t size)
|
||||
{
|
||||
EXIT_IF(buffer == nullptr);
|
||||
EXIT_IF(buffer->IsInvalid());
|
||||
|
||||
Core::LockGuard lock(g_render_ctx->GetMutex());
|
||||
|
||||
auto* vk_buffer = buffer->GetPool()->buffers[buffer->GetIndex()];
|
||||
|
||||
auto images = FindDepthStencil(vaddr, size, false);
|
||||
|
||||
for (auto* image: images)
|
||||
{
|
||||
GraphicsRenderDepthStencilBarrier(vk_buffer, image);
|
||||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
|
||||
static void FindRenderDepthInfo(CommandBuffer* /*buffer*/, const HW::HardwareContext& hw, RenderDepthInfo* r)
|
||||
{
|
||||
@@ -3500,6 +3517,8 @@ static void FindRenderColorInfo(CommandBuffer* buffer, const HW::HardwareContext
|
||||
uint32_t format = 0;
|
||||
bool render_to_texture = false;
|
||||
|
||||
auto video_image = VideoOut::VideoOutGetImage(rt.base.addr);
|
||||
|
||||
if (rt.attrib.tile_mode == 0x8)
|
||||
{
|
||||
tile = false;
|
||||
@@ -3507,7 +3526,7 @@ static void FindRenderColorInfo(CommandBuffer* buffer, const HW::HardwareContext
|
||||
{
|
||||
tile = true;
|
||||
|
||||
if (rt.info.format == 0xa && rt.info.channel_type == 0x0 && rt.info.channel_order == 0x0 && rt.size.width == rt.size.height)
|
||||
if (rt.info.format == 0xa && rt.info.channel_type == 0x0 && (rt.info.channel_order == 0x0 || rt.info.channel_order == 0x1))
|
||||
{
|
||||
render_to_texture = true;
|
||||
}
|
||||
@@ -3520,26 +3539,38 @@ static void FindRenderColorInfo(CommandBuffer* buffer, const HW::HardwareContext
|
||||
EXIT("unknown tile mode: %u\n", rt.attrib.tile_mode);
|
||||
}
|
||||
|
||||
if (render_to_texture && video_image.image != nullptr)
|
||||
{
|
||||
render_to_texture = false;
|
||||
}
|
||||
|
||||
if (render_to_texture)
|
||||
{
|
||||
RenderTextureFormat rt_format = RenderTextureFormat::Unknown;
|
||||
|
||||
if (rt.info.format == 0xa && rt.info.channel_type == 0x0 && rt.info.channel_order == 0x0)
|
||||
{
|
||||
// Render to texture
|
||||
RenderTextureObject vulkan_buffer_info(RenderTextureFormat::R8G8B8A8Unorm, width, height, tile, rt.info.neo_mode, pitch);
|
||||
auto* buffer_vulkan = static_cast<Graphics::RenderTextureVulkanImage*>(
|
||||
Graphics::GpuMemoryCreateObject(g_render_ctx->GetGraphicCtx(), buffer, rt.base.addr, size, vulkan_buffer_info));
|
||||
EXIT_NOT_IMPLEMENTED(buffer_vulkan == nullptr);
|
||||
r->type = RenderColorType::RenderTexture;
|
||||
r->base_addr = rt.base.addr;
|
||||
r->vulkan_buffer = buffer_vulkan;
|
||||
r->buffer_size = size;
|
||||
rt_format = RenderTextureFormat::R8G8B8A8Unorm;
|
||||
} else if (rt.info.format == 0xa && rt.info.channel_type == 0x0 && rt.info.channel_order == 0x1)
|
||||
{
|
||||
rt_format = RenderTextureFormat::B8G8R8A8Unorm;
|
||||
} else
|
||||
{
|
||||
EXIT("unknown format");
|
||||
}
|
||||
|
||||
// Render to texture
|
||||
RenderTextureObject vulkan_buffer_info(rt_format, width, height, tile, rt.info.neo_mode, pitch);
|
||||
auto* buffer_vulkan = static_cast<Graphics::RenderTextureVulkanImage*>(
|
||||
Graphics::GpuMemoryCreateObject(g_render_ctx->GetGraphicCtx(), buffer, rt.base.addr, size, vulkan_buffer_info));
|
||||
EXIT_NOT_IMPLEMENTED(buffer_vulkan == nullptr);
|
||||
r->type = RenderColorType::RenderTexture;
|
||||
r->base_addr = rt.base.addr;
|
||||
r->vulkan_buffer = buffer_vulkan;
|
||||
r->buffer_size = size;
|
||||
} else
|
||||
{
|
||||
if (rt.info.format == 0xa && rt.info.channel_type == 0x6 && rt.info.channel_order == 0x1)
|
||||
if (rt.info.format == 0xa && (rt.info.channel_type == 0x6 || rt.info.channel_type == 0x0) && rt.info.channel_order == 0x1)
|
||||
{
|
||||
format = 0x80000000;
|
||||
} else
|
||||
@@ -3547,7 +3578,6 @@ static void FindRenderColorInfo(CommandBuffer* buffer, const HW::HardwareContext
|
||||
EXIT("unknown format");
|
||||
}
|
||||
|
||||
auto video_image = VideoOut::VideoOutGetImage(rt.base.addr);
|
||||
if (video_image.image == nullptr)
|
||||
{
|
||||
// Offscreen buffer
|
||||
@@ -3679,7 +3709,7 @@ static void PrepareTextures(CommandBuffer* buffer, const ShaderTextureResources&
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(r.Base() == 0);
|
||||
EXIT_NOT_IMPLEMENTED(r.MinLod() != 0);
|
||||
EXIT_NOT_IMPLEMENTED(r.Dfmt() != 10 && r.Dfmt() != 37 && r.Dfmt() != 4);
|
||||
EXIT_NOT_IMPLEMENTED(r.Dfmt() != 1 && r.Dfmt() != 10 && r.Dfmt() != 37 && r.Dfmt() != 4);
|
||||
EXIT_NOT_IMPLEMENTED(r.Nfmt() != 9 && r.Nfmt() != 0 && r.Nfmt() != 7);
|
||||
// EXIT_NOT_IMPLEMENTED(r.Width() != 511);
|
||||
// EXIT_NOT_IMPLEMENTED(r.Height() != 511);
|
||||
@@ -3815,9 +3845,9 @@ static void PrepareSamplers(const ShaderSamplerResources& samplers, uint64_t* sa
|
||||
{
|
||||
auto r = samplers.samplers[i];
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(r.ClampX() != 0);
|
||||
EXIT_NOT_IMPLEMENTED(r.ClampY() != 0);
|
||||
EXIT_NOT_IMPLEMENTED(r.ClampZ() != 0);
|
||||
// EXIT_NOT_IMPLEMENTED(r.ClampX() != 0);
|
||||
// EXIT_NOT_IMPLEMENTED(r.ClampY() != 0);
|
||||
// EXIT_NOT_IMPLEMENTED(r.ClampZ() != 0);
|
||||
// EXIT_NOT_IMPLEMENTED(r.MaxAnisoRatio() != 0);
|
||||
EXIT_NOT_IMPLEMENTED(r.DepthCompareFunc() != 0);
|
||||
EXIT_NOT_IMPLEMENTED(r.ForceUnormCoords() != false);
|
||||
@@ -3832,7 +3862,7 @@ static void PrepareSamplers(const ShaderSamplerResources& samplers, uint64_t* sa
|
||||
// EXIT_NOT_IMPLEMENTED(r.MaxLod() != 4095);
|
||||
EXIT_NOT_IMPLEMENTED(r.PerfMip() != 0);
|
||||
EXIT_NOT_IMPLEMENTED(r.PerfZ() != 0);
|
||||
EXIT_NOT_IMPLEMENTED(r.LodBias() != 0);
|
||||
// EXIT_NOT_IMPLEMENTED(r.LodBias() != 0);
|
||||
EXIT_NOT_IMPLEMENTED(r.LodBiasSec() != 0);
|
||||
// EXIT_NOT_IMPLEMENTED(r.XyMagFilter() != 1);
|
||||
// EXIT_NOT_IMPLEMENTED(r.XyMinFilter() != 1);
|
||||
@@ -4184,9 +4214,9 @@ void GraphicsRenderDrawIndexAuto(CommandBuffer* buffer, HW::HardwareContext* ctx
|
||||
|
||||
switch (ucfg->GetPrimType())
|
||||
{
|
||||
case 4: topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; break;
|
||||
case 17: topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; break;
|
||||
case 19: topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN; break;
|
||||
case 4: topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; break; // kPrimitiveTypeTriList
|
||||
case 17: topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; break; // kPrimitiveTypeRectList
|
||||
case 19: topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN; break; // kPrimitiveTypeQuadList
|
||||
default: EXIT("unknown primitive type: %u\n", ucfg->GetPrimType());
|
||||
}
|
||||
|
||||
@@ -4239,8 +4269,11 @@ void GraphicsRenderDrawIndexAuto(CommandBuffer* buffer, HW::HardwareContext* ctx
|
||||
vkCmdDraw(vk_buffer, 4, 1, 0, 0);
|
||||
break;
|
||||
case 19:
|
||||
EXIT_NOT_IMPLEMENTED(index_count != 4);
|
||||
vkCmdDraw(vk_buffer, 4, 1, 0, 0);
|
||||
EXIT_NOT_IMPLEMENTED((index_count & 0x3u) != 0);
|
||||
for (uint32_t i = 0; i < index_count; i += 4)
|
||||
{
|
||||
vkCmdDraw(vk_buffer, 4, 1, i, 0);
|
||||
}
|
||||
break;
|
||||
default: EXIT("unknown primitive type: %u\n", ucfg->GetPrimType());
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ public:
|
||||
void WriteBack();
|
||||
void MemoryBarrier();
|
||||
void RenderTextureBarrier(uint64_t vaddr, uint64_t size);
|
||||
void DepthStencilBarrier(uint64_t vaddr, uint64_t size);
|
||||
void DispatchDirect(uint32_t thread_group_x, uint32_t thread_group_y, uint32_t thread_group_z, uint32_t mode);
|
||||
void WaitFlipDone(uint32_t video_out_handle, uint32_t display_buffer_index);
|
||||
void TriggerEvent(uint32_t event_type, uint32_t event_index);
|
||||
@@ -1115,6 +1116,15 @@ void CommandProcessor::RenderTextureBarrier(uint64_t vaddr, uint64_t size)
|
||||
GraphicsRenderRenderTextureBarrier(m_buffer[m_current_buffer], vaddr, size);
|
||||
}
|
||||
|
||||
void CommandProcessor::DepthStencilBarrier(uint64_t vaddr, uint64_t size)
|
||||
{
|
||||
Core::LockGuard lock(m_mutex);
|
||||
|
||||
EXIT_IF(m_current_buffer < 0 || m_current_buffer >= VK_BUFFERS_NUM);
|
||||
|
||||
GraphicsRenderDepthStencilBarrier(m_buffer[m_current_buffer], vaddr, size);
|
||||
}
|
||||
|
||||
void CommandProcessor::TriggerEvent(uint32_t event_type, uint32_t event_index)
|
||||
{
|
||||
Core::LockGuard lock(m_mutex);
|
||||
@@ -1902,6 +1912,17 @@ KYTY_HW_CTX_PARSER(hw_ctx_set_vs_shader)
|
||||
return 28;
|
||||
}
|
||||
|
||||
KYTY_HW_CTX_PARSER(hw_ctx_update_vs_shader)
|
||||
{
|
||||
EXIT_NOT_IMPLEMENTED(cmd_id != 0xc01b103c);
|
||||
|
||||
auto shader_modifier = buffer[0];
|
||||
|
||||
cp->GetCtx()->UpdateVsShader(reinterpret_cast<const HW::VsStageRegisters*>(buffer + 1), shader_modifier);
|
||||
|
||||
return 28;
|
||||
}
|
||||
|
||||
KYTY_HW_CTX_PARSER(hw_ctx_set_vs_embedded)
|
||||
{
|
||||
EXIT_NOT_IMPLEMENTED(cmd_id != 0xc01b1034);
|
||||
@@ -1961,6 +1982,25 @@ KYTY_HW_CTX_PARSER(hw_ctx_set_ps_shader)
|
||||
return 39;
|
||||
}
|
||||
|
||||
KYTY_HW_CTX_PARSER(hw_ctx_update_ps_shader)
|
||||
{
|
||||
EXIT_NOT_IMPLEMENTED(cmd_id != 0xc0261040);
|
||||
|
||||
HW::PsStageRegisters r {};
|
||||
|
||||
r.data_addr = (static_cast<uint64_t>(buffer[0]) << 8u) | (static_cast<uint64_t>(buffer[1]) << 40u);
|
||||
r.vgprs = (buffer[2] >> Pm4::SPI_SHADER_PGM_RSRC1_PS_VGPRS_SHIFT) & Pm4::SPI_SHADER_PGM_RSRC1_PS_VGPRS_MASK;
|
||||
r.sgprs = (buffer[2] >> Pm4::SPI_SHADER_PGM_RSRC1_PS_SGPRS_SHIFT) & Pm4::SPI_SHADER_PGM_RSRC1_PS_SGPRS_MASK;
|
||||
r.scratch_en = (buffer[3] >> Pm4::SPI_SHADER_PGM_RSRC2_PS_SCRATCH_EN_SHIFT) & Pm4::SPI_SHADER_PGM_RSRC2_PS_SCRATCH_EN_MASK;
|
||||
r.user_sgpr = (buffer[3] >> Pm4::SPI_SHADER_PGM_RSRC2_PS_USER_SGPR_SHIFT) & Pm4::SPI_SHADER_PGM_RSRC2_PS_USER_SGPR_MASK;
|
||||
r.wave_cnt_en = (buffer[3] >> Pm4::SPI_SHADER_PGM_RSRC2_PS_WAVE_CNT_EN_SHIFT) & Pm4::SPI_SHADER_PGM_RSRC2_PS_WAVE_CNT_EN_MASK;
|
||||
r.shader_z_format = buffer[4];
|
||||
|
||||
cp->GetCtx()->UpdatePsShader(&r);
|
||||
|
||||
return 39;
|
||||
}
|
||||
|
||||
KYTY_HW_CTX_PARSER(hw_ctx_set_cs_shader)
|
||||
{
|
||||
EXIT_NOT_IMPLEMENTED(cmd_id != 0xC017101C);
|
||||
@@ -2500,7 +2540,12 @@ KYTY_CP_OP_PARSER(cp_op_acquire_mem)
|
||||
// target_mask: 0x00004000 (Depth Target)
|
||||
// extended_action: 0x04000000 (FlushAndInvalidateDbCache)
|
||||
// action: 0x38 (WriteBackAndInvalidateL1andL2)
|
||||
KYTY_NOT_IMPLEMENTED;
|
||||
EXIT_IF(target_mask != 0x00004000);
|
||||
EXIT_IF(extended_action != 0x04000000);
|
||||
EXIT_IF(action != 0x38);
|
||||
|
||||
cp->DepthStencilBarrier(base_lo << 8u, size_lo << 8u);
|
||||
cp->WriteBack();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -2668,6 +2713,8 @@ KYTY_CP_OP_PARSER(cp_op_nop)
|
||||
case Pm4::R_POP_MARKER: return cp_op_pop_marker(cp, cmd_id, buffer, dw, num_dw); break;
|
||||
case Pm4::R_VS_EMBEDDED: return hw_ctx_set_vs_embedded(cp, cmd_id, 0, buffer, dw); break;
|
||||
case Pm4::R_PS_EMBEDDED: return hw_ctx_set_ps_embedded(cp, cmd_id, 0, buffer, dw); break;
|
||||
case Pm4::R_VS_UPDATE: return hw_ctx_update_vs_shader(cp, cmd_id, 0, buffer, dw); break;
|
||||
case Pm4::R_PS_UPDATE: return hw_ctx_update_ps_shader(cp, cmd_id, 0, buffer, dw); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
|
||||
static bool Enabled()
|
||||
{
|
||||
static const bool enabled = !Core::dbg_is_debugger_present();
|
||||
static const bool enabled = false; // !Core::dbg_is_debugger_present();
|
||||
return enabled;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,6 +165,7 @@ static void* create_func(GraphicContext* ctx, const uint64_t* params, const uint
|
||||
switch (pixel_format) // NOLINT
|
||||
{
|
||||
case static_cast<uint64_t>(RenderTextureFormat::R8G8B8A8Unorm): vk_format = VK_FORMAT_R8G8B8A8_UNORM; break;
|
||||
case static_cast<uint64_t>(RenderTextureFormat::B8G8R8A8Unorm): vk_format = VK_FORMAT_B8G8R8A8_UNORM; break;
|
||||
default: EXIT("unknown format: %" PRIu64 "\n", pixel_format);
|
||||
}
|
||||
|
||||
@@ -267,6 +268,7 @@ static void* create2_func(GraphicContext* ctx, CommandBuffer* buffer, const uint
|
||||
switch (pixel_format) // NOLINT
|
||||
{
|
||||
case static_cast<uint64_t>(RenderTextureFormat::R8G8B8A8Unorm): vk_format = VK_FORMAT_R8G8B8A8_UNORM; break;
|
||||
case static_cast<uint64_t>(RenderTextureFormat::B8G8R8A8Unorm): vk_format = VK_FORMAT_B8G8R8A8_UNORM; break;
|
||||
default: EXIT("unknown format: %" PRIu64 "\n", pixel_format);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,10 @@ static VkFormat get_texture_format(uint32_t dfmt, uint32_t nfmt)
|
||||
{
|
||||
return VK_FORMAT_R8G8B8A8_UNORM;
|
||||
}
|
||||
if (nfmt == 0 && dfmt == 1)
|
||||
{
|
||||
return VK_FORMAT_R8_UNORM;
|
||||
}
|
||||
if (nfmt == 9 && dfmt == 37)
|
||||
{
|
||||
return VK_FORMAT_BC3_SRGB_BLOCK;
|
||||
|
||||
@@ -12,7 +12,34 @@
|
||||
|
||||
namespace Kyty::Libs::Graphics {
|
||||
|
||||
static void* create_func(GraphicContext* ctx, const uint64_t* /*params*/, const uint64_t* vaddr, const uint64_t* size, int vaddr_num,
|
||||
static void update_func(GraphicContext* ctx, const uint64_t* /*params*/, void* obj, const uint64_t* vaddr, const uint64_t* size,
|
||||
int vaddr_num)
|
||||
{
|
||||
KYTY_PROFILER_BLOCK("VertexBufferGpuObject::update_func");
|
||||
|
||||
EXIT_IF(vaddr_num != 1 || size == nullptr || vaddr == nullptr || *vaddr == 0);
|
||||
EXIT_IF(obj == nullptr);
|
||||
|
||||
auto* vk_obj = static_cast<VulkanBuffer*>(obj);
|
||||
|
||||
VulkanBuffer staging_buffer {};
|
||||
staging_buffer.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
|
||||
staging_buffer.memory.property = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
|
||||
|
||||
VulkanCreateBuffer(ctx, *size, &staging_buffer);
|
||||
EXIT_NOT_IMPLEMENTED(staging_buffer.buffer == nullptr);
|
||||
|
||||
void* data = nullptr;
|
||||
VulkanMapMemory(ctx, &staging_buffer.memory, &data);
|
||||
memcpy(data, reinterpret_cast<void*>(*vaddr), *size);
|
||||
VulkanUnmapMemory(ctx, &staging_buffer.memory);
|
||||
|
||||
UtilCopyBuffer(&staging_buffer, vk_obj, *size);
|
||||
|
||||
VulkanDeleteBuffer(ctx, &staging_buffer);
|
||||
}
|
||||
|
||||
static void* create_func(GraphicContext* ctx, const uint64_t* params, const uint64_t* vaddr, const uint64_t* size, int vaddr_num,
|
||||
VulkanMemory* mem)
|
||||
{
|
||||
KYTY_PROFILER_BLOCK("VertexBufferGpuObject::Create");
|
||||
@@ -30,35 +57,11 @@ static void* create_func(GraphicContext* ctx, const uint64_t* /*params*/, const
|
||||
VulkanCreateBuffer(ctx, *size, vk_obj);
|
||||
EXIT_NOT_IMPLEMENTED(vk_obj->buffer == nullptr);
|
||||
|
||||
VulkanBuffer staging_buffer {};
|
||||
staging_buffer.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
|
||||
staging_buffer.memory.property = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
|
||||
|
||||
VulkanCreateBuffer(ctx, *size, &staging_buffer);
|
||||
EXIT_NOT_IMPLEMENTED(staging_buffer.buffer == nullptr);
|
||||
|
||||
void* data = nullptr;
|
||||
// vkMapMemory(ctx->device, staging_buffer.memory.memory, staging_buffer.memory.offset, *size, 0, &data);
|
||||
VulkanMapMemory(ctx, &staging_buffer.memory, &data);
|
||||
memcpy(data, reinterpret_cast<void*>(*vaddr), *size);
|
||||
// vkUnmapMemory(ctx->device, staging_buffer.memory.memory);
|
||||
VulkanUnmapMemory(ctx, &staging_buffer.memory);
|
||||
|
||||
UtilCopyBuffer(&staging_buffer, vk_obj, *size);
|
||||
|
||||
VulkanDeleteBuffer(ctx, &staging_buffer);
|
||||
update_func(ctx, params, vk_obj, vaddr, size, vaddr_num);
|
||||
|
||||
return vk_obj;
|
||||
}
|
||||
|
||||
static void update_func(GraphicContext* /*ctx*/, const uint64_t* /*params*/, void* /*obj*/, const uint64_t* /*vaddr*/,
|
||||
const uint64_t* /*size*/, int /*vaddr_num*/)
|
||||
{
|
||||
KYTY_PROFILER_BLOCK("VertexBufferGpuObject::update_func");
|
||||
|
||||
KYTY_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static void delete_func(GraphicContext* ctx, void* obj, VulkanMemory* /*mem*/)
|
||||
{
|
||||
KYTY_PROFILER_BLOCK("VertexBufferGpuObject::delete_func");
|
||||
|
||||
@@ -212,7 +212,8 @@ static String dbg_fmt_to_str(const ShaderInstruction& inst)
|
||||
case ShaderInstructionFormat::Vdata4VaddrSvSoffsIdxen: return U"Vdata4VaddrSvSoffsIdxen"; break;
|
||||
case ShaderInstructionFormat::Vdata4VaddrSvSoffsIdxenFloat4: return U"Vdata4VaddrSvSoffsIdxenFloat4"; break;
|
||||
case ShaderInstructionFormat::Vdata4Vaddr2SvSoffsOffenIdxenFloat4: return U"Vdata4Vaddr2SvSoffsOffenIdxenFloat4"; break;
|
||||
case ShaderInstructionFormat::Vdata3Vaddr3StSsDmask7: return U"Vdata4Vaddr3StSsDmask7"; break;
|
||||
case ShaderInstructionFormat::Vdata1Vaddr3StSsDmask1: return U"Vdata1Vaddr3StSsDmask1"; break;
|
||||
case ShaderInstructionFormat::Vdata3Vaddr3StSsDmask7: return U"Vdata3Vaddr3StSsDmask7"; break;
|
||||
case ShaderInstructionFormat::Vdata4Vaddr3StSsDmaskF: return U"Vdata4Vaddr3StSsDmaskF"; break;
|
||||
case ShaderInstructionFormat::Vdata4Vaddr3StDmaskF: return U"Vdata4Vaddr3StDmaskF"; break;
|
||||
case ShaderInstructionFormat::Vdata4Vaddr4StDmaskF: return U"Vdata4Vaddr4StDmaskF"; break;
|
||||
@@ -286,6 +287,7 @@ static String dbg_fmt_print(const ShaderInstruction& inst)
|
||||
case ShaderInstructionFormat::Compr: s = U"compr"; break;
|
||||
case ShaderInstructionFormat::Vm: s = U"vm"; break;
|
||||
case ShaderInstructionFormat::L: s = String::FromPrintf("label_%04" PRIx32, inst.pc + 4 + inst.src[0].constant.i); break;
|
||||
case ShaderInstructionFormat::Dmask1: s = U"dmask:0x1"; break;
|
||||
case ShaderInstructionFormat::Dmask7: s = U"dmask:0x7"; break;
|
||||
case ShaderInstructionFormat::DmaskF: s = U"dmask:0xf"; break;
|
||||
case ShaderInstructionFormat::Gds: s = U"gds"; break;
|
||||
@@ -1532,7 +1534,7 @@ KYTY_SHADER_PARSER(shader_parse_mimg)
|
||||
EXIT_NOT_IMPLEMENTED(glc == 1);
|
||||
EXIT_NOT_IMPLEMENTED(slc == 1);
|
||||
EXIT_NOT_IMPLEMENTED(unrm == 1);
|
||||
EXIT_NOT_IMPLEMENTED(dmask != 0xf && dmask != 0x7);
|
||||
// EXIT_NOT_IMPLEMENTED(dmask != 0xf && dmask != 0x7);
|
||||
|
||||
uint32_t size = 2;
|
||||
|
||||
@@ -1584,14 +1586,27 @@ KYTY_SHADER_PARSER(shader_parse_mimg)
|
||||
inst.src[0].size = 3;
|
||||
inst.src[1].size = 8;
|
||||
inst.src[2].size = 4;
|
||||
if (dmask == 0x7)
|
||||
switch (dmask)
|
||||
{
|
||||
inst.format = ShaderInstructionFormat::Vdata3Vaddr3StSsDmask7;
|
||||
inst.dst.size = 3;
|
||||
} else if (dmask == 0xf)
|
||||
{
|
||||
inst.format = ShaderInstructionFormat::Vdata4Vaddr3StSsDmaskF;
|
||||
inst.dst.size = 4;
|
||||
case 0x1:
|
||||
{
|
||||
inst.format = ShaderInstructionFormat::Vdata1Vaddr3StSsDmask1;
|
||||
inst.dst.size = 1;
|
||||
break;
|
||||
}
|
||||
case 0x7:
|
||||
{
|
||||
inst.format = ShaderInstructionFormat::Vdata3Vaddr3StSsDmask7;
|
||||
inst.dst.size = 3;
|
||||
break;
|
||||
}
|
||||
case 0xf:
|
||||
{
|
||||
inst.format = ShaderInstructionFormat::Vdata4Vaddr3StSsDmaskF;
|
||||
inst.dst.size = 4;
|
||||
break;
|
||||
}
|
||||
default:;
|
||||
}
|
||||
break;
|
||||
default: printf("%s", dst->DbgDump().C_Str()); EXIT("unknown mimg opcode: 0x%02" PRIx32 " at addr 0x%08" PRIx32 "\n", opcode, pc);
|
||||
@@ -1600,7 +1615,7 @@ KYTY_SHADER_PARSER(shader_parse_mimg)
|
||||
if (inst.format == ShaderInstructionFormat::Unknown)
|
||||
{
|
||||
printf("%s", dst->DbgDump().C_Str());
|
||||
EXIT("unknown mimg format for opcode: 0x%02" PRIx32 " at addr 0x%08" PRIx32 "\n", opcode, pc)
|
||||
EXIT("unknown mimg format for opcode: 0x%02" PRIx32 " at addr 0x%08" PRIx32 ", dmask: 0x%" PRIx32 "\n", opcode, pc, dmask);
|
||||
}
|
||||
|
||||
dst->GetInstructions().Add(inst);
|
||||
|
||||
@@ -2217,6 +2217,61 @@ KYTY_RECOMPILER_FUNC(Recompile_Exp_Pos0Vsrc0Vsrc1Vsrc2Vsrc3Done)
|
||||
return true;
|
||||
}
|
||||
|
||||
KYTY_RECOMPILER_FUNC(Recompile_ImageSample_Vdata1Vaddr3StSsDmask1)
|
||||
{
|
||||
const auto& inst = code.GetInstructions().At(index);
|
||||
const auto* bind_info = spirv->GetBindInfo();
|
||||
// const auto& bind_params = spirv->GetBindParams();
|
||||
|
||||
if (bind_info != nullptr && bind_info->textures2D.textures2d_sampled_num > 0 && bind_info->samplers.samplers_num > 0)
|
||||
{
|
||||
auto dst_value0 = operand_variable_to_str(inst.dst, 0);
|
||||
auto src0_value0 = operand_variable_to_str(inst.src[0], 0);
|
||||
auto src0_value1 = operand_variable_to_str(inst.src[0], 1);
|
||||
auto src0_value2 = operand_variable_to_str(inst.src[0], 2);
|
||||
auto src1_value0 = operand_variable_to_str(inst.src[1], 0);
|
||||
auto src2_value0 = operand_variable_to_str(inst.src[2], 0);
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(dst_value0.type != SpirvType::Float);
|
||||
EXIT_NOT_IMPLEMENTED(src0_value0.type != SpirvType::Float);
|
||||
EXIT_NOT_IMPLEMENTED(src1_value0.type != SpirvType::Uint);
|
||||
EXIT_NOT_IMPLEMENTED(src2_value0.type != SpirvType::Uint);
|
||||
|
||||
// TODO() check VSKIP
|
||||
// TODO() check LOD_CLAMPED
|
||||
|
||||
static const char32_t* text = UR"(
|
||||
%t24_<index> = OpLoad %uint %<src1_value0>
|
||||
%t26_<index> = OpAccessChain %_ptr_UniformConstant_ImageS %textures2D_S %t24_<index>
|
||||
%t27_<index> = OpLoad %ImageS %t26_<index>
|
||||
%t33_<index> = OpLoad %uint %<src2_value0>
|
||||
%t35_<index> = OpAccessChain %_ptr_UniformConstant_Sampler %samplers %t33_<index>
|
||||
%t36_<index> = OpLoad %Sampler %t35_<index>
|
||||
%t38_<index> = OpSampledImage %SampledImage %t27_<index> %t36_<index>
|
||||
%t39_<index> = OpLoad %float %<src0_value0>
|
||||
%t40_<index> = OpLoad %float %<src0_value1>
|
||||
%t42_<index> = OpCompositeConstruct %v2float %t39_<index> %t40_<index>
|
||||
%t43_<index> = OpImageSampleImplicitLod %v4float %t38_<index> %t42_<index>
|
||||
OpStore %temp_v4float %t43_<index>
|
||||
%t46_<index> = OpAccessChain %_ptr_Function_float %temp_v4float %uint_0
|
||||
%t47_<index> = OpLoad %float %t46_<index>
|
||||
OpStore %<dst_value0> %t47_<index>
|
||||
)";
|
||||
*dst_source += String(text)
|
||||
.ReplaceStr(U"<index>", String::FromPrintf("%u", index))
|
||||
.ReplaceStr(U"<src0_value0>", src0_value0.value)
|
||||
.ReplaceStr(U"<src0_value1>", src0_value1.value)
|
||||
.ReplaceStr(U"<src0_value2>", src0_value2.value)
|
||||
.ReplaceStr(U"<src1_value0>", src1_value0.value)
|
||||
.ReplaceStr(U"<src2_value0>", src2_value0.value)
|
||||
.ReplaceStr(U"<dst_value0>", dst_value0.value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
KYTY_RECOMPILER_FUNC(Recompile_ImageSample_Vdata3Vaddr3StSsDmask7)
|
||||
{
|
||||
const auto& inst = code.GetInstructions().At(index);
|
||||
@@ -4855,6 +4910,7 @@ static RecompilerFunc g_recomp_func[] = {
|
||||
{Recompile_Exp_Pos0Vsrc0Vsrc1Vsrc2Vsrc3Done, ShaderInstructionType::Exp, ShaderInstructionFormat::Pos0Vsrc0Vsrc1Vsrc2Vsrc3Done, {U""}},
|
||||
|
||||
{Recompile_ImageLoad_Vdata4Vaddr3StDmaskF, ShaderInstructionType::ImageLoad, ShaderInstructionFormat::Vdata4Vaddr3StDmaskF, {U""}},
|
||||
{Recompile_ImageSample_Vdata1Vaddr3StSsDmask1, ShaderInstructionType::ImageSample, ShaderInstructionFormat::Vdata1Vaddr3StSsDmask1, {U""}},
|
||||
{Recompile_ImageSample_Vdata3Vaddr3StSsDmask7, ShaderInstructionType::ImageSample, ShaderInstructionFormat::Vdata3Vaddr3StSsDmask7, {U""}},
|
||||
{Recompile_ImageSample_Vdata4Vaddr3StSsDmaskF, ShaderInstructionType::ImageSample, ShaderInstructionFormat::Vdata4Vaddr3StSsDmaskF, {U""}},
|
||||
{Recompile_ImageStore_Vdata4Vaddr3StDmaskF, ShaderInstructionType::ImageStore, ShaderInstructionFormat::Vdata4Vaddr3StDmaskF, {U""}},
|
||||
|
||||
@@ -678,6 +678,11 @@ void TileGetTextureSize(uint32_t dfmt, uint32_t nfmt, uint32_t width, uint32_t h
|
||||
{ {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}, } },
|
||||
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
@@ -1434,6 +1434,13 @@ static VkPhysicalDevice VulkanFindPhysicalDevice(VkInstance instance, VkSurfaceK
|
||||
skip_device = true;
|
||||
}
|
||||
|
||||
if (!skip_device &&
|
||||
!CheckFormat(device, VK_FORMAT_R8_UNORM, true, VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT))
|
||||
{
|
||||
printf("Format VK_FORMAT_R8_UNORM cannot be used as texture\n");
|
||||
skip_device = true;
|
||||
}
|
||||
|
||||
if (!skip_device &&
|
||||
!CheckFormat(device, VK_FORMAT_R8G8B8A8_SRGB, true, VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user