From 2385b87804ad3fab4571bff669c694315c3be0f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 20 Apr 2016 21:38:58 -0700 Subject: [PATCH 1/6] glsl-optimizer: Fixed MSAA texelFetch. --- .../src/glsl/ir_print_glsl_visitor.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_print_glsl_visitor.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_print_glsl_visitor.cpp index f11893bba..3f85b41c4 100644 --- a/3rdparty/glsl-optimizer/src/glsl/ir_print_glsl_visitor.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/ir_print_glsl_visitor.cpp @@ -825,6 +825,7 @@ void ir_print_glsl_visitor::visit(ir_texture *ir) glsl_sampler_dim sampler_dim = (glsl_sampler_dim)ir->sampler->type->sampler_dimensionality; const bool is_shadow = ir->sampler->type->sampler_shadow; const bool is_array = ir->sampler->type->sampler_array; + const bool is_msaa = ir->op == ir_txf_ms; const glsl_type* uv_type = ir->coordinate->type; const int uv_dim = uv_type->vector_elements; int sampler_uv_dim = tex_sampler_dim_size[sampler_dim]; @@ -832,6 +833,8 @@ void ir_print_glsl_visitor::visit(ir_texture *ir) sampler_uv_dim += 1; if (is_array) sampler_uv_dim += 1; + if (is_msaa) + sampler_uv_dim += 1; const bool is_proj = (uv_dim > sampler_uv_dim); const bool is_lod = (ir->op == ir_txl); @@ -876,8 +879,10 @@ void ir_print_glsl_visitor::visit(ir_texture *ir) } else { - if (ir->op == ir_txf) + if (ir->op == ir_txf + || ir->op == ir_txf_ms) { buffer.asprintf_append ("texelFetch"); + } else buffer.asprintf_append ("texture"); } @@ -885,7 +890,7 @@ void ir_print_glsl_visitor::visit(ir_texture *ir) if (is_array && state->EXT_texture_array_enable) buffer.asprintf_append ("Array"); - if (is_proj) + if (ir->op == ir_tex && is_proj) buffer.asprintf_append ("Proj"); if (ir->op == ir_txl) buffer.asprintf_append ("Lod"); @@ -921,12 +926,12 @@ void ir_print_glsl_visitor::visit(ir_texture *ir) ir->coordinate->accept(this); // lod - if (ir->op == ir_txl || ir->op == ir_txf) + if (ir->op == ir_txl || ir->op == ir_txf || ir->op == ir_txf_ms) { buffer.asprintf_append (", "); ir->lod_info.lod->accept(this); } - + // grad if (ir->op == ir_txd) { From be8b66a96be0a09615bf26a7e009acde9168834b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 20 Apr 2016 22:19:12 -0700 Subject: [PATCH 2/6] GL: MSAA texture. --- src/renderer_gl.cpp | 45 ++++++++++++++++++++++++++++++++------------- src/renderer_gl.h | 12 ++++++++++++ 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 0956663e2..9cb5437c6 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -3410,7 +3410,6 @@ namespace bgfx { namespace gl GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT) ); GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR) ); GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) ); - GL_CHECK(glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LEVEL, 0) ); } } @@ -3580,6 +3579,10 @@ namespace bgfx { namespace gl GLSL_TYPE(GL_INT_SAMPLER_CUBE); GLSL_TYPE(GL_UNSIGNED_INT_SAMPLER_CUBE); + GLSL_TYPE(GL_SAMPLER_2D_MULTISAMPLE); + GLSL_TYPE(GL_INT_SAMPLER_2D_MULTISAMPLE); + GLSL_TYPE(GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE); + GLSL_TYPE(GL_SAMPLER_2D_SHADOW); GLSL_TYPE(GL_IMAGE_1D); @@ -3670,6 +3673,10 @@ namespace bgfx { namespace gl case GL_SAMPLER_2D_SHADOW: + case GL_SAMPLER_2D_MULTISAMPLE: + case GL_INT_SAMPLER_2D_MULTISAMPLE: + case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE: + case GL_IMAGE_1D: case GL_INT_IMAGE_1D: case GL_UNSIGNED_INT_IMAGE_1D: @@ -4151,17 +4158,22 @@ namespace bgfx { namespace gl m_vcref.invalidate(s_renderGL->m_vaoStateCache); } - static void texImage(GLenum _target, GLint _level, GLint _internalFormat, GLsizei _width, GLsizei _height, GLsizei _depth, GLint _border, GLenum _format, GLenum _type, const GLvoid* _data) + static void texImage(GLenum _target, uint32_t _msaaQuality, GLint _level, GLint _internalFormat, GLsizei _width, GLsizei _height, GLsizei _depth, GLint _border, GLenum _format, GLenum _type, const GLvoid* _data) { if (_target == GL_TEXTURE_3D) { GL_CHECK(glTexImage3D(_target, _level, _internalFormat, _width, _height, _depth, _border, _format, _type, _data) ); } + else if (_target == GL_TEXTURE_2D_MULTISAMPLE) + { + GL_CHECK(glTexImage2DMultisample(_target, _msaaQuality, _internalFormat, _width, _height, false) ); + } else { - BX_UNUSED(_depth); GL_CHECK(glTexImage2D(_target, _level, _internalFormat, _width, _height, _border, _format, _type, _data) ); } + + BX_UNUSED(_msaaQuality, _depth, _border, _data); } static void texSubImage(GLenum _target, GLint _level, GLint _xoffset, GLint _yoffset, GLint _zoffset, GLsizei _width, GLsizei _height, GLsizei _depth, GLenum _format, GLenum _type, const GLvoid* _data) @@ -4348,7 +4360,14 @@ namespace bgfx { namespace gl m_requestedFormat = uint8_t(imageContainer.m_format); m_textureFormat = uint8_t(getViableTextureFormat(imageContainer) ); - GLenum target = GL_TEXTURE_2D; + const bool computeWrite = 0 != (_flags&BGFX_TEXTURE_COMPUTE_WRITE); + const bool srgb = 0 != (_flags&BGFX_TEXTURE_SRGB); + const bool msaaSample = 0 != (_flags&BGFX_TEXTURE_MSAA_SAMPLE); + uint32_t msaaQuality = ( (_flags&BGFX_TEXTURE_RT_MSAA_MASK)>>BGFX_TEXTURE_RT_MSAA_SHIFT); + msaaQuality = bx::uint32_satsub(msaaQuality, 1); + msaaQuality = bx::uint32_min(s_renderGL->m_maxMsaa, msaaQuality == 0 ? 0 : 1<>BGFX_TEXTURE_U_SHIFT]) ); GL_CHECK(glTexParameteri(target, GL_TEXTURE_WRAP_T, s_textureAddress[(flags&BGFX_TEXTURE_V_MASK)>>BGFX_TEXTURE_V_SHIFT]) ); @@ -4701,7 +4720,7 @@ namespace bgfx { namespace gl if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL || BGFX_CONFIG_RENDERER_OPENGLES >= 30) || s_extension[Extension::APPLE_texture_max_level].m_supported) { - GL_CHECK(glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, numMips-1) ); + GL_CHECK(glTexParameteri(targetMsaa, GL_TEXTURE_MAX_LEVEL, numMips-1) ); } if (target == GL_TEXTURE_3D) @@ -4736,12 +4755,12 @@ namespace bgfx { namespace gl const uint32_t cmpFunc = (flags&BGFX_TEXTURE_COMPARE_MASK)>>BGFX_TEXTURE_COMPARE_SHIFT; if (0 == cmpFunc) { - GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_COMPARE_MODE, GL_NONE) ); + GL_CHECK(glTexParameteri(target, GL_TEXTURE_COMPARE_MODE, GL_NONE) ); } else { - GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE) ); - GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_COMPARE_FUNC, s_cmpFunc[cmpFunc]) ); + GL_CHECK(glTexParameteri(target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE) ); + GL_CHECK(glTexParameteri(target, GL_TEXTURE_COMPARE_FUNC, s_cmpFunc[cmpFunc]) ); } } diff --git a/src/renderer_gl.h b/src/renderer_gl.h index 188e5a0b5..4e205fe30 100644 --- a/src/renderer_gl.h +++ b/src/renderer_gl.h @@ -640,6 +640,18 @@ typedef uint64_t GLuint64; # define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 #endif // GL_UNSIGNED_INT_SAMPLER_CUBE +#ifndef GL_SAMPLER_2D_MULTISAMPLE +# define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#endif // GL_SAMPLER_2D_MULTISAMPLE + +#ifndef GL_INT_SAMPLER_2D_MULTISAMPLE +# define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#endif // GL_INT_SAMPLER_2D_MULTISAMPLE + +#ifndef GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE +# define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#endif // GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE + #ifndef GL_SAMPLER_2D_SHADOW # define GL_SAMPLER_2D_SHADOW 0x8B62 #endif // GL_SAMPLER_2D_SHADOW From a483ee936cf1b1e8e88b84d32071888d1266c90b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 20 Apr 2016 22:24:42 -0700 Subject: [PATCH 3/6] GLES: Fixed imports. --- src/glimports.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/glimports.h b/src/glimports.h index 7e110f069..a12acb19d 100644 --- a/src/glimports.h +++ b/src/glimports.h @@ -487,6 +487,7 @@ GL_IMPORT_OES__(true, PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC, glCompressedT GL_IMPORT_EXT__(true, PFNGLTEXSTORAGE2DPROC, glTexStorage2D); GL_IMPORT_EXT__(true, PFNGLTEXSTORAGE3DPROC, glTexStorage3D); +GL_IMPORT______(true, PFNGLTEXIMAGE2DMULTISAMPLEPROC, glTexImage2DMultisample); GL_IMPORT_EXT__(true, PFNGLINSERTEVENTMARKEREXTPROC, glInsertEventMarker); GL_IMPORT_EXT__(true, PFNGLPUSHGROUPMARKEREXTPROC, glPushGroupMarker); @@ -567,6 +568,7 @@ GL_IMPORT______(true, PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC, glCompressedT GL_IMPORT______(true, PFNGLTEXSTORAGE2DPROC, glTexStorage2D); GL_IMPORT______(true, PFNGLTEXSTORAGE3DPROC, glTexStorage3D); +GL_IMPORT______(true, PFNGLTEXIMAGE2DMULTISAMPLEPROC, glTexImage2DMultisample); GL_IMPORT______(true, PFNGLINSERTEVENTMARKEREXTPROC, glInsertEventMarker); GL_IMPORT______(true, PFNGLPUSHGROUPMARKEREXTPROC, glPushGroupMarker); From 5aad5b12eff5efd7f260943c98c8a2344ad5eebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Thu, 21 Apr 2016 07:46:03 -0700 Subject: [PATCH 4/6] Updated ImGui. --- 3rdparty/ocornut-imgui/imgui_internal.h | 1 + 1 file changed, 1 insertion(+) diff --git a/3rdparty/ocornut-imgui/imgui_internal.h b/3rdparty/ocornut-imgui/imgui_internal.h index e49c63b0d..c105a4852 100644 --- a/3rdparty/ocornut-imgui/imgui_internal.h +++ b/3rdparty/ocornut-imgui/imgui_internal.h @@ -716,6 +716,7 @@ namespace ImGui IMGUI_API bool ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0); IMGUI_API bool ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0,0), ImGuiButtonFlags flags = 0); + IMGUI_API bool CloseButton(ImGuiID id, const ImVec2& pos, float radius); IMGUI_API bool SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_min, float v_max, float power, int decimal_precision, ImGuiSliderFlags flags = 0); IMGUI_API bool SliderFloatN(const char* label, float* v, int components, float v_min, float v_max, const char* display_format, float power); From 3be0c4091f22cb15607149f82a65e57c357098df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Thu, 21 Apr 2016 08:11:53 -0700 Subject: [PATCH 5/6] shaderc: Fixed issue #768. --- 3rdparty/fcpp/cpp6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/fcpp/cpp6.c b/3rdparty/fcpp/cpp6.c index 0419152fb..30d22697c 100644 --- a/3rdparty/fcpp/cpp6.c +++ b/3rdparty/fcpp/cpp6.c @@ -1084,7 +1084,7 @@ void domsg(struct Global *global, ; tp = file ? file->filename : 0; Error(global, "%s\"%s\", line %d: %s: ", - MSG_PREFIX, tp, global->infile->fp?global->line:file->line, severity); + MSG_PREFIX, tp, global->infile?global->line:(file?file->line:0), severity); if(global->error) global->error(global->userdata, ErrorMessage[error], arg); #if defined(UNIX) From e759e55fd23bf90e0b75ae0ed48cc4fd9f5b7707 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Thu, 21 Apr 2016 19:47:57 +0200 Subject: [PATCH 6/6] Fixing a memory overflow that caused the camera to move right all the time. --- examples/common/entry/input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/common/entry/input.cpp b/examples/common/entry/input.cpp index bb9925990..5e67f23c1 100644 --- a/examples/common/entry/input.cpp +++ b/examples/common/entry/input.cpp @@ -72,7 +72,7 @@ struct Mouse struct Keyboard { Keyboard() - : m_ring(BX_COUNTOF(m_char) ) + : m_ring(BX_COUNTOF(m_char)-4) { }