Duckstation/src/pse/gpu_hw_opengl.h

60 lines
1.6 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-17 14:22:41 +00:00
bool Initialize(System* system, DMA* dma, InterruptController* interrupt_controller) override;
2019-09-12 02:53:04 +00:00
void Reset() override;
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;
void UpdateTexturePageTexture() override;
2019-09-12 15:10:08 +00:00
void FlushRender() override;
2019-09-12 02:53:04 +00:00
private:
std::tuple<s32, s32> ConvertToFramebufferCoordinates(s32 x, s32 y);
2019-09-12 02:53:04 +00:00
void CreateFramebuffer();
void ClearFramebuffer();
void DestroyFramebuffer();
void CreateVertexBuffer();
2019-09-12 14:18:13 +00:00
bool CompilePrograms();
bool CompileProgram(GL::Program& prog, bool textured, bool blending);
2019-09-12 14:18:13 +00:00
void SetProgram(bool textured, bool blending);
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_texture_page_texture;
GLuint m_texture_page_fbo_id = 0;
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
2019-09-12 14:18:13 +00:00
GL::Program m_texture_program;
GL::Program m_color_program;
GL::Program m_blended_texture_program;
std::array<GL::Program, 3> m_texture_page_programs;
2019-09-12 02:53:04 +00:00
};