@@ -872,6 +872,7 @@ struct RenderCommand
872872 GuestDevice* device;
873873 uint32_t flags;
874874 GuestTexture* texture;
875+ uint32_t destSliceOrFace;
875876 } stretchRect;
876877
877878 struct
@@ -3221,13 +3222,14 @@ static void FlushViewport()
32213222 }
32223223}
32233224
3224- static void StretchRect (GuestDevice* device, uint32_t flags, uint32_t , GuestTexture* texture)
3225+ static void StretchRect (GuestDevice* device, uint32_t flags, uint32_t , GuestTexture* texture, uint32_t , uint32_t , uint32_t destSliceOrFace )
32253226{
32263227 // printf("StretchRect %x\n", texture);
32273228 RenderCommand cmd;
32283229 cmd.type = RenderCommandType::StretchRect;
32293230 cmd.stretchRect .flags = flags;
32303231 cmd.stretchRect .texture = texture;
3232+ cmd.stretchRect .destSliceOrFace = destSliceOrFace;
32313233 g_renderQueue.enqueue (cmd);
32323234}
32333235
@@ -3247,7 +3249,7 @@ static void ProcStretchRect(const RenderCommand& cmd)
32473249
32483250 args.texture ->sourceSurface = surface;
32493251 // printf("ProcStretchRect: surface - %x %x ? (%x : %x)\n", surface, isDepthStencil, g_depthStencil, g_renderTarget);
3250- surface->destinationTextures .emplace (args.texture );
3252+ surface->destinationTextures .emplace (args.texture , args. destSliceOrFace );
32513253
32523254 // If the texture is assigned to any slots, set it again. This'll also push the barrier.
32533255 for (uint32_t i = 0 ; i < std::size (g_textures); i++)
@@ -3373,7 +3375,7 @@ static bool PopulateBarriersForStretchRect(GuestSurface* renderTarget, GuestSurf
33733375
33743376 AddBarrier (surface, srcLayout);
33753377
3376- for (const auto texture : surface->destinationTextures )
3378+ for (const auto [ texture, _] : surface->destinationTextures )
33773379 AddBarrier (texture, dstLayout);
33783380
33793381 addedAny = true ;
@@ -3393,7 +3395,7 @@ static void ExecutePendingStretchRectCommands(GuestSurface* renderTarget, GuestS
33933395 {
33943396 const bool multiSampling = surface->sampleCount != RenderSampleCount::COUNT_1 ;
33953397
3396- for (const auto texture : surface->destinationTextures )
3398+ for (const auto [ texture, slice] : surface->destinationTextures )
33973399 {
33983400 bool shaderResolve = true ;
33993401
@@ -3483,27 +3485,29 @@ static void ExecutePendingStretchRectCommands(GuestSurface* renderTarget, GuestS
34833485 }
34843486 }
34853487
3486- if (texture->framebuffer == nullptr )
3488+ auto & framebuffer = texture->framebuffers [slice];
3489+ if (framebuffer == nullptr )
34873490 {
34883491 if (texture->format == RenderFormat::D32_FLOAT )
34893492 {
34903493 RenderFramebufferDesc desc;
34913494 desc.depthAttachment = texture->texture ;
3492- texture->framebuffer = g_device->createFramebuffer (desc);
3495+ desc.depthAttachmentSlice = slice;
3496+ framebuffer = g_device->createFramebuffer (desc);
34933497 }
34943498 else
34953499 {
34963500 RenderFramebufferDesc desc;
34973501 desc.colorAttachments = const_cast <const RenderTexture**>(&texture->texture );
34983502 desc.colorAttachmentsCount = 1 ;
3499- texture-> framebuffer = g_device->createFramebuffer (desc);
3503+ framebuffer = g_device->createFramebuffer (desc);
35003504 }
35013505 }
35023506
3503- if (g_framebuffer != texture-> framebuffer .get ())
3507+ if (g_framebuffer != framebuffer.get ())
35043508 {
3505- commandList->setFramebuffer (texture-> framebuffer .get ());
3506- g_framebuffer = texture-> framebuffer .get ();
3509+ commandList->setFramebuffer (framebuffer.get ());
3510+ g_framebuffer = framebuffer.get ();
35073511 }
35083512
35093513 commandList->setPipeline (pipeline);
@@ -3559,7 +3563,7 @@ static void ProcExecutePendingStretchRectCommands(const RenderCommand& cmd)
35593563 if (surface->format != RenderFormat::D32_FLOAT )
35603564 ExecutePendingStretchRectCommands (surface, nullptr );
35613565
3562- for (const auto texture : surface->destinationTextures )
3566+ for (const auto [ texture, _] : surface->destinationTextures )
35633567 texture->sourceSurface = nullptr ;
35643568
35653569 surface->destinationTextures .clear ();
@@ -8068,7 +8072,7 @@ int D3DDevice_EndTiling(GuestDevice* device, uint32_t flags, Rect* pResolveRects
80688072 // printf("pResolveParams: %x %x %x\n", resolveParams->format.get(), resolveParams->unk.get(), resolveParams->format2.get());
80698073 // }
80708074 if (pDestTexture) {
8071- StretchRect (device, flags, 0 , pDestTexture);
8075+ StretchRect (device, flags, 0 , pDestTexture, 0 , 0 , 0 );
80728076 }
80738077 return 0 ;
80748078}
0 commit comments