deko3d icon indicating copy to clipboard operation
deko3d copied to clipboard

Issue with 32x8 textures

Open RSDuck opened this issue 4 years ago • 4 comments

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 avatar Jun 19 '21 19:06 RSDuck

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

RSDuck avatar Jun 19 '21 21:06 RSDuck

https://github.com/RSDuck/deko3d/commit/f3a1249dde681c035d642cb0b30767b724729d71 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 avatar Jul 08 '21 20:07 RSDuck

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 avatar Feb 15 '24 20:02 averne