From f2e7b29c14e0207e0476299d69dac7ed4c213c74 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Wed, 10 Jul 2019 15:38:31 -0400 Subject: Maxwell3D: Rework the dirty system to be more consistant and scaleable --- src/video_core/engines/maxwell_3d.h | 74 +++++++++++++++++++++++++++++++------ 1 file changed, 63 insertions(+), 11 deletions(-) (limited to 'src/video_core/engines/maxwell_3d.h') diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 8d15c8a48..84e6ca145 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h @@ -1124,23 +1124,73 @@ public: State state{}; - struct DirtyFlags { - std::bitset<8> color_buffer{0xFF}; - std::bitset<32> vertex_array{0xFFFFFFFF}; + struct DirtyRegs { + static constexpr std::size_t NUM_REGS = 256; + union { + struct { + bool null_dirty; + // Vertex Attributes + bool vertex_attrib_format; + // Vertex Arrays + std::array vertex_array; + + bool vertex_array_buffers; + // Vertex Instances + std::array vertex_instance; + + bool vertex_instances; + // Render Targets + std::array render_target; + bool depth_buffer; + + bool render_settings; + // Shaders + bool shaders; + // State + bool viewport; + bool clip_enabled; + bool clip_coefficient; + bool cull_mode; + bool primitive_restart; + bool depth_test; + bool stencil_test; + bool blend_state; + bool logic_op; + bool fragment_color_clamp; + bool multi_sample; + bool scissor_test; + bool transform_feedback; + bool point; + bool color_mask; + bool polygon_offset; + bool alpha_test; + + bool memory_general; + }; + std::array regs; + }; + + void ResetVertexArrays() { + std::fill(vertex_array.begin(), vertex_array.end(), true); + vertex_array_buffers = true; + } - bool vertex_attrib_format = true; - bool zeta_buffer = true; - bool shaders = true; + void ResetRenderTargets() { + depth_buffer = true; + std::fill(render_target.begin(), render_target.end(), true); + render_settings = true; + } void OnMemoryWrite() { - zeta_buffer = true; shaders = true; - color_buffer.set(); - vertex_array.set(); + memory_general = true; + ResetRenderTargets(); + ResetVertexArrays(); } - }; - DirtyFlags dirty_flags; + } dirty{}; + + std::array dirty_pointers{}; /// Reads a register value located at the input method address u32 GetRegisterValue(u32 method) const; @@ -1200,6 +1250,8 @@ private: /// Retrieves information about a specific TSC entry from the TSC buffer. Texture::TSCEntry GetTSCEntry(u32 tsc_index) const; + void InitDirtySettings(); + /** * Call a macro on this engine. * @param method Method to call -- cgit v1.2.3