mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-02 21:01:01 +00:00
Be more precise with texture remapping to handle integer textures
This commit is contained in:
@@ -58,5 +58,6 @@ DECLARE_EMBED(glsl_ms2array_comp);
|
||||
DECLARE_EMBED(glsl_deptharr2ms_frag);
|
||||
DECLARE_EMBED(glsl_depthms2arr_frag);
|
||||
DECLARE_EMBED(glsl_gles_texsample_h);
|
||||
DECLARE_EMBED(glsl_texremap_frag);
|
||||
|
||||
#undef DECLARE_EMBED
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/******************************************************************************
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Baldur Karlsson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(OPENGL_ES)
|
||||
|
||||
#extension GL_EXT_texture_cube_map_array : enable
|
||||
#extension GL_EXT_texture_buffer : enable
|
||||
|
||||
#endif
|
||||
|
||||
#define TEXDISPLAY_UBO
|
||||
|
||||
#include "glsl_ubos.h"
|
||||
|
||||
#if defined(VULKAN)
|
||||
#include "vk_texsample.h"
|
||||
#elif defined(OPENGL_ES)
|
||||
#include "gles_texsample.h"
|
||||
#elif defined(OPENGL)
|
||||
#include "gl_texsample.h"
|
||||
#endif
|
||||
|
||||
// for GLES compatibility where we must match blit.vert
|
||||
IO_LOCATION(0) in vec2 uv;
|
||||
|
||||
#if UINT_TEX
|
||||
IO_LOCATION(0) out uvec4 color_out;
|
||||
#elif SINT_TEX
|
||||
IO_LOCATION(0) out ivec4 color_out;
|
||||
#else
|
||||
IO_LOCATION(0) out vec4 color_out;
|
||||
#endif
|
||||
|
||||
void main(void)
|
||||
{
|
||||
int texType = (texdisplay.OutputDisplayFormat & TEXDISPLAY_TYPEMASK);
|
||||
|
||||
// calc screen co-ords with origin top left, modified by Position
|
||||
vec2 scr = gl_FragCoord.xy / texdisplay.TextureResolutionPS.xy;
|
||||
|
||||
#if UINT_TEX
|
||||
color_out = SampleTextureUInt4(texType, scr, texdisplay.Slice, texdisplay.MipLevel,
|
||||
texdisplay.SampleIdx, texdisplay.TextureResolutionPS);
|
||||
#elif SINT_TEX
|
||||
color_out = SampleTextureSInt4(texType, scr, texdisplay.Slice, texdisplay.MipLevel,
|
||||
texdisplay.SampleIdx, texdisplay.TextureResolutionPS);
|
||||
#else
|
||||
color_out = SampleTextureFloat4(texType, scr, texdisplay.Slice, texdisplay.MipLevel,
|
||||
texdisplay.SampleIdx, texdisplay.TextureResolutionPS,
|
||||
texdisplay.YUVDownsampleRate, texdisplay.YUVAChannels);
|
||||
#endif
|
||||
|
||||
if(texdisplay.Channels == vec4(1, 0, 0, 0))
|
||||
{
|
||||
color_out.y = color_out.x;
|
||||
color_out.z = color_out.x;
|
||||
color_out.w = color_out.x;
|
||||
}
|
||||
else if(texdisplay.Channels == vec4(0, 1, 0, 0))
|
||||
{
|
||||
color_out.x = color_out.y;
|
||||
color_out.z = color_out.y;
|
||||
color_out.w = color_out.y;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/******************************************************************************
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Baldur Karlsson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include "hlsl_cbuffers.h"
|
||||
#include "hlsl_texsample.h"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_Position;
|
||||
float4 tex : TEXCOORD0;
|
||||
};
|
||||
|
||||
float4 RENDERDOC_TexRemapFloat(v2f IN) : SV_Target0
|
||||
{
|
||||
return SampleTextureFloat4(OutputDisplayFormat & TEXDISPLAY_TYPEMASK,
|
||||
(ScalePS < 1 && MipLevel == 0), IN.tex.xy, Slice, MipLevel, SampleIdx,
|
||||
TextureResolutionPS, YUVDownsampleRate, YUVAChannels);
|
||||
}
|
||||
|
||||
uint4 RENDERDOC_TexRemapUInt(v2f IN) : SV_Target0
|
||||
{
|
||||
return SampleTextureUInt4(OutputDisplayFormat & TEXDISPLAY_TYPEMASK, IN.tex.xy, Slice, MipLevel,
|
||||
SampleIdx, TextureResolutionPS);
|
||||
}
|
||||
|
||||
int4 RENDERDOC_TexRemapSInt(v2f IN) : SV_Target0
|
||||
{
|
||||
return SampleTextureInt4(OutputDisplayFormat & TEXDISPLAY_TYPEMASK, IN.tex.xy, Slice, MipLevel,
|
||||
SampleIdx, TextureResolutionPS);
|
||||
}
|
||||
@@ -112,6 +112,7 @@ RESOURCE_mesh_hlsl TYPE_EMBED "hlsl/mesh.hlsl"
|
||||
RESOURCE_texdisplay_hlsl TYPE_EMBED "hlsl/texdisplay.hlsl"
|
||||
RESOURCE_pixelhistory_hlsl TYPE_EMBED "hlsl/pixelhistory.hlsl"
|
||||
RESOURCE_quadoverdraw_hlsl TYPE_EMBED "hlsl/quadoverdraw.hlsl"
|
||||
RESOURCE_texremap_hlsl TYPE_EMBED "hlsl/texremap.hlsl"
|
||||
|
||||
RESOURCE_sourcecodepro_ttf TYPE_EMBED "sourcecodepro.ttf"
|
||||
|
||||
@@ -143,6 +144,7 @@ RESOURCE_glsl_gles_texsample_h TYPE_EMBED "glsl/gles_texsample.h"
|
||||
RESOURCE_glsl_gltext_vert TYPE_EMBED "glsl/gltext.vert"
|
||||
RESOURCE_glsl_gltext_frag TYPE_EMBED "glsl/gltext.frag"
|
||||
RESOURCE_glsl_glsl_globals_h TYPE_EMBED "glsl/glsl_globals.h"
|
||||
RESOURCE_glsl_texremap_frag TYPE_EMBED "glsl/texremap.frag"
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#define RESOURCE_texdisplay_hlsl 108
|
||||
#define RESOURCE_pixelhistory_hlsl 109
|
||||
#define RESOURCE_quadoverdraw_hlsl 110
|
||||
#define RESOURCE_texremap_hlsl 111
|
||||
|
||||
#define RESOURCE_sourcecodepro_ttf 301
|
||||
|
||||
@@ -46,6 +47,7 @@
|
||||
#define RESOURCE_glsl_gltext_vert 429
|
||||
#define RESOURCE_glsl_gltext_frag 430
|
||||
#define RESOURCE_glsl_glsl_globals_h 440
|
||||
#define RESOURCE_glsl_texremap_frag 441
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user