diff --git a/src/xenia/gpu/d3d11/d3d11_buffer_resource.cc b/src/xenia/gpu/d3d11/d3d11_buffer_resource.cc index ae7914632..82c8b4717 100644 --- a/src/xenia/gpu/d3d11/d3d11_buffer_resource.cc +++ b/src/xenia/gpu/d3d11/d3d11_buffer_resource.cc @@ -9,6 +9,8 @@ #include +#include + #include #include @@ -131,6 +133,9 @@ int D3D11VertexBufferResource::InvalidateRegion( // TODO(benvanik): rewrite to be faster/special case common/etc uint32_t stride = info_.stride_words; size_t count = (memory_range_.length / 4) / stride; + if (FLAGS_max_draw_elements) { + count = std::min(FLAGS_max_draw_elements, count); + } for (size_t n = 0; n < info_.element_count; n++) { const auto& el = info_.elements[n]; const uint32_t* src_ptr = (const uint32_t*)( diff --git a/src/xenia/gpu/gpu-private.h b/src/xenia/gpu/gpu-private.h index 6bd36d298..cdaf4346d 100644 --- a/src/xenia/gpu/gpu-private.h +++ b/src/xenia/gpu/gpu-private.h @@ -18,5 +18,7 @@ DECLARE_string(gpu); DECLARE_bool(trace_ring_buffer); DECLARE_string(dump_shaders); +DECLARE_uint64(max_draw_elements); + #endif // XENIA_GPU_PRIVATE_H_ diff --git a/src/xenia/gpu/gpu.cc b/src/xenia/gpu/gpu.cc index 11af8022e..8462cc65c 100644 --- a/src/xenia/gpu/gpu.cc +++ b/src/xenia/gpu/gpu.cc @@ -19,6 +19,9 @@ DEFINE_bool(trace_ring_buffer, false, "Trace GPU ring buffer packets."); DEFINE_string(dump_shaders, "", "Path to write GPU shaders to as they are compiled."); +DEFINE_uint64(max_draw_elements, 0, + "Maximum element count; anything over this is ignored."); + #include std::unique_ptr xe::gpu::CreateNop(Emulator* emulator) { return xe::gpu::nop::Create(emulator);