mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 06:34:10 +00:00
Fixed dynamic shadows on Vulkan. Enabled PBR GGX for interaction shaders
This commit is contained in:
parent
e6960cb876
commit
ab5b233e8e
9 changed files with 204 additions and 213 deletions
|
@ -96,7 +96,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
half3 halfAngleVector = normalize( lightVector + viewVector );
|
||||
half hdotN = clamp( dot3( halfAngleVector, localNormal ), 0.0, 1.0 );
|
||||
|
||||
#if 0 //defined(USE_PBR)
|
||||
#if 1 //defined(USE_PBR)
|
||||
|
||||
#if 0 //defined(USE_METALNESS)
|
||||
const half metallic = specMapSRGB.g;
|
||||
|
@ -165,7 +165,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
//half3 diffuseColor = mix( diffuseMap, F0, metal ) * rpDiffuseModifier.xyz;
|
||||
half3 diffuseBRDF = diffuseColor * lambert * sRGBToLinearRGB( rpDiffuseModifier.xyz );
|
||||
|
||||
result.color.xyz = ( diffuseBRDF + specularBRDF ) * lightColor * fragment.color.rgb * shadow;
|
||||
result.color.xyz = ( diffuseBRDF + specularBRDF ) * lightColor * fragment.color.rgb;
|
||||
result.color.w = 1.0;
|
||||
|
||||
#else
|
||||
|
|
|
@ -276,7 +276,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
half3 halfAngleVector = normalize( lightVector + viewVector );
|
||||
half hdotN = clamp( dot3( halfAngleVector, localNormal ), 0.0, 1.0 );
|
||||
|
||||
#if 0 //defined(USE_PBR)
|
||||
#if 1 //defined(USE_PBR)
|
||||
|
||||
#if 0 //defined(USE_METALNESS)
|
||||
const half metallic = specMapSRGB.g;
|
||||
|
|
|
@ -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-2015 Robert Beckebans
|
||||
Copyright (C) 2013-2019 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").
|
||||
|
@ -682,7 +682,6 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf )
|
|||
pc.c_drawIndexes += surf->numIndexes;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=========================================================================================================
|
||||
|
||||
|
@ -717,6 +716,94 @@ void idRenderBackend::GL_EndFrame()
|
|||
glFlush();
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
GL_BlockingSwapBuffers
|
||||
|
||||
We want to exit this with the GPU idle, right at vsync
|
||||
=============
|
||||
*/
|
||||
void idRenderBackend::GL_BlockingSwapBuffers()
|
||||
{
|
||||
RENDERLOG_PRINTF( "***************** GL_BlockingSwapBuffers *****************\n\n\n" );
|
||||
|
||||
const int beforeFinish = Sys_Milliseconds();
|
||||
|
||||
if( !glConfig.syncAvailable )
|
||||
{
|
||||
glFinish();
|
||||
}
|
||||
|
||||
const int beforeSwap = Sys_Milliseconds();
|
||||
if( r_showSwapBuffers.GetBool() && beforeSwap - beforeFinish > 1 )
|
||||
{
|
||||
common->Printf( "%i msec to glFinish\n", beforeSwap - beforeFinish );
|
||||
}
|
||||
|
||||
GLimp_SwapBuffers();
|
||||
|
||||
const int beforeFence = Sys_Milliseconds();
|
||||
if( r_showSwapBuffers.GetBool() && beforeFence - beforeSwap > 1 )
|
||||
{
|
||||
common->Printf( "%i msec to swapBuffers\n", beforeFence - beforeSwap );
|
||||
}
|
||||
|
||||
if( glConfig.syncAvailable )
|
||||
{
|
||||
swapIndex ^= 1;
|
||||
|
||||
if( glIsSync( renderSync[swapIndex] ) )
|
||||
{
|
||||
glDeleteSync( renderSync[swapIndex] );
|
||||
}
|
||||
// draw something tiny to ensure the sync is after the swap
|
||||
const int start = Sys_Milliseconds();
|
||||
glScissor( 0, 0, 1, 1 );
|
||||
glEnable( GL_SCISSOR_TEST );
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
renderSync[swapIndex] = glFenceSync( GL_SYNC_GPU_COMMANDS_COMPLETE, 0 );
|
||||
const int end = Sys_Milliseconds();
|
||||
if( r_showSwapBuffers.GetBool() && end - start > 1 )
|
||||
{
|
||||
common->Printf( "%i msec to start fence\n", end - start );
|
||||
}
|
||||
|
||||
GLsync syncToWaitOn;
|
||||
if( r_syncEveryFrame.GetBool() )
|
||||
{
|
||||
syncToWaitOn = renderSync[swapIndex];
|
||||
}
|
||||
else
|
||||
{
|
||||
syncToWaitOn = renderSync[!swapIndex];
|
||||
}
|
||||
|
||||
if( glIsSync( syncToWaitOn ) )
|
||||
{
|
||||
for( GLenum r = GL_TIMEOUT_EXPIRED; r == GL_TIMEOUT_EXPIRED; )
|
||||
{
|
||||
r = glClientWaitSync( syncToWaitOn, GL_SYNC_FLUSH_COMMANDS_BIT, 1000 * 1000 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const int afterFence = Sys_Milliseconds();
|
||||
if( r_showSwapBuffers.GetBool() && afterFence - beforeFence > 1 )
|
||||
{
|
||||
common->Printf( "%i msec to wait on fence\n", afterFence - beforeFence );
|
||||
}
|
||||
|
||||
const int64 exitBlockTime = Sys_Microseconds();
|
||||
|
||||
static int64 prevBlockTime;
|
||||
if( r_showSwapBuffers.GetBool() && prevBlockTime )
|
||||
{
|
||||
const int delta = ( int )( exitBlockTime - prevBlockTime );
|
||||
common->Printf( "blockToBlock: %i\n", delta );
|
||||
}
|
||||
prevBlockTime = exitBlockTime;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
GL_SetDefaultState
|
||||
|
@ -1427,6 +1514,76 @@ void idRenderBackend::CheckCVars()
|
|||
// RB end
|
||||
}
|
||||
|
||||
/*
|
||||
============================================================================
|
||||
|
||||
RENDER BACK END THREAD FUNCTIONS
|
||||
|
||||
============================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
=============
|
||||
idRenderBackend::DrawFlickerBox
|
||||
=============
|
||||
*/
|
||||
void idRenderBackend::DrawFlickerBox()
|
||||
{
|
||||
if( !r_drawFlickerBox.GetBool() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if( tr.frameCount & 1 )
|
||||
{
|
||||
glClearColor( 1, 0, 0, 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
glClearColor( 0, 1, 0, 1 );
|
||||
}
|
||||
glScissor( 0, 0, 256, 256 );
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
idRenderBackend::SetBuffer
|
||||
=============
|
||||
*/
|
||||
void idRenderBackend::SetBuffer( const void* data )
|
||||
{
|
||||
// see which draw buffer we want to render the frame to
|
||||
|
||||
const setBufferCommand_t* cmd = ( const setBufferCommand_t* )data;
|
||||
|
||||
RENDERLOG_PRINTF( "---------- RB_SetBuffer ---------- to buffer # %d\n", cmd->buffer );
|
||||
|
||||
GL_Scissor( 0, 0, tr.GetWidth(), tr.GetHeight() );
|
||||
|
||||
// clear screen for debugging
|
||||
// automatically enable this with several other debug tools
|
||||
// that might leave unrendered portions of the screen
|
||||
if( r_clear.GetFloat() || idStr::Length( r_clear.GetString() ) != 1 || r_singleArea.GetBool() || r_showOverDraw.GetBool() )
|
||||
{
|
||||
float c[3];
|
||||
if( sscanf( r_clear.GetString(), "%f %f %f", &c[0], &c[1], &c[2] ) == 3 )
|
||||
{
|
||||
GL_Clear( true, false, false, 0, c[0], c[1], c[2], 1.0f, true );
|
||||
}
|
||||
else if( r_clear.GetInteger() == 2 )
|
||||
{
|
||||
GL_Clear( true, false, false, 0, 0.0f, 0.0f, 0.0f, 1.0f, true );
|
||||
}
|
||||
else if( r_showOverDraw.GetBool() )
|
||||
{
|
||||
GL_Clear( true, false, false, 0, 1.0f, 1.0f, 1.0f, 1.0f, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
GL_Clear( true, false, false, 0, 0.4f, 0.0f, 0.25f, 1.0f, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==============================================================================================
|
||||
|
@ -1435,12 +1592,11 @@ STENCIL SHADOW RENDERING
|
|||
|
||||
==============================================================================================
|
||||
*/
|
||||
extern idCVar r_useStencilShadowPreload;
|
||||
|
||||
/*
|
||||
==================
|
||||
=====================
|
||||
idRenderBackend::DrawStencilShadowPass
|
||||
==================
|
||||
=====================
|
||||
*/
|
||||
void idRenderBackend::DrawStencilShadowPass( const drawSurf_t* drawSurf, const bool renderZPass )
|
||||
{
|
||||
|
@ -1476,7 +1632,7 @@ void idRenderBackend::DrawStencilShadowPass( const drawSurf_t* drawSurf, const b
|
|||
idLib::Warning( "DrawStencilShadowPass, vertexBuffer == NULL" );
|
||||
return;
|
||||
}
|
||||
vertexBuffer = &vertexCache.frameData[vertexCache.drawListNum].vertexBuffer;
|
||||
vertexBuffer = &vertexCache.frameData[ vertexCache.drawListNum ].vertexBuffer;
|
||||
}
|
||||
const int vertOffset = ( int )( vbHandle >> VERTCACHE_OFFSET_SHIFT ) & VERTCACHE_OFFSET_MASK;
|
||||
|
||||
|
@ -1495,7 +1651,7 @@ void idRenderBackend::DrawStencilShadowPass( const drawSurf_t* drawSurf, const b
|
|||
idLib::Warning( "DrawStencilShadowPass, indexBuffer == NULL" );
|
||||
return;
|
||||
}
|
||||
indexBuffer = &vertexCache.frameData[vertexCache.drawListNum].indexBuffer;
|
||||
indexBuffer = &vertexCache.frameData[ vertexCache.drawListNum ].indexBuffer;
|
||||
}
|
||||
const uint64 indexOffset = ( int )( ibHandle >> VERTCACHE_OFFSET_SHIFT ) & VERTCACHE_OFFSET_MASK;
|
||||
|
||||
|
@ -1629,166 +1785,6 @@ void idRenderBackend::DrawStencilShadowPass( const drawSurf_t* drawSurf, const b
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
============================================================================
|
||||
|
||||
RENDER BACK END THREAD FUNCTIONS
|
||||
|
||||
============================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
=============
|
||||
idRenderBackend::DrawFlickerBox
|
||||
=============
|
||||
*/
|
||||
void idRenderBackend::DrawFlickerBox()
|
||||
{
|
||||
if( !r_drawFlickerBox.GetBool() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if( tr.frameCount & 1 )
|
||||
{
|
||||
glClearColor( 1, 0, 0, 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
glClearColor( 0, 1, 0, 1 );
|
||||
}
|
||||
glScissor( 0, 0, 256, 256 );
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
idRenderBackend::SetBuffer
|
||||
=============
|
||||
*/
|
||||
void idRenderBackend::SetBuffer( const void* data )
|
||||
{
|
||||
// see which draw buffer we want to render the frame to
|
||||
|
||||
const setBufferCommand_t* cmd = ( const setBufferCommand_t* )data;
|
||||
|
||||
RENDERLOG_PRINTF( "---------- RB_SetBuffer ---------- to buffer # %d\n", cmd->buffer );
|
||||
|
||||
GL_Scissor( 0, 0, tr.GetWidth(), tr.GetHeight() );
|
||||
|
||||
// clear screen for debugging
|
||||
// automatically enable this with several other debug tools
|
||||
// that might leave unrendered portions of the screen
|
||||
if( r_clear.GetFloat() || idStr::Length( r_clear.GetString() ) != 1 || r_singleArea.GetBool() || r_showOverDraw.GetBool() )
|
||||
{
|
||||
float c[3];
|
||||
if( sscanf( r_clear.GetString(), "%f %f %f", &c[0], &c[1], &c[2] ) == 3 )
|
||||
{
|
||||
GL_Clear( true, false, false, 0, c[0], c[1], c[2], 1.0f, true );
|
||||
}
|
||||
else if( r_clear.GetInteger() == 2 )
|
||||
{
|
||||
GL_Clear( true, false, false, 0, 0.0f, 0.0f, 0.0f, 1.0f, true );
|
||||
}
|
||||
else if( r_showOverDraw.GetBool() )
|
||||
{
|
||||
GL_Clear( true, false, false, 0, 1.0f, 1.0f, 1.0f, 1.0f, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
GL_Clear( true, false, false, 0, 0.4f, 0.0f, 0.25f, 1.0f, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
GL_BlockingSwapBuffers
|
||||
|
||||
We want to exit this with the GPU idle, right at vsync
|
||||
=============
|
||||
*/
|
||||
void idRenderBackend::GL_BlockingSwapBuffers()
|
||||
{
|
||||
RENDERLOG_PRINTF( "***************** GL_BlockingSwapBuffers *****************\n\n\n" );
|
||||
|
||||
const int beforeFinish = Sys_Milliseconds();
|
||||
|
||||
if( !glConfig.syncAvailable )
|
||||
{
|
||||
glFinish();
|
||||
}
|
||||
|
||||
const int beforeSwap = Sys_Milliseconds();
|
||||
if( r_showSwapBuffers.GetBool() && beforeSwap - beforeFinish > 1 )
|
||||
{
|
||||
common->Printf( "%i msec to glFinish\n", beforeSwap - beforeFinish );
|
||||
}
|
||||
|
||||
GLimp_SwapBuffers();
|
||||
|
||||
const int beforeFence = Sys_Milliseconds();
|
||||
if( r_showSwapBuffers.GetBool() && beforeFence - beforeSwap > 1 )
|
||||
{
|
||||
common->Printf( "%i msec to swapBuffers\n", beforeFence - beforeSwap );
|
||||
}
|
||||
|
||||
if( glConfig.syncAvailable )
|
||||
{
|
||||
swapIndex ^= 1;
|
||||
|
||||
if( glIsSync( renderSync[swapIndex] ) )
|
||||
{
|
||||
glDeleteSync( renderSync[swapIndex] );
|
||||
}
|
||||
// draw something tiny to ensure the sync is after the swap
|
||||
const int start = Sys_Milliseconds();
|
||||
glScissor( 0, 0, 1, 1 );
|
||||
glEnable( GL_SCISSOR_TEST );
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
renderSync[swapIndex] = glFenceSync( GL_SYNC_GPU_COMMANDS_COMPLETE, 0 );
|
||||
const int end = Sys_Milliseconds();
|
||||
if( r_showSwapBuffers.GetBool() && end - start > 1 )
|
||||
{
|
||||
common->Printf( "%i msec to start fence\n", end - start );
|
||||
}
|
||||
|
||||
GLsync syncToWaitOn;
|
||||
if( r_syncEveryFrame.GetBool() )
|
||||
{
|
||||
syncToWaitOn = renderSync[swapIndex];
|
||||
}
|
||||
else
|
||||
{
|
||||
syncToWaitOn = renderSync[!swapIndex];
|
||||
}
|
||||
|
||||
if( glIsSync( syncToWaitOn ) )
|
||||
{
|
||||
for( GLenum r = GL_TIMEOUT_EXPIRED; r == GL_TIMEOUT_EXPIRED; )
|
||||
{
|
||||
r = glClientWaitSync( syncToWaitOn, GL_SYNC_FLUSH_COMMANDS_BIT, 1000 * 1000 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const int afterFence = Sys_Milliseconds();
|
||||
if( r_showSwapBuffers.GetBool() && afterFence - beforeFence > 1 )
|
||||
{
|
||||
common->Printf( "%i msec to wait on fence\n", afterFence - beforeFence );
|
||||
}
|
||||
|
||||
const int64 exitBlockTime = Sys_Microseconds();
|
||||
|
||||
static int64 prevBlockTime;
|
||||
if( r_showSwapBuffers.GetBool() && prevBlockTime )
|
||||
{
|
||||
const int delta = ( int )( exitBlockTime - prevBlockTime );
|
||||
common->Printf( "blockToBlock: %i\n", delta );
|
||||
}
|
||||
prevBlockTime = exitBlockTime;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
idRenderBackend::idRenderBackend
|
||||
|
|
|
@ -214,13 +214,13 @@ void idRenderProgManager::Init()
|
|||
int vIndex = -1;
|
||||
if( builtins[ i ].stages & SHADER_STAGE_VERTEX )
|
||||
{
|
||||
vIndex = FindShader( builtins[ i ].name, SHADER_STAGE_VERTEX, builtins[i].nameOutSuffix, shaderFeatures, true );
|
||||
vIndex = FindShader( builtins[ i ].name, SHADER_STAGE_VERTEX, builtins[i].nameOutSuffix, shaderFeatures, true, builtins[i].layout );
|
||||
}
|
||||
|
||||
int fIndex = -1;
|
||||
if( builtins[ i ].stages & SHADER_STAGE_FRAGMENT )
|
||||
{
|
||||
fIndex = FindShader( builtins[ i ].name, SHADER_STAGE_FRAGMENT, builtins[i].nameOutSuffix, shaderFeatures, true );
|
||||
fIndex = FindShader( builtins[ i ].name, SHADER_STAGE_FRAGMENT, builtins[i].nameOutSuffix, shaderFeatures, true, builtins[i].layout );
|
||||
}
|
||||
|
||||
//idLib::Printf( "Loading GLSL program %i %i %i\n", i, vIndex, fIndex );
|
||||
|
@ -318,7 +318,7 @@ void idRenderProgManager::Shutdown()
|
|||
idRenderProgManager::FindVertexShader
|
||||
================================================================================================
|
||||
*/
|
||||
int idRenderProgManager::FindShader( const char* name, rpStage_t stage, const char* nameOutSuffix, uint32 features, bool builtin )
|
||||
int idRenderProgManager::FindShader( const char* name, rpStage_t stage, const char* nameOutSuffix, uint32 features, bool builtin, vertexLayoutType_t vertexLayout )
|
||||
{
|
||||
idStr shaderName( name );
|
||||
shaderName.StripFileExtension();
|
||||
|
@ -340,6 +340,7 @@ int idRenderProgManager::FindShader( const char* name, rpStage_t stage, const ch
|
|||
shader.shaderFeatures = features;
|
||||
shader.builtin = builtin;
|
||||
shader.stage = stage;
|
||||
shader.vertexLayout = vertexLayout;
|
||||
|
||||
int index = shaders.Append( shader );
|
||||
LoadShader( index, stage );
|
||||
|
|
|
@ -255,7 +255,7 @@ public:
|
|||
void SetRenderParm( renderParm_t rp, const float* value );
|
||||
void SetRenderParms( renderParm_t rp, const float* values, int numValues );
|
||||
|
||||
int FindShader( const char* name, rpStage_t stage, const char* nameOutSuffix, uint32 features, bool builtin );
|
||||
int FindShader( const char* name, rpStage_t stage, const char* nameOutSuffix, uint32 features, bool builtin, vertexLayoutType_t vertexLayout = LAYOUT_DRAW_VERT );
|
||||
|
||||
void BindProgram( int progIndex );
|
||||
|
||||
|
@ -656,7 +656,7 @@ private:
|
|||
void LoadShader( int index, rpStage_t stage );
|
||||
|
||||
idStr StripDeadCode( const idStr& in, const char* name, const idStrList& compileMacros, bool builtin );
|
||||
idStr ConvertCG2GLSL( const idStr& in, const char* name, rpStage_t stage, idStr& layout, bool vkGLSL, bool hasGPUSkinning );
|
||||
idStr ConvertCG2GLSL( const idStr& in, const char* name, rpStage_t stage, idStr& outLayout, bool vkGLSL, bool hasGPUSkinning, vertexLayoutType_t vertexLayout );
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -775,12 +775,14 @@ private:
|
|||
shader_t() :
|
||||
shaderFeatures( 0 ),
|
||||
builtin( false ),
|
||||
vertexLayout( LAYOUT_DRAW_VERT ),
|
||||
module( VK_NULL_HANDLE ) {}
|
||||
idStr name;
|
||||
idStr nameOutSuffix;
|
||||
uint32 shaderFeatures; // RB: Cg compile macros
|
||||
bool builtin; // RB: part of the core shaders built into the executable
|
||||
rpStage_t stage;
|
||||
vertexLayoutType_t vertexLayout;
|
||||
VkShaderModule module;
|
||||
idList<rpBinding_t> bindings;
|
||||
idList<int> parmIndices;
|
||||
|
|
|
@ -911,7 +911,7 @@ struct inOutVariable_t
|
|||
ParseInOutStruct
|
||||
========================
|
||||
*/
|
||||
void ParseInOutStruct( idLexer& src, int attribType, int attribIgnoreType, idList< inOutVariable_t >& inOutVars )
|
||||
void ParseInOutStruct( idLexer& src, int attribType, int attribIgnoreType, idList< inOutVariable_t >& inOutVars, bool in_Position4 )
|
||||
{
|
||||
src.ExpectTokenString( "{" );
|
||||
|
||||
|
@ -997,7 +997,7 @@ void ParseInOutStruct( idLexer& src, int attribType, int attribIgnoreType, idLis
|
|||
if( glConfig.driverType == GLDRV_VULKAN )
|
||||
{
|
||||
// RB: HACK change vec4 in_Position to vec3
|
||||
if( var.nameGLSL == "in_Position" && var.type == "vec4" )
|
||||
if( !in_Position4 && var.nameGLSL == "in_Position" && var.type == "vec4" )
|
||||
{
|
||||
var.type = "vec3";
|
||||
}
|
||||
|
@ -1014,7 +1014,7 @@ void ParseInOutStruct( idLexer& src, int attribType, int attribIgnoreType, idLis
|
|||
ConvertCG2GLSL
|
||||
========================
|
||||
*/
|
||||
idStr idRenderProgManager::ConvertCG2GLSL( const idStr& in, const char* name, rpStage_t stage, idStr& layout, bool vkGLSL, bool hasGPUSkinning )
|
||||
idStr idRenderProgManager::ConvertCG2GLSL( const idStr& in, const char* name, rpStage_t stage, idStr& outLayout, bool vkGLSL, bool hasGPUSkinning, vertexLayoutType_t vertexLayout )
|
||||
{
|
||||
idStr program;
|
||||
program.ReAllocate( in.Length() * 2, false );
|
||||
|
@ -1026,6 +1026,8 @@ idStr idRenderProgManager::ConvertCG2GLSL( const idStr& in, const char* name, rp
|
|||
|
||||
idLexer src( LEXFL_NOFATALERRORS );
|
||||
src.LoadMemory( in.c_str(), in.Length(), name );
|
||||
|
||||
bool in_Position4 = ( vertexLayout == LAYOUT_DRAW_SHADOW_VERT ) || ( vertexLayout == LAYOUT_DRAW_SHADOW_VERT_SKINNED );
|
||||
|
||||
bool inMain = false;
|
||||
bool justEnteredMain = false;
|
||||
|
@ -1135,7 +1137,7 @@ idStr idRenderProgManager::ConvertCG2GLSL( const idStr& in, const char* name, rp
|
|||
{
|
||||
if( src.CheckTokenString( "VS_IN" ) )
|
||||
{
|
||||
ParseInOutStruct( src, AT_VS_IN, 0, varsIn );
|
||||
ParseInOutStruct( src, AT_VS_IN, 0, varsIn, in_Position4 );
|
||||
|
||||
program += "\n\n";
|
||||
for( int i = 0; i < varsIn.Num(); i++ )
|
||||
|
@ -1158,7 +1160,7 @@ idStr idRenderProgManager::ConvertCG2GLSL( const idStr& in, const char* name, rp
|
|||
else if( src.CheckTokenString( "VS_OUT" ) )
|
||||
{
|
||||
// RB
|
||||
ParseInOutStruct( src, AT_VS_OUT, AT_VS_OUT_RESERVED, varsOut );
|
||||
ParseInOutStruct( src, AT_VS_OUT, AT_VS_OUT_RESERVED, varsOut, in_Position4 );
|
||||
|
||||
program += "\n";
|
||||
int numDeclareOut = 0;
|
||||
|
@ -1183,7 +1185,7 @@ idStr idRenderProgManager::ConvertCG2GLSL( const idStr& in, const char* name, rp
|
|||
}
|
||||
else if( src.CheckTokenString( "PS_IN" ) )
|
||||
{
|
||||
ParseInOutStruct( src, AT_PS_IN, AT_PS_IN_RESERVED, varsIn );
|
||||
ParseInOutStruct( src, AT_PS_IN, AT_PS_IN_RESERVED, varsIn, in_Position4 );
|
||||
|
||||
program += "\n\n";
|
||||
int numDeclareOut = 0;
|
||||
|
@ -1214,7 +1216,7 @@ idStr idRenderProgManager::ConvertCG2GLSL( const idStr& in, const char* name, rp
|
|||
else if( src.CheckTokenString( "PS_OUT" ) )
|
||||
{
|
||||
// RB begin
|
||||
ParseInOutStruct( src, AT_PS_OUT, AT_PS_OUT_RESERVED, varsOut );
|
||||
ParseInOutStruct( src, AT_PS_OUT, AT_PS_OUT_RESERVED, varsOut, in_Position4 );
|
||||
|
||||
program += "\n";
|
||||
for( int i = 0; i < varsOut.Num(); i++ )
|
||||
|
@ -1291,7 +1293,7 @@ idStr idRenderProgManager::ConvertCG2GLSL( const idStr& in, const char* name, rp
|
|||
newline[len - 0] = '\0';
|
||||
|
||||
// RB: add this to every vertex shader
|
||||
if( inMain && !justEnteredMain && ( stage == SHADER_STAGE_VERTEX ) && vkGLSL )
|
||||
if( inMain && !justEnteredMain && ( stage == SHADER_STAGE_VERTEX ) && vkGLSL && !in_Position4 )
|
||||
{
|
||||
program += "\n\tvec4 position4 = vec4( in_Position, 1.0 );\n";
|
||||
justEnteredMain = true;
|
||||
|
@ -1408,7 +1410,7 @@ idStr idRenderProgManager::ConvertCG2GLSL( const idStr& in, const char* name, rp
|
|||
RB: HACK use position4 instead of in_Position directly
|
||||
because I can't figure out how to do strides with Vulkan
|
||||
*/
|
||||
if( vkGLSL && ( varsIn[i].nameGLSL == "in_Position" ) )
|
||||
if( !in_Position4 && vkGLSL && ( varsIn[i].nameGLSL == "in_Position" ) )
|
||||
{
|
||||
program += "position4";
|
||||
}
|
||||
|
@ -1511,8 +1513,6 @@ idStr idRenderProgManager::ConvertCG2GLSL( const idStr& in, const char* name, rp
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1612,32 +1612,32 @@ idStr idRenderProgManager::ConvertCG2GLSL( const idStr& in, const char* name, rp
|
|||
|
||||
out += program;
|
||||
|
||||
layout += "uniforms [\n";
|
||||
outLayout += "uniforms [\n";
|
||||
for( int i = 0; i < uniformList.Num(); i++ )
|
||||
{
|
||||
layout += "\t";
|
||||
layout += uniformList[i];
|
||||
layout += "\n";
|
||||
outLayout += "\t";
|
||||
outLayout += uniformList[i];
|
||||
outLayout += "\n";
|
||||
}
|
||||
layout += "]\n";
|
||||
outLayout += "]\n";
|
||||
|
||||
layout += "bindings [\n";
|
||||
outLayout += "bindings [\n";
|
||||
|
||||
if( uniformList.Num() > 0 )
|
||||
{
|
||||
layout += "\tubo\n";
|
||||
outLayout += "\tubo\n";
|
||||
}
|
||||
|
||||
if( hasGPUSkinning && ( stage == SHADER_STAGE_VERTEX ) )
|
||||
{
|
||||
layout += "\tubo\n";
|
||||
outLayout += "\tubo\n";
|
||||
}
|
||||
|
||||
for( int i = 0; i < samplerList.Num(); i++ )
|
||||
{
|
||||
layout += "\tsampler\n";
|
||||
outLayout += "\tsampler\n";
|
||||
}
|
||||
layout += "]\n";
|
||||
outLayout += "]\n";
|
||||
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -267,7 +267,12 @@ idCVar r_ldrContrastThreshold( "r_ldrContrastThreshold", "1.1", CVAR_RENDERER |
|
|||
idCVar r_ldrContrastOffset( "r_ldrContrastOffset", "3", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
|
||||
idCVar r_useFilmicPostProcessEffects( "r_useFilmicPostProcessEffects", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "apply several post process effects to mimic a filmic look" );
|
||||
|
||||
#if defined( USE_VULKAN )
|
||||
idCVar r_forceAmbient( "r_forceAmbient", "0.15", CVAR_RENDERER | CVAR_FLOAT, "render additional ambient pass to make the game less dark", 0.0f, 0.4f );
|
||||
#else
|
||||
idCVar r_forceAmbient( "r_forceAmbient", "0.3", CVAR_RENDERER | CVAR_FLOAT, "render additional ambient pass to make the game less dark", 0.0f, 0.4f );
|
||||
#endif
|
||||
|
||||
idCVar r_useSSGI( "r_useSSGI", "0", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "use screen space global illumination and reflections" );
|
||||
idCVar r_ssgiDebug( "r_ssgiDebug", "0", CVAR_RENDERER | CVAR_INTEGER, "" );
|
||||
|
|
|
@ -2224,19 +2224,6 @@ void idRenderBackend::DrawFlickerBox()
|
|||
clearRect.rect.extent = extent;
|
||||
|
||||
vkCmdClearAttachments( vkcontext.commandBuffer[ vkcontext.frameParity ], 1, &attachment, 1, &clearRect );
|
||||
|
||||
/*
|
||||
if( tr.frameCount & 1 )
|
||||
{
|
||||
glClearColor( 1, 0, 0, 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
glClearColor( 0, 1, 0, 1 );
|
||||
}
|
||||
glScissor( 0, 0, 256, 256 );
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2345,7 +2332,7 @@ void idRenderBackend::DrawStencilShadowPass( const drawSurf_t* drawSurf, const b
|
|||
const uint64 frameNum = ( int )( vbHandle >> VERTCACHE_FRAME_SHIFT ) & VERTCACHE_FRAME_MASK;
|
||||
if( frameNum != ( ( vertexCache.currentFrame - 1 ) & VERTCACHE_FRAME_MASK ) )
|
||||
{
|
||||
idLib::Warning( "RB_DrawElementsWithCounters, vertexBuffer == NULL" );
|
||||
idLib::Warning( "DrawStencilShadowPass, vertexBuffer == NULL" );
|
||||
return;
|
||||
}
|
||||
vertexBuffer = &vertexCache.frameData[ vertexCache.drawListNum ].vertexBuffer;
|
||||
|
@ -2364,12 +2351,12 @@ void idRenderBackend::DrawStencilShadowPass( const drawSurf_t* drawSurf, const b
|
|||
const uint64 frameNum = ( int )( ibHandle >> VERTCACHE_FRAME_SHIFT ) & VERTCACHE_FRAME_MASK;
|
||||
if( frameNum != ( ( vertexCache.currentFrame - 1 ) & VERTCACHE_FRAME_MASK ) )
|
||||
{
|
||||
idLib::Warning( "RB_DrawElementsWithCounters, indexBuffer == NULL" );
|
||||
idLib::Warning( "DrawStencilShadowPass, indexBuffer == NULL" );
|
||||
return;
|
||||
}
|
||||
indexBuffer = &vertexCache.frameData[ vertexCache.drawListNum ].indexBuffer;
|
||||
}
|
||||
int indexOffset = ( int )( ibHandle >> VERTCACHE_OFFSET_SHIFT ) & VERTCACHE_OFFSET_MASK;
|
||||
const uint64 indexOffset = ( int )( ibHandle >> VERTCACHE_OFFSET_SHIFT ) & VERTCACHE_OFFSET_MASK;
|
||||
|
||||
RENDERLOG_PRINTF( "Binding Buffers(%d): %p:%i %p:%i\n", drawSurf->numIndexes, vertexBuffer, vertOffset, indexBuffer, indexOffset );
|
||||
|
||||
|
|
|
@ -691,7 +691,7 @@ void idRenderProgManager::LoadShader( shader_t& shader )
|
|||
|
||||
idStr hlslCode( hlslFileBuffer );
|
||||
idStr programHLSL = StripDeadCode( hlslCode, inFile, compileMacros, shader.builtin );
|
||||
programGLSL = ConvertCG2GLSL( programHLSL, inFile, shader.stage, programLayout, true, hasGPUSkinning );
|
||||
programGLSL = ConvertCG2GLSL( programHLSL, inFile, shader.stage, programLayout, true, hasGPUSkinning, shader.vertexLayout );
|
||||
|
||||
fileSystem->WriteFile( outFileHLSL, programHLSL.c_str(), programHLSL.Length(), "fs_savepath" );
|
||||
fileSystem->WriteFile( outFileGLSL, programGLSL.c_str(), programGLSL.Length(), "fs_savepath" );
|
||||
|
|
Loading…
Reference in a new issue