2018-04-07 11:12:38 +02:00
|
|
|
// Copyright 2018 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-04-11 00:26:27 +02:00
|
|
|
#include <cstddef>
|
|
|
|
|
2018-04-07 11:12:38 +02:00
|
|
|
#include <glad/glad.h>
|
2018-08-23 23:30:27 +02:00
|
|
|
|
2018-04-07 11:12:38 +02:00
|
|
|
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
|
|
|
#include "video_core/renderer_opengl/maxwell_to_gl.h"
|
|
|
|
|
2020-05-18 03:32:49 +02:00
|
|
|
namespace OpenGL {
|
|
|
|
|
|
|
|
class Device;
|
2018-04-07 11:12:38 +02:00
|
|
|
|
|
|
|
/// Uniform structure for the Uniform Buffer Object, all vectors must be 16-byte aligned
|
2019-03-27 18:10:40 +01:00
|
|
|
/// @note Always keep a vec4 at the end. The GL spec is not clear whether the alignment at
|
|
|
|
/// the end of a uniform block is included in UNIFORM_BLOCK_DATA_SIZE or not.
|
|
|
|
/// Not following that rule will cause problems on some AMD drivers.
|
2019-10-30 04:23:09 +01:00
|
|
|
struct alignas(16) MaxwellUniformData {
|
|
|
|
void SetFromRegs(const Tegra::Engines::Maxwell3D& maxwell);
|
|
|
|
|
|
|
|
GLfloat y_direction;
|
2018-04-07 11:12:38 +02:00
|
|
|
};
|
2019-10-30 04:23:09 +01:00
|
|
|
static_assert(sizeof(MaxwellUniformData) == 16, "MaxwellUniformData structure size is incorrect");
|
2018-04-07 11:12:38 +02:00
|
|
|
static_assert(sizeof(MaxwellUniformData) < 16384,
|
|
|
|
"MaxwellUniformData structure must be less than 16kb as per the OpenGL spec");
|
|
|
|
|
|
|
|
class ProgramManager {
|
|
|
|
public:
|
2020-05-18 03:32:49 +02:00
|
|
|
explicit ProgramManager(const Device& device);
|
2019-04-11 00:26:27 +02:00
|
|
|
~ProgramManager();
|
|
|
|
|
2020-05-18 03:32:49 +02:00
|
|
|
/// Binds a compute program
|
|
|
|
void BindCompute(GLuint program);
|
2018-04-07 11:12:38 +02:00
|
|
|
|
2020-05-18 03:32:49 +02:00
|
|
|
/// Updates bound programs.
|
2020-03-11 05:03:01 +01:00
|
|
|
void BindGraphicsPipeline();
|
|
|
|
|
2020-05-18 03:32:49 +02:00
|
|
|
/// Binds an OpenGL pipeline object unsynchronized with the guest state.
|
|
|
|
void BindHostPipeline(GLuint pipeline);
|
|
|
|
|
|
|
|
/// Rewinds BindHostPipeline state changes.
|
|
|
|
void RestoreGuestPipeline();
|
2019-12-26 20:04:41 +01:00
|
|
|
|
2020-06-25 22:12:33 +02:00
|
|
|
void UseVertexShader(GLuint program);
|
|
|
|
void UseGeometryShader(GLuint program);
|
|
|
|
void UseFragmentShader(GLuint program);
|
2018-04-15 21:14:57 +02:00
|
|
|
|
2018-11-29 07:24:21 +01:00
|
|
|
private:
|
2019-04-11 00:26:27 +02:00
|
|
|
struct PipelineState {
|
2020-05-18 03:32:49 +02:00
|
|
|
GLuint vertex = 0;
|
|
|
|
GLuint geometry = 0;
|
|
|
|
GLuint fragment = 0;
|
2019-04-11 00:26:27 +02:00
|
|
|
};
|
|
|
|
|
2020-05-18 03:32:49 +02:00
|
|
|
/// Update GLSL programs.
|
|
|
|
void UpdateSourcePrograms();
|
|
|
|
|
2020-03-11 05:03:01 +01:00
|
|
|
OGLPipeline graphics_pipeline;
|
2020-05-18 03:32:49 +02:00
|
|
|
|
2019-04-11 00:26:27 +02:00
|
|
|
PipelineState current_state;
|
|
|
|
PipelineState old_state;
|
2020-05-18 03:32:49 +02:00
|
|
|
|
|
|
|
bool use_assembly_programs = false;
|
|
|
|
|
2020-03-11 05:03:01 +01:00
|
|
|
bool is_graphics_bound = true;
|
2020-05-18 03:32:49 +02:00
|
|
|
|
|
|
|
bool vertex_enabled = false;
|
|
|
|
bool geometry_enabled = false;
|
|
|
|
bool fragment_enabled = false;
|
2018-04-07 11:12:38 +02:00
|
|
|
};
|
|
|
|
|
2020-05-18 03:32:49 +02:00
|
|
|
} // namespace OpenGL
|