@@ -598,6 +598,33 @@ void D3D12TextureCache::RequestTextures(uint32_t used_texture_mask) {
598598
599599 TextureCache::RequestTextures (used_texture_mask);
600600
601+ // Pre-create 3D-as-2D wrappers for any 3D textures while we're still in
602+ // the texture loading phase (before graphics pipeline setup). LoadTextureData
603+ // dispatches compute shaders, which must not happen during draw call setup
604+ // as VKD3D asserts a graphics pipeline is active at that point.
605+ if (cvars::gpu_3d_to_2d_texture) {
606+ uint32_t textures_3d = used_texture_mask;
607+ uint32_t index_3d;
608+ while (xe::bit_scan_forward (textures_3d, &index_3d)) {
609+ textures_3d = xe::clear_lowest_bit (textures_3d);
610+ const TextureBinding* binding = GetValidTextureBinding (index_3d);
611+ if (!binding || binding->key .dimension != xenos::DataDimension::k3D) {
612+ continue ;
613+ }
614+ D3D12Texture* texture = static_cast <D3D12Texture*>(binding->texture );
615+ if (texture) {
616+ texture->GetOrCreate3DAs2DResource (
617+ D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
618+ }
619+ D3D12Texture* texture_signed =
620+ static_cast <D3D12Texture*>(binding->texture_signed );
621+ if (texture_signed) {
622+ texture_signed->GetOrCreate3DAs2DResource (
623+ D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
624+ }
625+ }
626+ }
627+
601628 // Transition the textures to the needed usage - always in
602629 // NON_PIXEL_SHADER_RESOURCE | PIXEL_SHADER_RESOURCE states because barriers
603630 // between read-only stages, if needed, are discouraged (also if these were
0 commit comments