Vulkan can handle FMT_R11G11B10F textures

This commit is contained in:
Robert Beckebans 2021-03-26 17:39:04 +01:00
parent 9fae3ccdb2
commit 39facaa1ac
5 changed files with 44 additions and 11 deletions

View file

@ -150,11 +150,8 @@ void main( PS_IN fragment, out PS_OUT result )
float2 screenTexCoord = fragment.position.xy * rpWindowCoord.xy;
float ao = 1.0;
#if !defined( USE_VULKAN )
ao = tex2D( samp4, screenTexCoord ).r;
//diffuseColor.rgb *= ao;
#endif
// evaluate diffuse IBL

View file

@ -78,7 +78,7 @@ int BitsForFormat( textureFormat_t format )
case FMT_R32F:
return 32;
case FMT_R11G11B10F:
return 8;
return 32;
// RB end
case FMT_DEPTH:
return 32;

View file

@ -1353,15 +1353,18 @@ void idRenderBackend::DrawSingleInteraction( drawInteraction_t* din, bool useFas
globalImages->brdfLutImage->Bind();
GL_SelectTexture( INTERACTION_TEXUNIT_PROJECTION );
#if defined( USE_VULKAN )
globalImages->whiteImage->Bind();
#else
if( !r_useSSAO.GetBool() )
{
globalImages->whiteImage->Bind();
//globalImages->brdfLutImage->Bind();
}
else
{
globalImages->ambientOcclusionImage[0]->Bind();
}
#endif
// TODO bind the 3 closest probes
GL_SelectTexture( INTERACTION_TEXUNIT_AMBIENT_CUBE1 );

View file

@ -4625,11 +4625,8 @@ static const cgShaderDef_t cg_renderprogs[] =
" float2 screenTexCoord = fragment.position.xy * rpWindowCoord.xy;\n"
"\n"
" float ao = 1.0;\n"
"\n"
"#if !defined( USE_VULKAN )\n"
" ao = tex2D( samp4, screenTexCoord ).r;\n"
" //diffuseColor.rgb *= ao;\n"
"#endif\n"
"\n"
" // evaluate diffuse IBL\n"
"\n"

View file

@ -3,7 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2013-2018 Robert Beckebans
Copyright (C) 2013-2021 Robert Beckebans
Copyright (C) 2016-2017 Dustin Land
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -30,6 +30,8 @@ If you have questions concerning this license or the applicable additional terms
#pragma hdrstop
#include "precompiled.h"
//#include "../../libs/mesa/format_r11g11b10f.h"
/*
================================================================================================
Contains the Image implementation for Vulkan
@ -166,14 +168,12 @@ static VkComponentMapping VK_GetComponentMappingFromTextureFormat( const texture
componentMapping.a = VK_COMPONENT_SWIZZLE_R;
break;
/*
case FMT_R11G11B10F:
componentMapping.r = VK_COMPONENT_SWIZZLE_R;
componentMapping.g = VK_COMPONENT_SWIZZLE_G;
componentMapping.b = VK_COMPONENT_SWIZZLE_B;
componentMapping.a = VK_COMPONENT_SWIZZLE_ONE;
break;
*/
default:
componentMapping.r = VK_COMPONENT_SWIZZLE_R;
@ -678,6 +678,42 @@ void idImage::SubImageUpload( int mipLevel, int x, int y, int z, int width, int
data[ i + 1 ] = imgData[ i ];
}
}
#if 0
else if( opts.format == FMT_R11G11B10F )
{
// convert R11G11B10F to RGBA8 for testing
byte* imgData = ( byte* )pic;
for( int i = 0; i < size; i += 4 )
{
// unpack RGBA8 to 3 floats
union
{
uint32 i;
byte b[4];
} tmp;
tmp.b[0] = imgData[ i + 0 ];
tmp.b[1] = imgData[ i + 1 ];
tmp.b[2] = imgData[ i + 2 ];
tmp.b[3] = imgData[ i + 3 ];
float hdr[3];
r11g11b10f_to_float3( tmp.i, hdr );
// tonemap
hdr[0] = hdr[0] / ( hdr[0] + 1.0f );
hdr[1] = hdr[1] / ( hdr[1] + 1.0f );
hdr[2] = hdr[2] / ( hdr[2] + 1.0f );
// tonemapped to LDR
data[ i + 0 ] = byte( hdr[0] * 255 );
data[ i + 1 ] = byte( hdr[1] * 255 );
data[ i + 2 ] = byte( hdr[2] * 255 );
data[ i + 3 ] = 255;
}
}
#endif
else
{
memcpy( data, pic, size );