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>
|
2019-09-13 16:07:31 +00:00
|
|
|
#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:
|
2019-09-13 16:07:31 +00:00
|
|
|
void UpdateDisplay() override;
|
2019-09-14 10:45:26 +00:00
|
|
|
void ReadVRAM(u32 x, u32 y, u32 width, u32 height, void* buffer) override;
|
2019-09-14 06:43:39 +00:00
|
|
|
void FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 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-13 16:07:31 +00:00
|
|
|
void UpdateTexturePageTexture() override;
|
2019-09-12 15:10:08 +00:00
|
|
|
void FlushRender() override;
|
2019-09-12 02:53:04 +00:00
|
|
|
|
|
|
|
private:
|
2019-09-13 16:07:31 +00:00
|
|
|
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();
|
2019-09-13 16:07:31 +00:00
|
|
|
bool CompileProgram(GL::Program& prog, bool textured, bool blending);
|
2019-09-12 14:18:13 +00:00
|
|
|
|
2019-09-13 16:07:31 +00:00
|
|
|
void SetProgram(bool textured, bool blending);
|
2019-09-12 14:18:13 +00:00
|
|
|
void SetViewport();
|
|
|
|
void SetScissor();
|
|
|
|
|
|
|
|
std::unique_ptr<GL::Texture> m_framebuffer_texture;
|
2019-09-12 02:53:04 +00:00
|
|
|
GLuint m_framebuffer_fbo_id = 0;
|
|
|
|
|
2019-09-13 16:07:31 +00:00
|
|
|
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;
|
2019-09-13 16:07:31 +00:00
|
|
|
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;
|
2019-09-13 16:07:31 +00:00
|
|
|
GL::Program m_blended_texture_program;
|
|
|
|
std::array<GL::Program, 3> m_texture_page_programs;
|
2019-09-12 02:53:04 +00:00
|
|
|
};
|