From 45e554b7e85555bfa6518eb92ef6a2c0afb9083f Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Fri, 22 Mar 2019 11:51:37 -0700 Subject: Updated core + fixed sampler type mismatch issue in texturing tests --- Tests/TestApp/assets/Shaders/TextureIntTestDX.psh | 2 +- Tests/TestApp/assets/Shaders/TextureIntTestGL.psh | 26 +++++++++++----------- Tests/TestApp/src/TestTexturing.cpp | 27 +++++++++++++++++++---- 3 files changed, 37 insertions(+), 18 deletions(-) (limited to 'Tests/TestApp') diff --git a/Tests/TestApp/assets/Shaders/TextureIntTestDX.psh b/Tests/TestApp/assets/Shaders/TextureIntTestDX.psh index 1d785ab..4dfc67f 100644 --- a/Tests/TestApp/assets/Shaders/TextureIntTestDX.psh +++ b/Tests/TestApp/assets/Shaders/TextureIntTestDX.psh @@ -1,5 +1,5 @@ -Texture2D g_tex2DTest : register(t4); +Texture2D g_tex2DTest : register(t4); struct VSOut { diff --git a/Tests/TestApp/assets/Shaders/TextureIntTestGL.psh b/Tests/TestApp/assets/Shaders/TextureIntTestGL.psh index 003426d..23c3532 100644 --- a/Tests/TestApp/assets/Shaders/TextureIntTestGL.psh +++ b/Tests/TestApp/assets/Shaders/TextureIntTestGL.psh @@ -1,7 +1,7 @@ // Fragment Shader – file "minimal.frag" layout(location = 1)in vec2 in_UV; -uniform isampler2D g_tex2DTest; +uniform SAMPLER_TYPE g_tex2DTest; layout(location = 0) out vec4 out_Color; @@ -9,25 +9,25 @@ void main(void) { vec2 TexSize; - TexSize = vec2( textureSize(g_tex2DTest, 0) ); - ivec4 texel0 = texelFetch(g_tex2DTest, ivec2(in_UV*TexSize), 0); + TexSize = vec2(textureSize(g_tex2DTest, 0)); + vec4 texel0 = vec4(texelFetch(g_tex2DTest, ivec2(in_UV*TexSize), 0)); - TexSize = vec2( textureSize(g_tex2DTest, 2) ); - ivec4 texel1 = texelFetch(g_tex2DTest, ivec2(in_UV*TexSize), 2); + TexSize = vec2(textureSize(g_tex2DTest, 2)); + vec4 texel1 = vec4(texelFetch(g_tex2DTest, ivec2(in_UV*TexSize), 2)); - TexSize = vec2( textureSize(g_tex2DTest, 4) ); - ivec4 texel2 = texelFetch(g_tex2DTest, ivec2(in_UV*TexSize), 4); + TexSize = vec2(textureSize(g_tex2DTest, 4)); + vec4 texel2 = vec4(texelFetch(g_tex2DTest, ivec2(in_UV*TexSize), 4)); - TexSize = vec2( textureSize(g_tex2DTest, 5) ); - ivec4 texel3 = texelFetch(g_tex2DTest, ivec2(in_UV*TexSize), 5); + TexSize = vec2(textureSize(g_tex2DTest, 5)); + vec4 texel3 = vec4(texelFetch(g_tex2DTest, ivec2(in_UV*TexSize), 5)); if( in_UV.x < 0.5 && in_UV.y < 0.5 ) - out_Color = vec4(texel0) / 127.f; + out_Color = texel0 / 127.f; else if( in_UV.x > 0.5 && in_UV.y < 0.5 ) - out_Color = vec4(texel1) / 127.f; + out_Color = texel1 / 127.f; else if( in_UV.x < 0.5 && in_UV.y > 0.5 ) - out_Color = vec4(texel2) / 127.f; + out_Color = texel2 / 127.f; else - out_Color = vec4(texel3) / 127.f; + out_Color = texel3 / 127.f; } diff --git a/Tests/TestApp/src/TestTexturing.cpp b/Tests/TestApp/src/TestTexturing.cpp index d57e540..5c2ccf8 100644 --- a/Tests/TestApp/src/TestTexturing.cpp +++ b/Tests/TestApp/src/TestTexturing.cpp @@ -29,6 +29,7 @@ #include "TestTexturing.h" #include "GraphicsUtilities.h" #include "BasicShaderSourceStreamFactory.h" +#include "ShaderMacroHelper.h" using namespace Diligent; @@ -179,14 +180,32 @@ void TestTexturing::Init( IRenderDevice *pDevice, IDeviceContext *pDeviceContext m_pRenderDevice->CreateShader( CreationAttrs, &pVS ); } - bool bIsIntTexture = PixelFormatAttribs.ComponentType == COMPONENT_TYPE_UINT || - PixelFormatAttribs.ComponentType == COMPONENT_TYPE_SINT; + bool bIsIntTexture = false; { - if( bIsIntTexture ) - CreationAttrs.FilePath = bUseGLSL ? "Shaders\\TextureIntTestGL.psh" : "Shaders\\TextureIntTestDX.psh"; + ShaderMacroHelper Macros; + if (PixelFormatAttribs.ComponentType == COMPONENT_TYPE_UINT || + PixelFormatAttribs.ComponentType == COMPONENT_TYPE_SINT) + { + if (bUseGLSL) + { + CreationAttrs.FilePath = "Shaders\\TextureIntTestGL.psh"; + Macros.AddShaderMacro("SAMPLER_TYPE", PixelFormatAttribs.ComponentType == COMPONENT_TYPE_UINT ? "usampler2D" : "isampler2D"); + } + else + { + CreationAttrs.FilePath = "Shaders\\TextureIntTestDX.psh"; + Macros.AddShaderMacro("DATA_TYPE", PixelFormatAttribs.ComponentType == COMPONENT_TYPE_UINT ? "uint4" : "int4"); + } + + bIsIntTexture = true; + } else + { CreationAttrs.FilePath = bUseGLSL ? "Shaders\\TextureTestGL.psh" : "Shaders\\TextureTestDX.psh"; + bIsIntTexture = false; + } CreationAttrs.Desc.ShaderType = SHADER_TYPE_PIXEL; + CreationAttrs.Macros = Macros; m_pRenderDevice->CreateShader( CreationAttrs, &pPS ); } -- cgit v1.2.3