mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:47:35 +00:00
LibGL+Lib*GPU: Set model view and projection matrices separately
LibSoftGPU used to calculate the normal transformation based on the model view transformation for every primitive, because that's when we sent over the matrix. By making LibGL a bit smarter and only update the matrices when they could have changed, we only need to calculate the normal transformation once on every matrix update. When viewing `Tuba.obj` in 3DFileViewer, this brings the percentage of time spent in `FloatMatrix4x4::inverse()` down from 15% to 0%. :^)
This commit is contained in:
parent
126adfc392
commit
edcb6176ce
8 changed files with 75 additions and 24 deletions
|
@ -26,6 +26,7 @@
|
|||
#include <LibGPU/TextureUnitConfiguration.h>
|
||||
#include <LibGPU/Vertex.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/Matrix3x3.h>
|
||||
#include <LibGfx/Matrix4x4.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
#include <LibGfx/Vector4.h>
|
||||
|
@ -48,7 +49,7 @@ public:
|
|||
|
||||
virtual GPU::DeviceInfo info() const override;
|
||||
|
||||
virtual void draw_primitives(GPU::PrimitiveType, FloatMatrix4x4 const& model_view_transform, FloatMatrix4x4 const& projection_transform, Vector<GPU::Vertex>& vertices) override;
|
||||
virtual void draw_primitives(GPU::PrimitiveType, Vector<GPU::Vertex>& vertices) override;
|
||||
virtual void resize(Gfx::IntSize min_size) override;
|
||||
virtual void clear_color(FloatVector4 const&) override;
|
||||
virtual void clear_depth(GPU::DepthType) override;
|
||||
|
@ -68,6 +69,8 @@ public:
|
|||
virtual NonnullRefPtr<GPU::Image> create_image(GPU::PixelFormat const&, u32 width, u32 height, u32 depth, u32 max_levels) override;
|
||||
virtual ErrorOr<NonnullRefPtr<GPU::Shader>> create_shader(GPU::IR::Shader const&) override;
|
||||
|
||||
virtual void set_model_view_transform(FloatMatrix4x4 const&) override;
|
||||
virtual void set_projection_transform(FloatMatrix4x4 const&) override;
|
||||
virtual void set_sampler_config(unsigned, GPU::SamplerConfig const&) override;
|
||||
virtual void set_light_state(unsigned, GPU::Light const&) override;
|
||||
virtual void set_material_state(GPU::Face, GPU::Material const&) override;
|
||||
|
@ -77,7 +80,7 @@ public:
|
|||
|
||||
virtual GPU::RasterPosition raster_position() const override { return m_raster_position; }
|
||||
virtual void set_raster_position(GPU::RasterPosition const& raster_position) override;
|
||||
virtual void set_raster_position(FloatVector4 const& position, FloatMatrix4x4 const& model_view_transform, FloatMatrix4x4 const& projection_transform) override;
|
||||
virtual void set_raster_position(FloatVector4 const& position) override;
|
||||
|
||||
virtual void bind_fragment_shader(RefPtr<GPU::Shader>) override;
|
||||
|
||||
|
@ -105,6 +108,9 @@ private:
|
|||
|
||||
RefPtr<FrameBuffer<GPU::ColorType, GPU::DepthType, GPU::StencilType>> m_frame_buffer {};
|
||||
GPU::RasterizerOptions m_options;
|
||||
FloatMatrix4x4 m_model_view_transform;
|
||||
FloatMatrix3x3 m_normal_transform;
|
||||
FloatMatrix4x4 m_projection_transform;
|
||||
GPU::LightModelParameters m_lighting_model;
|
||||
Clipper m_clipper;
|
||||
Vector<Triangle> m_triangle_list;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue