From 70dee3a79c57dc7b3f12c38147481f66fa5a31d7 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Mon, 6 Jun 2022 13:21:14 +0200 Subject: [PATCH 1/2] WIP non-compiling GPU skinning fixes --- neo/renderer/NVRHI/RenderBackend_NVRHI.cpp | 246 ++++++++++++++++++--- neo/renderer/RenderBackend.h | 3 +- neo/renderer/RenderCommon.h | 40 +++- neo/renderer/RenderProgs.cpp | 50 ++++- neo/shaders/builtin/depth.ps.hlsl | 5 +- neo/shaders/builtin/depth.vs.hlsl | 12 +- neo/shaders/builtin/depth_skinned.ps.hlsl | 45 ---- neo/shaders/builtin/depth_skinned.vs.hlsl | 93 -------- neo/shaders/builtin/gbuffer.vs.hlsl | 12 +- 9 files changed, 314 insertions(+), 192 deletions(-) delete mode 100644 neo/shaders/builtin/depth_skinned.ps.hlsl delete mode 100644 neo/shaders/builtin/depth_skinned.vs.hlsl diff --git a/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp b/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp index b5c9f392..f5cd9581 100644 --- a/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp +++ b/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp @@ -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* 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; } diff --git a/neo/renderer/RenderBackend.h b/neo/renderer/RenderBackend.h index 4b37b222..4b9fe3d1 100644 --- a/neo/renderer/RenderBackend.h +++ b/neo/renderer/RenderBackend.h @@ -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; diff --git a/neo/renderer/RenderCommon.h b/neo/renderer/RenderCommon.h index 25c35649..16f19775 100644 --- a/neo/renderer/RenderCommon.h +++ b/neo/renderer/RenderCommon.h @@ -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 diff --git a/neo/renderer/RenderProgs.cpp b/neo/renderer/RenderProgs.cpp index 50f07789..8584f7a8 100644 --- a/neo/renderer/RenderProgs.cpp +++ b/neo/renderer/RenderProgs.cpp @@ -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() diff --git a/neo/shaders/builtin/depth.ps.hlsl b/neo/shaders/builtin/depth.ps.hlsl index e8825700..e00371ba 100644 --- a/neo/shaders/builtin/depth.ps.hlsl +++ b/neo/shaders/builtin/depth.ps.hlsl @@ -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* diff --git a/neo/shaders/builtin/depth.vs.hlsl b/neo/shaders/builtin/depth.vs.hlsl index d7e3cf7c..4ebba455 100644 --- a/neo/shaders/builtin/depth.vs.hlsl +++ b/neo/shaders/builtin/depth.vs.hlsl @@ -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* diff --git a/neo/shaders/builtin/depth_skinned.ps.hlsl b/neo/shaders/builtin/depth_skinned.ps.hlsl deleted file mode 100644 index a7ae7cd7..00000000 --- a/neo/shaders/builtin/depth_skinned.ps.hlsl +++ /dev/null @@ -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 . - -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 ); -} \ No newline at end of file diff --git a/neo/shaders/builtin/depth_skinned.vs.hlsl b/neo/shaders/builtin/depth_skinned.vs.hlsl deleted file mode 100644 index 2cfb93e7..00000000 --- a/neo/shaders/builtin/depth_skinned.vs.hlsl +++ /dev/null @@ -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 . - -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 ); -} \ No newline at end of file diff --git a/neo/shaders/builtin/gbuffer.vs.hlsl b/neo/shaders/builtin/gbuffer.vs.hlsl index 28e59760..4b2d5837 100644 --- a/neo/shaders/builtin/gbuffer.vs.hlsl +++ b/neo/shaders/builtin/gbuffer.vs.hlsl @@ -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; From 539b25d79964b164a503641e531bc2afaa722b18 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Mon, 27 Jun 2022 19:54:20 +0200 Subject: [PATCH 2/2] Merged GPU skinning code by SP and did additional refactoring --- neo/renderer/BindingCache.cpp | 4 + neo/renderer/ImageManager.cpp | 9 +- neo/renderer/NVRHI/BufferObject_NVRHI.cpp | 65 ++- neo/renderer/NVRHI/RenderBackend_NVRHI.cpp | 530 +++++++++++++++--- neo/renderer/PipelineCache.cpp | 5 +- neo/renderer/RenderBackend.h | 5 +- neo/renderer/RenderCommon.h | 4 +- neo/renderer/RenderProgs.cpp | 211 +++---- neo/renderer/RenderProgs.h | 1 + neo/renderer/tr_frontend_addmodels.cpp | 5 +- neo/shaders/builtin/color.vs.hlsl | 8 +- neo/shaders/builtin/debug/lightgrid.vs.hlsl | 16 +- neo/shaders/builtin/debug/octahedron.vs.hlsl | 16 +- neo/shaders/builtin/debug/shadowDebug.vs.hlsl | 11 +- neo/shaders/builtin/depth.vs.hlsl | 7 +- neo/shaders/builtin/fog/blendLight.vs.hlsl | 67 ++- neo/shaders/builtin/fog/fog.vs.hlsl | 11 +- neo/shaders/builtin/gbuffer.vs.hlsl | 9 +- .../builtin/legacy/bumpyenvironment.vs.hlsl | 10 +- .../builtin/legacy/environment.vs.hlsl | 14 +- .../lighting/ambient_lightgrid_IBL.vs.hlsl | 13 +- .../lighting/ambient_lighting_IBL.vs.hlsl | 14 +- .../builtin/lighting/interaction.vs.hlsl | 14 +- .../lighting/interactionAmbient.vs.hlsl | 51 +- .../builtin/lighting/interactionSM.vs.hlsl | 12 +- neo/shaders/builtin/lighting/shadow.vs.hlsl | 11 +- neo/shaders/builtin/texture_color.vs.hlsl | 13 +- neo/shaders/heatHazeWithMask.vs.hlsl | 7 +- neo/shaders/heatHazeWithMaskAndVertex.vs.hlsl | 14 +- neo/shaders/heathaze.vs.hlsl | 14 +- neo/shaders/mattiascrt.vs.hlsl | 14 +- neo/shaders/shaders.cfg | 4 +- neo/shaders/vornoipattern.vs.hlsl | 19 +- 33 files changed, 808 insertions(+), 400 deletions(-) diff --git a/neo/renderer/BindingCache.cpp b/neo/renderer/BindingCache.cpp index 67eeebea..c17ae1ac 100644 --- a/neo/renderer/BindingCache.cpp +++ b/neo/renderer/BindingCache.cpp @@ -92,6 +92,10 @@ void BindingCache::Clear() // will try to gain a conflicting mutex lock and cause an abort signal mutex.Lock(); + for( int i = 0; i < bindingSets.Num(); i++ ) + { + bindingSets[i].Reset(); + } bindingSets.Clear(); bindingHash.Clear(); mutex.Unlock(); diff --git a/neo/renderer/ImageManager.cpp b/neo/renderer/ImageManager.cpp index ffe95956..3891e5d5 100644 --- a/neo/renderer/ImageManager.cpp +++ b/neo/renderer/ImageManager.cpp @@ -73,11 +73,10 @@ void R_ReloadImages_f( const idCmdArgs& args ) } #if defined( USE_NVRHI ) - nvrhi::CommandListHandle commandList = deviceManager->GetDevice()->createCommandList(); - commandList->open(); - globalImages->ReloadImages( all, commandList ); - commandList->close(); - deviceManager->GetDevice()->executeCommandList( commandList ); + tr.commandList->open(); + globalImages->ReloadImages( all, tr.commandList ); + tr.commandList->close(); + deviceManager->GetDevice()->executeCommandList( tr.commandList ); #else globalImages->ReloadImages( all ); #endif diff --git a/neo/renderer/NVRHI/BufferObject_NVRHI.cpp b/neo/renderer/NVRHI/BufferObject_NVRHI.cpp index f1553c8c..be662ce5 100644 --- a/neo/renderer/NVRHI/BufferObject_NVRHI.cpp +++ b/neo/renderer/NVRHI/BufferObject_NVRHI.cpp @@ -386,7 +386,7 @@ void idIndexBuffer::Update( const void* data, int updateSize, int offset, bool i idLib::FatalError( "idIndexBuffer::Update: size overrun, %i > %i\n", updateSize, GetSize() ); } - int numBytes = ( updateSize + 15 ) & ~15; + const int numBytes = ( updateSize + 15 ) & ~15; if( usage == BU_DYNAMIC ) { @@ -419,7 +419,7 @@ void* idIndexBuffer::MapBuffer( bufferMapType_t mapType ) assert( IsMapped() == false ); nvrhi::CpuAccessMode accessMode = nvrhi::CpuAccessMode::Write; - if( mapType == bufferMapType_t::BM_READ ) + if( mapType == BM_READ ) { accessMode = nvrhi::CpuAccessMode::Read; } @@ -428,7 +428,7 @@ void* idIndexBuffer::MapBuffer( bufferMapType_t mapType ) SetMapped(); - if( buffer == NULL ) + if( buffer == nullptr ) { idLib::FatalError( "idVertexBuffer::MapBuffer: failed" ); } @@ -492,7 +492,7 @@ idUniformBuffer::idUniformBuffer() idUniformBuffer::AllocBufferObject ======================== */ -bool idUniformBuffer::AllocBufferObject( const void* data, int allocSize, bufferUsageType_t _usage, nvrhi::ICommandList* commandList ) +bool idUniformBuffer::AllocBufferObject( const void* data, int allocSize, bufferUsageType_t allocatedUsage, nvrhi::ICommandList* commandList ) { assert( !bufferHandle ); assert_16_byte_aligned( data ); @@ -503,38 +503,46 @@ bool idUniformBuffer::AllocBufferObject( const void* data, int allocSize, buffer } size = allocSize; - usage = _usage; + usage = allocatedUsage; - bool allocationFailed = false; - - int numBytes = GetAllocedSize(); + const int numBytes = GetAllocedSize(); + // This buffer is a shader resource as opposed to a constant buffer due to + // constant buffers not being able to be sub-ranged. nvrhi::BufferDesc bufferDesc; + bufferDesc.initialState = nvrhi::ResourceStates::ShaderResource; + bufferDesc.keepInitialState = true; + bufferDesc.canHaveTypedViews = true; + bufferDesc.canHaveRawViews = true; bufferDesc.byteSize = numBytes; - bufferDesc.isConstantBuffer = true; - bufferDesc.initialState = nvrhi::ResourceStates::Common; + bufferDesc.structStride = sizeof( idVec4 ); if( usage == BU_DYNAMIC ) { - bufferDesc.debugName = "Mapped ConstantBuffer"; + bufferDesc.debugName = "Mapped JointBuffer"; bufferDesc.initialState = nvrhi::ResourceStates::CopyDest; bufferDesc.cpuAccess = nvrhi::CpuAccessMode::Write; } else { - bufferDesc.debugName = "Static ConstantBuffer"; + bufferDesc.debugName = "Static JointBuffer"; bufferDesc.keepInitialState = true; } bufferHandle = deviceManager->GetDevice()->createBuffer( bufferDesc ); + if( !bufferHandle ) + { + return false; + } + // copy the data - if( data != NULL ) + if( data ) { Update( data, allocSize, 0, true, commandList ); } - return !allocationFailed; + return true; } /* @@ -544,6 +552,31 @@ idUniformBuffer::FreeBufferObject */ void idUniformBuffer::FreeBufferObject() { + if( IsMapped() ) + { + UnmapBuffer(); + } + + // if this is a sub-allocation inside a larger buffer, don't actually free anything. + if( OwnsBuffer() == false ) + { + ClearWithoutFreeing(); + return; + } + + if( !bufferHandle ) + { + return; + } + + if( r_showBuffers.GetBool() ) + { + idLib::Printf( "index buffer free %p, api %p (%i bytes)\n", this, bufferHandle.Get(), GetSize() ); + } + + bufferHandle.Reset(); + + ClearWithoutFreeing(); } /* @@ -574,7 +607,7 @@ void idUniformBuffer::Update( const void* data, int updateSize, int offset, bool { commandList->beginTrackingBufferState( bufferHandle, nvrhi::ResourceStates::Common ); commandList->writeBuffer( bufferHandle, data, numBytes, GetOffset() + offset ); - commandList->setPermanentBufferState( bufferHandle, nvrhi::ResourceStates::ConstantBuffer | nvrhi::ResourceStates::ShaderResource ); + commandList->setPermanentBufferState( bufferHandle, nvrhi::ResourceStates::Common | nvrhi::ResourceStates::ShaderResource ); } else { @@ -594,7 +627,7 @@ void* idUniformBuffer::MapBuffer( bufferMapType_t mapType ) assert( IsMapped() == false ); nvrhi::CpuAccessMode accessMode = nvrhi::CpuAccessMode::Write; - if( mapType == bufferMapType_t::BM_READ ) + if( mapType == BM_READ ) { accessMode = nvrhi::CpuAccessMode::Read; } diff --git a/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp b/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp index f5cd9581..baacc6fd 100644 --- a/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp +++ b/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp @@ -178,6 +178,9 @@ void idRenderBackend::Init() prevMVP[1] = renderMatrix_identity; prevViewsValid = false; + currentJointBuffer = nullptr; + currentJointOffset = 0; + // RB: prepare ImGui system //ImGui_Init(); } @@ -223,7 +226,7 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf ) currentVertexOffset = vertOffset; } - if( currentVertexBuffer != ( nvrhi::IBuffer* )vertexBuffer->GetAPIObject() || !r_useStateCaching.GetBool() ) + if( currentVertexBuffer != vertexBuffer->GetAPIObject() || !r_useStateCaching.GetBool() ) { currentVertexBuffer = vertexBuffer->GetAPIObject(); changeState = true; @@ -255,7 +258,7 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf ) currentIndexOffset = indexOffset; } - if( currentIndexBuffer != ( nvrhi::IBuffer* )indexBuffer->GetAPIObject() || !r_useStateCaching.GetBool() ) + if( currentIndexBuffer != indexBuffer->GetAPIObject() || !r_useStateCaching.GetBool() ) { currentIndexBuffer = indexBuffer->GetAPIObject(); changeState = true; @@ -264,7 +267,12 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf ) // // get GPU Skinning joint buffer // - if( surf->jointCache ) + const vertCacheHandle_t jointHandle = surf->jointCache; + currentJointBuffer = nullptr; + currentJointOffset = 0; + +#if 0 + if( jointHandle ) { //if( !verify( renderProgManager.ShaderUsesJoints() ) ) if( !renderProgManager.ShaderUsesJoints() ) @@ -279,36 +287,40 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf ) return; } } +#endif - nvrhi::BufferHandle nativeJointBuffer; - if( surf->jointCache ) + if( jointHandle ) { - idUniformBuffer jointBuffer; - if( !vertexCache.GetJointBuffer( surf->jointCache, &jointBuffer ) ) + const idUniformBuffer* jointBuffer = nullptr; + + if( vertexCache.CacheIsStatic( jointHandle ) ) { - idLib::Warning( "RB_DrawElementsWithCounters, jointBuffer == NULL" ); - return; + jointBuffer = &vertexCache.staticData.jointBuffer; + } + else + { + const uint64 frameNum = jointHandle >> VERTCACHE_FRAME_SHIFT & VERTCACHE_FRAME_MASK; + if( frameNum != ( ( vertexCache.currentFrame - 1 ) & VERTCACHE_FRAME_MASK ) ) + { + idLib::Warning( "RB_DrawElementsWithCounters, jointBuffer == NULL" ); + return; + } + jointBuffer = &vertexCache.frameData[vertexCache.drawListNum].jointBuffer; } - assert( ( jointBuffer.GetOffset() & ( glConfig.uniformBufferOffsetAlignment - 1 ) ) == 0 ); - nativeJointBuffer = jointBuffer.GetAPIObject(); - } - - if( currentJointBuffer != ( nvrhi::IBuffer* )nativeJointBuffer || !r_useStateCaching.GetBool() ) - { - currentIndexBuffer = nativeJointBuffer; - changeState = true; + currentJointBuffer = jointBuffer->GetAPIObject(); + currentJointOffset = static_cast( jointHandle >> VERTCACHE_OFFSET_SHIFT ) & VERTCACHE_OFFSET_MASK; } // // set up matching binding layout // - int bindingLayoutType = renderProgManager.BindingLayoutType(); + const int bindingLayoutType = renderProgManager.BindingLayoutType(); idStaticList* layouts = renderProgManager.GetBindingLayout( bindingLayoutType ); - GetCurrentBindingLayout( bindingLayoutType, nativeJointBuffer ); + GetCurrentBindingLayout( bindingLayoutType ); for( int i = 0; i < layouts->Num(); i++ ) { @@ -319,11 +331,11 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf ) } } - uint64_t stateBits = glStateBits; + const uint64_t stateBits = glStateBits; - int program = renderProgManager.CurrentProgram(); - PipelineKey key{ stateBits, program, depthBias, slopeScaleBias, currentFrameBuffer }; - auto pipeline = pipelineCache.GetOrCreatePipeline( key ); + const int program = renderProgManager.CurrentProgram(); + const PipelineKey key{ stateBits, program, depthBias, slopeScaleBias, currentFrameBuffer }; + const auto pipeline = pipelineCache.GetOrCreatePipeline( key ); if( currentPipeline != pipeline ) { @@ -400,8 +412,9 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf ) pc.c_drawIndexes += surf->numIndexes; } -void idRenderBackend::GetCurrentBindingLayout( int type, nvrhi::IBuffer* jointBuffer ) +void idRenderBackend::GetCurrentBindingLayout( int type ) { + constexpr auto numBoneMatrices = 480; auto& desc = pendingBindingSetDescs[type]; if( desc.Num() == 0 ) @@ -454,13 +467,15 @@ void idRenderBackend::GetCurrentBindingLayout( int type, nvrhi::IBuffer* jointBu desc[0].bindings = { nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ), - nvrhi::BindingSetItem::ConstantBuffer( 1, jointBuffer ), + nvrhi::BindingSetItem::StructuredBuffer_SRV( 11, currentJointBuffer, nvrhi::Format::UNKNOWN, nvrhi::BufferRange( currentJointOffset, sizeof( idVec4 ) * numBoneMatrices ) ) }; } else { - desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer(); - desc[0].bindings[1].resourceHandle = jointBuffer; + auto& bindings = desc[0].bindings; + bindings[0].resourceHandle = renderProgManager.ConstantBuffer(); + bindings[1].resourceHandle = currentJointBuffer; + bindings[1].range = nvrhi::BufferRange{ currentJointOffset, sizeof( idVec4 )* numBoneMatrices }; } if( desc[1].bindings.empty() ) @@ -508,12 +523,15 @@ void idRenderBackend::GetCurrentBindingLayout( int type, nvrhi::IBuffer* jointBu desc[0].bindings = { nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ), - nvrhi::BindingSetItem::ConstantBuffer( 1, jointBuffer ), + nvrhi::BindingSetItem::StructuredBuffer_SRV( 11, currentJointBuffer, nvrhi::Format::UNKNOWN, nvrhi::BufferRange( currentJointOffset, sizeof( idVec4 ) * numBoneMatrices ) ) }; } else { - desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer(); + auto& bindings = desc[0].bindings; + bindings[0].resourceHandle = renderProgManager.ConstantBuffer(); + bindings[1].resourceHandle = currentJointBuffer; + bindings[1].range = nvrhi::BufferRange{ currentJointOffset, sizeof( idVec4 )* numBoneMatrices }; } } /* @@ -557,9 +575,9 @@ void idRenderBackend::GetCurrentBindingLayout( int type, nvrhi::IBuffer* jointBu } 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(); + desc[1].bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID(); + desc[1].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID(); + desc[1].bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID(); } if( desc[2].bindings.empty() ) @@ -605,13 +623,15 @@ void idRenderBackend::GetCurrentBindingLayout( int type, nvrhi::IBuffer* jointBu desc[0].bindings = { nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ), - nvrhi::BindingSetItem::ConstantBuffer( 1, jointBuffer ), + nvrhi::BindingSetItem::StructuredBuffer_SRV( 11, currentJointBuffer, nvrhi::Format::UNKNOWN, nvrhi::BufferRange( currentJointOffset, sizeof( idVec4 ) * numBoneMatrices ) ) }; } else { - desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer(); - desc[0].bindings[1].resourceHandle = jointBuffer; + auto& bindings = desc[0].bindings; + bindings[0].resourceHandle = renderProgManager.ConstantBuffer(); + bindings[1].resourceHandle = currentJointBuffer; + bindings[1].range = nvrhi::BufferRange{ currentJointOffset, sizeof( idVec4 )* numBoneMatrices }; } if( desc[1].bindings.empty() ) @@ -625,9 +645,9 @@ void idRenderBackend::GetCurrentBindingLayout( int type, nvrhi::IBuffer* jointBu } 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(); + desc[1].bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID(); + desc[1].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID(); + desc[1].bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID(); } if( desc[2].bindings.empty() ) @@ -698,8 +718,9 @@ void idRenderBackend::GetCurrentBindingLayout( int type, nvrhi::IBuffer* jointBu desc[1].bindings[0] = nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_PointWrapSampler ); } } - else if( type == BINDING_LAYOUT_DRAW_SHADOWVOLUME ) + else if( type == BINDING_LAYOUT_DRAW_INTERACTION ) { + // renderparms: 0 if( desc[0].bindings.empty() ) { desc[0].bindings = @@ -711,14 +732,12 @@ void idRenderBackend::GetCurrentBindingLayout( int type, nvrhi::IBuffer* jointBu { desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer(); } - } - else if( type == BINDING_LAYOUT_DRAW_INTERACTION ) - { - if( desc[0].bindings.empty() ) + + // materials: 1 + if( desc[1].bindings.empty() ) { - desc[0].bindings = + desc[1].bindings = { - nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ), 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() ) @@ -726,15 +745,15 @@ void idRenderBackend::GetCurrentBindingLayout( int type, nvrhi::IBuffer* jointBu } 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[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID(); + desc[1].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID(); + desc[1].bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID(); } - if( desc[1].bindings.empty() ) + // light projection: 2 + 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() ) @@ -742,13 +761,14 @@ void idRenderBackend::GetCurrentBindingLayout( int type, nvrhi::IBuffer* jointBu } else { - desc[1].bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID(); - desc[1].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID(); + desc[2].bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID(); + desc[2].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID(); } - if( desc[2].bindings.empty() ) + // samplers: 3 + if( desc[3].bindings.empty() ) { - desc[2].bindings = + desc[3].bindings = { nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_AnisotropicWrapSampler ), nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_LinearBorderSampler ) @@ -756,17 +776,34 @@ void idRenderBackend::GetCurrentBindingLayout( int type, nvrhi::IBuffer* jointBu } else { - desc[2].bindings[0].resourceHandle = commonPasses.m_AnisotropicWrapSampler; - desc[2].bindings[1].resourceHandle = commonPasses.m_LinearBorderSampler; + desc[3].bindings[0].resourceHandle = commonPasses.m_AnisotropicWrapSampler; + desc[3].bindings[1].resourceHandle = commonPasses.m_LinearBorderSampler; } } - else if( type == BINDING_LAYOUT_DRAW_INTERACTION_SM ) + else if( type == BINDING_LAYOUT_DRAW_INTERACTION_SKINNED ) { + // renderparms / skinning joints: 0 if( desc[0].bindings.empty() ) { desc[0].bindings = { nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ), + nvrhi::BindingSetItem::StructuredBuffer_SRV( 11, currentJointBuffer, nvrhi::Format::UNKNOWN, nvrhi::BufferRange( currentJointOffset, sizeof( idVec4 ) * numBoneMatrices ) ) + }; + } + else + { + auto& bindings = desc[0].bindings; + bindings[0].resourceHandle = renderProgManager.ConstantBuffer(); + bindings[1].resourceHandle = currentJointBuffer; + bindings[1].range = nvrhi::BufferRange{ currentJointOffset, sizeof( idVec4 )* numBoneMatrices }; + } + + // materials: 1 + 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() ) @@ -774,16 +811,78 @@ void idRenderBackend::GetCurrentBindingLayout( int type, nvrhi::IBuffer* jointBu } else { - auto& bindings = desc[0].bindings; - bindings[0].resourceHandle = renderProgManager.ConstantBuffer(); - bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID(); - bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID(); - bindings[3].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID(); + desc[1].bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID(); + desc[1].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID(); + desc[1].bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID(); } + // light projection: 2 + 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() ) + }; + } + else + { + desc[2].bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID(); + desc[2].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID(); + } + + // samplers: 3 + if( desc[3].bindings.empty() ) + { + desc[3].bindings = + { + nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_AnisotropicWrapSampler ), + nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_LinearBorderSampler ) + }; + } + else + { + desc[3].bindings[0].resourceHandle = commonPasses.m_AnisotropicWrapSampler; + desc[3].bindings[1].resourceHandle = commonPasses.m_LinearBorderSampler; + } + } + else if( type == BINDING_LAYOUT_DRAW_INTERACTION_SM ) + { + // renderparms: 0 + if( desc[0].bindings.empty() ) + { + desc[0].bindings = + { + nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ), + }; + } + else + { + desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer(); + } + + // materials: 1 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 { auto& bindings = desc[1].bindings; + bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID(); + bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID(); + bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID(); + } + + // light projection: 2 + if( desc[2].bindings.empty() ) + { + auto& bindings = desc[2].bindings; bindings = { nvrhi::BindingSetItem::Texture_SRV( 3, ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID() ), @@ -794,16 +893,17 @@ void idRenderBackend::GetCurrentBindingLayout( int type, nvrhi::IBuffer* jointBu } else { - auto& bindings = desc[1].bindings; + auto& bindings = desc[2].bindings; bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID(); bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID(); bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 5 )->GetTextureID(); bindings[3].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 6 )->GetTextureID(); } - if( desc[2].bindings.empty() ) + // samplers: 3 + if( desc[3].bindings.empty() ) { - auto& bindings = desc[2].bindings; + auto& bindings = desc[3].bindings; bindings = { nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_AnisotropicWrapSampler ), @@ -814,34 +914,124 @@ void idRenderBackend::GetCurrentBindingLayout( int type, nvrhi::IBuffer* jointBu } else { - auto& bindings = desc[2].bindings; + auto& bindings = desc[3].bindings; bindings[0].resourceHandle = commonPasses.m_AnisotropicWrapSampler; bindings[1].resourceHandle = commonPasses.m_LinearBorderSampler; bindings[2].resourceHandle = commonPasses.m_LinearClampCompareSampler; bindings[3].resourceHandle = commonPasses.m_PointWrapSampler; } } - else if( type == BINDING_LAYOUT_DRAW_FOG ) + else if( type == BINDING_LAYOUT_DRAW_INTERACTION_SM_SKINNED ) + { + // renderparms: 0 + if( desc[0].bindings.empty() ) + { + desc[0].bindings = + { + nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ), + nvrhi::BindingSetItem::StructuredBuffer_SRV( 11, currentJointBuffer, nvrhi::Format::UNKNOWN, nvrhi::BufferRange( currentJointOffset, sizeof( idVec4 ) * numBoneMatrices ) ) + }; + } + else + { + auto& bindings = desc[0].bindings; + bindings[0].resourceHandle = renderProgManager.ConstantBuffer(); + bindings[1].resourceHandle = currentJointBuffer; + bindings[1].range = nvrhi::BufferRange{ currentJointOffset, sizeof( idVec4 )* numBoneMatrices }; + } + + // materials: 1 + 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 + { + auto& bindings = desc[1].bindings; + bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID(); + bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID(); + bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID(); + } + + // light projection: 2 + if( desc[2].bindings.empty() ) + { + auto& bindings = desc[2].bindings; + 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( 5, ( nvrhi::ITexture* )GetImageAt( 5 )->GetTextureID() ), + nvrhi::BindingSetItem::Texture_SRV( 6, ( nvrhi::ITexture* )GetImageAt( 6 )->GetTextureID() ) + }; + } + else + { + auto& bindings = desc[2].bindings; + bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID(); + bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID(); + bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 5 )->GetTextureID(); + bindings[3].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 6 )->GetTextureID(); + } + + // samplers: 3 + if( desc[3].bindings.empty() ) + { + auto& bindings = desc[3].bindings; + bindings = + { + nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_AnisotropicWrapSampler ), + nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_LinearBorderSampler ), + nvrhi::BindingSetItem::Sampler( 2, commonPasses.m_LinearClampCompareSampler ), + nvrhi::BindingSetItem::Sampler( 3, commonPasses.m_PointWrapSampler ) // blue noise + }; + } + else + { + auto& bindings = desc[3].bindings; + bindings[0].resourceHandle = commonPasses.m_AnisotropicWrapSampler; + bindings[1].resourceHandle = commonPasses.m_LinearBorderSampler; + bindings[2].resourceHandle = commonPasses.m_LinearClampCompareSampler; + bindings[3].resourceHandle = commonPasses.m_PointWrapSampler; + } + } + else if( type == BINDING_LAYOUT_FOG ) { if( desc[0].bindings.empty() ) { 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() ) }; } 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(); + auto& bindings = desc[1].bindings; + bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID(); + bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID(); } - if( desc[1].bindings.empty() ) + if( desc[2].bindings.empty() ) { - desc[1].bindings = + desc[2].bindings = { nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_LinearClampSampler ), nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_LinearClampSampler ) @@ -849,8 +1039,57 @@ void idRenderBackend::GetCurrentBindingLayout( int type, nvrhi::IBuffer* jointBu } else { - desc[1].bindings[0].resourceHandle = commonPasses.m_LinearClampSampler; - desc[1].bindings[1].resourceHandle = commonPasses.m_LinearClampSampler; + auto& bindings = desc[2].bindings; + bindings[0].resourceHandle = commonPasses.m_LinearClampSampler; + bindings[1].resourceHandle = commonPasses.m_LinearClampSampler; + } + } + else if( type == BINDING_LAYOUT_FOG_SKINNED ) + { + if( desc[0].bindings.empty() ) + { + desc[0].bindings = + { + nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ), + nvrhi::BindingSetItem::StructuredBuffer_SRV( 11, currentJointBuffer, nvrhi::Format::UNKNOWN, nvrhi::BufferRange( currentJointOffset, sizeof( idVec4 ) * numBoneMatrices ) ) + }; + } + else + { + auto& bindings = desc[0].bindings; + bindings[0].resourceHandle = renderProgManager.ConstantBuffer(); + bindings[1].resourceHandle = currentJointBuffer; + bindings[1].range = nvrhi::BufferRange{ currentJointOffset, sizeof( idVec4 )* numBoneMatrices }; + } + + 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() ) + }; + } + else + { + auto& bindings = desc[1].bindings; + bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID(); + bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID(); + } + + if( desc[2].bindings.empty() ) + { + desc[2].bindings = + { + nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_LinearClampSampler ), + nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_LinearClampSampler ) + }; + } + else + { + auto& bindings = desc[2].bindings; + bindings[0].resourceHandle = commonPasses.m_LinearClampSampler; + bindings[1].resourceHandle = commonPasses.m_LinearClampSampler; } } else if( type == BINDING_LAYOUT_BLENDLIGHT ) @@ -860,27 +1099,83 @@ void idRenderBackend::GetCurrentBindingLayout( int type, nvrhi::IBuffer* jointBu desc[0].bindings = { nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ), - nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ), - nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() ) }; } 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(); } 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() ) + }; + } + else + { + auto& bindings = desc[1].bindings; + bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID(); + bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID(); + } + + if( desc[2].bindings.empty() ) + { + desc[2].bindings = { nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_LinearBorderSampler ) }; } else { - desc[1].bindings[0].resourceHandle = commonPasses.m_LinearBorderSampler; + desc[2].bindings[0].resourceHandle = commonPasses.m_LinearBorderSampler; + } + } + else if( type == BINDING_LAYOUT_BLENDLIGHT_SKINNED ) + { + if( desc[0].bindings.empty() ) + { + desc[0].bindings = + { + nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ), + nvrhi::BindingSetItem::StructuredBuffer_SRV( 11, currentJointBuffer, nvrhi::Format::UNKNOWN, nvrhi::BufferRange( currentJointOffset, sizeof( idVec4 ) * numBoneMatrices ) ) + }; + } + else + { + auto& bindings = desc[0].bindings; + bindings[0].resourceHandle = renderProgManager.ConstantBuffer(); + bindings[1].resourceHandle = currentJointBuffer; + bindings[1].range = nvrhi::BufferRange{ currentJointOffset, sizeof( idVec4 )* numBoneMatrices }; + } + + 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() ) + }; + } + else + { + auto& bindings = desc[1].bindings; + bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID(); + bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID(); + } + + if( desc[2].bindings.empty() ) + { + desc[2].bindings = + { + nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_LinearBorderSampler ) + }; + } + else + { + desc[2].bindings[0].resourceHandle = commonPasses.m_LinearBorderSampler; } } else if( type == BINDING_LAYOUT_POST_PROCESS_INGAME ) @@ -954,27 +1249,84 @@ void idRenderBackend::GetCurrentBindingLayout( int type, nvrhi::IBuffer* jointBu desc[0].bindings = { nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ), - nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ), - nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() ) }; } 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(); } 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() ) + }; + } + else + { + auto& bindings = desc[1].bindings; + bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID(); + bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID(); + } + + if( desc[2].bindings.empty() ) + { + desc[2].bindings = { nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_LinearWrapSampler ) }; } else { - desc[1].bindings[0].resourceHandle = commonPasses.m_LinearWrapSampler; + desc[2].bindings[0].resourceHandle = commonPasses.m_LinearWrapSampler; + } + } + else if( type == BINDING_LAYOUT_NORMAL_CUBE_SKINNED ) + { + if( desc[0].bindings.empty() ) + { + desc[0].bindings = + { + nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ), + nvrhi::BindingSetItem::StructuredBuffer_SRV( 11, currentJointBuffer, nvrhi::Format::UNKNOWN, nvrhi::BufferRange( currentJointOffset, sizeof( idVec4 ) * numBoneMatrices ) ) + }; + } + else + { + desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer(); + auto& bindings = desc[0].bindings; + bindings[0].resourceHandle = renderProgManager.ConstantBuffer(); + bindings[1].resourceHandle = currentJointBuffer; + bindings[1].range = nvrhi::BufferRange{ currentJointOffset, sizeof( idVec4 )* numBoneMatrices }; + } + + 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() ) + }; + } + else + { + auto& bindings = desc[1].bindings; + bindings[0].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID(); + bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID(); + } + + if( desc[2].bindings.empty() ) + { + desc[2].bindings = + { + nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_LinearWrapSampler ) + }; + } + else + { + desc[2].bindings[0].resourceHandle = commonPasses.m_LinearWrapSampler; } } else if( type == BINDING_LAYOUT_BINK_VIDEO ) @@ -1441,6 +1793,13 @@ void idRenderBackend::ClearCaches() delete taaPass; taaPass = nullptr; } + + currentVertexBuffer = nullptr; + currentIndexBuffer = nullptr; + currentIndexOffset = -1; + currentVertexOffset = -1; + currentBindingLayout = nullptr; + currentPipeline = nullptr; } /* @@ -1713,6 +2072,7 @@ idRenderBackend::idRenderBackend() memset( &glConfig, 0, sizeof( glConfig ) ); glConfig.gpuSkinningAvailable = true; + glConfig.uniformBufferOffsetAlignment = 256; glConfig.timerQueryAvailable = true; } diff --git a/neo/renderer/PipelineCache.cpp b/neo/renderer/PipelineCache.cpp index 67105552..150c7148 100644 --- a/neo/renderer/PipelineCache.cpp +++ b/neo/renderer/PipelineCache.cpp @@ -62,7 +62,7 @@ nvrhi::GraphicsPipelineHandle PipelineCache::GetOrCreatePipeline( const Pipeline } nvrhi::GraphicsPipelineDesc pipelineDesc; - programInfo_t progInfo = renderProgManager.GetProgramInfo( key.program ); + const programInfo_t progInfo = renderProgManager.GetProgramInfo( key.program ); pipelineDesc.setVertexShader( progInfo.vs ).setFragmentShader( progInfo.ps ); pipelineDesc.inputLayout = progInfo.inputLayout; for( int i = 0; i < progInfo.bindingLayouts->Num(); i++ ) @@ -78,9 +78,6 @@ nvrhi::GraphicsPipelineHandle PipelineCache::GetOrCreatePipeline( const Pipeline { target.enableBlend(); } - //pipelineDesc.renderState.rasterState.enableDepthClip(); - //pipelineDesc.renderState.rasterState.depthBias = 0; - //pipelineDesc.renderState.rasterState.slopeScaledDepthBias = 0; // Specialize the state with the state key. GetRenderState( key.state, key, pipelineDesc.renderState ); diff --git a/neo/renderer/RenderBackend.h b/neo/renderer/RenderBackend.h index 4b9fe3d1..aeadd644 100644 --- a/neo/renderer/RenderBackend.h +++ b/neo/renderer/RenderBackend.h @@ -295,7 +295,7 @@ public: private: void DrawFlickerBox(); - void GetCurrentBindingLayout( int bindingLayoutType, nvrhi::IBuffer* jointBuffer ); + void GetCurrentBindingLayout( int bindingLayoutType ); void DrawStencilShadowPass( const drawSurf_t* drawSurf, const bool renderZPass ); void SetColorMappings(); @@ -528,8 +528,9 @@ private: uint currentVertexOffset; nvrhi::BufferHandle currentIndexBuffer; uint currentIndexOffset; - nvrhi::BufferHandle currentJointBuffer; nvrhi::BindingLayoutHandle currentBindingLayout; + nvrhi::IBuffer* currentJointBuffer; + uint currentJointOffset; nvrhi::GraphicsPipelineHandle currentPipeline; idStaticList currentBindingSets; diff --git a/neo/renderer/RenderCommon.h b/neo/renderer/RenderCommon.h index 16f19775..91170ec5 100644 --- a/neo/renderer/RenderCommon.h +++ b/neo/renderer/RenderCommon.h @@ -864,8 +864,8 @@ enum bindingLayoutType_t 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_SHADOWVOLUME, // TODO FIX or REMOVE? + //BINDING_LAYOUT_DRAW_SHADOWVOLUME_SKINNED, BINDING_LAYOUT_DRAW_INTERACTION, BINDING_LAYOUT_DRAW_INTERACTION_SKINNED, diff --git a/neo/renderer/RenderProgs.cpp b/neo/renderer/RenderProgs.cpp index 8584f7a8..50991353 100644 --- a/neo/renderer/RenderProgs.cpp +++ b/neo/renderer/RenderProgs.cpp @@ -181,17 +181,10 @@ void idRenderProgManager::Init( nvrhi::IDevice* device ) auto skinningLayoutDesc = nvrhi::BindingLayoutDesc() .setVisibility( nvrhi::ShaderType::All ) .addItem( nvrhi::BindingLayoutItem::VolatileConstantBuffer( 0 ) ) - .addItem( nvrhi::BindingLayoutItem::VolatileConstantBuffer( 1 ) ); + .addItem( nvrhi::BindingLayoutItem::StructuredBuffer_SRV( 11 ) ); // joint buffer; 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 ) ); @@ -206,29 +199,9 @@ void idRenderProgManager::Init( nvrhi::IDevice* device ) 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 ) ); - - 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 @@ -285,27 +258,43 @@ void idRenderProgManager::Init( nvrhi::IDevice* device ) bindingLayouts[BINDING_LAYOUT_DRAW_AO1] = { device->createBindingLayout( aoLayoutDesc2 ), samplerOneBindingLayout }; - nvrhi::BindingLayoutDesc shadowLayout; - shadowLayout.visibility = nvrhi::ShaderType::All; - shadowLayout.bindings = + /* + nvrhi::BindingLayoutDesc shadowLayoutDesc; + shadowLayoutDesc.visibility = nvrhi::ShaderType::All; + shadowLayoutDesc.bindings = { nvrhi::BindingLayoutItem::VolatileConstantBuffer( 0 ) }; - bindingLayouts[BINDING_LAYOUT_DRAW_SHADOWVOLUME] = { device->createBindingLayout( shadowLayout ) }; + auto shadowLayout = device->createBindingLayout( shadowLayoutDesc ); + bindingLayouts[BINDING_LAYOUT_DRAW_SHADOWVOLUME] = + { - auto interactionBindingLayout = nvrhi::BindingLayoutDesc() - .setVisibility( nvrhi::ShaderType::All ) - .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 3 ) ) // light falloff - .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 4 ) ); // light projection + }; + */ - bindingLayouts[BINDING_LAYOUT_DRAW_INTERACTION] = { defaultMaterialLayout, device->createBindingLayout( interactionBindingLayout ), samplerTwoBindingLayout }; + auto interactionBindingLayoutDesc = nvrhi::BindingLayoutDesc() + .setVisibility( nvrhi::ShaderType::Pixel ) + .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 3 ) ) // light falloff + .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 4 ) ); // light projection - auto interactionSmBindingLayout = nvrhi::BindingLayoutDesc() - .setVisibility( nvrhi::ShaderType::All ) - .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 3 ) ) // light falloff - .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 4 ) ) // light projection - .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 5 ) ) // shadow map array - .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 6 ) ); // jitter + auto interactionBindingLayout = device->createBindingLayout( interactionBindingLayoutDesc ); + bindingLayouts[BINDING_LAYOUT_DRAW_INTERACTION] = + { + uniformsLayout, defaultMaterialLayout, interactionBindingLayout, samplerTwoBindingLayout + }; + bindingLayouts[BINDING_LAYOUT_DRAW_INTERACTION_SKINNED] = + { + skinningLayout, defaultMaterialLayout, interactionBindingLayout, samplerTwoBindingLayout + }; + + auto interactionSmBindingLayoutDesc = nvrhi::BindingLayoutDesc() + .setVisibility( nvrhi::ShaderType::Pixel ) + .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 3 ) ) // light falloff + .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 4 ) ) // light projection + .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 5 ) ) // shadow map array + .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 6 ) ); // jitter + + auto interactionSmBindingLayout = device->createBindingLayout( interactionSmBindingLayoutDesc ); auto samplerFourBindingLayoutDesc = nvrhi::BindingLayoutDesc() .setVisibility( nvrhi::ShaderType::Pixel ) @@ -315,23 +304,46 @@ void idRenderProgManager::Init( nvrhi::IDevice* device ) .addItem( nvrhi::BindingLayoutItem::Sampler( 3 ) ); // blue noise for shadow jitter auto samplerFourBindingLayout = device->createBindingLayout( samplerFourBindingLayoutDesc ); - bindingLayouts[BINDING_LAYOUT_DRAW_INTERACTION_SM] = { defaultMaterialLayout, device->createBindingLayout( interactionSmBindingLayout ), samplerFourBindingLayout }; + bindingLayouts[BINDING_LAYOUT_DRAW_INTERACTION_SM] = + { + uniformsLayout, defaultMaterialLayout, interactionSmBindingLayout, samplerFourBindingLayout + }; + bindingLayouts[BINDING_LAYOUT_DRAW_INTERACTION_SM_SKINNED] = + { + skinningLayout, defaultMaterialLayout, interactionSmBindingLayout, samplerFourBindingLayout + }; - auto fogBindingLayout = nvrhi::BindingLayoutDesc() - .setVisibility( nvrhi::ShaderType::All ) - .addItem( nvrhi::BindingLayoutItem::VolatileConstantBuffer( 0 ) ) - .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 0 ) ) - .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 1 ) ); + auto fogBindingLayoutDesc = nvrhi::BindingLayoutDesc() + .setVisibility( nvrhi::ShaderType::Pixel ) + .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 0 ) ) + .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 1 ) ); - bindingLayouts[BINDING_LAYOUT_DRAW_FOG] = { device->createBindingLayout( fogBindingLayout ), samplerTwoBindingLayout }; + auto fogBindingLayout = device->createBindingLayout( fogBindingLayoutDesc ); - auto blendLightBindingLayout = nvrhi::BindingLayoutDesc() - .setVisibility( nvrhi::ShaderType::All ) - .addItem( nvrhi::BindingLayoutItem::VolatileConstantBuffer( 0 ) ) - .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 0 ) ) // light 1 - .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 1 ) ); // light 2 + bindingLayouts[BINDING_LAYOUT_FOG] = + { + uniformsLayout, fogBindingLayout, samplerTwoBindingLayout + }; + bindingLayouts[BINDING_LAYOUT_FOG_SKINNED] = + { + skinningLayout, fogBindingLayout, samplerTwoBindingLayout + }; - bindingLayouts[BINDING_LAYOUT_BLENDLIGHT] = { device->createBindingLayout( blendLightBindingLayout ), samplerOneBindingLayout }; + auto blendLightBindingLayoutDesc = nvrhi::BindingLayoutDesc() + .setVisibility( nvrhi::ShaderType::Pixel ) + .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 0 ) ) // light 1 + .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 1 ) ); // light 2 + + auto blendLightBindingLayout = device->createBindingLayout( blendLightBindingLayoutDesc ); + + bindingLayouts[BINDING_LAYOUT_BLENDLIGHT] = + { + uniformsLayout, blendLightBindingLayout, samplerOneBindingLayout + }; + bindingLayouts[BINDING_LAYOUT_BLENDLIGHT_SKINNED] = + { + uniformsLayout, blendLightBindingLayout, samplerOneBindingLayout + }; auto pp3DBindingLayout = nvrhi::BindingLayoutDesc() .setVisibility( nvrhi::ShaderType::All ) @@ -350,13 +362,21 @@ void idRenderProgManager::Init( nvrhi::IDevice* device ) bindingLayouts[BINDING_LAYOUT_POST_PROCESS_FINAL] = { device->createBindingLayout( ppFxBindingLayout ), samplerTwoBindingLayout }; - auto normalCubeBindingLayout = nvrhi::BindingLayoutDesc() - .setVisibility( nvrhi::ShaderType::All ) - .addItem( nvrhi::BindingLayoutItem::VolatileConstantBuffer( 0 ) ) - .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 0 ) ) // cube map - .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 1 ) ); // normal map + auto normalCubeBindingLayoutDesc = nvrhi::BindingLayoutDesc() + .setVisibility( nvrhi::ShaderType::Pixel ) + .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 0 ) ) // cube map + .addItem( nvrhi::BindingLayoutItem::Texture_SRV( 1 ) ); // normal map - bindingLayouts[BINDING_LAYOUT_NORMAL_CUBE] = { device->createBindingLayout( normalCubeBindingLayout ), samplerOneBindingLayout }; + auto normalCubeBindingLayout = device->createBindingLayout( normalCubeBindingLayoutDesc ); + + bindingLayouts[BINDING_LAYOUT_NORMAL_CUBE] = + { + uniformsLayout, normalCubeBindingLayout, samplerOneBindingLayout + }; + bindingLayouts[BINDING_LAYOUT_NORMAL_CUBE_SKINNED] = + { + skinningLayout, normalCubeBindingLayout, samplerOneBindingLayout + }; auto binkVideoBindingLayout = nvrhi::BindingLayoutDesc() .setVisibility( nvrhi::ShaderType::All ) @@ -424,106 +444,107 @@ void idRenderProgManager::Init( nvrhi::IDevice* device ) { BUILTIN_GUI, "builtin/gui", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, { BUILTIN_COLOR, "builtin/color", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, // RB begin - { BUILTIN_COLOR_SKINNED, "builtin/color", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, + { BUILTIN_COLOR_SKINNED, "builtin/color", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT_SKINNED }, { BUILTIN_VERTEX_COLOR, "builtin/vertex_color", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, { BUILTIN_AMBIENT_LIGHTING_IBL, "builtin/lighting/ambient_lighting_IBL", "", { { "USE_GPU_SKINNING", "0" }, { "USE_PBR", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_AMBIENT_LIGHTING_IBL }, - { BUILTIN_AMBIENT_LIGHTING_IBL_SKINNED, "builtin/lighting/ambient_lighting_IBL", "_skinned", { { "USE_GPU_SKINNING", "1" }, { "USE_PBR", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_AMBIENT_LIGHTING_IBL }, + { BUILTIN_AMBIENT_LIGHTING_IBL_SKINNED, "builtin/lighting/ambient_lighting_IBL", "_skinned", { { "USE_GPU_SKINNING", "1" }, { "USE_PBR", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_AMBIENT_LIGHTING_IBL_SKINNED }, { BUILTIN_AMBIENT_LIGHTING_IBL_PBR, "builtin/lighting/ambient_lighting_IBL", "_PBR", { { "USE_GPU_SKINNING", "0" }, { "USE_PBR", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_AMBIENT_LIGHTING_IBL }, - { BUILTIN_AMBIENT_LIGHTING_IBL_PBR_SKINNED, "builtin/lighting/ambient_lighting_IBL", "_PBR_skinned", { { "USE_GPU_SKINNING", "1" }, { "USE_PBR", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_AMBIENT_LIGHTING_IBL }, + { BUILTIN_AMBIENT_LIGHTING_IBL_PBR_SKINNED, "builtin/lighting/ambient_lighting_IBL", "_PBR_skinned", { { "USE_GPU_SKINNING", "1" }, { "USE_PBR", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_AMBIENT_LIGHTING_IBL_SKINNED }, { BUILTIN_AMBIENT_LIGHTGRID_IBL, "builtin/lighting/ambient_lightgrid_IBL", "", { { "USE_GPU_SKINNING", "0" }, { "USE_PBR", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_AMBIENT_LIGHTING_IBL }, - { BUILTIN_AMBIENT_LIGHTGRID_IBL_SKINNED, "builtin/lighting/ambient_lightgrid_IBL", "_skinned", { { "USE_GPU_SKINNING", "1" }, { "USE_PBR", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_AMBIENT_LIGHTING_IBL }, + { BUILTIN_AMBIENT_LIGHTGRID_IBL_SKINNED, "builtin/lighting/ambient_lightgrid_IBL", "_skinned", { { "USE_GPU_SKINNING", "1" }, { "USE_PBR", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_AMBIENT_LIGHTING_IBL_SKINNED }, { BUILTIN_AMBIENT_LIGHTGRID_IBL_PBR, "builtin/lighting/ambient_lightgrid_IBL", "_PBR", { { "USE_GPU_SKINNING", "0" }, { "USE_PBR", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_AMBIENT_LIGHTING_IBL }, - { BUILTIN_AMBIENT_LIGHTGRID_IBL_PBR_SKINNED, "builtin/lighting/ambient_lightgrid_IBL", "_PBR_skinned", { { "USE_GPU_SKINNING", "1" }, { "USE_PBR", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_AMBIENT_LIGHTING_IBL }, + { BUILTIN_AMBIENT_LIGHTGRID_IBL_PBR_SKINNED, "builtin/lighting/ambient_lightgrid_IBL", "_PBR_skinned", { { "USE_GPU_SKINNING", "1" }, { "USE_PBR", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_AMBIENT_LIGHTING_IBL_SKINNED }, { BUILTIN_SMALL_GEOMETRY_BUFFER, "builtin/gbuffer", "", { {"USE_GPU_SKINNING", "0" }, { "USE_NORMAL_FMT_RGB8", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, - { BUILTIN_SMALL_GEOMETRY_BUFFER_SKINNED, "builtin/gbuffer", "_skinned", { {"USE_GPU_SKINNING", "1" }, { "USE_NORMAL_FMT_RGB8", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, + { BUILTIN_SMALL_GEOMETRY_BUFFER_SKINNED, "builtin/gbuffer", "_skinned", { {"USE_GPU_SKINNING", "1" }, { "USE_NORMAL_FMT_RGB8", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT_SKINNED }, // RB end { BUILTIN_TEXTURED, "builtin/texture", "", { }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, { BUILTIN_TEXTURE_VERTEXCOLOR, "builtin/texture_color", "", { {"USE_GPU_SKINNING", "0" }, {"USE_SRGB", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, { BUILTIN_TEXTURE_VERTEXCOLOR_SRGB, "builtin/texture_color", "_sRGB", { {"USE_GPU_SKINNING", "0" }, {"USE_SRGB", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, - { BUILTIN_TEXTURE_VERTEXCOLOR_SKINNED, "builtin/texture_color", "_skinned", { {"USE_GPU_SKINNING", "1" }, {"USE_SRGB", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, + { BUILTIN_TEXTURE_VERTEXCOLOR_SKINNED, "builtin/texture_color", "_skinned", { {"USE_GPU_SKINNING", "1" }, {"USE_SRGB", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT_SKINNED }, { BUILTIN_TEXTURE_TEXGEN_VERTEXCOLOR, "builtin/texture_color_texgen", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, // RB begin { BUILTIN_INTERACTION, "builtin/lighting/interaction", "", { {"USE_GPU_SKINNING", "0" }, { "USE_PBR", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION }, - { BUILTIN_INTERACTION_SKINNED, "builtin/lighting/interaction", "_skinned", { {"USE_GPU_SKINNING", "1" }, { "USE_PBR", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION }, + { BUILTIN_INTERACTION_SKINNED, "builtin/lighting/interaction", "_skinned", { {"USE_GPU_SKINNING", "1" }, { "USE_PBR", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SKINNED }, { BUILTIN_INTERACTION_AMBIENT, "builtin/lighting/interactionAmbient", "", { {"USE_GPU_SKINNING", "0" }, { "USE_PBR", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION }, - { BUILTIN_INTERACTION_AMBIENT_SKINNED, "builtin/lighting/interactionAmbient", "_skinned", { {"USE_GPU_SKINNING", "1" }, { "USE_PBR", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION }, + { BUILTIN_INTERACTION_AMBIENT_SKINNED, "builtin/lighting/interactionAmbient", "_skinned", { {"USE_GPU_SKINNING", "1" }, { "USE_PBR", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SKINNED }, // PBR variants { BUILTIN_PBR_INTERACTION, "builtin/lighting/interaction", "_PBR", { {"USE_GPU_SKINNING", "0" }, { "USE_PBR", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION }, - { BUILTIN_PBR_INTERACTION_SKINNED, "builtin/lighting/interaction", "_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "USE_PBR", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION }, + { BUILTIN_PBR_INTERACTION_SKINNED, "builtin/lighting/interaction", "_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "USE_PBR", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SKINNED }, { BUILTIN_PBR_INTERACTION_AMBIENT, "builtin/lighting/interactionAmbient", "_PBR", { {"USE_GPU_SKINNING", "0" }, { "USE_PBR", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION }, - { BUILTIN_PBR_INTERACTION_AMBIENT_SKINNED, "builtin/lighting/interactionAmbient", "_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "USE_PBR", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION }, + { BUILTIN_PBR_INTERACTION_AMBIENT_SKINNED, "builtin/lighting/interactionAmbient", "_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "USE_PBR", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SKINNED }, // regular shadow mapping { BUILTIN_INTERACTION_SHADOW_MAPPING_SPOT, "builtin/lighting/interactionSM", "_spot", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, - { BUILTIN_INTERACTION_SHADOW_MAPPING_SPOT_SKINNED, "builtin/lighting/interactionSM", "_spot_skinned", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, + { BUILTIN_INTERACTION_SHADOW_MAPPING_SPOT_SKINNED, "builtin/lighting/interactionSM", "_spot_skinned", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM_SKINNED }, { BUILTIN_INTERACTION_SHADOW_MAPPING_POINT, "builtin/lighting/interactionSM", "_point", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, - { BUILTIN_INTERACTION_SHADOW_MAPPING_POINT_SKINNED, "builtin/lighting/interactionSM", "_point_skinned", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, + { BUILTIN_INTERACTION_SHADOW_MAPPING_POINT_SKINNED, "builtin/lighting/interactionSM", "_point_skinned", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM_SKINNED }, { BUILTIN_INTERACTION_SHADOW_MAPPING_PARALLEL, "builtin/lighting/interactionSM", "_parallel", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, - { BUILTIN_INTERACTION_SHADOW_MAPPING_PARALLEL_SKINNED, "builtin/lighting/interactionSM", "_parallel_skinned", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, + { BUILTIN_INTERACTION_SHADOW_MAPPING_PARALLEL_SKINNED, "builtin/lighting/interactionSM", "_parallel_skinned", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM_SKINNED }, { BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_SPOT, "builtin/lighting/interactionSM", "_spot_PBR", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, - { BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_SPOT_SKINNED, "builtin/lighting/interactionSM", "_spot_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, + { BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_SPOT_SKINNED, "builtin/lighting/interactionSM", "_spot_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM_SKINNED }, { BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_POINT, "builtin/lighting/interactionSM", "_point_PBR", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, - { BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_POINT_SKINNED, "builtin/lighting/interactionSM", "_point_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, + { BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_POINT_SKINNED, "builtin/lighting/interactionSM", "_point_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM_SKINNED }, { BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_PARALLEL, "builtin/lighting/interactionSM", "_parallel_PBR", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, - { BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_PARALLEL_SKINNED, "builtin/lighting/interactionSM", "_parallel_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, + { BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_PARALLEL_SKINNED, "builtin/lighting/interactionSM", "_parallel_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM_SKINNED }, // shadow mapping using a big atlas { BUILTIN_INTERACTION_SHADOW_ATLAS_SPOT, "builtin/lighting/interactionSM", "_atlas_spot", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, - { BUILTIN_INTERACTION_SHADOW_ATLAS_SPOT_SKINNED, "builtin/lighting/interactionSM", "_atlas_spot_skinned", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, + { BUILTIN_INTERACTION_SHADOW_ATLAS_SPOT_SKINNED, "builtin/lighting/interactionSM", "_atlas_spot_skinned", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM_SKINNED }, { BUILTIN_INTERACTION_SHADOW_ATLAS_POINT, "builtin/lighting/interactionSM", "_atlas_point", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, - { BUILTIN_INTERACTION_SHADOW_ATLAS_POINT_SKINNED, "builtin/lighting/interactionSM", "_atlas_point_skinned", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, + { BUILTIN_INTERACTION_SHADOW_ATLAS_POINT_SKINNED, "builtin/lighting/interactionSM", "_atlas_point_skinned", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM_SKINNED }, { BUILTIN_INTERACTION_SHADOW_ATLAS_PARALLEL, "builtin/lighting/interactionSM", "_atlas_parallel", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, - { BUILTIN_INTERACTION_SHADOW_ATLAS_PARALLEL_SKINNED, "builtin/lighting/interactionSM", "_atlas_parallel_skinned", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, + { BUILTIN_INTERACTION_SHADOW_ATLAS_PARALLEL_SKINNED, "builtin/lighting/interactionSM", "_atlas_parallel_skinned", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM_SKINNED }, { BUILTIN_PBR_INTERACTION_SHADOW_ATLAS_SPOT, "builtin/lighting/interactionSM", "_atlas_spot_PBR", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, - { BUILTIN_PBR_INTERACTION_SHADOW_ATLAS_SPOT_SKINNED, "builtin/lighting/interactionSM", "_atlas_spot_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, + { BUILTIN_PBR_INTERACTION_SHADOW_ATLAS_SPOT_SKINNED, "builtin/lighting/interactionSM", "_atlas_spot_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM_SKINNED }, { BUILTIN_PBR_INTERACTION_SHADOW_ATLAS_POINT, "builtin/lighting/interactionSM", "_atlas_point_PBR", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, - { BUILTIN_PBR_INTERACTION_SHADOW_ATLAS_POINT_SKINNED, "builtin/lighting/interactionSM", "_atlas_point_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, + { BUILTIN_PBR_INTERACTION_SHADOW_ATLAS_POINT_SKINNED, "builtin/lighting/interactionSM", "_atlas_point_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM_SKINNED }, { BUILTIN_PBR_INTERACTION_SHADOW_ATLAS_PARALLEL, "builtin/lighting/interactionSM", "_atlas_parallel_PBR", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, - { BUILTIN_PBR_INTERACTION_SHADOW_ATLAS_PARALLEL_SKINNED, "builtin/lighting/interactionSM", "_atlas_parallel_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM }, + { BUILTIN_PBR_INTERACTION_SHADOW_ATLAS_PARALLEL_SKINNED, "builtin/lighting/interactionSM", "_atlas_parallel_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" }, { "USE_SHADOW_ATLAS", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM_SKINNED }, // debug stuff { BUILTIN_DEBUG_LIGHTGRID, "builtin/debug/lightgrid", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, - { BUILTIN_DEBUG_LIGHTGRID_SKINNED, "builtin/debug/lightgrid", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, + { BUILTIN_DEBUG_LIGHTGRID_SKINNED, "builtin/debug/lightgrid", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT_SKINNED }, { BUILTIN_DEBUG_OCTAHEDRON, "builtin/debug/octahedron", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, - { BUILTIN_DEBUG_OCTAHEDRON_SKINNED, "builtin/debug/octahedron", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, + { BUILTIN_DEBUG_OCTAHEDRON_SKINNED, "builtin/debug/octahedron", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT_SKINNED }, // RB end { BUILTIN_ENVIRONMENT, "builtin/legacy/environment", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, - { BUILTIN_ENVIRONMENT_SKINNED, "builtin/legacy/environment", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true , SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, + { BUILTIN_ENVIRONMENT_SKINNED, "builtin/legacy/environment", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true , SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT_SKINNED }, { BUILTIN_BUMPY_ENVIRONMENT, "builtin/legacy/bumpyenvironment", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_NORMAL_CUBE }, - { BUILTIN_BUMPY_ENVIRONMENT_SKINNED, "builtin/legacy/bumpyenvironment", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_NORMAL_CUBE }, + { BUILTIN_BUMPY_ENVIRONMENT_SKINNED, "builtin/legacy/bumpyenvironment", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_NORMAL_CUBE_SKINNED }, { BUILTIN_DEPTH, "builtin/depth", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_CONSTANT_BUFFER_ONLY }, - { BUILTIN_DEPTH_SKINNED, "builtin/depth", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_CONSTANT_BUFFER_ONLY }, + { BUILTIN_DEPTH_SKINNED, "builtin/depth", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_CONSTANT_BUFFER_ONLY_SKINNED }, { BUILTIN_SHADOW, "builtin/lighting/shadow", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_SHADOW_VERT, BINDING_LAYOUT_CONSTANT_BUFFER_ONLY }, - { BUILTIN_SHADOW_SKINNED, "builtin/lighting/shadow", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_SHADOW_VERT_SKINNED, BINDING_LAYOUT_CONSTANT_BUFFER_ONLY }, + { BUILTIN_SHADOW_SKINNED, "builtin/lighting/shadow", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_SHADOW_VERT_SKINNED, BINDING_LAYOUT_CONSTANT_BUFFER_ONLY_SKINNED }, { BUILTIN_SHADOW_DEBUG, "builtin/debug/shadowDebug", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, - { BUILTIN_SHADOW_DEBUG_SKINNED, "builtin/debug/shadowDebug", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, + { BUILTIN_SHADOW_DEBUG_SKINNED, "builtin/debug/shadowDebug", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT_SKINNED }, - { BUILTIN_BLENDLIGHT, "builtin/fog/blendlight", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_BLENDLIGHT }, - { BUILTIN_FOG, "builtin/fog/fog", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_FOG }, - { BUILTIN_FOG_SKINNED, "builtin/fog/fog", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_FOG }, + { BUILTIN_BLENDLIGHT, "builtin/fog/blendlight", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_BLENDLIGHT }, + { BUILTIN_BLENDLIGHT_SKINNED, "builtin/fog/blendlight", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_BLENDLIGHT_SKINNED }, + { BUILTIN_FOG, "builtin/fog/fog", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_FOG }, + { BUILTIN_FOG_SKINNED, "builtin/fog/fog", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_FOG_SKINNED }, { BUILTIN_SKYBOX, "builtin/legacy/skybox", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, { BUILTIN_WOBBLESKY, "builtin/legacy/wobblesky", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT }, { BUILTIN_POSTPROCESS, "builtin/post/postprocess", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_POST_PROCESS_FINAL }, diff --git a/neo/renderer/RenderProgs.h b/neo/renderer/RenderProgs.h index c327b932..4a5774e5 100644 --- a/neo/renderer/RenderProgs.h +++ b/neo/renderer/RenderProgs.h @@ -365,6 +365,7 @@ enum BUILTIN_SHADOW_DEBUG_SKINNED, BUILTIN_BLENDLIGHT, + BUILTIN_BLENDLIGHT_SKINNED, BUILTIN_FOG, BUILTIN_FOG_SKINNED, BUILTIN_SKYBOX, diff --git a/neo/renderer/tr_frontend_addmodels.cpp b/neo/renderer/tr_frontend_addmodels.cpp index 53530a6c..e3cc6115 100644 --- a/neo/renderer/tr_frontend_addmodels.cpp +++ b/neo/renderer/tr_frontend_addmodels.cpp @@ -334,7 +334,7 @@ R_SetupDrawSurfJoints */ void R_SetupDrawSurfJoints( drawSurf_t* drawSurf, const srfTriangles_t* tri, const idMaterial* shader, nvrhi::ICommandList* commandList ) { - // RB: added check wether GPU skinning is available at all + // RB: added check whether GPU skinning is available at all if( tri->staticModelWithJoints == NULL || !r_useGPUSkinning.GetBool() || !glConfig.gpuSkinningAvailable ) { drawSurf->jointCache = 0; @@ -347,7 +347,6 @@ void R_SetupDrawSurfJoints( drawSurf_t* drawSurf, const srfTriangles_t* tri, con if( !vertexCache.CacheIsCurrent( model->jointsInvertedBuffer ) ) { - const int alignment = glConfig.uniformBufferOffsetAlignment; model->jointsInvertedBuffer = vertexCache.AllocJoint( model->jointsInverted, model->numInvertedJoints, sizeof( idJointMat ), commandList ); } drawSurf->jointCache = model->jointsInvertedBuffer; @@ -734,7 +733,7 @@ void R_AddSingleModel( viewEntity_t* vEntity ) // individual surfaces. const bool surfaceDirectlyVisible = modelIsVisible && !idRenderMatrix::CullBoundsToMVP( vEntity->mvp, tri->bounds ); - // RB: added check wether GPU skinning is available at all + // RB: added check whether GPU skinning is available at all const bool gpuSkinned = ( tri->staticModelWithJoints != NULL && r_useGPUSkinning.GetBool() && glConfig.gpuSkinningAvailable ); // RB end diff --git a/neo/shaders/builtin/color.vs.hlsl b/neo/shaders/builtin/color.vs.hlsl index a20b0c29..e7525599 100644 --- a/neo/shaders/builtin/color.vs.hlsl +++ b/neo/shaders/builtin/color.vs.hlsl @@ -30,15 +30,11 @@ 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 ) -{ - float4 matrices[408]; -}; +StructuredBuffer matrices : register(t11); #endif -// *INDENT-OFF* struct VS_IN { float4 position : POSITION; diff --git a/neo/shaders/builtin/debug/lightgrid.vs.hlsl b/neo/shaders/builtin/debug/lightgrid.vs.hlsl index c9e3f92e..df778083 100644 --- a/neo/shaders/builtin/debug/lightgrid.vs.hlsl +++ b/neo/shaders/builtin/debug/lightgrid.vs.hlsl @@ -30,18 +30,13 @@ 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 ) -{ - float4 matrices[408]; -}; - +StructuredBuffer matrices: register(t11); #endif -// *INDENT-OFF* -struct VS_IN { +struct VS_IN +{ float4 position : POSITION; float2 texcoord : TEXCOORD0; float4 normal : NORMAL; @@ -50,7 +45,8 @@ struct VS_IN { float4 color2 : COLOR1; }; -struct VS_OUT { +struct VS_OUT +{ float4 position : SV_Position; float3 texcoord0 : TEXCOORD0_centroid; float3 texcoord1 : TEXCOORD1_centroid; diff --git a/neo/shaders/builtin/debug/octahedron.vs.hlsl b/neo/shaders/builtin/debug/octahedron.vs.hlsl index 11d8edc4..a85b38e7 100644 --- a/neo/shaders/builtin/debug/octahedron.vs.hlsl +++ b/neo/shaders/builtin/debug/octahedron.vs.hlsl @@ -30,18 +30,13 @@ 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 ) -{ - float4 matrices[408]; -}; - +StructuredBuffer matrices: register(t11); #endif -// *INDENT-OFF* -struct VS_IN { +struct VS_IN +{ float4 position : POSITION; float2 texcoord : TEXCOORD0; float4 normal : NORMAL; @@ -50,7 +45,8 @@ struct VS_IN { float4 color2 : COLOR1; }; -struct VS_OUT { +struct VS_OUT +{ float4 position : SV_Position; float3 texcoord0 : TEXCOORD0_centroid; float3 texcoord1 : TEXCOORD1_centroid; diff --git a/neo/shaders/builtin/debug/shadowDebug.vs.hlsl b/neo/shaders/builtin/debug/shadowDebug.vs.hlsl index bc2d1fa8..d4807521 100644 --- a/neo/shaders/builtin/debug/shadowDebug.vs.hlsl +++ b/neo/shaders/builtin/debug/shadowDebug.vs.hlsl @@ -31,13 +31,11 @@ If you have questions concerning this license or the applicable additional terms // *INDENT-OFF* #if USE_GPU_SKINNING -cbuffer CB : register( b1 VK_DESCRIPTOR_SET( 0 )) -{ - float4 matrices[408]; -}; +StructuredBuffer matrices: register(t11); #endif -struct VS_IN { +struct VS_IN +{ float4 position : POSITION; #if USE_GPU_SKINNING float4 color : COLOR0; @@ -45,7 +43,8 @@ struct VS_IN { #endif }; -struct VS_OUT { +struct VS_OUT +{ float4 position : SV_Position; }; // *INDENT-ON* diff --git a/neo/shaders/builtin/depth.vs.hlsl b/neo/shaders/builtin/depth.vs.hlsl index 4ebba455..4937d8bc 100644 --- a/neo/shaders/builtin/depth.vs.hlsl +++ b/neo/shaders/builtin/depth.vs.hlsl @@ -30,13 +30,10 @@ If you have questions concerning this license or the applicable additional terms // *INDENT-OFF* #if USE_GPU_SKINNING -cbuffer CB : register( b1 ) -{ - float4 matrices[408]; -}; +StructuredBuffer matrices : register(t11); #endif -struct VS_IN +struct VS_IN { float4 position : POSITION; #if USE_GPU_SKINNING diff --git a/neo/shaders/builtin/fog/blendLight.vs.hlsl b/neo/shaders/builtin/fog/blendLight.vs.hlsl index 7b295657..50977a24 100644 --- a/neo/shaders/builtin/fog/blendLight.vs.hlsl +++ b/neo/shaders/builtin/fog/blendLight.vs.hlsl @@ -30,15 +30,24 @@ If you have questions concerning this license or the applicable additional terms // *INDENT-OFF* -struct VS_IN { +#if USE_GPU_SKINNING +StructuredBuffer matrices: register(t11); +#endif + +struct VS_IN +{ float4 position : POSITION; float2 texcoord : TEXCOORD0; float4 normal : NORMAL; float4 tangent : TANGENT; float4 color : COLOR0; +#if USE_GPU_SKINNING + float4 color2 : COLOR1; +#endif }; -struct VS_OUT { +struct VS_OUT +{ float4 position : SV_Position; float4 texcoord0 : TEXCOORD0_centroid; float2 texcoord1 : TEXCOORD1_centroid; @@ -47,6 +56,59 @@ struct VS_OUT { void main( VS_IN vertex, out VS_OUT result ) { +#if USE_GPU_SKINNING + //-------------------------------------------------------------- + // 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; + // end of skinning + + // start of fog portion + result.position.x = dot4( modelPosition, rpMVPmatrixX ); + result.position.y = dot4( modelPosition, rpMVPmatrixY ); + result.position.z = dot4( modelPosition, rpMVPmatrixZ ); + result.position.w = dot4( modelPosition, rpMVPmatrixW ); + + result.texcoord0.x = dot4( modelPosition, rpTexGen0S ); + result.texcoord0.y = dot4( modelPosition, rpTexGen0T ); + result.texcoord0.z = 0.0; + result.texcoord0.w = dot4( modelPosition, rpTexGen0Q ); + + result.texcoord1.x = dot4( modelPosition, rpTexGen1S ); + result.texcoord1.y = 0.5; +#else result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); @@ -59,4 +121,5 @@ void main( VS_IN vertex, out VS_OUT result ) result.texcoord1.x = dot4( vertex.position, rpTexGen1S ); result.texcoord1.y = 0.5; +#endif } diff --git a/neo/shaders/builtin/fog/fog.vs.hlsl b/neo/shaders/builtin/fog/fog.vs.hlsl index a86a4ff5..441dad2a 100644 --- a/neo/shaders/builtin/fog/fog.vs.hlsl +++ b/neo/shaders/builtin/fog/fog.vs.hlsl @@ -31,13 +31,11 @@ If you have questions concerning this license or the applicable additional terms // *INDENT-OFF* #if USE_GPU_SKINNING -cbuffer CB : register( b1 ) -{ - float4 matrices[408]; -}; +StructuredBuffer matrices: register(t11); #endif -struct VS_IN { +struct VS_IN +{ float4 position : POSITION; float2 texcoord : TEXCOORD0; float4 normal : NORMAL; @@ -48,7 +46,8 @@ struct VS_IN { #endif }; -struct VS_OUT { +struct VS_OUT +{ float4 position : SV_Position; float2 texcoord0 : TEXCOORD0_centroid; float2 texcoord1 : TEXCOORD1_centroid; diff --git a/neo/shaders/builtin/gbuffer.vs.hlsl b/neo/shaders/builtin/gbuffer.vs.hlsl index 4b2d5837..6699a845 100644 --- a/neo/shaders/builtin/gbuffer.vs.hlsl +++ b/neo/shaders/builtin/gbuffer.vs.hlsl @@ -31,13 +31,10 @@ If you have questions concerning this license or the applicable additional terms // *INDENT-OFF* #if USE_GPU_SKINNING -cbuffer CB : register( b1 ) -{ - float4 matrices[408]; -}; +StructuredBuffer matrices : register(t11); #endif -struct VS_IN +struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -47,7 +44,7 @@ struct VS_IN float4 color2 : COLOR1; }; -struct VS_OUT +struct VS_OUT { float4 position : SV_Position; float2 texcoord0 : TEXCOORD0_centroid; diff --git a/neo/shaders/builtin/legacy/bumpyenvironment.vs.hlsl b/neo/shaders/builtin/legacy/bumpyenvironment.vs.hlsl index ba4b508e..40d8477a 100644 --- a/neo/shaders/builtin/legacy/bumpyenvironment.vs.hlsl +++ b/neo/shaders/builtin/legacy/bumpyenvironment.vs.hlsl @@ -30,12 +30,11 @@ If you have questions concerning this license or the applicable additional terms // *INDENT-OFF* #if USE_GPU_SKINNING -cbuffer CB : register( b1 VK_DESCRIPTOR_SET( 0 )) { - float4 matrices[408]; -}; +StructuredBuffer matrices : register(t11); #endif -struct VS_IN { +struct VS_IN +{ float4 position : POSITION; float2 texcoord : TEXCOORD0; float4 normal : NORMAL; @@ -46,7 +45,8 @@ struct VS_IN { #endif }; -struct VS_OUT { +struct VS_OUT +{ float4 position : SV_Position; float2 texcoord0 : TEXCOORD0_centroid; float3 texcoord1 : TEXCOORD1_centroid; diff --git a/neo/shaders/builtin/legacy/environment.vs.hlsl b/neo/shaders/builtin/legacy/environment.vs.hlsl index 2f4bc0bd..8eadde1a 100644 --- a/neo/shaders/builtin/legacy/environment.vs.hlsl +++ b/neo/shaders/builtin/legacy/environment.vs.hlsl @@ -28,16 +28,13 @@ 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 ) -{ - float4 matrices[408]; -}; +StructuredBuffer matrices : register(t11); #endif -// *INDENT-OFF* -struct VS_IN { +struct VS_IN +{ float4 position : POSITION; float4 normal : NORMAL; float4 color : COLOR0; @@ -46,7 +43,8 @@ struct VS_IN { #endif }; -struct VS_OUT { +struct VS_OUT +{ float4 position : SV_Position; float3 texcoord0 : TEXCOORD0_centroid; float3 texcoord1 : TEXCOORD1_centroid; diff --git a/neo/shaders/builtin/lighting/ambient_lightgrid_IBL.vs.hlsl b/neo/shaders/builtin/lighting/ambient_lightgrid_IBL.vs.hlsl index c01b6337..4a425e9b 100644 --- a/neo/shaders/builtin/lighting/ambient_lightgrid_IBL.vs.hlsl +++ b/neo/shaders/builtin/lighting/ambient_lightgrid_IBL.vs.hlsl @@ -30,16 +30,14 @@ 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 ) -{ - float4 matrices[408]; -}; +StructuredBuffer matrices: register(t11); #endif // *INDENT-OFF* -struct VS_IN { +struct VS_IN +{ float4 position : POSITION; float2 texcoord : TEXCOORD0; float4 normal : NORMAL; @@ -48,7 +46,8 @@ struct VS_IN { float4 color2 : COLOR1; }; -struct VS_OUT { +struct VS_OUT +{ float4 position : SV_Position; float4 texcoord0 : TEXCOORD0_centroid; float4 texcoord1 : TEXCOORD1_centroid; diff --git a/neo/shaders/builtin/lighting/ambient_lighting_IBL.vs.hlsl b/neo/shaders/builtin/lighting/ambient_lighting_IBL.vs.hlsl index 5bbdace4..dac791d0 100644 --- a/neo/shaders/builtin/lighting/ambient_lighting_IBL.vs.hlsl +++ b/neo/shaders/builtin/lighting/ambient_lighting_IBL.vs.hlsl @@ -30,16 +30,13 @@ 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 ) -{ - float4 matrices[408]; -}; +StructuredBuffer matrices: register(t11); #endif -// *INDENT-OFF* -struct VS_IN { +struct VS_IN +{ float4 position : POSITION; float2 texcoord : TEXCOORD0; float4 normal : NORMAL; @@ -48,7 +45,8 @@ struct VS_IN { float4 color2 : COLOR1; }; -struct VS_OUT { +struct VS_OUT +{ float4 position : SV_Position; float4 texcoord0 : TEXCOORD0_centroid; float4 texcoord1 : TEXCOORD1_centroid; diff --git a/neo/shaders/builtin/lighting/interaction.vs.hlsl b/neo/shaders/builtin/lighting/interaction.vs.hlsl index 35799621..03d7ac08 100644 --- a/neo/shaders/builtin/lighting/interaction.vs.hlsl +++ b/neo/shaders/builtin/lighting/interaction.vs.hlsl @@ -29,16 +29,13 @@ 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 ) -{ - float4 matrices[408]; -}; +StructuredBuffer matrices: register(t11); #endif -// *INDENT-OFF* -struct VS_IN { +struct VS_IN +{ float4 position : POSITION; float2 texcoord : TEXCOORD0; float4 normal : NORMAL; @@ -47,7 +44,8 @@ struct VS_IN { float4 color2 : COLOR1; }; -struct VS_OUT { +struct VS_OUT +{ float4 position : SV_Position; float4 texcoord0 : TEXCOORD0_centroid; float4 texcoord1 : TEXCOORD1_centroid; diff --git a/neo/shaders/builtin/lighting/interactionAmbient.vs.hlsl b/neo/shaders/builtin/lighting/interactionAmbient.vs.hlsl index c85bdab8..bafcbd30 100644 --- a/neo/shaders/builtin/lighting/interactionAmbient.vs.hlsl +++ b/neo/shaders/builtin/lighting/interactionAmbient.vs.hlsl @@ -28,49 +28,32 @@ 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 ) -{ - float4 matrices[408]; -}; +StructuredBuffer matrices: register(t11); #endif struct VS_IN { -float4 position : - POSITION; -float2 texcoord : - TEXCOORD0; -float4 normal : - NORMAL; -float4 tangent : - TANGENT; -float4 color : - COLOR0; -float4 color2 : - COLOR1; + float4 position : POSITION; + float2 texcoord : TEXCOORD0; + float4 normal : NORMAL; + float4 tangent : TANGENT; + float4 color : COLOR0; + float4 color2 : COLOR1; }; struct VS_OUT { -float4 position : - SV_Position; - //float4 texcoord0 : TEXCOORD0_centroid; -float4 texcoord1 : - TEXCOORD1_centroid; -float4 texcoord2 : - TEXCOORD2_centroid; -float4 texcoord3 : - TEXCOORD3_centroid; -float4 texcoord4 : - TEXCOORD4_centroid; -float4 texcoord5 : - TEXCOORD5_centroid; -float4 texcoord6 : - TEXCOORD6_centroid; -float4 color : - COLOR0; + float4 position : SV_Position; + //float4 texcoord0 : TEXCOORD0_centroid; + float4 texcoord1 : TEXCOORD1_centroid; + float4 texcoord2 : TEXCOORD2_centroid; + float4 texcoord3 : TEXCOORD3_centroid; + float4 texcoord4 : TEXCOORD4_centroid; + float4 texcoord5 : TEXCOORD5_centroid; + float4 texcoord6 : TEXCOORD6_centroid; + float4 color : COLOR0; }; // *INDENT-ON* diff --git a/neo/shaders/builtin/lighting/interactionSM.vs.hlsl b/neo/shaders/builtin/lighting/interactionSM.vs.hlsl index 42a75738..cfae79df 100644 --- a/neo/shaders/builtin/lighting/interactionSM.vs.hlsl +++ b/neo/shaders/builtin/lighting/interactionSM.vs.hlsl @@ -30,15 +30,12 @@ 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 ) -{ - float4 matrices[408]; -}; +StructuredBuffer matrices: register(t11); #endif -struct VS_IN { +struct VS_IN +{ float4 position : POSITION; float2 texcoord : TEXCOORD0; float4 normal : NORMAL; @@ -47,7 +44,8 @@ struct VS_IN { float4 color2 : COLOR1; }; -struct VS_OUT { +struct VS_OUT +{ float4 position : SV_Position; float4 texcoord0 : TEXCOORD0_centroid; float4 texcoord1 : TEXCOORD1_centroid; diff --git a/neo/shaders/builtin/lighting/shadow.vs.hlsl b/neo/shaders/builtin/lighting/shadow.vs.hlsl index 3f906b82..039a8cf2 100644 --- a/neo/shaders/builtin/lighting/shadow.vs.hlsl +++ b/neo/shaders/builtin/lighting/shadow.vs.hlsl @@ -31,13 +31,11 @@ If you have questions concerning this license or the applicable additional terms // *INDENT-OFF* #if USE_GPU_SKINNING -cbuffer CB : register( b1 ) -{ - float4 matrices[408]; -}; +StructuredBuffer matrices : register(t11); #endif -struct VS_IN { +struct VS_IN +{ float4 position : POSITION; #if USE_GPU_SKINNING float4 color : COLOR0; @@ -45,7 +43,8 @@ struct VS_IN { #endif }; -struct VS_OUT { +struct VS_OUT +{ float4 position : POSITION; }; // *INDENT-ON* diff --git a/neo/shaders/builtin/texture_color.vs.hlsl b/neo/shaders/builtin/texture_color.vs.hlsl index eef39e2f..84b6b669 100644 --- a/neo/shaders/builtin/texture_color.vs.hlsl +++ b/neo/shaders/builtin/texture_color.vs.hlsl @@ -28,24 +28,21 @@ If you have questions concerning this license or the applicable additional terms #include "global_inc.hlsl" -//#pragma pack_matrix(row_major) - // *INDENT-OFF* #if USE_GPU_SKINNING -cbuffer CB : register( b1 ) -{ - float4 matrices[408]; -}; +StructuredBuffer matrices : register(t11); #endif -struct VS_IN { +struct VS_IN +{ float4 position : POSITION; float2 texcoord : TEXCOORD0; float4 color : COLOR0; float4 color2 : COLOR1; }; -struct VS_OUT { +struct VS_OUT +{ float4 position : SV_Position; float2 texcoord0 : TEXCOORD0_centroid; float4 color : COLOR0; diff --git a/neo/shaders/heatHazeWithMask.vs.hlsl b/neo/shaders/heatHazeWithMask.vs.hlsl index 4f6834b5..45f7217e 100644 --- a/neo/shaders/heatHazeWithMask.vs.hlsl +++ b/neo/shaders/heatHazeWithMask.vs.hlsl @@ -33,14 +33,9 @@ If you have questions concerning this license or the applicable additional terms // User Renderparms start at 128 as per renderprogs.h // *INDENT-OFF* -// #if USE_GPU_SKINNING -cbuffer CB : register( b1 ) -{ - float4 matrices[408]; -}; +StructuredBuffer matrices : register(t11); #endif -// RB end struct VS_IN { diff --git a/neo/shaders/heatHazeWithMaskAndVertex.vs.hlsl b/neo/shaders/heatHazeWithMaskAndVertex.vs.hlsl index f8636755..5707356f 100644 --- a/neo/shaders/heatHazeWithMaskAndVertex.vs.hlsl +++ b/neo/shaders/heatHazeWithMaskAndVertex.vs.hlsl @@ -30,16 +30,13 @@ 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 ) -{ - float4 matrices[408]; -}; +StructuredBuffer matrices : register(t11); #endif -// *INDENT-OFF* -struct VS_IN { +struct VS_IN +{ float4 position : POSITION; float2 texcoord : TEXCOORD0; float4 normal : NORMAL; @@ -48,7 +45,8 @@ struct VS_IN { float4 color2 : COLOR1; }; -struct VS_OUT { +struct VS_OUT +{ float4 position : SV_Position; float4 texcoord0 : TEXCOORD0_centroid; float4 texcoord1 : TEXCOORD1_centroid; diff --git a/neo/shaders/heathaze.vs.hlsl b/neo/shaders/heathaze.vs.hlsl index aedf6699..eeea0e10 100644 --- a/neo/shaders/heathaze.vs.hlsl +++ b/neo/shaders/heathaze.vs.hlsl @@ -33,17 +33,12 @@ If you have questions concerning this license or the applicable additional terms // User Renderparms start at 128 as per renderprogs.h // *INDENT-OFF* -// -// RB: no GPU skinning with ES 2.0 #if USE_GPU_SKINNING -cbuffer CB : register( b1 ) -{ - float4 matrices[408]; -}; +StructuredBuffer matrices : register(t11); #endif -// RB end -struct VS_IN { +struct VS_IN +{ float4 position : POSITION; float2 texcoord : TEXCOORD0; float4 normal : NORMAL; @@ -52,7 +47,8 @@ struct VS_IN { float4 color2 : COLOR1; }; -struct VS_OUT { +struct VS_OUT +{ float4 position : SV_Position; float4 texcoord0 : TEXCOORD0_centroid; float4 texcoord1 : TEXCOORD1_centroid; diff --git a/neo/shaders/mattiascrt.vs.hlsl b/neo/shaders/mattiascrt.vs.hlsl index f9b9984f..f6da194c 100644 --- a/neo/shaders/mattiascrt.vs.hlsl +++ b/neo/shaders/mattiascrt.vs.hlsl @@ -28,18 +28,13 @@ If you have questions concerning this license or the applicable additional terms #include "global_inc.hlsl" -// RB: no GPU skinning with ES 2.0 // *INDENT-OFF* #if USE_GPU_SKINNING -cbuffer CB : -register( b1 ) -{ - float4 matrices[408]; -}; +StructuredBuffer matrices : register(t11); #endif -// RB end -struct VS_IN { +struct VS_IN +{ float4 position : POSITION; float2 texcoord : TEXCOORD0; float4 normal : NORMAL; @@ -48,7 +43,8 @@ struct VS_IN { float4 color2 : COLOR1; }; -struct VS_OUT { +struct VS_OUT +{ float4 position : SV_Position; float4 texcoord0 : TEXCOORD0; float4 texcoord1 : TEXCOORD1; diff --git a/neo/shaders/shaders.cfg b/neo/shaders/shaders.cfg index 48515f2b..93b6745b 100644 --- a/neo/shaders/shaders.cfg +++ b/neo/shaders/shaders.cfg @@ -88,8 +88,8 @@ builtin/SSGI/DeepGBufferRadiosity_blur.ps.hlsl -T ps_5_0 builtin/SSGI/DeepGBufferRadiosity_radiosity.vs.hlsl -T vs_5_0 builtin/SSGI/DeepGBufferRadiosity_radiosity.ps.hlsl -T ps_5_0 -builtin/fog/blendLight.vs.hlsl -T vs_5_0 -builtin/fog/blendLight.ps.hlsl -T ps_5_0 +builtin/fog/blendLight.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1} +builtin/fog/blendLight.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1} builtin/fog/fog.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1} builtin/fog/fog.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1} diff --git a/neo/shaders/vornoipattern.vs.hlsl b/neo/shaders/vornoipattern.vs.hlsl index 951c0805..a4e2e1d7 100644 --- a/neo/shaders/vornoipattern.vs.hlsl +++ b/neo/shaders/vornoipattern.vs.hlsl @@ -28,19 +28,13 @@ If you have questions concerning this license or the applicable additional terms #include "global_inc.hlsl" -// RB: no GPU skinning with ES 2.0 -#if USE_GPU_SKINNING -cbuffer CB : -register( b1 ) -{ - float4 matrices[408]; -}; -#endif -// RB end - // *INDENT-OFF* +#if USE_GPU_SKINNING +StructuredBuffer matrices : register(t11); +#endif -struct VS_IN { +struct VS_IN +{ float4 position : POSITION; float2 texcoord : TEXCOORD0; float4 normal : NORMAL; @@ -49,7 +43,8 @@ struct VS_IN { float4 color2 : COLOR1; }; -struct VS_OUT { +struct VS_OUT +{ float4 position : POSITION; float4 texcoord0 : TEXCOORD0; float4 texcoord1 : TEXCOORD1;