Skip to content

Commit 1bc1256

Browse files
authored
revert mipmap changes from 66a7657
This was causing RGUI to flicker and Ozone menu to randomly crash. Unfortunately, this re-breaks mipmaps on this driver, but the instability is a bigger problem.
1 parent 11891ae commit 1bc1256

1 file changed

Lines changed: 31 additions & 45 deletions

File tree

gfx/drivers/d3d12.c

Lines changed: 31 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -720,13 +720,13 @@ static void d3d12_init_texture(D3D12Device device, d3d12_texture_t* texture)
720720
if (!texture->desc.MipLevels)
721721
texture->desc.MipLevels = 1;
722722

723-
/* Calculate mipmap count */
724-
if (texture->desc.Width > 1 || texture->desc.Height > 1)
723+
if ( !(texture->desc.Width >> (texture->desc.MipLevels - 1))
724+
&& !(texture->desc.Height >> (texture->desc.MipLevels - 1)))
725725
{
726-
unsigned width = texture->desc.Width;
727-
unsigned height = texture->desc.Height;
726+
unsigned width = texture->desc.Width >> 5;
727+
unsigned height = texture->desc.Height >> 5;
728728
texture->desc.MipLevels = 1;
729-
while ((width > 1) || (height > 1))
729+
while (width && height)
730730
{
731731
width >>= 1;
732732
height >>= 1;
@@ -835,11 +835,33 @@ static void d3d12_init_texture(D3D12Device device, d3d12_texture_t* texture)
835835
texture->size_data.w = 1.0f / texture->desc.Height;
836836
}
837837

838-
static void d3d12_generate_mipmaps(
839-
D3D12GraphicsCommandList cmd,
840-
d3d12_texture_t* texture,
841-
void *userdata)
838+
static void d3d12_upload_texture(D3D12GraphicsCommandList cmd,
839+
d3d12_texture_t* texture, void *userdata)
842840
{
841+
D3D12_TEXTURE_COPY_LOCATION src, dst;
842+
843+
src.pResource = texture->upload_buffer;
844+
src.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
845+
src.PlacedFootprint = texture->layout;
846+
847+
dst.pResource = texture->handle;
848+
dst.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
849+
dst.SubresourceIndex = 0;
850+
851+
D3D12_RESOURCE_TRANSITION(
852+
cmd,
853+
texture->handle,
854+
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
855+
D3D12_RESOURCE_STATE_COPY_DEST);
856+
857+
cmd->lpVtbl->CopyTextureRegion(cmd, &dst, 0, 0, 0, &src, NULL);
858+
859+
D3D12_RESOURCE_TRANSITION(
860+
cmd,
861+
texture->handle,
862+
D3D12_RESOURCE_STATE_COPY_DEST,
863+
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
864+
843865
if (texture->desc.MipLevels > 1)
844866
{
845867
unsigned i;
@@ -893,37 +915,6 @@ static void d3d12_generate_mipmaps(
893915
}
894916
}
895917
}
896-
}
897-
898-
static void d3d12_upload_texture(D3D12GraphicsCommandList cmd,
899-
d3d12_texture_t* texture, void *userdata)
900-
{
901-
D3D12_TEXTURE_COPY_LOCATION src, dst;
902-
903-
src.pResource = texture->upload_buffer;
904-
src.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
905-
src.PlacedFootprint = texture->layout;
906-
907-
dst.pResource = texture->handle;
908-
dst.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
909-
dst.SubresourceIndex = 0;
910-
911-
D3D12_RESOURCE_TRANSITION(
912-
cmd,
913-
texture->handle,
914-
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
915-
D3D12_RESOURCE_STATE_COPY_DEST);
916-
917-
cmd->lpVtbl->CopyTextureRegion(cmd, &dst, 0, 0, 0, &src, NULL);
918-
919-
D3D12_RESOURCE_TRANSITION(
920-
cmd,
921-
texture->handle,
922-
D3D12_RESOURCE_STATE_COPY_DEST,
923-
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
924-
925-
d3d12_generate_mipmaps(cmd, texture, userdata);
926-
927918
texture->dirty = false;
928919
}
929920

@@ -3715,8 +3706,6 @@ static void d3d12_init_render_targets(d3d12_video_t* d3d12, unsigned width, unsi
37153706
d3d12->pass[i].rt.desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
37163707
d3d12->pass[i].rt.srv_heap = &d3d12->desc.srv_heap;
37173708
d3d12->pass[i].rt.desc.Format = glslang_format_to_dxgi(d3d12->pass[i].semantics.format);
3718-
/* Initialize MipLevels so mipmaps are created for render target */
3719-
d3d12->pass[i].rt.desc.MipLevels = 0;
37203709
d3d12_release_texture(&d3d12->pass[i].rt);
37213710
d3d12_init_texture(d3d12->device, &d3d12->pass[i].rt);
37223711

@@ -4365,9 +4354,6 @@ static bool d3d12_gfx_frame(
43654354
d3d12->pass[i].rt.handle,
43664355
D3D12_RESOURCE_STATE_RENDER_TARGET,
43674356
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
4368-
4369-
/* Generate mipmaps for framebuffer if it has multiple mipmap levels */
4370-
d3d12_generate_mipmaps(cmd, &d3d12->pass[i].rt, d3d12);
43714357
texture = &d3d12->pass[i].rt;
43724358
}
43734359
else

0 commit comments

Comments
 (0)