Skip to content

Commit

Permalink
n2va/vk: Key textures on sampler state for now
Browse files Browse the repository at this point in the history
  • Loading branch information
mborgerson committed Aug 1, 2024
1 parent 0c15e7d commit 1359e71
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
3 changes: 3 additions & 0 deletions hw/xbox/nv2a/pgraph/vk/renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ typedef struct TextureKey {
hwaddr palette_vram_offset;
hwaddr palette_length;
float scale;
uint32_t filter;
uint32_t address;
uint32_t border_color;
} TextureKey;

typedef struct TextureBinding {
Expand Down
18 changes: 12 additions & 6 deletions hw/xbox/nv2a/pgraph/vk/texture.c
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,13 @@ static void create_texture(PGRAPHState *pg, int texture_idx)

size_t texture_length = pgraph_get_texture_length(pg, &state);

uint32_t filter =
pgraph_reg_r(pg, NV_PGRAPH_TEXFILTER0 + texture_idx * 4);
uint32_t address =
pgraph_reg_r(pg, NV_PGRAPH_TEXADDRESS0 + texture_idx * 4);
uint32_t border_color_pack32 =
pgraph_reg_r(pg, NV_PGRAPH_BORDERCOLOR0 + texture_idx * 4);

TextureKey key;
memset(&key, 0, sizeof(key));
key.state = state;
Expand All @@ -1099,6 +1106,11 @@ static void create_texture(PGRAPHState *pg, int texture_idx)
key.palette_length = texture_palette_data_size;
key.scale = 1;

// FIXME: Separate sampler from texture
key.filter = filter;
key.address = address;
key.border_color = border_color_pack32;

bool is_indexed = (state.color_format ==
NV097_SET_TEXTURE_FORMAT_COLOR_SZ_I8_A8R8G8B8);

Expand Down Expand Up @@ -1244,8 +1256,6 @@ static void create_texture(PGRAPHState *pg, int texture_idx)

VkSamplerCustomBorderColorCreateInfoEXT custom_border_color_create_info;
VkBorderColor vk_border_color;
uint32_t border_color_pack32 =
pgraph_reg_r(pg, NV_PGRAPH_BORDERCOLOR0 + texture_idx * 4);

bool is_integer_type = vkf.vk_format == VK_FORMAT_R32_UINT;

Expand Down Expand Up @@ -1285,7 +1295,6 @@ static void create_texture(PGRAPHState *pg, int texture_idx)
}
}

uint32_t filter = pgraph_reg_r(pg, NV_PGRAPH_TEXFILTER0 + texture_idx * 4);
if (filter & NV_PGRAPH_TEXFILTER0_ASIGNED)
NV2A_UNIMPLEMENTED("NV_PGRAPH_TEXFILTER0_ASIGNED");
if (filter & NV_PGRAPH_TEXFILTER0_RSIGNED)
Expand Down Expand Up @@ -1320,9 +1329,6 @@ static void create_texture(PGRAPHState *pg, int texture_idx)
min_filter == NV_PGRAPH_TEXFILTER0_MIN_BOX_NEARESTLOD ||
min_filter == NV_PGRAPH_TEXFILTER0_MIN_TENT_NEARESTLOD;

uint32_t address =
pgraph_reg_r(pg, NV_PGRAPH_TEXADDRESS0 + texture_idx * 4);

VkSamplerCreateInfo sampler_create_info = {
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
.magFilter = vk_mag_filter,
Expand Down

0 comments on commit 1359e71

Please sign in to comment.