Duckstation/src/pse/gpu_hw_opengl.h

71 lines
1.9 KiB
C
Raw Normal View History

2019-09-12 02:53:04 +00:00
#pragma once
2019-09-12 14:18:13 +00:00
#include "common/gl_program.h"
#include "common/gl_texture.h"
2019-09-12 02:53:04 +00:00
#include "glad.h"
2019-09-12 14:18:13 +00:00
#include "gpu_hw.h"
2019-09-12 02:53:04 +00:00
#include <array>
2019-09-12 14:18:13 +00:00
#include <memory>
#include <tuple>
2019-09-12 02:53:04 +00:00
class GPU_HW_OpenGL : public GPU_HW
{
public:
GPU_HW_OpenGL();
~GPU_HW_OpenGL() override;
2019-09-20 13:40:19 +00:00
bool Initialize(System* system, DMA* dma, InterruptController* interrupt_controller, Timers* timers) override;
2019-09-12 02:53:04 +00:00
void Reset() override;
2019-09-26 04:03:32 +00:00
void RenderUI() override;
2019-09-12 02:53:04 +00:00
protected:
void UpdateDisplay() override;
2019-09-14 10:45:26 +00:00
void ReadVRAM(u32 x, u32 y, u32 width, u32 height, void* buffer) override;
void FillVRAM(u32 x, u32 y, u32 width, u32 height, u16 color) override;
2019-09-12 15:10:08 +00:00
void UpdateVRAM(u32 x, u32 y, u32 width, u32 height, const void* data) override;
2019-09-17 14:58:30 +00:00
void CopyVRAM(u32 src_x, u32 src_y, u32 dst_x, u32 dst_y, u32 width, u32 height) override;
2019-09-12 15:10:08 +00:00
void FlushRender() override;
void InvalidateVRAMReadCache() override;
2019-09-12 02:53:04 +00:00
private:
2019-09-26 04:03:32 +00:00
struct GLStats
{
u32 num_vram_read_texture_updates;
2019-09-26 04:03:32 +00:00
u32 num_batches;
u32 num_vertices;
};
std::tuple<s32, s32> ConvertToFramebufferCoordinates(s32 x, s32 y);
2019-09-12 02:53:04 +00:00
void CreateFramebuffer();
void ClearFramebuffer();
void DestroyFramebuffer();
void UpdateVRAMReadTexture();
2019-09-12 02:53:04 +00:00
void CreateVertexBuffer();
2019-09-12 14:18:13 +00:00
bool CompilePrograms();
bool CompileProgram(GL::Program& prog, bool textured, bool blending, bool transparent, TextureColorMode texture_color_mode);
2019-09-12 14:18:13 +00:00
void SetProgram();
2019-09-12 14:18:13 +00:00
void SetViewport();
void SetScissor();
2019-09-18 14:55:06 +00:00
void SetBlendState();
2019-09-12 14:18:13 +00:00
std::unique_ptr<GL::Texture> m_framebuffer_texture;
2019-09-12 02:53:04 +00:00
GLuint m_framebuffer_fbo_id = 0;
std::unique_ptr<GL::Texture> m_vram_read_texture;
GLuint m_vram_read_fbo_id = 0;
bool m_vram_read_texture_dirty = true;
2019-09-12 02:53:04 +00:00
GLuint m_vertex_buffer = 0;
GLuint m_vao_id = 0;
GLuint m_attributeless_vao_id = 0;
2019-09-12 02:53:04 +00:00
std::array<std::array<std::array<std::array<GL::Program, 3>, 2>, 2>, 2> m_render_programs;
std::array<GL::Program, 3> m_texture_page_programs;
2019-09-26 04:03:32 +00:00
GLStats m_stats = {};
GLStats m_last_stats = {};
2019-09-12 02:53:04 +00:00
};