From 310bcfcfeb16967721b08e6e249439cbf336cd7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 30 Mar 2016 20:32:13 -0700 Subject: [PATCH] Cleanup. --- src/bgfx_shader.sh | 8 -------- src/glimports.h | 6 ++++++ src/renderer_gl.cpp | 16 +++++++++++++++- tools/shaderc/shaderc.cpp | 16 ++++++++++++++++ 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/bgfx_shader.sh b/src/bgfx_shader.sh index 5cff1a47d..3a1c669f3 100644 --- a/src/bgfx_shader.sh +++ b/src/bgfx_shader.sh @@ -116,14 +116,6 @@ struct BgfxSampler2DMS Texture2DMS m_texture; }; -vec4 bgfxTexture2DMS(BgfxSampler2DMS _sampler, vec2 _coord, int _sampleIdx) -{ - ivec2 size; - int numSamples; - _sampler.m_texture.GetDimensions(size.x, size.y, numSamples); - return _sampler.m_texture.Load(ivec2(_coord * size), _sampleIdx); -} - struct BgfxSampler2DShadow { SamplerComparisonState m_sampler; diff --git a/src/glimports.h b/src/glimports.h index e3ee0a6a9..a69c6c6e6 100644 --- a/src/glimports.h +++ b/src/glimports.h @@ -170,6 +170,7 @@ typedef void (GL_APIENTRYP PFNGLREADBUFFERPROC) (GLenum mode); typedef void (GL_APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); @@ -182,7 +183,9 @@ typedef void (GL_APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, typedef void (GL_APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); typedef void (GL_APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); typedef void (GL_APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat* param); typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); @@ -356,6 +359,7 @@ GL_IMPORT______(true, PFNGLREADBUFFERPROC, glReadBuffer) GL_IMPORT______(false, PFNGLREADPIXELSPROC, glReadPixels); GL_IMPORT______(true, PFNGLRENDERBUFFERSTORAGEPROC, glRenderbufferStorage); GL_IMPORT______(true, PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC, glRenderbufferStorageMultisample); +GL_IMPORT______(true, PFNGLSAMPLEMASKIPROC, glSampleMaskI); GL_IMPORT______(true, PFNGLSAMPLERPARAMETERIPROC, glSamplerParameteri); GL_IMPORT______(true, PFNGLSAMPLERPARAMETERFPROC, glSamplerParameterf); GL_IMPORT______(true, PFNGLSAMPLERPARAMETERFVPROC, glSamplerParameterfv); @@ -368,7 +372,9 @@ GL_IMPORT______(true, PFNGLSTENCILMASKSEPARATEPROC, glStencilMask GL_IMPORT______(false, PFNGLSTENCILOPPROC, glStencilOp); GL_IMPORT______(true, PFNGLSTENCILOPSEPARATEPROC, glStencilOpSeparate); GL_IMPORT______(false, PFNGLTEXIMAGE2DPROC, glTexImage2D); +GL_IMPORT______(true, PFNGLTEXIMAGE2DMULTISAMPLEPROC, glTexImage2DMultisample); GL_IMPORT______(true, PFNGLTEXIMAGE3DPROC, glTexImage3D); +GL_IMPORT______(true, PFNGLTEXIMAGE3DMULTISAMPLEPROC, glTexImage3DMultisample); GL_IMPORT______(false, PFNGLTEXPARAMETERIPROC, glTexParameteri); GL_IMPORT______(false, PFNGLTEXPARAMETERIVPROC, glTexParameteriv); GL_IMPORT______(false, PFNGLTEXPARAMETERFPROC, glTexParameterf); diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 1bffc7c4e..ca09b64eb 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -910,6 +910,14 @@ namespace bgfx { namespace gl NULL }; + static const char* s_ARB_texture_multisample[] = + { + "sampler2DMS", + "isampler2DMS", + "usampler2DMS", + NULL + }; + static void GL_APIENTRY stubVertexAttribDivisor(GLuint /*_index*/, GLuint /*_divisor*/) { } @@ -4836,9 +4844,10 @@ namespace bgfx { namespace gl ; const bool usesIUsamplers = !!bx::findIdentifierMatch(code, s_uisamplers); const bool usesTexelFetch = !!bx::findIdentifierMatch(code, s_texelFetch); + const bool usesTextureMS = !!bx::findIdentifierMatch(code, s_ARB_texture_multisample); uint32_t version = - usesTexelFetch || usesIUsamplers ? 130 + usesIUsamplers || usesTexelFetch || usesTextureMS ? 130 : usesTextureLod ? 120 : 0 ; @@ -4856,6 +4865,11 @@ namespace bgfx { namespace gl } } + if (usesTextureMS) + { + writeString(&writer, "#extension GL_ARB_texture_multisample : enable\n"); + } + if (130 <= version) { if (m_type == GL_FRAGMENT_SHADER) diff --git a/tools/shaderc/shaderc.cpp b/tools/shaderc/shaderc.cpp index b07556915..a0f89e4f6 100644 --- a/tools/shaderc/shaderc.cpp +++ b/tools/shaderc/shaderc.cpp @@ -98,6 +98,14 @@ namespace bgfx NULL }; + static const char* s_ARB_texture_multisample[] = + { + "sampler2DMS", + "isampler2DMS", + "usampler2DMS", + NULL + }; + const char* s_uniformTypeName[UniformType::Count] = { "int", @@ -1725,6 +1733,7 @@ namespace bgfx const bool hasTextureLod = NULL != bx::findIdentifierMatch(input, s_ARB_shader_texture_lod /*EXT_shader_texture_lod*/); const bool hasShader5 = NULL != bx::findIdentifierMatch(input, s_ARB_gpu_shader5); const bool hasShaderPacking = NULL != bx::findIdentifierMatch(input, s_ARB_shading_language_packing); + const bool hasTextureMS = NULL != bx::findIdentifierMatch(input, s_ARB_texture_multisample); if (0 == essl) { @@ -1767,6 +1776,13 @@ namespace bgfx , "#extension GL_ARB_shader_texture_lod : enable\n" ); } + + if (hasTextureMS) + { + bx::stringPrintf(code + , "#extension GL_ARB_texture_multisample : enable\n" + ); + } } else {