mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-30 18:44:15 +01:00
gl_resource_manager: Grab latest upstream.
This commit is contained in:
parent
ed7e597b44
commit
dbfd106ba0
@ -13,14 +13,16 @@
|
|||||||
class OGLTexture : private NonCopyable {
|
class OGLTexture : private NonCopyable {
|
||||||
public:
|
public:
|
||||||
OGLTexture() = default;
|
OGLTexture() = default;
|
||||||
OGLTexture(OGLTexture&& o) {
|
|
||||||
std::swap(handle, o.handle);
|
OGLTexture(OGLTexture&& o) : handle(std::exchange(o.handle, 0)) {}
|
||||||
}
|
|
||||||
~OGLTexture() {
|
~OGLTexture() {
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
OGLTexture& operator=(OGLTexture&& o) {
|
OGLTexture& operator=(OGLTexture&& o) {
|
||||||
std::swap(handle, o.handle);
|
Release();
|
||||||
|
handle = std::exchange(o.handle, 0);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,14 +48,16 @@ public:
|
|||||||
class OGLSampler : private NonCopyable {
|
class OGLSampler : private NonCopyable {
|
||||||
public:
|
public:
|
||||||
OGLSampler() = default;
|
OGLSampler() = default;
|
||||||
OGLSampler(OGLSampler&& o) {
|
|
||||||
std::swap(handle, o.handle);
|
OGLSampler(OGLSampler&& o) : handle(std::exchange(o.handle, 0)) {}
|
||||||
}
|
|
||||||
~OGLSampler() {
|
~OGLSampler() {
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
OGLSampler& operator=(OGLSampler&& o) {
|
OGLSampler& operator=(OGLSampler&& o) {
|
||||||
std::swap(handle, o.handle);
|
Release();
|
||||||
|
handle = std::exchange(o.handle, 0);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,25 +83,71 @@ public:
|
|||||||
class OGLShader : private NonCopyable {
|
class OGLShader : private NonCopyable {
|
||||||
public:
|
public:
|
||||||
OGLShader() = default;
|
OGLShader() = default;
|
||||||
OGLShader(OGLShader&& o) {
|
|
||||||
std::swap(handle, o.handle);
|
OGLShader(OGLShader&& o) : handle(std::exchange(o.handle, 0)) {}
|
||||||
}
|
|
||||||
~OGLShader() {
|
~OGLShader() {
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
OGLShader& operator=(OGLShader&& o) {
|
OGLShader& operator=(OGLShader&& o) {
|
||||||
std::swap(handle, o.handle);
|
Release();
|
||||||
|
handle = std::exchange(o.handle, 0);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new internal OpenGL resource and stores the handle
|
void Create(const char* source, GLenum type) {
|
||||||
void Create(const char* vert_shader, const char* geo_shader, const char* frag_shader,
|
|
||||||
const std::vector<const char*>& feedback_vars = {},
|
|
||||||
bool separable_program = false) {
|
|
||||||
if (handle != 0)
|
if (handle != 0)
|
||||||
return;
|
return;
|
||||||
handle = GLShader::LoadProgram(vert_shader, geo_shader, frag_shader, feedback_vars,
|
if (source == nullptr)
|
||||||
separable_program);
|
return;
|
||||||
|
handle = GLShader::LoadShader(source, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Release() {
|
||||||
|
if (handle == 0)
|
||||||
|
return;
|
||||||
|
glDeleteShader(handle);
|
||||||
|
handle = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLuint handle = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class OGLProgram : private NonCopyable {
|
||||||
|
public:
|
||||||
|
OGLProgram() = default;
|
||||||
|
|
||||||
|
OGLProgram(OGLProgram&& o) : handle(std::exchange(o.handle, 0)) {}
|
||||||
|
|
||||||
|
~OGLProgram() {
|
||||||
|
Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
OGLProgram& operator=(OGLProgram&& o) {
|
||||||
|
Release();
|
||||||
|
handle = std::exchange(o.handle, 0);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename... T>
|
||||||
|
void Create(bool separable_program = false, T... shaders) {
|
||||||
|
if (handle != 0)
|
||||||
|
return;
|
||||||
|
handle = GLShader::LoadProgram(separable_program, shaders...);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a new internal OpenGL resource and stores the handle
|
||||||
|
void CreateFromSource(const char* vert_shader, const char* geo_shader, const char* frag_shader,
|
||||||
|
bool separable_program = false) {
|
||||||
|
OGLShader vert, geo, frag;
|
||||||
|
if (vert_shader)
|
||||||
|
vert.Create(vert_shader, GL_VERTEX_SHADER);
|
||||||
|
if (geo_shader)
|
||||||
|
geo.Create(geo_shader, GL_GEOMETRY_SHADER);
|
||||||
|
if (frag_shader)
|
||||||
|
frag.Create(frag_shader, GL_FRAGMENT_SHADER);
|
||||||
|
Create(separable_program, vert.handle, geo.handle, frag.handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deletes the internal OpenGL resource
|
/// Deletes the internal OpenGL resource
|
||||||
@ -148,14 +198,16 @@ public:
|
|||||||
class OGLBuffer : private NonCopyable {
|
class OGLBuffer : private NonCopyable {
|
||||||
public:
|
public:
|
||||||
OGLBuffer() = default;
|
OGLBuffer() = default;
|
||||||
OGLBuffer(OGLBuffer&& o) {
|
|
||||||
std::swap(handle, o.handle);
|
OGLBuffer(OGLBuffer&& o) : handle(std::exchange(o.handle, 0)) {}
|
||||||
}
|
|
||||||
~OGLBuffer() {
|
~OGLBuffer() {
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
OGLBuffer& operator=(OGLBuffer&& o) {
|
OGLBuffer& operator=(OGLBuffer&& o) {
|
||||||
std::swap(handle, o.handle);
|
Release();
|
||||||
|
handle = std::exchange(o.handle, 0);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,14 +266,16 @@ public:
|
|||||||
class OGLVertexArray : private NonCopyable {
|
class OGLVertexArray : private NonCopyable {
|
||||||
public:
|
public:
|
||||||
OGLVertexArray() = default;
|
OGLVertexArray() = default;
|
||||||
OGLVertexArray(OGLVertexArray&& o) {
|
|
||||||
std::swap(handle, o.handle);
|
OGLVertexArray(OGLVertexArray&& o) : handle(std::exchange(o.handle, 0)) {}
|
||||||
}
|
|
||||||
~OGLVertexArray() {
|
~OGLVertexArray() {
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
OGLVertexArray& operator=(OGLVertexArray&& o) {
|
OGLVertexArray& operator=(OGLVertexArray&& o) {
|
||||||
std::swap(handle, o.handle);
|
Release();
|
||||||
|
handle = std::exchange(o.handle, 0);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,14 +301,16 @@ public:
|
|||||||
class OGLFramebuffer : private NonCopyable {
|
class OGLFramebuffer : private NonCopyable {
|
||||||
public:
|
public:
|
||||||
OGLFramebuffer() = default;
|
OGLFramebuffer() = default;
|
||||||
OGLFramebuffer(OGLFramebuffer&& o) {
|
|
||||||
std::swap(handle, o.handle);
|
OGLFramebuffer(OGLFramebuffer&& o) : handle(std::exchange(o.handle, 0)) {}
|
||||||
}
|
|
||||||
~OGLFramebuffer() {
|
~OGLFramebuffer() {
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
OGLFramebuffer& operator=(OGLFramebuffer&& o) {
|
OGLFramebuffer& operator=(OGLFramebuffer&& o) {
|
||||||
std::swap(handle, o.handle);
|
Release();
|
||||||
|
handle = std::exchange(o.handle, 0);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user