yuzu-emu
/
yuzu
Archived
1
0
Fork 0

Rasterizer: Refactor and simplify DrawBatch Interface.

This commit is contained in:
Fernando Sahmkow 2019-09-19 11:41:07 -04:00 committed by FernandoS27
parent d2ea592ddb
commit 7761e44d18
4 changed files with 16 additions and 35 deletions

View File

@ -486,7 +486,7 @@ void Maxwell3D::FlushMMEInlineDraw() {
"Illegal combination of instancing parameters"); "Illegal combination of instancing parameters");
const bool is_indexed = mme_draw.current_mode == MMMEDrawMode::Indexed; const bool is_indexed = mme_draw.current_mode == MMMEDrawMode::Indexed;
rasterizer.AccelerateDrawMultiBatch(is_indexed); rasterizer.DrawMultiBatch(is_indexed);
if (debug_context) { if (debug_context) {
debug_context->OnEvent(Tegra::DebugContext::Event::FinishedPrimitiveBatch, nullptr); debug_context->OnEvent(Tegra::DebugContext::Event::FinishedPrimitiveBatch, nullptr);
@ -657,7 +657,7 @@ void Maxwell3D::DrawArrays() {
} }
const bool is_indexed{regs.index_array.count && !regs.vertex_buffer.count}; const bool is_indexed{regs.index_array.count && !regs.vertex_buffer.count};
rasterizer.AccelerateDrawBatch(is_indexed); rasterizer.DrawBatch(is_indexed);
if (debug_context) { if (debug_context) {
debug_context->OnEvent(Tegra::DebugContext::Event::FinishedPrimitiveBatch, nullptr); debug_context->OnEvent(Tegra::DebugContext::Event::FinishedPrimitiveBatch, nullptr);

View File

@ -29,10 +29,10 @@ public:
virtual ~RasterizerInterface() {} virtual ~RasterizerInterface() {}
/// Draw the current batch of vertex arrays /// Draw the current batch of vertex arrays
virtual void DrawArrays() = 0; virtual bool DrawBatch(bool is_indexed) = 0;
/// Draw the current batch of multiple instasnces of vertex arrays /// Draw the current batch of multiple instasnces of vertex arrays
virtual void DrawMultiArrays() = 0; virtual bool DrawMultiBatch(bool is_indexed) = 0;
/// Clear the current framebuffer /// Clear the current framebuffer
virtual void Clear() = 0; virtual void Clear() = 0;
@ -72,14 +72,6 @@ public:
return false; return false;
} }
virtual bool AccelerateDrawBatch(bool is_indexed) {
return false;
}
virtual bool AccelerateDrawMultiBatch(bool is_indexed) {
return false;
}
/// Increase/decrease the number of object in pages touching the specified region /// Increase/decrease the number of object in pages touching the specified region
virtual void UpdatePagesCachedCount(VAddr addr, u64 size, int delta) {} virtual void UpdatePagesCachedCount(VAddr addr, u64 size, int delta) {}

View File

@ -342,18 +342,6 @@ std::size_t RasterizerOpenGL::CalculateIndexBufferSize() const {
static_cast<std::size_t>(regs.index_array.FormatSizeInBytes()); static_cast<std::size_t>(regs.index_array.FormatSizeInBytes());
} }
bool RasterizerOpenGL::AccelerateDrawBatch(bool is_indexed) {
accelerate_draw = is_indexed ? AccelDraw::Indexed : AccelDraw::Arrays;
DrawArrays();
return true;
}
bool RasterizerOpenGL::AccelerateDrawMultiBatch(bool is_indexed) {
accelerate_draw = is_indexed ? AccelDraw::Indexed : AccelDraw::Arrays;
DrawMultiArrays();
return true;
}
template <typename Map, typename Interval> template <typename Map, typename Interval>
static constexpr auto RangeFromInterval(Map& map, const Interval& interval) { static constexpr auto RangeFromInterval(Map& map, const Interval& interval) {
return boost::make_iterator_range(map.equal_range(interval)); return boost::make_iterator_range(map.equal_range(interval));
@ -764,14 +752,15 @@ struct DrawParams {
} }
}; };
void RasterizerOpenGL::DrawArrays() { bool RasterizerOpenGL::DrawBatch(bool is_indexed) {
accelerate_draw = is_indexed ? AccelDraw::Indexed : AccelDraw::Arrays;
DrawPrelude(); DrawPrelude();
auto& maxwell3d = system.GPU().Maxwell3D(); auto& maxwell3d = system.GPU().Maxwell3D();
const auto& regs = maxwell3d.regs; const auto& regs = maxwell3d.regs;
const auto current_instance = maxwell3d.state.current_instance; const auto current_instance = maxwell3d.state.current_instance;
DrawParams draw_call{}; DrawParams draw_call{};
draw_call.is_indexed = accelerate_draw == AccelDraw::Indexed; draw_call.is_indexed = is_indexed;
draw_call.num_instances = static_cast<GLint>(1); draw_call.num_instances = static_cast<GLint>(1);
draw_call.base_instance = static_cast<GLint>(current_instance); draw_call.base_instance = static_cast<GLint>(current_instance);
draw_call.is_instanced = current_instance > 0; draw_call.is_instanced = current_instance > 0;
@ -787,19 +776,20 @@ void RasterizerOpenGL::DrawArrays() {
} }
draw_call.DispatchDraw(); draw_call.DispatchDraw();
accelerate_draw = AccelDraw::Disabled;
maxwell3d.dirty.memory_general = false; maxwell3d.dirty.memory_general = false;
accelerate_draw = AccelDraw::Disabled;
return true;
} }
void RasterizerOpenGL::DrawMultiArrays() { bool RasterizerOpenGL::DrawMultiBatch(bool is_indexed) {
accelerate_draw = is_indexed ? AccelDraw::Indexed : AccelDraw::Arrays;
DrawPrelude(); DrawPrelude();
auto& maxwell3d = system.GPU().Maxwell3D(); auto& maxwell3d = system.GPU().Maxwell3D();
const auto& regs = maxwell3d.regs; const auto& regs = maxwell3d.regs;
const auto& draw_setup = maxwell3d.mme_draw; const auto& draw_setup = maxwell3d.mme_draw;
DrawParams draw_call{}; DrawParams draw_call{};
draw_call.is_indexed = draw_call.is_indexed = is_indexed;
draw_setup.current_mode == Tegra::Engines::Maxwell3D::MMMEDrawMode::Indexed;
draw_call.num_instances = static_cast<GLint>(draw_setup.instance_count); draw_call.num_instances = static_cast<GLint>(draw_setup.instance_count);
draw_call.base_instance = static_cast<GLint>(regs.vb_base_instance); draw_call.base_instance = static_cast<GLint>(regs.vb_base_instance);
draw_call.is_instanced = draw_setup.instance_count > 1; draw_call.is_instanced = draw_setup.instance_count > 1;
@ -815,8 +805,9 @@ void RasterizerOpenGL::DrawMultiArrays() {
} }
draw_call.DispatchDraw(); draw_call.DispatchDraw();
accelerate_draw = AccelDraw::Disabled;
maxwell3d.dirty.memory_general = false; maxwell3d.dirty.memory_general = false;
accelerate_draw = AccelDraw::Disabled;
return true;
} }
void RasterizerOpenGL::DispatchCompute(GPUVAddr code_addr) { void RasterizerOpenGL::DispatchCompute(GPUVAddr code_addr) {

View File

@ -57,8 +57,8 @@ public:
ScreenInfo& info); ScreenInfo& info);
~RasterizerOpenGL() override; ~RasterizerOpenGL() override;
void DrawArrays() override; bool DrawBatch(bool is_indexed) override;
void DrawMultiArrays() override; bool DrawMultiBatch(bool is_indexed) override;
void Clear() override; void Clear() override;
void DispatchCompute(GPUVAddr code_addr) override; void DispatchCompute(GPUVAddr code_addr) override;
void FlushAll() override; void FlushAll() override;
@ -72,8 +72,6 @@ public:
const Tegra::Engines::Fermi2D::Config& copy_config) override; const Tegra::Engines::Fermi2D::Config& copy_config) override;
bool AccelerateDisplay(const Tegra::FramebufferConfig& config, VAddr framebuffer_addr, bool AccelerateDisplay(const Tegra::FramebufferConfig& config, VAddr framebuffer_addr,
u32 pixel_stride) override; u32 pixel_stride) override;
bool AccelerateDrawBatch(bool is_indexed) override;
bool AccelerateDrawMultiBatch(bool is_indexed) override;
void UpdatePagesCachedCount(VAddr addr, u64 size, int delta) override; void UpdatePagesCachedCount(VAddr addr, u64 size, int delta) override;
void LoadDiskResources(const std::atomic_bool& stop_loading, void LoadDiskResources(const std::atomic_bool& stop_loading,
const VideoCore::DiskResourceLoadCallback& callback) override; const VideoCore::DiskResourceLoadCallback& callback) override;