Draw tex coords for invalid textures.

This commit is contained in:
Ben Vanik 2015-01-01 12:25:16 -08:00
parent 825c09dd16
commit 0e04e1c455
2 changed files with 28 additions and 24 deletions

View File

@ -2132,15 +2132,19 @@ bool CommandProcessor::PopulateSampler(DrawCommand* draw_command,
// ? // ?
assert_true(fetch.type == 0x2); assert_true(fetch.type == 0x2);
// Reset slot.
// If we fail, we still draw but with an invalid texture.
draw_command->state_data->texture_samplers[desc.fetch_slot] = 0;
TextureInfo texture_info; TextureInfo texture_info;
if (!TextureInfo::Prepare(fetch, &texture_info)) { if (!TextureInfo::Prepare(fetch, &texture_info)) {
XELOGE("Unable to parse texture fetcher info"); XELOGE("Unable to parse texture fetcher info");
return false; // invalid texture used return true; // invalid texture used
} }
SamplerInfo sampler_info; SamplerInfo sampler_info;
if (!SamplerInfo::Prepare(fetch, desc.tex_fetch, &sampler_info)) { if (!SamplerInfo::Prepare(fetch, desc.tex_fetch, &sampler_info)) {
XELOGE("Unable to parse sampler info"); XELOGE("Unable to parse sampler info");
return false; // invalid texture used return true; // invalid texture used
} }
uint32_t guest_base = fetch.address << 12; uint32_t guest_base = fetch.address << 12;
@ -2150,7 +2154,7 @@ bool CommandProcessor::PopulateSampler(DrawCommand* draw_command,
if (!entry_view) { if (!entry_view) {
// Unable to create/fetch/etc. // Unable to create/fetch/etc.
XELOGE("Failed to demand texture"); XELOGE("Failed to demand texture");
return false; return true;
} }
// Shaders will use bindless to fetch right from it. // Shaders will use bindless to fetch right from it.

View File

@ -1472,7 +1472,8 @@ bool GL4ShaderTranslator::TranslateTextureFetch(const instr_fetch_tex_t* tex,
// Translate. // Translate.
// TODO(benvanik): if sampler == null, set to invalid color. // TODO(benvanik): if sampler == null, set to invalid color.
Append(" t = texture("); Append(" if (state.texture_samplers[%d].x != 0) {\n", tex->const_idx & 0xF);
Append(" t = texture(");
Append("%s(state.texture_samplers[%d])", sampler_type, tex->const_idx & 0xF); Append("%s(state.texture_samplers[%d])", sampler_type, tex->const_idx & 0xF);
Append(", r%u.", tex->src_reg); Append(", r%u.", tex->src_reg);
src_swiz = tex->src_swiz; src_swiz = tex->src_swiz;
@ -1481,26 +1482,25 @@ bool GL4ShaderTranslator::TranslateTextureFetch(const instr_fetch_tex_t* tex,
src_swiz >>= 2; src_swiz >>= 2;
} }
Append(");\n"); Append(");\n");
Append(" } else {\n");
// Output texture coordinates as color. Append(" t = vec4(r%u.", tex->src_reg);
// TODO(benvanik): only if texture is invalid? src_swiz = tex->src_swiz;
// Append(" t = vec4(r%u.", tex->src_reg); for (int i = 0; i < src_component_count; i++) {
// src_swiz = tex->src_swiz; Append("%c", chan_names[src_swiz & 0x3]);
// for (int i = 0; i < src_component_count; i++) { src_swiz >>= 2;
// Append("%c", chan_names[src_swiz & 0x3]); }
// src_swiz >>= 2; switch (src_component_count) {
//} case 1:
// switch (src_component_count) { Append(", 0.0, 0.0, 1.0);\n");
// case 1: break;
// Append(", 0.0, 0.0, 1.0);\n"); case 2:
// break; Append(", 0.0, 1.0);\n");
// case 2: break;
// Append(", 0.0, 1.0);\n"); case 3:
// break; Append(", 1.0);\n");
// case 3: break;
// Append(", 1.0);\n"); }
// break; Append(" }\n");
//}
Append(" r%u.xyzw = vec4(", tex->dst_reg); Append(" r%u.xyzw = vec4(", tex->dst_reg);
uint32_t dst_swiz = tex->dst_swiz; uint32_t dst_swiz = tex->dst_swiz;