diff --git a/src/Layers/xrRenderDX11/dx11SH_Texture.cpp b/src/Layers/xrRenderDX11/dx11SH_Texture.cpp index 9e70f5b8d73..98032dd9d59 100644 --- a/src/Layers/xrRenderDX11/dx11SH_Texture.cpp +++ b/src/Layers/xrRenderDX11/dx11SH_Texture.cpp @@ -117,23 +117,19 @@ void CTexture::surface_set(ID3DBaseTexture* surf) _RELEASE(srv_all); CHK_DX(HW.pDevice->CreateShaderResourceView(pSurface, &ViewDesc, &srv_all)); + if (desc.SampleDesc.Count <= 1) + ViewDesc.Texture2DArray.ArraySize = desc.ArraySize; + else + ViewDesc.Texture2DMSArray.ArraySize = desc.ArraySize; + srv_per_slice.resize(desc.ArraySize); - for (u32 id = 0; id < desc.ArraySize; ++id) + for (auto &x : srv_per_slice) { - _RELEASE(srv_per_slice[id]); - - if (desc.SampleDesc.Count <= 1) - { - ViewDesc.Texture2DArray.ArraySize = 1; - ViewDesc.Texture2DArray.FirstArraySlice = id; - } - else - { - ViewDesc.Texture2DMSArray.ArraySize = 1; - ViewDesc.Texture2DMSArray.FirstArraySlice = id; - } - CHK_DX(HW.pDevice->CreateShaderResourceView(pSurface, &ViewDesc, &srv_per_slice[id])); + x->Release(); + x = nullptr; } + CHK_DX(HW.pDevice->CreateShaderResourceView(pSurface, &ViewDesc, srv_per_slice.data())); + set_slice(-1); } else