Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D3D12: Crash when rendering a non-square texture with mipmaps #96352

Closed
BlueCube3310 opened this issue Aug 30, 2024 · 1 comment · Fixed by #96758
Closed

D3D12: Crash when rendering a non-square texture with mipmaps #96352

BlueCube3310 opened this issue Aug 30, 2024 · 1 comment · Fixed by #96758

Comments

@BlueCube3310
Copy link
Contributor

BlueCube3310 commented Aug 30, 2024

Tested versions

Reproducible in 4.3-stable, 4.4-dev1

System information

Windows 10.0.19045 - d3d12 (Forward+) - dedicated NVIDIA GeForce RTX 4060 Ti (NVIDIA; 31.0.15.5244) - AMD Ryzen 9 5900X 12-Core Processor (24 Threads)

Issue description

The engine crashes when trying to create a non-square texture with mipmaps on the GPU under D3D12. The crash always occurs, even if both the texture's width and height are powers of 2.

Steps to reproduce

  1. Open the MRP.
  2. Click on aa.png to preview it in the inspector.
  3. The crash should occur.

Minimal reproduction project (MRP)

d3d12-mip-crash.zip

@alvinhochun
Copy link
Contributor

alvinhochun commented Sep 1, 2024

Here it is crashing with 0xc0000094 (STATUS_INTEGER_DIVIDE_BY_ZERO) at

uint32_t row_pitch = image_size / (p_regions[i].texture_region_size.y * computed_d) * block_h;

p_regions[i].texture_region_size.y is 0:

p_regions._ptr[9]
(const RenderingDeviceDriver::BufferTextureCopyRegion) {
  buffer_offset = 0
  texture_subresources = {
    aspect = (value = 1)
    mipmap = 9
    base_layer = 0
    layer_count = 1
  }
  texture_offset = {
     = {
       = (x = 0, y = 0, z = 0)
      coord = ([0] = 0, [1] = 0, [2] = 0)
    }
  }
  texture_region_size = {
     = {
       = (x = 1, y = 0, z = 1)
      coord = ([0] = 1, [1] = 0, [2] = 1)
    }
  }
}

Just a quick guess, it might be coming from

for (uint32_t i = 0; i < tex->mipmaps; i++) {
RDD::BufferTextureCopyRegion copy_region;
copy_region.buffer_offset = mip_layouts[i].offset;
copy_region.texture_subresources.aspect = tex->read_aspect_flags;
copy_region.texture_subresources.mipmap = i;
copy_region.texture_subresources.base_layer = p_layer;
copy_region.texture_subresources.layer_count = 1;
copy_region.texture_region_size.x = w;
copy_region.texture_region_size.y = h;
copy_region.texture_region_size.z = d;
command_buffer_texture_copy_regions_vector.push_back(copy_region);
w = (w >> 1);
h = (h >> 1);
d = MAX(1u, d >> 1);
}

Might be a regression from #94069 (CC @RandomShaper)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants