mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 22:06:59 +01:00
graphics: preserve indirect instance state
This commit is contained in:
@@ -83,8 +83,7 @@ public:
|
|||||||
uint32_t first_instance = 0);
|
uint32_t first_instance = 0);
|
||||||
void DrawIndexOffset(uint32_t index_offset, uint32_t index_count, uint32_t flags);
|
void DrawIndexOffset(uint32_t index_offset, uint32_t index_count, uint32_t flags);
|
||||||
void DrawIndexAuto(uint32_t index_count, uint32_t flags,
|
void DrawIndexAuto(uint32_t index_count, uint32_t flags,
|
||||||
uint32_t render_target_slice_offset = 0, uint32_t instance_count = 1,
|
uint32_t render_target_slice_offset = 0);
|
||||||
uint32_t first_vertex = 0, uint32_t first_instance = 0);
|
|
||||||
void DrawIndirect(uint32_t data_offset, uint32_t draw_initiator, bool indexed);
|
void DrawIndirect(uint32_t data_offset, uint32_t draw_initiator, bool indexed);
|
||||||
void DrawIndirectMulti(uint32_t data_offset, uint32_t max_count_or_count,
|
void DrawIndirectMulti(uint32_t data_offset, uint32_t max_count_or_count,
|
||||||
const volatile uint32_t* count_addr, uint32_t stride_in_bytes,
|
const volatile uint32_t* count_addr, uint32_t stride_in_bytes,
|
||||||
@@ -152,6 +151,9 @@ private:
|
|||||||
uint32_t interrupt_context_id);
|
uint32_t interrupt_context_id);
|
||||||
void ProcessPm4(Pm4Execution& execution, size_t stop_depth);
|
void ProcessPm4(Pm4Execution& execution, size_t stop_depth);
|
||||||
void SuspendPm4();
|
void SuspendPm4();
|
||||||
|
void SubmitNonIndexedDraw(uint32_t vertex_count, uint32_t flags,
|
||||||
|
uint32_t render_target_slice_offset, uint32_t first_vertex,
|
||||||
|
uint32_t first_instance);
|
||||||
|
|
||||||
CommandScheduler& GetScheduler() const { return m_renderer.GetCommandScheduler(); }
|
CommandScheduler& GetScheduler() const { return m_renderer.GetCommandScheduler(); }
|
||||||
RenderCommandBuffer& CurrentBuffer() { return GetScheduler().Current(); }
|
RenderCommandBuffer& CurrentBuffer() { return GetScheduler().Current(); }
|
||||||
@@ -168,7 +170,8 @@ private:
|
|||||||
uint64_t m_index_base_addr = 0;
|
uint64_t m_index_base_addr = 0;
|
||||||
uint64_t m_draw_indirect_args_base_addr = 0;
|
uint64_t m_draw_indirect_args_base_addr = 0;
|
||||||
uint64_t m_dispatch_indirect_args_base_addr = 0;
|
uint64_t m_dispatch_indirect_args_base_addr = 0;
|
||||||
uint32_t m_num_instances = 1;
|
// Persistent draw state: indirect draws update it for subsequent draws.
|
||||||
|
uint32_t m_num_instances = 1;
|
||||||
|
|
||||||
uint32_t m_de_count = 0;
|
uint32_t m_de_count = 0;
|
||||||
uint32_t m_ce_count = 0;
|
uint32_t m_ce_count = 0;
|
||||||
|
|||||||
@@ -983,8 +983,9 @@ void CommandProcessor::DrawIndirect(uint32_t data_offset, uint32_t draw_initiato
|
|||||||
args.start_vertex_location, args.start_instance_location);
|
args.start_vertex_location, args.start_instance_location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DrawIndexAuto(args.vertex_count_per_instance, 0, 0, args.instance_count,
|
m_num_instances = args.instance_count;
|
||||||
args.start_vertex_location, args.start_instance_location);
|
SubmitNonIndexedDraw(args.vertex_count_per_instance, 0, 0, args.start_vertex_location,
|
||||||
|
args.start_instance_location);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1024,6 +1025,7 @@ void CommandProcessor::DrawIndirect(uint32_t data_offset, uint32_t draw_initiato
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_num_instances = args.instance_count;
|
||||||
DrawIndex(index_count, index_addr, 0, 1, args.instance_count, nullptr, 0,
|
DrawIndex(index_count, index_addr, 0, 1, args.instance_count, nullptr, 0,
|
||||||
static_cast<int32_t>(args.base_vertex_location), args.start_instance_location);
|
static_cast<int32_t>(args.base_vertex_location), args.start_instance_location);
|
||||||
}
|
}
|
||||||
@@ -1081,8 +1083,9 @@ void CommandProcessor::DrawIndirectMulti(uint32_t data_offset, uint32_t max_coun
|
|||||||
args->start_vertex_location, args->start_instance_location);
|
args->start_vertex_location, args->start_instance_location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DrawIndexAuto(args->vertex_count_per_instance, 0, 0, args->instance_count,
|
m_num_instances = args->instance_count;
|
||||||
args->start_vertex_location, args->start_instance_location);
|
SubmitNonIndexedDraw(args->vertex_count_per_instance, 0, 0, args->start_vertex_location,
|
||||||
|
args->start_instance_location);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1123,6 +1126,7 @@ void CommandProcessor::DrawIndirectMulti(uint32_t data_offset, uint32_t max_coun
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_num_instances = args->instance_count;
|
||||||
DrawIndex(index_count, index_addr, 0, 1, args->instance_count, nullptr, 0,
|
DrawIndex(index_count, index_addr, 0, 1, args->instance_count, nullptr, 0,
|
||||||
static_cast<int32_t>(args->base_vertex_location), args->start_instance_location);
|
static_cast<int32_t>(args->base_vertex_location), args->start_instance_location);
|
||||||
}
|
}
|
||||||
@@ -1214,12 +1218,17 @@ void CommandProcessor::DispatchIndirect(uint32_t data_offset, uint32_t mode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CommandProcessor::DrawIndexAuto(uint32_t index_count, uint32_t flags,
|
void CommandProcessor::DrawIndexAuto(uint32_t index_count, uint32_t flags,
|
||||||
uint32_t render_target_slice_offset, uint32_t instance_count,
|
uint32_t render_target_slice_offset) {
|
||||||
uint32_t first_vertex, uint32_t first_instance) {
|
SubmitNonIndexedDraw(index_count, flags, render_target_slice_offset, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandProcessor::SubmitNonIndexedDraw(uint32_t vertex_count, uint32_t flags,
|
||||||
|
uint32_t render_target_slice_offset,
|
||||||
|
uint32_t first_vertex, uint32_t first_instance) {
|
||||||
CheckBuffer();
|
CheckBuffer();
|
||||||
|
|
||||||
m_renderer.GetRenderExecutor().DrawAuto(m_submit_id, CurrentBuffer(), index_count, flags,
|
m_renderer.GetRenderExecutor().DrawAuto(m_submit_id, CurrentBuffer(), vertex_count, flags,
|
||||||
render_target_slice_offset, instance_count,
|
render_target_slice_offset, m_num_instances,
|
||||||
first_vertex, first_instance);
|
first_vertex, first_instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1159,7 +1159,7 @@ void RenderExecutor::DrawIndex(uint64_t submit_id, RenderCommandBuffer& buffer,
|
|||||||
reinterpret_cast<uint64_t>(index_addr));
|
reinterpret_cast<uint64_t>(index_addr));
|
||||||
|
|
||||||
Common::LockGuard lock(m_context.GetMutex());
|
Common::LockGuard lock(m_context.GetMutex());
|
||||||
if (index_count == 0) {
|
if (index_count == 0 || instance_count == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1229,10 +1229,6 @@ void RenderExecutor::DrawIndex(uint64_t submit_id, RenderCommandBuffer& buffer,
|
|||||||
|
|
||||||
EXIT_NOT_IMPLEMENTED(flags != 0);
|
EXIT_NOT_IMPLEMENTED(flags != 0);
|
||||||
EXIT_NOT_IMPLEMENTED(type != 1);
|
EXIT_NOT_IMPLEMENTED(type != 1);
|
||||||
if (instance_count == 0) {
|
|
||||||
instance_count = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const DrawCallInfo draw {"DrawIndex", CommandBufferDebugOp::DrawIndex,
|
const DrawCallInfo draw {"DrawIndex", CommandBufferDebugOp::DrawIndex,
|
||||||
index_count, flags,
|
index_count, flags,
|
||||||
instance_count, first_instance};
|
instance_count, first_instance};
|
||||||
@@ -1292,7 +1288,7 @@ void RenderExecutor::DrawAuto(uint64_t submit_id, RenderCommandBuffer& buffer, u
|
|||||||
index_count, flags, first_vertex, instance_count, first_instance);
|
index_count, flags, first_vertex, instance_count, first_instance);
|
||||||
|
|
||||||
Common::LockGuard lock(m_context.GetMutex());
|
Common::LockGuard lock(m_context.GetMutex());
|
||||||
if (index_count == 0) {
|
if (index_count == 0 || instance_count == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1330,10 +1326,6 @@ void RenderExecutor::DrawAuto(uint64_t submit_id, RenderCommandBuffer& buffer, u
|
|||||||
hw_check(buffer);
|
hw_check(buffer);
|
||||||
|
|
||||||
EXIT_NOT_IMPLEMENTED(flags != 0);
|
EXIT_NOT_IMPLEMENTED(flags != 0);
|
||||||
if (instance_count == 0) {
|
|
||||||
instance_count = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const DrawCallInfo draw {"DrawIndexAuto", CommandBufferDebugOp::DrawIndexAuto,
|
const DrawCallInfo draw {"DrawIndexAuto", CommandBufferDebugOp::DrawIndexAuto,
|
||||||
index_count, flags,
|
index_count, flags,
|
||||||
instance_count, first_instance};
|
instance_count, first_instance};
|
||||||
|
|||||||
Reference in New Issue
Block a user