From 49eb54d1adffdf1cd881a2b16ab9eeaa55d56bc5 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Sat, 3 Nov 2018 12:01:03 +0100 Subject: [PATCH] First time Vulkan can render a map without light interactions --- base/renderprogs/ambient_lighting.ps.hlsl | 14 ++--- base/renderprogs/interaction.ps.hlsl | 18 +++--- base/renderprogs/interactionAmbient.ps.hlsl | 18 +++--- .../interactionAmbient_skinned.ps.hlsl | 18 +++--- base/renderprogs/interactionSM.ps.hlsl | 18 +++--- neo/renderer/GLMatrix.cpp | 9 ++- neo/renderer/Model_md5.cpp | 4 +- neo/renderer/OpenGL/RenderProgs_GL.cpp | 38 ++++++++++++- neo/renderer/RenderBackend.cpp | 44 +++++++------- neo/renderer/RenderProgs.cpp | 57 +------------------ neo/renderer/Vulkan/RenderBackend_VK.cpp | 7 --- neo/renderer/Vulkan/RenderProgs_VK.cpp | 56 ++++++++++++++++++ 12 files changed, 167 insertions(+), 134 deletions(-) diff --git a/base/renderprogs/ambient_lighting.ps.hlsl b/base/renderprogs/ambient_lighting.ps.hlsl index 099eaa34..a952a97d 100644 --- a/base/renderprogs/ambient_lighting.ps.hlsl +++ b/base/renderprogs/ambient_lighting.ps.hlsl @@ -29,11 +29,11 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" -uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface bump map -uniform sampler2D samp1 : register(s1); // texture 2 is the light falloff texture -uniform sampler2D samp2 : register(s2); // texture 3 is the light projection texture -uniform sampler2D samp3 : register(s3); // texture 4 is the per-surface diffuse map -uniform sampler2D samp4 : register(s4); // texture 5 is the per-surface specular map +uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface normal map +uniform sampler2D samp1 : register(s1); // texture 3 is the per-surface specular or roughness/metallic/AO mixer map +uniform sampler2D samp2 : register(s2); // texture 2 is the per-surface baseColor map +uniform sampler2D samp3 : register(s3); // texture 4 is the light falloff texture +uniform sampler2D samp4 : register(s4); // texture 5 is the light projection texture struct PS_IN { half4 position : VPOS; @@ -55,8 +55,8 @@ void main( PS_IN fragment, out PS_OUT result ) { half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy ); // half4 lightFalloff = idtex2Dproj( samp1, fragment.texcoord2 ); // half4 lightProj = idtex2Dproj( samp2, fragment.texcoord3 ); - half4 YCoCG = tex2D( samp3, fragment.texcoord4.xy ); - half4 specMap = sRGBAToLinearRGBA( tex2D( samp4, fragment.texcoord5.xy ) ); + half4 YCoCG = tex2D( samp2, fragment.texcoord4.xy ); + half4 specMap = sRGBAToLinearRGBA( tex2D( samp1, fragment.texcoord5.xy ) ); half3 lightVector = normalize( fragment.texcoord0.xyz ); half3 diffuseMap = sRGBToLinearRGB( ConvertYCoCgToRGB( YCoCG ) ); diff --git a/base/renderprogs/interaction.ps.hlsl b/base/renderprogs/interaction.ps.hlsl index 9d3a75f1..76b5a996 100644 --- a/base/renderprogs/interaction.ps.hlsl +++ b/base/renderprogs/interaction.ps.hlsl @@ -30,11 +30,11 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" #include "BRDF.inc.hlsl" -uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface bump map -uniform sampler2D samp1 : register(s1); // texture 2 is the light falloff texture -uniform sampler2D samp2 : register(s2); // texture 3 is the light projection texture -uniform sampler2D samp3 : register(s3); // texture 4 is the per-surface diffuse map -uniform sampler2D samp4 : register(s4); // texture 5 is the per-surface specular map +uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface normal map +uniform sampler2D samp1 : register(s1); // texture 3 is the per-surface specular or roughness/metallic/AO mixer map +uniform sampler2D samp2 : register(s2); // texture 2 is the per-surface baseColor map +uniform sampler2D samp3 : register(s3); // texture 4 is the light falloff texture +uniform sampler2D samp4 : register(s4); // texture 5 is the light projection texture struct PS_IN { @@ -57,10 +57,10 @@ struct PS_OUT void main( PS_IN fragment, out PS_OUT result ) { half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy ); - half4 lightFalloff = ( idtex2Dproj( samp1, fragment.texcoord2 ) ); - half4 lightProj = ( idtex2Dproj( samp2, fragment.texcoord3 ) ); - half4 YCoCG = tex2D( samp3, fragment.texcoord4.xy ); - half4 specMapSRGB = tex2D( samp4, fragment.texcoord5.xy ); + half4 lightFalloff = ( idtex2Dproj( samp3, fragment.texcoord2 ) ); + half4 lightProj = ( idtex2Dproj( samp4, fragment.texcoord3 ) ); + half4 YCoCG = tex2D( samp2, fragment.texcoord4.xy ); + half4 specMapSRGB = tex2D( samp1, fragment.texcoord5.xy ); half4 specMap = sRGBAToLinearRGBA( specMapSRGB ); half3 lightVector = normalize( fragment.texcoord0.xyz ); diff --git a/base/renderprogs/interactionAmbient.ps.hlsl b/base/renderprogs/interactionAmbient.ps.hlsl index 20939ef5..a66e5b45 100644 --- a/base/renderprogs/interactionAmbient.ps.hlsl +++ b/base/renderprogs/interactionAmbient.ps.hlsl @@ -28,11 +28,11 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" -uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface bump map -uniform sampler2D samp1 : register(s1); // texture 2 is the light falloff texture -uniform sampler2D samp2 : register(s2); // texture 3 is the light projection texture -uniform sampler2D samp3 : register(s3); // texture 4 is the per-surface diffuse map -uniform sampler2D samp4 : register(s4); // texture 5 is the per-surface specular map +uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface normal map +uniform sampler2D samp1 : register(s1); // texture 3 is the per-surface specular or roughness/metallic/AO mixer map +uniform sampler2D samp2 : register(s2); // texture 2 is the per-surface baseColor map +uniform sampler2D samp3 : register(s3); // texture 4 is the light falloff texture +uniform sampler2D samp4 : register(s4); // texture 5 is the light projection texture struct PS_IN { half4 position : VPOS; @@ -51,10 +51,10 @@ struct PS_OUT { void main( PS_IN fragment, out PS_OUT result ) { half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy ); - half4 lightFalloff = idtex2Dproj( samp1, fragment.texcoord2 ); - half4 lightProj = idtex2Dproj( samp2, fragment.texcoord3 ); - half4 YCoCG = tex2D( samp3, fragment.texcoord4.xy ); - half4 specMap = sRGBAToLinearRGBA( tex2D( samp4, fragment.texcoord5.xy ) ); + half4 lightFalloff = idtex2Dproj( samp3, fragment.texcoord2 ); + half4 lightProj = idtex2Dproj( samp4, fragment.texcoord3 ); + half4 YCoCG = tex2D( samp2, fragment.texcoord4.xy ); + half4 specMap = sRGBAToLinearRGBA( tex2D( samp1, fragment.texcoord5.xy ) ); const half3 ambientLightVector = half3( 0.5f, 9.5f - 0.385f, 0.8925f ); half3 lightVector = normalize( ambientLightVector ); diff --git a/base/renderprogs/interactionAmbient_skinned.ps.hlsl b/base/renderprogs/interactionAmbient_skinned.ps.hlsl index 518dcc3c..22baf1e3 100644 --- a/base/renderprogs/interactionAmbient_skinned.ps.hlsl +++ b/base/renderprogs/interactionAmbient_skinned.ps.hlsl @@ -29,11 +29,11 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" -uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface bump map -uniform sampler2D samp1 : register(s1); // texture 2 is the light falloff texture -uniform sampler2D samp2 : register(s2); // texture 3 is the light projection texture -uniform sampler2D samp3 : register(s3); // texture 4 is the per-surface diffuse map -uniform sampler2D samp4 : register(s4); // texture 5 is the per-surface specular map +uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface normal map +uniform sampler2D samp1 : register(s1); // texture 3 is the per-surface specular or roughness/metallic/AO mixer map +uniform sampler2D samp2 : register(s2); // texture 2 is the per-surface baseColor map +uniform sampler2D samp3 : register(s3); // texture 4 is the light falloff texture +uniform sampler2D samp4 : register(s4); // texture 5 is the light projection texture struct PS_IN { half4 position : VPOS; @@ -52,10 +52,10 @@ struct PS_OUT { void main( PS_IN fragment, out PS_OUT result ) { half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy ); - half4 lightFalloff = idtex2Dproj( samp1, fragment.texcoord2 ); - half4 lightProj = idtex2Dproj( samp2, fragment.texcoord3 ); - half4 YCoCG = tex2D( samp3, fragment.texcoord4.xy ); - half4 specMap = tex2D( samp4, fragment.texcoord5.xy ); + half4 lightFalloff = idtex2Dproj( samp3, fragment.texcoord2 ); + half4 lightProj = idtex2Dproj( samp4, fragment.texcoord3 ); + half4 YCoCG = tex2D( samp2, fragment.texcoord4.xy ); + half4 specMap = tex2D( samp1, fragment.texcoord5.xy ); const half3 ambientLightVector = half3( 0.5f, 9.5f - 0.385f, 0.8925f ); half3 lightVector = normalize( ambientLightVector ); diff --git a/base/renderprogs/interactionSM.ps.hlsl b/base/renderprogs/interactionSM.ps.hlsl index 1b00cc16..c214e4a5 100644 --- a/base/renderprogs/interactionSM.ps.hlsl +++ b/base/renderprogs/interactionSM.ps.hlsl @@ -30,11 +30,11 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" #include "BRDF.inc.hlsl" -uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface bump map -uniform sampler2D samp1 : register(s1); // texture 2 is the light falloff texture -uniform sampler2D samp2 : register(s2); // texture 3 is the light projection texture -uniform sampler2D samp3 : register(s3); // texture 4 is the per-surface diffuse map -uniform sampler2D samp4 : register(s4); // texture 5 is the per-surface specular map +uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface normal map +uniform sampler2D samp1 : register(s1); // texture 3 is the per-surface specular or roughness/metallic/AO mixer map +uniform sampler2D samp2 : register(s2); // texture 2 is the per-surface baseColor map +uniform sampler2D samp3 : register(s3); // texture 4 is the light falloff texture +uniform sampler2D samp4 : register(s4); // texture 5 is the light projection texture uniform sampler2DArrayShadow samp5 : register(s5); // texture 6 is the shadowmap array uniform sampler2D samp6 : register(s6); // texture 7 is the jitter texture @@ -64,10 +64,10 @@ struct PS_OUT void main( PS_IN fragment, out PS_OUT result ) { half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy ); - half4 lightFalloff = ( idtex2Dproj( samp1, fragment.texcoord2 ) ); - half4 lightProj = ( idtex2Dproj( samp2, fragment.texcoord3 ) ); - half4 YCoCG = tex2D( samp3, fragment.texcoord4.xy ); - half4 specMapSRGB = tex2D( samp4, fragment.texcoord5.xy ); + half4 lightFalloff = ( idtex2Dproj( samp3, fragment.texcoord2 ) ); + half4 lightProj = ( idtex2Dproj( samp4, fragment.texcoord3 ) ); + half4 YCoCG = tex2D( samp2, fragment.texcoord4.xy ); + half4 specMapSRGB = tex2D( samp1, fragment.texcoord5.xy ); half4 specMap = sRGBAToLinearRGBA( specMapSRGB ); half3 lightVector = normalize( fragment.texcoord0.xyz ); diff --git a/neo/renderer/GLMatrix.cpp b/neo/renderer/GLMatrix.cpp index 79f284e0..0028c1d5 100644 --- a/neo/renderer/GLMatrix.cpp +++ b/neo/renderer/GLMatrix.cpp @@ -454,7 +454,7 @@ void R_SetupProjectionMatrix( viewDef_t* viewDef ) ymax += jittery * height; // RB: IMPORTANT - the projectionMatrix has a few changes to make it work with Vulkan - // In Vulkan is the y-axis flipped + // for a detailed explanation see https://matthewwellings.com/blog/the-new-vulkan-coordinate-system/ viewDef->projectionMatrix[0 * 4 + 0] = 2.0f * zNear / width; viewDef->projectionMatrix[1 * 4 + 0] = 0.0f; @@ -462,6 +462,8 @@ void R_SetupProjectionMatrix( viewDef_t* viewDef ) viewDef->projectionMatrix[3 * 4 + 0] = 0.0f; viewDef->projectionMatrix[0 * 4 + 1] = 0.0f; + + // RB: Y axis now points down the screen #if defined(USE_VULKAN) viewDef->projectionMatrix[1 * 4 + 1] = -2.0f * zNear / height; #else @@ -476,7 +478,10 @@ void R_SetupProjectionMatrix( viewDef_t* viewDef ) viewDef->projectionMatrix[0 * 4 + 2] = 0.0f; viewDef->projectionMatrix[1 * 4 + 2] = 0.0f; viewDef->projectionMatrix[2 * 4 + 2] = -0.999f; // adjust value to prevent imprecision issues - viewDef->projectionMatrix[3 * 4 + 2] = -1.0f * zNear; // RB: was -2.0f * zNear + + // RB: was -2.0f * zNear + // the transformation into window space has changed from [-1 .. -1] to [0 .. -1] + viewDef->projectionMatrix[3 * 4 + 2] = -1.0f * zNear; viewDef->projectionMatrix[0 * 4 + 3] = 0.0f; viewDef->projectionMatrix[1 * 4 + 3] = 0.0f; diff --git a/neo/renderer/Model_md5.cpp b/neo/renderer/Model_md5.cpp index c29119ab..f6f7d9d1 100644 --- a/neo/renderer/Model_md5.cpp +++ b/neo/renderer/Model_md5.cpp @@ -4,6 +4,7 @@ Doom 3 BFG Edition GPL Source Code Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2013-2014 Robert Beckebans +Copyright (C) 2016-2017 Dustin Land This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). @@ -1392,8 +1393,7 @@ idRenderModel* idRenderModelMD5::InstantiateDynamicModel( const struct renderEnt if( staticModel->jointsInverted == NULL ) { staticModel->numInvertedJoints = numInvertedJoints; - const int alignment = glConfig.uniformBufferOffsetAlignment; - staticModel->jointsInverted = ( idJointMat* )Mem_ClearedAlloc( ALIGN( numInvertedJoints * sizeof( idJointMat ), alignment ), TAG_JOINTMAT ); + staticModel->jointsInverted = ( idJointMat* )Mem_ClearedAlloc( numInvertedJoints * sizeof( idJointMat ), TAG_JOINTMAT ); staticModel->jointsInvertedBuffer = 0; } else diff --git a/neo/renderer/OpenGL/RenderProgs_GL.cpp b/neo/renderer/OpenGL/RenderProgs_GL.cpp index 0dc767ff..ad1f1372 100644 --- a/neo/renderer/OpenGL/RenderProgs_GL.cpp +++ b/neo/renderer/OpenGL/RenderProgs_GL.cpp @@ -530,6 +530,40 @@ void idRenderProgManager::CommitUniforms( uint64 stateBits ) //GL_CheckErrors(); } +/* +================================================================================================ +idRenderProgManager::KillAllShaders() +================================================================================================ +*/ +void idRenderProgManager::KillAllShaders() +{ + Unbind(); + + for( int i = 0; i < shaders.Num(); i++ ) + { + if( shaders[i].progId != INVALID_PROGID ) + { + glDeleteShader( shaders[i].progId ); + shaders[i].progId = INVALID_PROGID; + } + } + + for( int i = 0; i < renderProgs.Num(); ++i ) + { + if( renderProgs[i].progId != INVALID_PROGID ) + { + glDeleteProgram( renderProgs[i].progId ); + renderProgs[i].progId = INVALID_PROGID; + } + } +} - - +/* +==================== +idRenderBackend::ResizeImages +==================== +*/ +void idRenderBackend::ResizeImages() +{ + // TODO resize framebuffers here +} \ No newline at end of file diff --git a/neo/renderer/RenderBackend.cpp b/neo/renderer/RenderBackend.cpp index 805a8c03..f9c4b03a 100644 --- a/neo/renderer/RenderBackend.cpp +++ b/neo/renderer/RenderBackend.cpp @@ -1195,10 +1195,10 @@ GENERAL INTERACTION RENDERING */ const int INTERACTION_TEXUNIT_BUMP = 0; -const int INTERACTION_TEXUNIT_FALLOFF = 1; -const int INTERACTION_TEXUNIT_PROJECTION = 2; -const int INTERACTION_TEXUNIT_DIFFUSE = 3; -const int INTERACTION_TEXUNIT_SPECULAR = 4; +const int INTERACTION_TEXUNIT_SPECULARMIX = 1; +const int INTERACTION_TEXUNIT_BASECOLOR = 2; +const int INTERACTION_TEXUNIT_FALLOFF = 3; +const int INTERACTION_TEXUNIT_PROJECTION = 4; const int INTERACTION_TEXUNIT_SHADOWMAPS = 5; const int INTERACTION_TEXUNIT_JITTER = 6; @@ -1318,14 +1318,14 @@ void idRenderBackend::DrawSingleInteraction( drawInteraction_t* din ) GL_SelectTexture( INTERACTION_TEXUNIT_BUMP ); din->bumpImage->Bind(); - // texture 3 is the per-surface diffuse map - GL_SelectTexture( INTERACTION_TEXUNIT_DIFFUSE ); - din->diffuseImage->Bind(); - - // texture 4 is the per-surface specular map - GL_SelectTexture( INTERACTION_TEXUNIT_SPECULAR ); + // texture 1 is the per-surface specular map + GL_SelectTexture( INTERACTION_TEXUNIT_SPECULARMIX ); din->specularImage->Bind(); + // texture 2 is the per-surface diffuse map + GL_SelectTexture( INTERACTION_TEXUNIT_BASECOLOR ); + din->diffuseImage->Bind(); + DrawElementsWithCounters( din->surf ); } @@ -1779,14 +1779,14 @@ void idRenderBackend::RenderInteractions( const drawSurf_t* surfList, const view GL_SelectTexture( INTERACTION_TEXUNIT_BUMP ); surfaceShader->GetFastPathBumpImage()->Bind(); - // texture 3 is the per-surface diffuse map - GL_SelectTexture( INTERACTION_TEXUNIT_DIFFUSE ); - surfaceShader->GetFastPathDiffuseImage()->Bind(); - - // texture 4 is the per-surface specular map - GL_SelectTexture( INTERACTION_TEXUNIT_SPECULAR ); + // texture 1 is the per-surface specular map + GL_SelectTexture( INTERACTION_TEXUNIT_SPECULARMIX ); surfaceShader->GetFastPathSpecularImage()->Bind(); + // texture 2 is the per-surface diffuse map + GL_SelectTexture( INTERACTION_TEXUNIT_BASECOLOR ); + surfaceShader->GetFastPathDiffuseImage()->Bind(); + DrawElementsWithCounters( surf ); renderLog.CloseBlock(); @@ -2160,14 +2160,14 @@ void idRenderBackend::AmbientPass( const drawSurf_t* const* drawSurfs, int numDr GL_SelectTexture( INTERACTION_TEXUNIT_BUMP ); surfaceMaterial->GetFastPathBumpImage()->Bind(); - // texture 3 is the per-surface diffuse map - GL_SelectTexture( INTERACTION_TEXUNIT_DIFFUSE ); - surfaceMaterial->GetFastPathDiffuseImage()->Bind(); - - // texture 4 is the per-surface specular map - GL_SelectTexture( INTERACTION_TEXUNIT_SPECULAR ); + // texture 1 is the per-surface specular map + GL_SelectTexture( INTERACTION_TEXUNIT_SPECULARMIX ); surfaceMaterial->GetFastPathSpecularImage()->Bind(); + // texture 2 is the per-surface diffuse map + GL_SelectTexture( INTERACTION_TEXUNIT_BASECOLOR ); + surfaceMaterial->GetFastPathDiffuseImage()->Bind(); + DrawElementsWithCounters( drawSurf ); renderLog.CloseBlock(); diff --git a/neo/renderer/RenderProgs.cpp b/neo/renderer/RenderProgs.cpp index 0993873a..409f5dd4 100644 --- a/neo/renderer/RenderProgs.cpp +++ b/neo/renderer/RenderProgs.cpp @@ -289,62 +289,7 @@ void idRenderProgManager::LoadAllShaders() } } -/* -================================================================================================ -idRenderProgManager::KillAllShaders() -================================================================================================ -*/ -void idRenderProgManager::KillAllShaders() -{ - Unbind(); - - // destroy shaders - for( int i = 0; i < shaders.Num(); ++i ) - { - shader_t& shader = shaders[ i ]; - vkDestroyShaderModule( vkcontext.device, shader.module, NULL ); - shader.module = VK_NULL_HANDLE; - } - - // destroy pipelines - for( int i = 0; i < renderProgs.Num(); ++i ) - { - renderProg_t& prog = renderProgs[ i ]; - - for( int j = 0; j < prog.pipelines.Num(); ++j ) - { - vkDestroyPipeline( vkcontext.device, prog.pipelines[ j ].pipeline, NULL ); - } - prog.pipelines.Clear(); - - vkDestroyDescriptorSetLayout( vkcontext.device, prog.descriptorSetLayout, NULL ); - vkDestroyPipelineLayout( vkcontext.device, prog.pipelineLayout, NULL ); - } - renderProgs.Clear(); - - for( int i = 0; i < NUM_FRAME_DATA; ++i ) - { - parmBuffers[ i ]->FreeBufferObject(); - delete parmBuffers[ i ]; - parmBuffers[ i ] = NULL; - } - - emptyUBO.FreeBufferObject(); - - for( int i = 0; i < NUM_FRAME_DATA; ++i ) - { - //vkFreeDescriptorSets( vkcontext.device, descriptorPools[ i ], MAX_DESC_SETS, descriptorSets[ i ] ); - vkResetDescriptorPool( vkcontext.device, descriptorPools[ i ], 0 ); - vkDestroyDescriptorPool( vkcontext.device, descriptorPools[ i ], NULL ); - } - - memset( descriptorSets, 0, sizeof( descriptorSets ) ); - memset( descriptorPools, 0, sizeof( descriptorPools ) ); - - counter = 0; - currentData = 0; - currentDescSet = 0; -} + /* ================================================================================================ diff --git a/neo/renderer/Vulkan/RenderBackend_VK.cpp b/neo/renderer/Vulkan/RenderBackend_VK.cpp index e86e1e51..7ca475cb 100644 --- a/neo/renderer/Vulkan/RenderBackend_VK.cpp +++ b/neo/renderer/Vulkan/RenderBackend_VK.cpp @@ -1490,7 +1490,6 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf ) // RB: yes but it would require an additional blend light skinned shader //if( !verify( renderProgManager.ShaderUsesJoints() ) ) if( !renderProgManager.ShaderUsesJoints() ) - // DG end { return; } @@ -1512,12 +1511,6 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf ) idLib::Warning( "RB_DrawElementsWithCounters, jointBuffer == NULL" ); return; } - assert( ( jointBuffer.GetOffset() & ( glConfig.uniformBufferOffsetAlignment - 1 ) ) == 0 ); - - // FIXME - - //const GLintptr ubo = jointBuffer.GetAPIObject(); - //glBindBufferRange( GL_UNIFORM_BUFFER, 0, ubo, jointBuffer.GetOffset(), jointBuffer.GetSize() ); } renderProgManager.CommitUniforms( glStateBits ); diff --git a/neo/renderer/Vulkan/RenderProgs_VK.cpp b/neo/renderer/Vulkan/RenderProgs_VK.cpp index 262ca03a..476e5896 100644 --- a/neo/renderer/Vulkan/RenderProgs_VK.cpp +++ b/neo/renderer/Vulkan/RenderProgs_VK.cpp @@ -770,6 +770,62 @@ void idRenderProgManager::LoadGLSLProgram( const int programIndex, const int ver #endif } +/* +================================================================================================ +idRenderProgManager::KillAllShaders() +================================================================================================ +*/ +void idRenderProgManager::KillAllShaders() +{ + Unbind(); + + // destroy shaders + for( int i = 0; i < shaders.Num(); ++i ) + { + shader_t& shader = shaders[ i ]; + vkDestroyShaderModule( vkcontext.device, shader.module, NULL ); + shader.module = VK_NULL_HANDLE; + } + + // destroy pipelines + for( int i = 0; i < renderProgs.Num(); ++i ) + { + renderProg_t& prog = renderProgs[ i ]; + + for( int j = 0; j < prog.pipelines.Num(); ++j ) + { + vkDestroyPipeline( vkcontext.device, prog.pipelines[ j ].pipeline, NULL ); + } + prog.pipelines.Clear(); + + vkDestroyDescriptorSetLayout( vkcontext.device, prog.descriptorSetLayout, NULL ); + vkDestroyPipelineLayout( vkcontext.device, prog.pipelineLayout, NULL ); + } + renderProgs.Clear(); + + for( int i = 0; i < NUM_FRAME_DATA; ++i ) + { + parmBuffers[ i ]->FreeBufferObject(); + delete parmBuffers[ i ]; + parmBuffers[ i ] = NULL; + } + + emptyUBO.FreeBufferObject(); + + for( int i = 0; i < NUM_FRAME_DATA; ++i ) + { + //vkFreeDescriptorSets( vkcontext.device, descriptorPools[ i ], MAX_DESC_SETS, descriptorSets[ i ] ); + vkResetDescriptorPool( vkcontext.device, descriptorPools[ i ], 0 ); + vkDestroyDescriptorPool( vkcontext.device, descriptorPools[ i ], NULL ); + } + + memset( descriptorSets, 0, sizeof( descriptorSets ) ); + memset( descriptorPools, 0, sizeof( descriptorPools ) ); + + counter = 0; + currentData = 0; + currentDescSet = 0; +} /* ========================