Skip to content

Commit cce8e3a

Browse files
committed
SQUASHME: Enable samplerAnisotropy and PR cleanup
1 parent dcce545 commit cce8e3a

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

hw/xbox/nv2a/pgraph/vk/instance.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ static bool create_logical_device(PGRAPHState *pg, Error **errp)
547547
F(occlusionQueryPrecise, true),
548548
F(fillModeNonSolid, true),
549549
F(wideLines, false),
550+
F(samplerAnisotropy, false),
550551
#undef F
551552
// clang-format on
552553
};

hw/xbox/nv2a/pgraph/vk/renderer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ typedef struct TextureKey {
206206
uint32_t filter;
207207
uint32_t address;
208208
uint32_t border_color;
209+
uint32_t max_anisotropy;
209210
} TextureKey;
210211

211212
typedef struct TextureBinding {

hw/xbox/nv2a/pgraph/vk/texture.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,13 +1101,9 @@ static void create_texture(PGRAPHState *pg, int texture_idx)
11011101
pgraph_reg_r(pg, NV_PGRAPH_BORDERCOLOR0 + texture_idx * 4);
11021102
bool is_indexed = (state.color_format ==
11031103
NV097_SET_TEXTURE_FORMAT_COLOR_SZ_I8_A8R8G8B8);
1104-
uint32_t xbox_max_anisotropy =
1104+
uint32_t max_anisotropy =
11051105
1 << (GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_TEXCTL0_0 + texture_idx*4),
11061106
NV_PGRAPH_TEXCTL0_0_MAX_ANISOTROPY));
1107-
uint32_t max_anisotropy =
1108-
xbox_max_anisotropy <= r->device_props.limits.maxSamplerAnisotropy ?
1109-
xbox_max_anisotropy :
1110-
r->device_props.limits.maxSamplerAnisotropy;
11111107

11121108
TextureKey key;
11131109
memset(&key, 0, sizeof(key));
@@ -1127,6 +1123,7 @@ static void create_texture(PGRAPHState *pg, int texture_idx)
11271123
key.filter = filter;
11281124
key.address = address;
11291125
key.border_color = border_color_pack32;
1126+
key.max_anisotropy = max_anisotropy;
11301127

11311128
bool possibly_dirty = false;
11321129
bool possibly_dirty_checked = false;
@@ -1350,6 +1347,8 @@ static void create_texture(PGRAPHState *pg, int texture_idx)
13501347
} else if (lod_bias < -r->device_props.limits.maxSamplerLodBias) {
13511348
lod_bias = -r->device_props.limits.maxSamplerLodBias;
13521349
}
1350+
uint32_t sampler_max_anisotropy =
1351+
MIN(r->device_props.limits.maxSamplerAnisotropy, max_anisotropy);
13531352

13541353
VkSamplerCreateInfo sampler_create_info = {
13551354
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
@@ -1361,8 +1360,9 @@ static void create_texture(PGRAPHState *pg, int texture_idx)
13611360
GET_MASK(address, NV_PGRAPH_TEXADDRESS0_ADDRV)),
13621361
.addressModeW = (state.dimensionality > 2) ? lookup_texture_address_mode(
13631362
GET_MASK(address, NV_PGRAPH_TEXADDRESS0_ADDRP)) : 0,
1364-
.anisotropyEnable = max_anisotropy > 1,
1365-
.maxAnisotropy = max_anisotropy,
1363+
.anisotropyEnable = r->enabled_physical_device_features.wideLines &&
1364+
sampler_max_anisotropy > 1,
1365+
.maxAnisotropy = sampler_max_anisotropy,
13661366
.borderColor = vk_border_color,
13671367
.compareEnable = VK_FALSE,
13681368
.compareOp = VK_COMPARE_OP_ALWAYS,

0 commit comments

Comments
 (0)