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

Issue with 32x8 textures #10

Open
RSDuck opened this issue Jun 19, 2021 · 4 comments
Open

Issue with 32x8 textures #10

RSDuck opened this issue Jun 19, 2021 · 4 comments

Comments

@RSDuck
Copy link
Contributor

RSDuck commented Jun 19, 2021

This issue seems to be very weird. For some reason textures with a size of 32*8 pixels display wrongly. Instead of the right 16*8 pixels it reads from something else (it's noticable in situations where there are more textures around).

To reproduce it's enough to change this line in the textured cube example: https://github.com/switchbrew/switch-examples/blob/master/graphics/deko3d/deko_examples/source/Example04_TexturedCube.cpp#L189

to

texImage.load(*pool_images, *pool_data, device, queue, "romfs:/Unbenannt.data", 32, 8, DkImageFormat_RGBA8_Unorm);

here is the texture data I used:
Unbenannt.zip

This is the result:
2021061921161100-90646BC12AD199C21A10C53DE8289D0C

Note that if the height is reduced to 4 pixels, everything works fine (except ofc that only the first 4 lines of the texture are used):

2021061921154500-90646BC12AD199C21A10C53DE8289D0C

The texture transfer seems to work fine, I already tried retrieving the texture data from vram.

@RSDuck
Copy link
Contributor Author

RSDuck commented Jun 19, 2021

it works if the tile size is set to fixed one gob

RSDuck added a commit to RSDuck/deko3d that referenced this issue Jul 8, 2021
@RSDuck
Copy link
Contributor Author

RSDuck commented Jul 8, 2021

RSDuck@f3a1249 is what I've come with as a fix for it and I've been running this successfully for a while now in melonDS (though I haven't tested some things like mip maps).

RSDuck added a commit to RSDuck/deko3d that referenced this issue Dec 26, 2023
@averne
Copy link
Contributor

averne commented Feb 15, 2024

Hi, I also encountered this issue, with a 128x8 r8 texture (padded to 256b).
I attach the texture data before and after the transfer. I inspected manually some portions of it and couldn't find anything regarding the data swizzling.

Below is the corresponding TIC. Again, not sure whether if something is wrong.

(gdb) p (('maxwell::TextureImageControl' *)0x52b957000)[2]
$10 = {
  format_word = {
    image_format = 29,
    component_r = 2,
    component_g = 2,
    component_b = 2,
    component_a = 2,
    swizzle_x = 2,
    swizzle_y = 0,
    swizzle_z = 0,
    swizzle_w = 7,
    pack = 0
  },
  address_low = 82116608,
  address_high = 5,
  view_layer_base_3_7 = 0,
  hdr_version = 3,
  load_store_hint_maybe = 0,
  view_coherency_hash = 0,
  view_layer_base_8_10 = 0,
  {
    width_minus_one_16_31 = 8,
    pitch_5_20 = 8,
    {
      tile_width_gobs_log2 = 0,
      tile_height_gobs_log2 = 1,
      tile_depth_gobs_log2 = 0,
      sparse_tile_width_gobs_log2 = 0,
      gob_3d = 0
    }
  },
  lod_aniso_quality_2 = 1,
  lod_aniso_quality = 1,
  lod_iso_quality = 1,
  aniso_coarse_spread_modifier = 0,
  aniso_spread_scale = 0,
  use_header_opt_control = 0,
  depth_texture = 0,
  mip_max_levels = 0,
  width_minus_one = 127,
  view_layer_base_0_2 = 0,
  aniso_spread_max_log2 = 0,
  is_sRGB = 0,
  texture_type = 1,
  sector_promotion = 1,
  border_size = 7,
  height_minus_one = 7,
  depth_minus_one = 0,
  is_sparse = 0,
  normalized_coords = 1,
  color_key_op = 0,
  trilin_opt = 0,
  mip_lod_bias = 0,
  aniso_bias = 0,
  aniso_fine_spread_func = 2,
  aniso_coarse_spread_func = 1,
  max_anisotropy = 0,
  aniso_fine_spread_modifier = 0,
  {
    color_key_value = 0,
    {
      view_mip_min_level = 0,
      view_mip_max_level = 0,
      msaa_mode = 0,
      min_lod_clamp = 0
    }
  }
}

Do you happen to remember what the x1.5 factor (heightAndHalf) was for? I can't make sense of it.
From what I can tell, nouveau and nvk do no such thing. Perhaps a carryover from nvn?

Finally, a possible workaround for those unwilling to build a modified version of deko3d:

if (height <= 8) {
    layout_maker.flags   |= DkImageFlags_CustomTileSize;
    layout_maker.tileSize = 0;
}

@averne
Copy link
Contributor

averne commented May 18, 2024

Probably related: mpv-player/mpv#13909 (comment).
NVDEC always outputs a GOB-height of 2, for both the luma and chroma planes, however here chroma has a height of 8, leading to a situation similar to this bug (2-GOB layout with height <= 8). The 3D engine then fails to properly sample from it.
I reproduced this behavior on switch/deko3d, jetson nano/gles and multiple dGPUs/vulkan, so I'm wondering whether this could be a hardware issue.

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

No branches or pull requests

2 participants