mirror of
https://github.com/libretro/pcsx2.git
synced 2024-11-24 17:59:47 +00:00
gsdx ogl:
* some preliminary work to test/benchmark bindless texture in the future (glsl was not yet updated) Bindless texture allow to get a GPU texture pointer and then set it directly to the shader as a basic uniform. => no more texture unit selection/validation => no more texture validation neither texture hash lookup 3rdparty: update gl header to the latest gl4.4 git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5720 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
e66f515605
commit
07605941ef
19363
3rdparty/GL/glext.h
vendored
19363
3rdparty/GL/glext.h
vendored
File diff suppressed because it is too large
Load Diff
@ -108,7 +108,12 @@ PFNGLTEXSTORAGE2DPROC gl_TexStorage2D = NULL;
|
||||
PFNGLCLEARTEXIMAGEPROC gl_ClearTexImage = NULL;
|
||||
PFNGLBINDTEXTURESPROC gl_BindTextures = NULL;
|
||||
PFNGLBUFFERSTORAGEPROC gl_BufferStorage = NULL;
|
||||
|
||||
// GL_ARB_bindless_texture (GL5?)
|
||||
PFNGLGETTEXTURESAMPLERHANDLEARBPROC gl_GetTextureSamplerHandleARB = NULL;
|
||||
PFNGLMAKETEXTUREHANDLERESIDENTARBPROC gl_MakeTextureHandleResidentARB = NULL;
|
||||
PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC gl_MakeTextureHandleNonResidentARB = NULL;
|
||||
PFNGLUNIFORMHANDLEUI64VARBPROC gl_UniformHandleui64vARB = NULL;
|
||||
PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC gl_ProgramUniformHandleui64vARB = NULL;
|
||||
#endif
|
||||
|
||||
namespace GLLoader {
|
||||
@ -121,16 +126,17 @@ namespace GLLoader {
|
||||
bool found_GL_ARB_separate_shader_objects = false;
|
||||
bool found_geometry_shader = true;
|
||||
bool found_only_gl30 = false; // Drop it when mesa support GLSL330
|
||||
bool found_GL_ARB_clear_texture = false; // Don't know if GL3 hardawe can support it
|
||||
bool found_GL_ARB_clear_texture = false; // Don't know if GL3 GPU can support it
|
||||
bool found_GL_ARB_buffer_storage = false;
|
||||
// GL4 hardware
|
||||
bool found_GL_ARB_copy_image = false; // Not sure actually
|
||||
bool found_GL_ARB_copy_image = false; // Not sure actually maybe GL3 GPU can do it
|
||||
bool found_GL_ARB_gpu_shader5 = false;
|
||||
bool found_GL_ARB_shader_image_load_store = false;
|
||||
bool found_GL_ARB_shader_subroutine = false;
|
||||
bool found_GL_ARB_bindless_texture = false; // GL5 GPU?
|
||||
|
||||
// Mandatory for FULL GL (but optional for GLES)
|
||||
bool found_GL_ARB_multi_bind = false; // Not yet. Wait Mesa & AMD drivers
|
||||
bool found_GL_ARB_multi_bind = false; // Not yet. Wait Mesa & AMD drivers. Note might be deprecated by bindless_texture
|
||||
bool found_GL_ARB_shading_language_420pack = false; // Not yet. Wait Mesa & AMD drivers
|
||||
|
||||
// Mandatory
|
||||
@ -240,6 +246,9 @@ namespace GLLoader {
|
||||
if (ext.compare("GL_ARB_multi_bind") == 0) found_GL_ARB_multi_bind = true;
|
||||
if (ext.compare("GL_ARB_buffer_storage") == 0) found_GL_ARB_buffer_storage = true;
|
||||
#endif
|
||||
#ifdef GLBINDLESS // Need to debug the code first
|
||||
if (ext.compare("GL_ARB_bindless_texture") == 0) found_GL_ARB_bindless_texture = true;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_GLES
|
||||
fprintf(stderr, "DEBUG ext: %s\n", ext.c_str());
|
||||
@ -261,6 +270,7 @@ namespace GLLoader {
|
||||
status &= status_and_override(found_GL_ARB_texture_storage, "GL_ARB_texture_storage", true);
|
||||
status &= status_and_override(found_GL_ARB_shading_language_420pack,"GL_ARB_shading_language_420pack");
|
||||
status &= status_and_override(found_GL_ARB_multi_bind,"GL_ARB_multi_bind");
|
||||
status &= status_and_override(found_GL_ARB_bindless_texture,"GL_ARB_bindless_texture");
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
#endif
|
||||
|
@ -60,19 +60,30 @@ typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, con
|
||||
typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers);
|
||||
typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures);
|
||||
typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides);
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glBufferStorage (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags);
|
||||
GLAPI void APIENTRY glClearTexImage (GLuint texture, GLint level, GLenum format, GLenum type, const void *data);
|
||||
GLAPI void APIENTRY glClearTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data);
|
||||
GLAPI void APIENTRY glBindBuffersBase (GLenum target, GLuint first, GLsizei count, const GLuint *buffers);
|
||||
GLAPI void APIENTRY glBindBuffersRange (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes);
|
||||
GLAPI void APIENTRY glBindTextures (GLuint first, GLsizei count, const GLuint *textures);
|
||||
GLAPI void APIENTRY glBindSamplers (GLuint first, GLsizei count, const GLuint *samplers);
|
||||
GLAPI void APIENTRY glBindImageTextures (GLuint first, GLsizei count, const GLuint *textures);
|
||||
GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides);
|
||||
#endif
|
||||
#endif /* GL_VERSION_4_4 */
|
||||
|
||||
#ifndef GL_ARB_bindless_texture
|
||||
#define GL_ARB_bindless_texture 1
|
||||
typedef uint64_t GLuint64EXT;
|
||||
#define GL_UNSIGNED_INT64_ARB 0x140F
|
||||
typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture);
|
||||
typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler);
|
||||
typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle);
|
||||
typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle);
|
||||
typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format);
|
||||
typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access);
|
||||
typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle);
|
||||
typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value);
|
||||
typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value);
|
||||
typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value);
|
||||
typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values);
|
||||
typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle);
|
||||
typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT *v);
|
||||
typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT *params);
|
||||
#endif /* GL_ARB_bindless_texture */
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -161,6 +172,12 @@ extern PFNGLCOPYIMAGESUBDATAPROC gl_CopyImageSubData;
|
||||
extern PFNGLCLEARTEXIMAGEPROC gl_ClearTexImage;
|
||||
extern PFNGLBINDTEXTURESPROC gl_BindTextures;
|
||||
extern PFNGLBUFFERSTORAGEPROC gl_BufferStorage;
|
||||
// GL_ARB_bindless_texture (GL5?)
|
||||
extern PFNGLGETTEXTURESAMPLERHANDLEARBPROC gl_GetTextureSamplerHandleARB;
|
||||
extern PFNGLMAKETEXTUREHANDLERESIDENTARBPROC gl_MakeTextureHandleResidentARB;
|
||||
extern PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC gl_MakeTextureHandleNonResidentARB;
|
||||
extern PFNGLUNIFORMHANDLEUI64VARBPROC gl_UniformHandleui64vARB;
|
||||
extern PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC gl_ProgramUniformHandleui64vARB;
|
||||
|
||||
#else
|
||||
#define gl_ActiveTexture glActiveTexture
|
||||
@ -257,4 +274,5 @@ namespace GLLoader {
|
||||
extern bool found_GL_ARB_multi_bind;
|
||||
extern bool found_GL_ARB_buffer_storage;
|
||||
extern bool found_GL_ARB_shader_subroutine;
|
||||
extern bool found_GL_ARB_bindless_texture;
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ namespace GLState {
|
||||
GLuint ds = 0;
|
||||
GLuint tex_unit[2] = {0, 0};
|
||||
GLuint tex = 0;
|
||||
GLuint64 tex_handle[2] = { 0, 0};
|
||||
bool dirty_ressources = false;
|
||||
|
||||
GLuint ps = 0;
|
||||
GLuint gs = 0;
|
||||
@ -109,6 +111,8 @@ namespace GLState {
|
||||
tex_unit[0] = 0;
|
||||
tex_unit[1] = 0;
|
||||
tex = 0;
|
||||
tex_handle[0] = 0;
|
||||
tex_handle[1] = 0;
|
||||
|
||||
ps = 0;
|
||||
gs = 0;
|
||||
@ -116,5 +120,6 @@ namespace GLState {
|
||||
program = 0;
|
||||
dirty_prog = false;
|
||||
dirty_subroutine_ps = false;
|
||||
dirty_ressources = false;
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ namespace GLState {
|
||||
extern GLuint ds; // Depth-Stencil
|
||||
extern GLuint tex_unit[2]; // shader input texture
|
||||
extern GLuint tex; // Generic texture (for tex operation)
|
||||
extern GLuint64 tex_handle[2]; // shader input texture
|
||||
|
||||
extern GLuint ps;
|
||||
extern GLuint gs;
|
||||
@ -66,6 +67,7 @@ namespace GLState {
|
||||
extern GLuint program; // monolith program (when sso isn't supported)
|
||||
extern bool dirty_prog;
|
||||
extern bool dirty_subroutine_ps;
|
||||
extern bool dirty_ressources;
|
||||
|
||||
extern void Clear();
|
||||
}
|
||||
|
@ -83,8 +83,6 @@ GSDeviceOGL::~GSDeviceOGL()
|
||||
m_shader->Delete(m_convert.vs);
|
||||
for (uint32 i = 0; i < 2; i++)
|
||||
m_shader->Delete(m_convert.ps[i]);
|
||||
gl_DeleteSamplers(1, &m_convert.ln);
|
||||
gl_DeleteSamplers(1, &m_convert.pt);
|
||||
delete m_convert.dss;
|
||||
delete m_convert.bs;
|
||||
|
||||
@ -190,6 +188,11 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
|
||||
// unit 0-2 will allocated to shader input
|
||||
gl_ActiveTexture(GL_TEXTURE0 + 3);
|
||||
|
||||
// ****************************************************************
|
||||
// Pre Generate the different sampler object
|
||||
// ****************************************************************
|
||||
for (uint32 key = 0; key < PSSamplerSelector::size(); key++)
|
||||
m_ps_ss[key] = CreateSampler(PSSamplerSelector(key));
|
||||
|
||||
// ****************************************************************
|
||||
// convert
|
||||
@ -202,8 +205,12 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
|
||||
// Note: maybe enable blend with a factor of 1
|
||||
// m_convert.dss, m_convert.bs
|
||||
|
||||
m_convert.ln = CreateSampler(true, false, false);
|
||||
m_convert.pt = CreateSampler(false, false, false);
|
||||
PSSamplerSelector point;
|
||||
m_convert.pt = GetSamplerID(point);
|
||||
|
||||
PSSamplerSelector bilinear;
|
||||
bilinear.ltf = true;
|
||||
m_convert.ln = GetSamplerID(bilinear);
|
||||
|
||||
m_convert.dss = new GSDepthStencilOGL();
|
||||
m_convert.bs = new GSBlendStateOGL();
|
||||
@ -485,6 +492,11 @@ void GSDeviceOGL::ClearStencil(GSTexture* t, uint8 c)
|
||||
}
|
||||
}
|
||||
|
||||
GLuint GSDeviceOGL::CreateSampler(PSSamplerSelector sel)
|
||||
{
|
||||
return CreateSampler(sel.ltf, sel.tau, sel.tav);
|
||||
}
|
||||
|
||||
GLuint GSDeviceOGL::CreateSampler(bool bilinear, bool tau, bool tav)
|
||||
{
|
||||
GLuint sampler;
|
||||
@ -780,8 +792,13 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt,
|
||||
// Texture
|
||||
// ************************************
|
||||
|
||||
PSSetShaderResource(static_cast<GSTextureOGL*>(st)->GetID());
|
||||
PSSetSamplerState(linear ? m_convert.ln : m_convert.pt);
|
||||
if (GLLoader::found_GL_ARB_bindless_texture) {
|
||||
GLuint64 handle[2] = {static_cast<GSTextureOGL*>(st)->GetHandle(linear ? m_convert.ln : m_convert.pt) , 0};
|
||||
m_shader->PS_ressources(handle);
|
||||
} else {
|
||||
PSSetShaderResource(static_cast<GSTextureOGL*>(st)->GetID());
|
||||
PSSetSamplerState(linear ? m_convert.ln : m_convert.pt);
|
||||
}
|
||||
|
||||
// ************************************
|
||||
// Draw
|
||||
@ -901,8 +918,13 @@ void GSDeviceOGL::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* ver
|
||||
|
||||
// Texture
|
||||
|
||||
PSSetShaderResource(static_cast<GSTextureOGL*>(rt)->GetID());
|
||||
PSSetSamplerState(m_convert.pt);
|
||||
if (GLLoader::found_GL_ARB_bindless_texture) {
|
||||
GLuint64 handle[2] = {static_cast<GSTextureOGL*>(rt)->GetHandle(m_convert.pt) , 0};
|
||||
m_shader->PS_ressources(handle);
|
||||
} else {
|
||||
PSSetShaderResource(static_cast<GSTextureOGL*>(rt)->GetID());
|
||||
PSSetSamplerState(m_convert.pt);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
|
@ -503,8 +503,6 @@ class GSDeviceOGL : public GSDevice
|
||||
float bf; // blend factor
|
||||
} m_state;
|
||||
|
||||
GSShaderOGL* m_shader;
|
||||
|
||||
GLuint m_vs[1<<5];
|
||||
GLuint m_gs;
|
||||
GLuint m_ps_ss[1<<3];
|
||||
@ -534,6 +532,8 @@ class GSDeviceOGL : public GSDevice
|
||||
void OMSetFBO(GLuint fbo);
|
||||
|
||||
public:
|
||||
GSShaderOGL* m_shader;
|
||||
|
||||
GSDeviceOGL();
|
||||
virtual ~GSDeviceOGL();
|
||||
|
||||
@ -610,8 +610,10 @@ class GSDeviceOGL : public GSDevice
|
||||
void SetupGS(bool enable);
|
||||
void SetupPS(PSSelector sel);
|
||||
void SetupCB(const VSConstantBuffer* vs_cb, const PSConstantBuffer* ps_cb);
|
||||
void SetupSampler(PSSelector sel, PSSamplerSelector ssel);
|
||||
void SetupSampler(PSSamplerSelector ssel);
|
||||
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix);
|
||||
GLuint GetSamplerID(PSSamplerSelector ssel);
|
||||
GLuint GetPaletteSamplerID();
|
||||
|
||||
void Barrier(GLbitfield b);
|
||||
};
|
||||
|
@ -457,6 +457,25 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
|
||||
ps_ssel.tau = (context->CLAMP.WMS + 3) >> 1;
|
||||
ps_ssel.tav = (context->CLAMP.WMT + 3) >> 1;
|
||||
ps_ssel.ltf = bilinear && simple_sample;
|
||||
|
||||
// Setup Texture ressources
|
||||
if (GLLoader::found_GL_ARB_bindless_texture) {
|
||||
GLuint64 handle[2];
|
||||
handle[0] = tex->m_texture ? static_cast<GSTextureOGL*>(tex->m_texture)->GetHandle(dev->GetSamplerID(ps_ssel)): 0;
|
||||
handle[1] = tex->m_palette ? static_cast<GSTextureOGL*>(tex->m_palette)->GetHandle(dev->GetPaletteSamplerID()): 0;
|
||||
|
||||
dev->m_shader->PS_ressources(handle);
|
||||
} else {
|
||||
dev->SetupSampler(ps_ssel);
|
||||
|
||||
if (tex->m_palette) {
|
||||
GLuint textures[2] = {static_cast<GSTextureOGL*>(tex->m_texture)->GetID(), static_cast<GSTextureOGL*>(tex->m_palette)->GetID()};
|
||||
dev->PSSetShaderResources(textures);
|
||||
} else if (tex->m_texture) {
|
||||
// Only main texture
|
||||
dev->PSSetShaderResource(static_cast<GSTextureOGL*>(tex->m_texture)->GetID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WARNING: setup of the program must be done first. So you can setup
|
||||
@ -467,22 +486,6 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
|
||||
dev->SetupGS(m_vt.m_primclass == GS_SPRITE_CLASS);
|
||||
dev->SetupPS(ps_sel);
|
||||
|
||||
// Note: bindless texture will use uniform so it must be done after the program setup
|
||||
if(tex) {
|
||||
if (tex->m_palette) {
|
||||
// 2 textures (main + palette)
|
||||
dev->SetupSampler(ps_sel, ps_ssel);
|
||||
|
||||
GLuint textures[2] = {static_cast<GSTextureOGL*>(tex->m_texture)->GetID(), static_cast<GSTextureOGL*>(tex->m_palette)->GetID()};
|
||||
dev->PSSetShaderResources(textures);
|
||||
} else if (tex->m_texture) {
|
||||
// Only main texture
|
||||
dev->SetupSampler(ps_sel, ps_ssel);
|
||||
|
||||
dev->PSSetShaderResource(static_cast<GSTextureOGL*>(tex->m_texture)->GetID());
|
||||
}
|
||||
}
|
||||
|
||||
// rs
|
||||
|
||||
GSVector4i scissor = GSVector4i(GSVector4(rtscale).xyxy() * context->scissor.in).rintersect(GSVector4i(rtsize).zwxy());
|
||||
|
@ -28,7 +28,7 @@ GSShaderOGL::GSShaderOGL(bool debug) :
|
||||
m_sub_count(0)
|
||||
{
|
||||
|
||||
memset(&m_ps_sub, 0, countof(m_ps_sub)*sizeof(GLuint));
|
||||
memset(&m_ps_sub, 0, countof(m_ps_sub)*sizeof(m_ps_sub[0]));
|
||||
|
||||
m_single_prog.clear();
|
||||
#ifndef ENABLE_GLES
|
||||
@ -72,6 +72,15 @@ void GSShaderOGL::PS_subroutine(GLuint *sub)
|
||||
}
|
||||
}
|
||||
|
||||
void GSShaderOGL::PS_ressources(GLuint64 handle[2])
|
||||
{
|
||||
if (handle[0] != GLState::tex_handle[0] || handle[1] != GLState::tex_handle[1]) {
|
||||
GLState::tex_handle[0] = handle[0];
|
||||
GLState::tex_handle[1] = handle[1];
|
||||
GLState::dirty_ressources = true;
|
||||
}
|
||||
}
|
||||
|
||||
void GSShaderOGL::PS(GLuint s, GLuint sub_count)
|
||||
{
|
||||
if (GLState::ps != s)
|
||||
@ -124,6 +133,23 @@ void GSShaderOGL::SetSamplerBinding(GLuint prog, GLchar* name, GLuint binding)
|
||||
}
|
||||
}
|
||||
|
||||
void GSShaderOGL::SetupRessources()
|
||||
{
|
||||
if (!GLLoader::found_GL_ARB_bindless_texture) return;
|
||||
|
||||
if (GLState::dirty_ressources) {
|
||||
GLState::dirty_ressources = false;
|
||||
// FIXME count !
|
||||
// FIXME location !
|
||||
GLuint count = (GLState::tex_handle[1]) ? 2 : 1;
|
||||
if (GLLoader::found_GL_ARB_separate_shader_objects) {
|
||||
gl_ProgramUniformHandleui64vARB(GLState::ps, 0, count, GLState::tex_handle);
|
||||
} else {
|
||||
gl_UniformHandleui64vARB(0, count, GLState::tex_handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GSShaderOGL::SetupUniform()
|
||||
{
|
||||
if (GLLoader::found_GL_ARB_shading_language_420pack) return;
|
||||
@ -139,7 +165,7 @@ void GSShaderOGL::SetupUniform()
|
||||
|
||||
SetSamplerBinding(GLState::ps, "TextureSampler", 0);
|
||||
SetSamplerBinding(GLState::ps, "PaletteSampler", 1);
|
||||
SetSamplerBinding(GLState::ps, "RTCopySampler", 2);
|
||||
//SetSamplerBinding(GLState::ps, "RTCopySampler", 2);
|
||||
} else {
|
||||
SetUniformBinding(GLState::program, "cb20", 20);
|
||||
SetUniformBinding(GLState::program, "cb21", 21);
|
||||
@ -151,19 +177,19 @@ void GSShaderOGL::SetupUniform()
|
||||
|
||||
SetSamplerBinding(GLState::program, "TextureSampler", 0);
|
||||
SetSamplerBinding(GLState::program, "PaletteSampler", 1);
|
||||
SetSamplerBinding(GLState::program, "RTCopySampler", 2);
|
||||
//SetSamplerBinding(GLState::program, "RTCopySampler", 2);
|
||||
}
|
||||
}
|
||||
|
||||
void GSShaderOGL::SetSubroutineUniform()
|
||||
void GSShaderOGL::SetupSubroutineUniform()
|
||||
{
|
||||
if (!GLLoader::found_GL_ARB_shader_subroutine) return;
|
||||
if (m_sub_count == 0) return;
|
||||
|
||||
if (GLState::dirty_subroutine_ps || GLState::dirty_prog)
|
||||
if (GLState::dirty_subroutine_ps) {
|
||||
gl_UniformSubroutinesuiv(GL_FRAGMENT_SHADER, m_sub_count, m_ps_sub);
|
||||
|
||||
GLState::dirty_subroutine_ps = false;
|
||||
GLState::dirty_subroutine_ps = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool GSShaderOGL::ValidateShader(GLuint s)
|
||||
@ -252,6 +278,9 @@ GLuint GSShaderOGL::LinkNewProgram()
|
||||
void GSShaderOGL::UseProgram()
|
||||
{
|
||||
if (GLState::dirty_prog) {
|
||||
GLState::dirty_subroutine_ps = true;
|
||||
GLState::dirty_ressources = true;
|
||||
|
||||
if (!GLLoader::found_GL_ARB_separate_shader_objects) {
|
||||
hash_map<uint64, GLuint >::iterator it;
|
||||
// Note: shader are integer lookup pointer. They start from 1 and incr
|
||||
@ -286,7 +315,9 @@ void GSShaderOGL::UseProgram()
|
||||
}
|
||||
}
|
||||
|
||||
SetSubroutineUniform();
|
||||
SetupRessources();
|
||||
|
||||
SetupSubroutineUniform();
|
||||
|
||||
GLState::dirty_prog = false;
|
||||
}
|
||||
|
@ -29,8 +29,10 @@ class GSShaderOGL {
|
||||
|
||||
GLuint m_ps_sub[2];
|
||||
|
||||
void SetSubroutineUniform();
|
||||
void SetupSubroutineUniform();
|
||||
void SetupUniform();
|
||||
void SetupRessources();
|
||||
|
||||
void SetUniformBinding(GLuint prog, GLchar* name, GLuint binding);
|
||||
void SetSamplerBinding(GLuint prog, GLchar* name, GLuint binding);
|
||||
|
||||
@ -48,6 +50,7 @@ class GSShaderOGL {
|
||||
void GS(GLuint s);
|
||||
void PS(GLuint s, GLuint sub_count = 0);
|
||||
void PS_subroutine(GLuint *sub);
|
||||
void PS_ressources(GLuint64 handle[2]);
|
||||
void VS(GLuint s);
|
||||
|
||||
void UseProgram();
|
||||
|
@ -31,6 +31,7 @@ void GSDeviceOGL::CreateTextureFX()
|
||||
m_vs_cb = new GSUniformBufferOGL(g_vs_cb_index, sizeof(VSConstantBuffer));
|
||||
m_ps_cb = new GSUniformBufferOGL(g_ps_cb_index, sizeof(PSConstantBuffer));
|
||||
|
||||
// warning 1 sampler by image unit. So you cannot reuse m_ps_ss...
|
||||
m_palette_ss = CreateSampler(false, false, false);
|
||||
gl_BindSampler(1, m_palette_ss);
|
||||
|
||||
@ -53,18 +54,10 @@ void GSDeviceOGL::CreateTextureFX()
|
||||
for (uint32 key = 0; key < VSSelector::size(); key++)
|
||||
m_vs[key] = CompileVS(VSSelector(key));
|
||||
|
||||
for (uint32 key = 0; key < PSSamplerSelector::size(); key++)
|
||||
m_ps_ss[key] = CreateSampler(PSSamplerSelector(key));
|
||||
|
||||
for (uint32 key = 0; key < OMDepthStencilSelector::size(); key++)
|
||||
m_om_dss[key] = CreateDepthStencil(OMDepthStencilSelector(key));
|
||||
}
|
||||
|
||||
GLuint GSDeviceOGL::CreateSampler(PSSamplerSelector sel)
|
||||
{
|
||||
return CreateSampler(sel.ltf, sel.tau, sel.tav);
|
||||
}
|
||||
|
||||
GSDepthStencilOGL* GSDeviceOGL::CreateDepthStencil(OMDepthStencilSelector dssel)
|
||||
{
|
||||
GSDepthStencilOGL* dss = new GSDepthStencilOGL();
|
||||
@ -182,16 +175,21 @@ void GSDeviceOGL::SetupPS(PSSelector sel)
|
||||
m_shader->PS(ps, 2);
|
||||
}
|
||||
|
||||
void GSDeviceOGL::SetupSampler(PSSelector sel, PSSamplerSelector ssel)
|
||||
void GSDeviceOGL::SetupSampler(PSSamplerSelector ssel)
|
||||
{
|
||||
if(!(sel.fmt < 3 && sel.wms < 3 && sel.wmt < 3))
|
||||
{
|
||||
ssel.ltf = 0;
|
||||
}
|
||||
|
||||
PSSetSamplerState(m_ps_ss[ssel]);
|
||||
}
|
||||
|
||||
GLuint GSDeviceOGL::GetSamplerID(PSSamplerSelector ssel)
|
||||
{
|
||||
return m_ps_ss[ssel];
|
||||
}
|
||||
|
||||
GLuint GSDeviceOGL::GetPaletteSamplerID()
|
||||
{
|
||||
return m_palette_ss;
|
||||
}
|
||||
|
||||
void GSDeviceOGL::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix)
|
||||
{
|
||||
GSDepthStencilOGL* dss = m_om_dss[dssel];
|
||||
|
@ -91,6 +91,7 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, int format, GLuint fbo_read)
|
||||
m_type = type;
|
||||
m_fbo_read = fbo_read;
|
||||
m_texture_id = 0;
|
||||
memset(&m_handles, 0, countof(m_handles) * sizeof(m_handles[0]) );
|
||||
|
||||
// Bunch of constant parameter
|
||||
switch (m_format) {
|
||||
@ -244,6 +245,17 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch)
|
||||
#endif
|
||||
}
|
||||
|
||||
GLuint64 GSTextureOGL::GetHandle(GLuint sampler_id)
|
||||
{
|
||||
ASSERT(sampler_id < 12);
|
||||
if (!m_handles[sampler_id]) {
|
||||
m_handles[sampler_id] = gl_GetTextureSamplerHandleARB(m_texture_id, sampler_id);
|
||||
gl_MakeTextureHandleResidentARB(m_handles[sampler_id]);
|
||||
}
|
||||
|
||||
return m_handles[sampler_id];
|
||||
}
|
||||
|
||||
void GSTextureOGL::EnableUnit()
|
||||
{
|
||||
/* Not a real texture */
|
||||
|
@ -48,6 +48,8 @@ class GSTextureOGL : public GSTexture
|
||||
uint32 m_int_alignment;
|
||||
uint32 m_int_shift;
|
||||
|
||||
GLuint64 m_handles[12];
|
||||
|
||||
public:
|
||||
explicit GSTextureOGL(int type, int w, int h, int format, GLuint fbo_read);
|
||||
virtual ~GSTextureOGL();
|
||||
@ -67,4 +69,5 @@ class GSTextureOGL : public GSTexture
|
||||
bool IsDss() { return (m_type == GSTexture::DepthStencil); }
|
||||
|
||||
GLuint GetID() { return m_texture_id; }
|
||||
GLuint64 GetHandle(GLuint sampler_id);
|
||||
};
|
||||
|
@ -109,6 +109,13 @@ void GSWndGL::PopulateGlFunction()
|
||||
*(void**)&(gl_ClearTexImage) = GetProcAddress("glCLearTexImage", true);
|
||||
*(void**)&(gl_BindTextures) = GetProcAddress("glBindTextures", true);
|
||||
*(void**)&(gl_BufferStorage) = GetProcAddress("glBufferStorage", true);
|
||||
// GL_ARB_bindless_texture (GL5?)
|
||||
*(void**)&(gl_GetTextureSamplerHandleARB) = GetProcAddress("glGetTextureSamplerHandleARB", true);
|
||||
*(void**)&(gl_MakeTextureHandleResidentARB) = GetProcAddress("glMakeTextureHandleResidentARB", true);
|
||||
*(void**)&(gl_MakeTextureHandleNonResidentARB) = GetProcAddress("glMakeTextureHandleNonResidentARB", true);
|
||||
*(void**)&(gl_UniformHandleui64vARB) = GetProcAddress("glUniformHandleui64vARB", true);
|
||||
*(void**)&(gl_ProgramUniformHandleui64vARB) = GetProcAddress("glProgramUniformHandleui64vARB", true);
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@ -807,11 +807,11 @@ static const char* tfx_glsl =
|
||||
"#ifdef DISABLE_GL42\n"
|
||||
"uniform sampler2D TextureSampler;\n"
|
||||
"uniform sampler2D PaletteSampler;\n"
|
||||
"uniform sampler2D RTCopySampler;\n"
|
||||
"//uniform sampler2D RTCopySampler;\n"
|
||||
"#else\n"
|
||||
"layout(binding = 0) uniform sampler2D TextureSampler;\n"
|
||||
"layout(binding = 1) uniform sampler2D PaletteSampler;\n"
|
||||
"layout(binding = 2) uniform sampler2D RTCopySampler;\n"
|
||||
"//layout(binding = 2) uniform sampler2D RTCopySampler;\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"#ifndef DISABLE_GL42_image\n"
|
||||
@ -871,10 +871,12 @@ static const char* tfx_glsl =
|
||||
" return texture(PaletteSampler, vec2(u, 0.0f));\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"#if 0\n"
|
||||
"vec4 sample_rt(vec2 uv)\n"
|
||||
"{\n"
|
||||
" return texture(RTCopySampler, uv);\n"
|
||||
"}\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"vec4 wrapuv(vec4 uv)\n"
|
||||
"{\n"
|
||||
|
@ -297,11 +297,11 @@ layout(location = 0, index = 1) out vec4 SV_Target1;
|
||||
#ifdef DISABLE_GL42
|
||||
uniform sampler2D TextureSampler;
|
||||
uniform sampler2D PaletteSampler;
|
||||
uniform sampler2D RTCopySampler;
|
||||
//uniform sampler2D RTCopySampler;
|
||||
#else
|
||||
layout(binding = 0) uniform sampler2D TextureSampler;
|
||||
layout(binding = 1) uniform sampler2D PaletteSampler;
|
||||
layout(binding = 2) uniform sampler2D RTCopySampler;
|
||||
//layout(binding = 2) uniform sampler2D RTCopySampler;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_GL42_image
|
||||
@ -361,10 +361,12 @@ vec4 sample_p(float u)
|
||||
return texture(PaletteSampler, vec2(u, 0.0f));
|
||||
}
|
||||
|
||||
#if 0
|
||||
vec4 sample_rt(vec2 uv)
|
||||
{
|
||||
return texture(RTCopySampler, uv);
|
||||
}
|
||||
#endif
|
||||
|
||||
vec4 wrapuv(vec4 uv)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user