gl4: implement texture max anisotropy

This commit is contained in:
raven02 2015-06-24 08:25:22 -07:00
parent fc7695f874
commit d7dfb681aa
4 changed files with 36 additions and 4 deletions

View File

@ -362,8 +362,33 @@ TextureCache::SamplerEntry* TextureCache::LookupOrInsertSampler(
glSamplerParameteri(entry->handle, GL_TEXTURE_MIN_FILTER, min_filter);
glSamplerParameteri(entry->handle, GL_TEXTURE_MAG_FILTER, mag_filter);
// TODO(benvanik): anisotropic filtering.
// GL_TEXTURE_MAX_ANISOTROPY_EXT
GLfloat aniso;
switch (sampler_info.aniso_filter) {
case ucode::ANISO_FILTER_DISABLED:
aniso = 0.0f;
break;
case ucode::ANISO_FILTER_MAX_1_1:
aniso = 1.0f;
break;
case ucode::ANISO_FILTER_MAX_2_1:
aniso = 2.0f;
break;
case ucode::ANISO_FILTER_MAX_4_1:
aniso = 4.0f;
break;
case ucode::ANISO_FILTER_MAX_8_1:
aniso = 8.0f;
break;
case ucode::ANISO_FILTER_MAX_16_1:
aniso = 16.0f;
break;
default:
assert_unhandled_case(aniso);
return nullptr;
}
if (aniso)
glSamplerParameterf(entry->handle, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso);
// Add to map - map takes ownership.
auto entry_ptr = entry.get();

View File

@ -30,6 +30,10 @@ bool SamplerInfo::Prepare(const xenos::xe_gpu_texture_fetch_t& fetch,
out_info->clamp_u = fetch.clamp_x;
out_info->clamp_v = fetch.clamp_y;
out_info->clamp_w = fetch.clamp_z;
out_info->aniso_filter = static_cast<ucode::instr_aniso_filter_t>(
fetch_instr.aniso_filter == 7 ? fetch.aniso_filter
: fetch_instr.aniso_filter);
return true;
}

View File

@ -23,6 +23,7 @@ struct SamplerInfo {
uint32_t clamp_u;
uint32_t clamp_v;
uint32_t clamp_w;
ucode::instr_aniso_filter_t aniso_filter;
static bool Prepare(const xenos::xe_gpu_texture_fetch_t& fetch,
const ucode::instr_fetch_tex_t& fetch_instr,
@ -32,7 +33,8 @@ struct SamplerInfo {
bool operator==(const SamplerInfo& other) const {
return min_filter == other.min_filter && mag_filter == other.mag_filter &&
mip_filter == other.mip_filter && clamp_u == other.clamp_u &&
clamp_v == other.clamp_v && clamp_w == other.clamp_w;
clamp_v == other.clamp_v && clamp_w == other.clamp_w &&
aniso_filter == other.aniso_filter;
}
};

View File

@ -342,7 +342,8 @@ XEPACKEDUNION(xe_gpu_texture_fetch_t, {
uint32_t mag_filter : 2;
uint32_t min_filter : 2;
uint32_t mip_filter : 2;
uint32_t unk3_2 : 6;
uint32_t aniso_filter : 3; // correct ?
uint32_t arbitrary_filter : 3; // correct ?
uint32_t border : 1;
uint32_t unk4_0 : 2; // dword_4
uint32_t mip_min_level : 4;