WIP non-compiling GPU skinning fixes

This commit is contained in:
Robert Beckebans 2022-06-06 13:21:14 +02:00
parent e1bbf4bf28
commit 70dee3a79c
9 changed files with 314 additions and 192 deletions

View file

@ -195,7 +195,9 @@ idRenderBackend::DrawElementsWithCounters
*/
void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf )
{
// Get vertex buffer
//
// get vertex buffer
//
const vertCacheHandle_t vbHandle = surf->ambientCache;
idVertexBuffer* vertexBuffer;
if( vertexCache.CacheIsStatic( vbHandle ) )
@ -227,7 +229,9 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf )
changeState = true;
}
// Get index buffer
//
// get index buffer
//
const vertCacheHandle_t ibHandle = surf->indexCache;
idIndexBuffer* indexBuffer;
if( vertexCache.CacheIsStatic( ibHandle ) )
@ -257,12 +261,54 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf )
changeState = true;
}
//
// get GPU Skinning joint buffer
//
if( surf->jointCache )
{
//if( !verify( renderProgManager.ShaderUsesJoints() ) )
if( !renderProgManager.ShaderUsesJoints() )
{
return;
}
}
else
{
if( !verify( !renderProgManager.ShaderUsesJoints() || renderProgManager.ShaderHasOptionalSkinning() ) )
{
return;
}
}
nvrhi::BufferHandle nativeJointBuffer;
if( surf->jointCache )
{
idUniformBuffer jointBuffer;
if( !vertexCache.GetJointBuffer( surf->jointCache, &jointBuffer ) )
{
idLib::Warning( "RB_DrawElementsWithCounters, jointBuffer == NULL" );
return;
}
assert( ( jointBuffer.GetOffset() & ( glConfig.uniformBufferOffsetAlignment - 1 ) ) == 0 );
nativeJointBuffer = jointBuffer.GetAPIObject();
}
if( currentJointBuffer != ( nvrhi::IBuffer* )nativeJointBuffer || !r_useStateCaching.GetBool() )
{
currentIndexBuffer = nativeJointBuffer;
changeState = true;
}
//
// set up matching binding layout
//
int bindingLayoutType = renderProgManager.BindingLayoutType();
idStaticList<nvrhi::BindingLayoutHandle, nvrhi::c_MaxBindingLayouts>* layouts
= renderProgManager.GetBindingLayout( bindingLayoutType );
GetCurrentBindingLayout( bindingLayoutType );
GetCurrentBindingLayout( bindingLayoutType, nativeJointBuffer );
for( int i = 0; i < layouts->Num(); i++ )
{
@ -302,6 +348,9 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf )
renderProgManager.CommitConstantBuffer( commandList );
//
// create new graphics state if necessary
//
if( changeState )
{
nvrhi::GraphicsState state;
@ -338,18 +387,20 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf )
commandList->setGraphicsState( state );
}
//
// draw command
//
nvrhi::DrawArguments args;
args.startVertexLocation = currentVertexOffset / sizeof( idDrawVert );
args.startIndexLocation = currentIndexOffset / sizeof( triIndex_t );
args.vertexCount = surf->numIndexes;
commandList->drawIndexed( args );
// RB: added stats
pc.c_drawElements++;
pc.c_drawIndexes += surf->numIndexes;
}
void idRenderBackend::GetCurrentBindingLayout( int type )
void idRenderBackend::GetCurrentBindingLayout( int type, nvrhi::IBuffer* jointBuffer )
{
auto& desc = pendingBindingSetDescs[type];
@ -365,25 +416,75 @@ void idRenderBackend::GetCurrentBindingLayout( int type )
desc[0].bindings =
{
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() )
};
}
else
{
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
desc[0].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID();
}
if( desc[1].bindings.empty() )
{
desc[1].bindings =
{
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() )
};
}
else
{
desc[1].bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID();
}
if( desc[2].bindings.empty() )
{
desc[2].bindings =
{
nvrhi::BindingSetItem::Sampler( 0, ( nvrhi::ISampler* )GetImageAt( 0 )->GetSampler( samplerCache ) )
};
}
else
{
desc[1].bindings[0].resourceHandle = ( nvrhi::ISampler* )GetImageAt( 0 )->GetSampler( samplerCache );
desc[2].bindings[0].resourceHandle = ( nvrhi::ISampler* )GetImageAt( 0 )->GetSampler( samplerCache );
}
}
else if( type == BINDING_LAYOUT_DEFAULT_SKINNED )
{
if( desc[0].bindings.empty() )
{
desc[0].bindings =
{
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
nvrhi::BindingSetItem::ConstantBuffer( 1, jointBuffer ),
};
}
else
{
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
desc[0].bindings[1].resourceHandle = jointBuffer;
}
if( desc[1].bindings.empty() )
{
desc[1].bindings =
{
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() )
};
}
else
{
desc[1].bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID();
}
if( desc[2].bindings.empty() )
{
desc[2].bindings =
{
nvrhi::BindingSetItem::Sampler( 0, ( nvrhi::ISampler* )GetImageAt( 0 )->GetSampler( samplerCache ) )
};
}
else
{
desc[2].bindings[0].resourceHandle = ( nvrhi::ISampler* )GetImageAt( 0 )->GetSampler( samplerCache );
}
}
else if( type == BINDING_LAYOUT_CONSTANT_BUFFER_ONLY )
@ -400,6 +501,22 @@ void idRenderBackend::GetCurrentBindingLayout( int type )
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
}
}
else if( type == BINDING_LAYOUT_CONSTANT_BUFFER_ONLY_SKINNED )
{
if( desc[0].bindings.empty() )
{
desc[0].bindings =
{
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
nvrhi::BindingSetItem::ConstantBuffer( 1, jointBuffer ),
};
}
else
{
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
}
}
/*
else if( type == BINDING_LAYOUT_GBUFFER )
{
if( desc[0].bindings.empty() )
@ -414,6 +531,7 @@ void idRenderBackend::GetCurrentBindingLayout( int type )
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
}
}
*/
else if( type == BINDING_LAYOUT_AMBIENT_LIGHTING_IBL )
{
if( desc[0].bindings.empty() )
@ -421,6 +539,17 @@ void idRenderBackend::GetCurrentBindingLayout( int type )
desc[0].bindings =
{
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
};
}
else
{
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
}
if( desc[1].bindings.empty() )
{
desc[1].bindings =
{
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ),
nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() ),
nvrhi::BindingSetItem::Texture_SRV( 2, ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID() )
@ -428,15 +557,14 @@ void idRenderBackend::GetCurrentBindingLayout( int type )
}
else
{
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
desc[0].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID();
desc[0].bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID();
desc[0].bindings[3].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID();
desc[1].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID();
desc[1].bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID();
desc[1].bindings[3].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID();
}
if( desc[1].bindings.empty() )
if( desc[2].bindings.empty() )
{
desc[1].bindings =
desc[2].bindings =
{
nvrhi::BindingSetItem::Texture_SRV( 3, ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID() ),
nvrhi::BindingSetItem::Texture_SRV( 4, ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID() ),
@ -448,17 +576,17 @@ void idRenderBackend::GetCurrentBindingLayout( int type )
}
else
{
desc[1].bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID();
desc[1].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID();
desc[1].bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 7 )->GetTextureID();
desc[1].bindings[3].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 8 )->GetTextureID();
desc[1].bindings[4].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 9 )->GetTextureID();
desc[1].bindings[5].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 10 )->GetTextureID();
desc[2].bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID();
desc[2].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID();
desc[2].bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 7 )->GetTextureID();
desc[2].bindings[3].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 8 )->GetTextureID();
desc[2].bindings[4].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 9 )->GetTextureID();
desc[2].bindings[5].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 10 )->GetTextureID();
}
if( desc[2].bindings.empty() )
if( desc[3].bindings.empty() )
{
desc[2].bindings =
desc[3].bindings =
{
nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_AnisotropicWrapSampler ),
nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_LinearClampSampler )
@ -466,8 +594,76 @@ void idRenderBackend::GetCurrentBindingLayout( int type )
}
else
{
desc[2].bindings[0].resourceHandle = commonPasses.m_AnisotropicWrapSampler;
desc[2].bindings[1].resourceHandle = commonPasses.m_LinearClampSampler;
desc[3].bindings[0].resourceHandle = commonPasses.m_AnisotropicWrapSampler;
desc[3].bindings[1].resourceHandle = commonPasses.m_LinearClampSampler;
}
}
else if( type == BINDING_LAYOUT_AMBIENT_LIGHTING_IBL_SKINNED )
{
if( desc[0].bindings.empty() )
{
desc[0].bindings =
{
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
nvrhi::BindingSetItem::ConstantBuffer( 1, jointBuffer ),
};
}
else
{
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
desc[0].bindings[1].resourceHandle = jointBuffer;
}
if( desc[1].bindings.empty() )
{
desc[1].bindings =
{
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ),
nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() ),
nvrhi::BindingSetItem::Texture_SRV( 2, ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID() )
};
}
else
{
desc[1].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID();
desc[1].bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID();
desc[1].bindings[3].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID();
}
if( desc[2].bindings.empty() )
{
desc[2].bindings =
{
nvrhi::BindingSetItem::Texture_SRV( 3, ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID() ),
nvrhi::BindingSetItem::Texture_SRV( 4, ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID() ),
nvrhi::BindingSetItem::Texture_SRV( 7, ( nvrhi::ITexture* )GetImageAt( 7 )->GetTextureID() ),
nvrhi::BindingSetItem::Texture_SRV( 8, ( nvrhi::ITexture* )GetImageAt( 8 )->GetTextureID() ),
nvrhi::BindingSetItem::Texture_SRV( 9, ( nvrhi::ITexture* )GetImageAt( 9 )->GetTextureID() ),
nvrhi::BindingSetItem::Texture_SRV( 10, ( nvrhi::ITexture* )GetImageAt( 10 )->GetTextureID() )
};
}
else
{
desc[2].bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID();
desc[2].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID();
desc[2].bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 7 )->GetTextureID();
desc[2].bindings[3].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 8 )->GetTextureID();
desc[2].bindings[4].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 9 )->GetTextureID();
desc[2].bindings[5].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 10 )->GetTextureID();
}
if( desc[3].bindings.empty() )
{
desc[3].bindings =
{
nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_AnisotropicWrapSampler ),
nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_LinearClampSampler )
};
}
else
{
desc[3].bindings[0].resourceHandle = commonPasses.m_AnisotropicWrapSampler;
desc[3].bindings[1].resourceHandle = commonPasses.m_LinearClampSampler;
}
}
else if( type == BINDING_LAYOUT_DRAW_AO )
@ -1516,7 +1712,7 @@ idRenderBackend::idRenderBackend()
memset( &glConfig, 0, sizeof( glConfig ) );
//glConfig.gpuSkinningAvailable = true;
glConfig.gpuSkinningAvailable = true;
glConfig.timerQueryAvailable = true;
}

View file

@ -295,7 +295,7 @@ public:
private:
void DrawFlickerBox();
void GetCurrentBindingLayout( int bindingLayoutType );
void GetCurrentBindingLayout( int bindingLayoutType, nvrhi::IBuffer* jointBuffer );
void DrawStencilShadowPass( const drawSurf_t* drawSurf, const bool renderZPass );
void SetColorMappings();
@ -528,6 +528,7 @@ private:
uint currentVertexOffset;
nvrhi::BufferHandle currentIndexBuffer;
uint currentIndexOffset;
nvrhi::BufferHandle currentJointBuffer;
nvrhi::BindingLayoutHandle currentBindingLayout;
nvrhi::GraphicsPipelineHandle currentPipeline;

View file

@ -851,21 +851,43 @@ enum vertexLayoutType_t
enum bindingLayoutType_t
{
// REGULAR AND SKINNED VERSIONS
BINDING_LAYOUT_DEFAULT,
BINDING_LAYOUT_DEFAULT_SKINNED,
BINDING_LAYOUT_CONSTANT_BUFFER_ONLY,
BINDING_LAYOUT_GBUFFER,
BINDING_LAYOUT_CONSTANT_BUFFER_ONLY_SKINNED,
//BINDING_LAYOUT_GBUFFER,
//BINDING_LAYOUT_GBUFFER_SKINNED,
BINDING_LAYOUT_AMBIENT_LIGHTING_IBL,
BINDING_LAYOUT_AMBIENT_LIGHTING_IBL_SKINNED,
BINDING_LAYOUT_DRAW_SHADOWVOLUME, // TODO FIX or REMOVE?
BINDING_LAYOUT_DRAW_SHADOWVOLUME_SKINNED,
BINDING_LAYOUT_DRAW_INTERACTION,
BINDING_LAYOUT_DRAW_INTERACTION_SKINNED,
BINDING_LAYOUT_DRAW_INTERACTION_SM,
BINDING_LAYOUT_DRAW_INTERACTION_SM_SKINNED,
BINDING_LAYOUT_FOG,
BINDING_LAYOUT_FOG_SKINNED,
BINDING_LAYOUT_BLENDLIGHT,
BINDING_LAYOUT_BLENDLIGHT_SKINNED,
BINDING_LAYOUT_NORMAL_CUBE,
BINDING_LAYOUT_NORMAL_CUBE_SKINNED,
// NO GPU SKINNING ANYMORE
BINDING_LAYOUT_POST_PROCESS_INGAME,
BINDING_LAYOUT_POST_PROCESS_FINAL,
BINDING_LAYOUT_BLIT,
BINDING_LAYOUT_DRAW_AO,
BINDING_LAYOUT_DRAW_AO1,
BINDING_LAYOUT_DRAW_SHADOWVOLUME,
BINDING_LAYOUT_DRAW_INTERACTION,
BINDING_LAYOUT_DRAW_INTERACTION_SM,
BINDING_LAYOUT_DRAW_FOG,
BINDING_LAYOUT_POST_PROCESS_INGAME,
BINDING_LAYOUT_POST_PROCESS_FINAL,
BINDING_LAYOUT_NORMAL_CUBE,
BINDING_LAYOUT_BLENDLIGHT,
BINDING_LAYOUT_BINK_VIDEO,
// NVRHI render passes specific

View file

@ -172,10 +172,29 @@ void idRenderProgManager::Init( nvrhi::IDevice* device )
bindingLayouts.SetNum( NUM_BINDING_LAYOUTS );
auto uniformsLayoutDesc = nvrhi::BindingLayoutDesc()
.setVisibility( nvrhi::ShaderType::All )
.addItem( nvrhi::BindingLayoutItem::VolatileConstantBuffer( 0 ) );
auto uniformsLayout = device->createBindingLayout( uniformsLayoutDesc );
auto skinningLayoutDesc = nvrhi::BindingLayoutDesc()
.setVisibility( nvrhi::ShaderType::All )
.addItem( nvrhi::BindingLayoutItem::VolatileConstantBuffer( 0 ) )
.addItem( nvrhi::BindingLayoutItem::VolatileConstantBuffer( 1 ) );
auto skinningLayout = device->createBindingLayout( skinningLayoutDesc );
/*
auto defaultLayoutDesc = nvrhi::BindingLayoutDesc()
.setVisibility( nvrhi::ShaderType::All )
.addItem( nvrhi::BindingLayoutItem::VolatileConstantBuffer( 0 ) )
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 0 ) );
*/
auto defaultLayoutDesc = nvrhi::BindingLayoutDesc()
.setVisibility( nvrhi::ShaderType::Pixel )
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 0 ) );
auto samplerOneLayoutDesc = nvrhi::BindingLayoutDesc()
.setVisibility( nvrhi::ShaderType::Pixel )
@ -184,25 +203,42 @@ void idRenderProgManager::Init( nvrhi::IDevice* device )
auto defaultLayout = device->createBindingLayout( defaultLayoutDesc );
bindingLayouts[BINDING_LAYOUT_DEFAULT] = { defaultLayout, samplerOneBindingLayout };
bindingLayouts[BINDING_LAYOUT_DEFAULT] = { uniformsLayout, defaultLayout, samplerOneBindingLayout };
bindingLayouts[BINDING_LAYOUT_DEFAULT_SKINNED] = { skinningLayout, defaultLayout, samplerOneBindingLayout };
/*
auto constantBufferLayoutDesc = nvrhi::BindingLayoutDesc()
.setVisibility( nvrhi::ShaderType::All )
.addItem( nvrhi::BindingLayoutItem::VolatileConstantBuffer( 0 ) );
bindingLayouts[BINDING_LAYOUT_CONSTANT_BUFFER_ONLY] = { device->createBindingLayout( constantBufferLayoutDesc ) };
auto constantBufferSkinnedLayoutDesc = nvrhi::BindingLayoutDesc()
.setVisibility( nvrhi::ShaderType::All )
.addItem( nvrhi::BindingLayoutItem::VolatileConstantBuffer( 0 ) )
.addItem( nvrhi::BindingLayoutItem::VolatileConstantBuffer( 1 ) );
*/
bindingLayouts[BINDING_LAYOUT_CONSTANT_BUFFER_ONLY] = { uniformsLayout };
bindingLayouts[BINDING_LAYOUT_CONSTANT_BUFFER_ONLY_SKINNED] = { skinningLayout };
/*
auto defaultMaterialLayoutDesc = nvrhi::BindingLayoutDesc()
.setVisibility( nvrhi::ShaderType::All )
.addItem( nvrhi::BindingLayoutItem::VolatileConstantBuffer( 0 ) )
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 0 ) ) // normal
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 1 ) ) // specular
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 2 ) ); // base color
*/
auto defaultMaterialLayoutDesc = nvrhi::BindingLayoutDesc()
.setVisibility( nvrhi::ShaderType::Pixel )
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 0 ) ) // normal
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 1 ) ) // specular
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 2 ) ); // base color
auto defaultMaterialLayout = device->createBindingLayout( defaultMaterialLayoutDesc );
auto ambientIblLayoutDesc = nvrhi::BindingLayoutDesc()
.setVisibility( nvrhi::ShaderType::All )
.setVisibility( nvrhi::ShaderType::Pixel )
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 3 ) ) // brdf lut
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 4 ) ) // ssao
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 7 ) ) // irradiance cube map
@ -210,6 +246,8 @@ void idRenderProgManager::Init( nvrhi::IDevice* device )
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 9 ) ) // radiance cube map 2
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 10 ) ); // radiance cube map 3
auto ambientIblLayout = device->createBindingLayout( ambientIblLayoutDesc );
auto samplerTwoBindingLayoutDesc = nvrhi::BindingLayoutDesc()
.setVisibility( nvrhi::ShaderType::Pixel )
.addItem( nvrhi::BindingLayoutItem::Sampler( 0 ) ) // (Wrap) Anisotropic sampler: normal sampler & specular sampler
@ -218,7 +256,11 @@ void idRenderProgManager::Init( nvrhi::IDevice* device )
bindingLayouts[ BINDING_LAYOUT_AMBIENT_LIGHTING_IBL ] =
{
defaultMaterialLayout, device->createBindingLayout( ambientIblLayoutDesc ), samplerTwoBindingLayout
uniformsLayout, defaultMaterialLayout, ambientIblLayout, samplerTwoBindingLayout
};
bindingLayouts[ BINDING_LAYOUT_AMBIENT_LIGHTING_IBL_SKINNED ] =
{
skinningLayout, defaultMaterialLayout, ambientIblLayout, samplerTwoBindingLayout
};
auto blitLayoutDesc = nvrhi::BindingLayoutDesc()

View file

@ -28,10 +28,9 @@ If you have questions concerning this license or the applicable additional terms
#include "global_inc.hlsl"
// *INDENT-OFF*
struct PS_OUT {
struct PS_OUT
{
float4 color : SV_Target0;
};
// *INDENT-ON*

View file

@ -28,17 +28,16 @@ If you have questions concerning this license or the applicable additional terms
#include "global_inc.hlsl"
// *INDENT-OFF*
#if USE_GPU_SKINNING
cbuffer CB :
register( b1 )
cbuffer CB : register( b1 )
{
float4 matrices[408];
};
#endif
// *INDENT-OFF*
struct VS_IN {
struct VS_IN
{
float4 position : POSITION;
#if USE_GPU_SKINNING
float2 texcoord : TEXCOORD0;
@ -49,7 +48,8 @@ struct VS_IN {
#endif
};
struct VS_OUT {
struct VS_OUT
{
float4 position : SV_Position;
};
// *INDENT-ON*

View file

@ -1,45 +0,0 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "renderprogs/global.inc.hlsl"
// *INDENT-OFF*
Texture2D t_ViewDepth : register( t0 );
SamplerState LinearSampler : register( s0 );
struct PS_OUT {
float4 color : COLOR;
};
// *INDENT-ON*
void main( out PS_OUT result )
{
result.color = float4( 0.0, 0.0, 0.0, 1.0 );
}

View file

@ -1,93 +0,0 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2014 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "renderprogs/global.inc.hlsl"
uniform matrices_ubo { float4 matrices[408]; };
// *INDENT-OFF*
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
float4 color2 : COLOR1;
};
struct VS_OUT {
float4 position : POSITION;
};
// *INDENT-ON*
void main( VS_IN vertex, out VS_OUT result )
{
//--------------------------------------------------------------
// GPU transformation of the normal / binormal / bitangent
//
// multiplying with 255.1 give us the same result and is faster than floor( w * 255 + 0.5 )
//--------------------------------------------------------------
const float w0 = vertex.color2.x;
const float w1 = vertex.color2.y;
const float w2 = vertex.color2.z;
const float w3 = vertex.color2.w;
float4 matX, matY, matZ; // must be float4 for vec4
int joint = int( vertex.color.x * 255.1 * 3.0 );
matX = matrices[int( joint + 0 )] * w0;
matY = matrices[int( joint + 1 )] * w0;
matZ = matrices[int( joint + 2 )] * w0;
joint = int( vertex.color.y * 255.1 * 3.0 );
matX += matrices[int( joint + 0 )] * w1;
matY += matrices[int( joint + 1 )] * w1;
matZ += matrices[int( joint + 2 )] * w1;
joint = int( vertex.color.z * 255.1 * 3.0 );
matX += matrices[int( joint + 0 )] * w2;
matY += matrices[int( joint + 1 )] * w2;
matZ += matrices[int( joint + 2 )] * w2;
joint = int( vertex.color.w * 255.1 * 3.0 );
matX += matrices[int( joint + 0 )] * w3;
matY += matrices[int( joint + 1 )] * w3;
matZ += matrices[int( joint + 2 )] * w3;
float4 modelPosition;
modelPosition.x = dot4( matX, vertex.position );
modelPosition.y = dot4( matY, vertex.position );
modelPosition.z = dot4( matZ, vertex.position );
modelPosition.w = 1.0;
result.position.x = dot4( modelPosition, rpMVPmatrixX );
result.position.y = dot4( modelPosition, rpMVPmatrixY );
result.position.z = dot4( modelPosition, rpMVPmatrixZ );
result.position.w = dot4( modelPosition, rpMVPmatrixW );
}

View file

@ -29,17 +29,16 @@ If you have questions concerning this license or the applicable additional terms
#include "global_inc.hlsl"
// *INDENT-OFF*
#if USE_GPU_SKINNING
cbuffer CB :
register( b1 )
cbuffer CB : register( b1 )
{
float4 matrices[408];
};
#endif
// *INDENT-OFF*
struct VS_IN {
struct VS_IN
{
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
@ -48,7 +47,8 @@ struct VS_IN {
float4 color2 : COLOR1;
};
struct VS_OUT {
struct VS_OUT
{
float4 position : SV_Position;
float2 texcoord0 : TEXCOORD0_centroid;
float3 texcoord1 : TEXCOORD1_centroid;