Fast-pathing MDI's that have only one draw.

This commit is contained in:
Ben Vanik 2015-01-04 14:23:28 -08:00
parent 4fcf9c6229
commit 55c4488ab2
2 changed files with 27 additions and 8 deletions

View File

@ -335,6 +335,24 @@ bool DrawBatcher::Flush(FlushMode mode) {
batch_state_.command_stride, vertex_buffer_count); batch_state_.command_stride, vertex_buffer_count);
} }
} else { } else {
if (batch_state_.draw_count == 1) {
// Fast path for one draw. Removes MDI overhead when not required.
if (batch_state_.indexed) {
auto& cmd = active_draw_.draw_elements_cmd;
glDrawElementsInstancedBaseVertexBaseInstance(
prim_type, cmd->count, batch_state_.index_type,
reinterpret_cast<void*>(
uintptr_t(cmd->first_index) *
(batch_state_.index_type == GL_UNSIGNED_SHORT ? 2 : 4)),
cmd->instance_count, cmd->base_vertex, cmd->base_instance);
} else {
auto& cmd = active_draw_.draw_arrays_cmd;
glDrawArraysInstancedBaseInstance(prim_type, cmd->first_index,
cmd->count, cmd->instance_count,
cmd->base_instance);
}
} else {
// Full multi-draw.
if (batch_state_.indexed) { if (batch_state_.indexed) {
glMultiDrawElementsIndirect(prim_type, batch_state_.index_type, glMultiDrawElementsIndirect(prim_type, batch_state_.index_type,
indirect_offset, batch_state_.draw_count, indirect_offset, batch_state_.draw_count,
@ -345,6 +363,7 @@ bool DrawBatcher::Flush(FlushMode mode) {
batch_state_.command_stride); batch_state_.command_stride);
} }
} }
}
batch_state_.command_range_start = UINTPTR_MAX; batch_state_.command_range_start = UINTPTR_MAX;
batch_state_.command_range_length = 0; batch_state_.command_range_length = 0;

View File

@ -287,7 +287,7 @@ SHIM_CALL KeDelayExecutionThread_shim(PPCContext* ppc_state,
} }
SHIM_CALL NtYieldExecution_shim(PPCContext* ppc_state, KernelState* state) { SHIM_CALL NtYieldExecution_shim(PPCContext* ppc_state, KernelState* state) {
XELOGD("NtYieldExecution()"); //XELOGD("NtYieldExecution()");
XThread* thread = XThread::GetCurrentThread(); XThread* thread = XThread::GetCurrentThread();
X_STATUS result = thread->Delay(0, 0, 0); X_STATUS result = thread->Delay(0, 0, 0);
SHIM_SET_RETURN_64(0); SHIM_SET_RETURN_64(0);