Skip to content

Commit

Permalink
Fixed to OpenGL Renderer
Browse files Browse the repository at this point in the history
Fixed memory leak
Added shader source debug output
GLSL version changed from 4.10 to 4.50
  • Loading branch information
Xottab-DUTY committed Feb 4, 2018
1 parent 43116d8 commit 137605d
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 23 deletions.
1 change: 1 addition & 0 deletions src/Layers/xrRenderGL/Blender_Recorder_GL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void CBlender_Compile::r_Sampler_cmp(LPCSTR name, LPCSTR texture, bool b_ps1x_Pr
void CBlender_Compile::r_Pass(LPCSTR _vs, LPCSTR _gs, LPCSTR _ps, bool bFog, BOOL bZtest, BOOL bZwrite, BOOL bABlend,
D3DBLEND abSRC, D3DBLEND abDST, BOOL aTest, u32 aRef)
{
R_ASSERT2(_ps, "Probably you are using wrong r_Pass");
RS.Invalidate();
ctable.clear();
passTextures.clear();
Expand Down
24 changes: 12 additions & 12 deletions src/Layers/xrRenderPC_GL/blender_bloom_build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ void CBlender_bloom_build::Compile(CBlender_Compile& C)
switch (C.iElement)
{
case 0: // transfer into bloom-target
C.r_Pass("stub_notransform_build", "bloom_build", FALSE, FALSE, FALSE, FALSE, D3DBLEND_SRCALPHA,
C.r_Pass("stub_notransform_build", "bloom_build", false, FALSE, FALSE, FALSE, D3DBLEND_SRCALPHA,
D3DBLEND_INVSRCALPHA);
C.r_Sampler_clf("s_image", r2_RT_generic1);
C.r_End();
break;
case 1: // X-filter
C.r_Pass("stub_notransform_filter", "bloom_filter", FALSE, FALSE, FALSE);
C.r_Pass("stub_notransform_filter", "bloom_filter", false, FALSE, FALSE);
C.r_Sampler_clf("s_bloom", r2_RT_bloom1);
C.r_End();
break;
case 2: // Y-filter
C.r_Pass("stub_notransform_filter", "bloom_filter", FALSE, FALSE, FALSE);
C.r_Pass("stub_notransform_filter", "bloom_filter", false, FALSE, FALSE);
C.r_Sampler_clf("s_bloom", r2_RT_bloom2);
C.r_End();
break;
case 3: // FF-filter_P0
C.r_Pass("stub_notransform_build", "bloom_filter_f", FALSE, FALSE, FALSE);
C.r_Pass("stub_notransform_build", "bloom_filter_f", false, FALSE, FALSE);
C.r_Sampler_clf("s_bloom", r2_RT_bloom1);
C.r_End();
break;
case 4: // FF-filter_P1
C.r_Pass("stub_notransform_build", "bloom_filter_f", FALSE, FALSE, FALSE);
C.r_Pass("stub_notransform_build", "bloom_filter_f", false, FALSE, FALSE);
C.r_Sampler_clf("s_bloom", r2_RT_bloom2);
C.r_End();
break;
Expand All @@ -51,28 +51,28 @@ void CBlender_bloom_build_msaa::Compile(CBlender_Compile& C)
switch (C.iElement)
{
case 0: // transfer into bloom-target
C.r_Pass("stub_notransform_build", "bloom_build", FALSE, FALSE, FALSE, FALSE, D3DBLEND_SRCALPHA,
C.r_Pass("stub_notransform_build", "bloom_build", false, FALSE, FALSE, FALSE, D3DBLEND_SRCALPHA,
D3DBLEND_INVSRCALPHA);
C.r_Sampler_clf("s_image", r2_RT_generic1);
C.r_End();
break;
case 1: // X-filter
C.r_Pass("stub_notransform_filter", "bloom_filter", nullptr, false, FALSE);
C.r_Pass("stub_notransform_filter", "bloom_filter", false, FALSE, FALSE);
C.r_Sampler_clf("s_bloom", r2_RT_bloom1);
C.r_End();
break;
case 2: // Y-filter
C.r_Pass("stub_notransform_filter", "bloom_filter", nullptr, false, FALSE);
C.r_Pass("stub_notransform_filter", "bloom_filter", false, FALSE, FALSE);
C.r_Sampler_clf("s_bloom", r2_RT_bloom2);
C.r_End();
break;
case 3: // FF-filter_P0
C.r_Pass("stub_notransform_build", "bloom_filter_f", nullptr, false, FALSE);
C.r_Pass("stub_notransform_build", "bloom_filter_f", false, FALSE, FALSE);
C.r_Sampler_clf("s_bloom", r2_RT_bloom1);
C.r_End();
break;
case 4: // FF-filter_P1
C.r_Pass("stub_notransform_build", "bloom_filter_f", nullptr, false, FALSE);
C.r_Pass("stub_notransform_build", "bloom_filter_f", false, FALSE, FALSE);
C.r_Sampler_clf("s_bloom", r2_RT_bloom2);
C.r_End();
break;
Expand All @@ -89,7 +89,7 @@ void CBlender_postprocess_msaa::Compile(CBlender_Compile& C)
switch (C.iElement)
{
case 0: // transfer into bloom-target
C.r_Pass("stub_notransform_postpr", "postprocess", FALSE, FALSE, FALSE, FALSE, D3DBLEND_SRCALPHA,
C.r_Pass("stub_notransform_postpr", "postprocess", false, FALSE, FALSE, FALSE, D3DBLEND_SRCALPHA,
D3DBLEND_INVSRCALPHA);
C.r_Sampler_clf("s_base0", r2_RT_generic);
C.r_Sampler_clf("s_base1", r2_RT_generic);
Expand All @@ -98,7 +98,7 @@ void CBlender_postprocess_msaa::Compile(CBlender_Compile& C)
break;

case 4: // use color map
C.r_Pass("stub_notransform_postpr", "postprocess_CM", FALSE, FALSE, FALSE, FALSE, D3DBLEND_SRCALPHA,
C.r_Pass("stub_notransform_postpr", "postprocess_CM", false, FALSE, FALSE, FALSE, D3DBLEND_SRCALPHA,
D3DBLEND_INVSRCALPHA);
C.r_Sampler_clf("s_base0", r2_RT_generic);
C.r_Sampler_clf("s_base1", r2_RT_generic);
Expand Down
6 changes: 3 additions & 3 deletions src/Layers/xrRenderPC_GL/blender_ssao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void CBlender_SSAO_noMSAA::Compile(CBlender_Compile& C)
switch (C.iElement)
{
case 0: // calculate SSAO
C.r_Pass("combine_1", "ssao_calc_nomsaa", nullptr, false, FALSE);
C.r_Pass("combine_1", "ssao_calc_nomsaa", false, FALSE, FALSE);
C.r_Stencil(TRUE, D3DCMP_LESSEQUAL, 0xFF); // stencil should be >= 1
C.r_StencilRef(0x01);
C.r_CullMode(D3DCULL_NONE);
Expand All @@ -28,7 +28,7 @@ void CBlender_SSAO_noMSAA::Compile(CBlender_Compile& C)
C.r_End();
break;
case 1: // depth downsample for HBAO
C.r_Pass("combine_1", "depth_downs", nullptr, false, FALSE);
C.r_Pass("combine_1", "depth_downs", false, FALSE, FALSE);
// C.r_Stencil (TRUE, D3DCMP_LESSEQUAL, 0xFF); // stencil should be >= 1
// C.r_StencilRef (0x01);
C.r_CullMode(D3DCULL_NONE);
Expand Down Expand Up @@ -57,7 +57,7 @@ void CBlender_SSAO_MSAA::Compile(CBlender_Compile& C)
switch (C.iElement)
{
case 0: // combine
C.r_Pass("combine_1", "ssao_calc_msaa", nullptr, false, FALSE);
C.r_Pass("combine_1", "ssao_calc_msaa", false, FALSE, FALSE);
C.r_Stencil(TRUE, D3DCMP_EQUAL, 0x81); // stencil should be >= 1
C.r_StencilRef(0x81);
C.r_CullMode(D3DCULL_NONE);
Expand Down
22 changes: 16 additions & 6 deletions src/Layers/xrRenderPC_GL/gl_rendertarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@

void CRenderTarget::u_setrt(const ref_rt& _1, const ref_rt& _2, const ref_rt& _3, GLuint zb)
{
VERIFY(_1);
dwWidth = _1->dwWidth;
dwHeight = _1->dwHeight;
if (_1)
{
dwWidth = _1->dwWidth;
dwHeight = _1->dwHeight;
}
else
VERIFY3(false, __FUNCTION__, "TODO: implement 'else' path");

GLenum buffers[3] = {GL_NONE};
if (_1)
{
Expand All @@ -44,9 +49,14 @@ void CRenderTarget::u_setrt(const ref_rt& _1, const ref_rt& _2, const ref_rt& _3

void CRenderTarget::u_setrt(const ref_rt& _1, const ref_rt& _2, GLuint zb)
{
VERIFY(_1);
dwWidth = _1->dwWidth;
dwHeight = _1->dwHeight;
if (_1)
{
dwWidth = _1->dwWidth;
dwHeight = _1->dwHeight;
}
else
VERIFY3(false, __FUNCTION__, "TODO: implement 'else' path");

GLenum buffers[2] = {GL_NONE};
if (_1)
{
Expand Down
21 changes: 19 additions & 2 deletions src/Layers/xrRenderPC_GL/rgl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1265,9 +1265,9 @@ HRESULT CRender::shader_compile(
sprintf_s(name_comment, "// %s\n", name);
const char** sources = xr_alloc<const char*>(sources_len);
#ifdef DEBUG
sources[0] = "#version 410\n#pragma optimize (off)\n";
sources[0] = "#version 450\n#pragma optimize (off)\n";
#else
sources[0] = "#version 410\n";
sources[0] = "#version 450\n";
#endif
sources[1] = name_comment;
memcpy(sources + 2, defines, def_len * sizeof(char*));
Expand Down Expand Up @@ -1326,11 +1326,28 @@ HRESULT CRender::shader_compile(

if ((GLboolean)status == GL_FALSE)
{
#ifdef DEBUG
GLint srcLen;
CHK_GL(glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &srcLen));
GLchar* shaderSrc = xr_alloc<GLchar>(srcLen);
CHK_GL(glGetShaderSource(shader, srcLen, nullptr, shaderSrc));
#endif

Msg("! shader compilation failed");
Log("! ", name);
if (_pErrorMsgs)
Log("! error: ", _pErrorMsgs);

#ifdef DEBUG
if (shaderSrc)
{
Log("Shader source:");
Log(shaderSrc);
Log("Shader source end.");
}
#endif

CHK_GL(glDeleteShader(shader));
return E_FAIL;
}

Expand Down

0 comments on commit 137605d

Please sign in to comment.