mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-29 22:20:48 +00:00
rsx: Validate requested images before attempting to upload them
- Do not allow dimensions of 0 to reach the backend APIs
This commit is contained in:
parent
0e320d17c1
commit
86919ec0e1
@ -2084,6 +2084,7 @@ namespace rsx
|
|||||||
{
|
{
|
||||||
case rsx::texture_dimension_extended::texture_dimension_1d:
|
case rsx::texture_dimension_extended::texture_dimension_1d:
|
||||||
attributes.depth = 1;
|
attributes.depth = 1;
|
||||||
|
attributes.height = 1;
|
||||||
attributes.slice_h = 1;
|
attributes.slice_h = 1;
|
||||||
scale.height = scale.depth = 0.f;
|
scale.height = scale.depth = 0.f;
|
||||||
subsurface_count = 1;
|
subsurface_count = 1;
|
||||||
@ -2113,6 +2114,15 @@ namespace rsx
|
|||||||
fmt::throw_exception("Unsupported texture dimension %d", static_cast<int>(extended_dimension));
|
fmt::throw_exception("Unsupported texture dimension %d", static_cast<int>(extended_dimension));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validation
|
||||||
|
if (!attributes.width || !attributes.height || !attributes.depth)
|
||||||
|
{
|
||||||
|
rsx_log.warning("Image at address 0x%x has invalid dimensions. Type=%d, Dims=%dx%dx%d",
|
||||||
|
attributes.address, static_cast<s32>(extended_dimension),
|
||||||
|
attributes.width, attributes.height, attributes.depth);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
if (options.is_compressed_format)
|
if (options.is_compressed_format)
|
||||||
{
|
{
|
||||||
// Compressed textures cannot be 1D in some APIs
|
// Compressed textures cannot be 1D in some APIs
|
||||||
|
@ -298,15 +298,17 @@ void GLGSRender::load_texture_env()
|
|||||||
if (tex.enabled())
|
if (tex.enabled())
|
||||||
{
|
{
|
||||||
*sampler_state = m_gl_texture_cache.upload_texture(cmd, tex, m_rtts);
|
*sampler_state = m_gl_texture_cache.upload_texture(cmd, tex, m_rtts);
|
||||||
|
|
||||||
if (m_textures_dirty[i])
|
|
||||||
m_fs_sampler_states[i].apply(tex, fs_sampler_state[i].get());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*sampler_state = {};
|
*sampler_state = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_textures_dirty[i] && sampler_state->validate())
|
||||||
|
{
|
||||||
|
m_fs_sampler_states[i].apply(tex, fs_sampler_state[i].get());
|
||||||
|
}
|
||||||
|
|
||||||
m_textures_dirty[i] = false;
|
m_textures_dirty[i] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,12 +329,16 @@ void GLGSRender::load_texture_env()
|
|||||||
if (rsx::method_registers.vertex_textures[i].enabled())
|
if (rsx::method_registers.vertex_textures[i].enabled())
|
||||||
{
|
{
|
||||||
*sampler_state = m_gl_texture_cache.upload_texture(cmd, rsx::method_registers.vertex_textures[i], m_rtts);
|
*sampler_state = m_gl_texture_cache.upload_texture(cmd, rsx::method_registers.vertex_textures[i], m_rtts);
|
||||||
|
|
||||||
if (m_vertex_textures_dirty[i])
|
|
||||||
m_vs_sampler_states[i].apply(tex, vs_sampler_state[i].get());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
*sampler_state = {};
|
*sampler_state = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_vertex_textures_dirty[i] && sampler_state->validate())
|
||||||
|
{
|
||||||
|
m_vs_sampler_states[i].apply(tex, vs_sampler_state[i].get());
|
||||||
|
}
|
||||||
|
|
||||||
m_vertex_textures_dirty[i] = false;
|
m_vertex_textures_dirty[i] = false;
|
||||||
}
|
}
|
||||||
|
@ -1934,7 +1934,7 @@ namespace rsx
|
|||||||
auto &tex = rsx::method_registers.fragment_textures[i];
|
auto &tex = rsx::method_registers.fragment_textures[i];
|
||||||
current_fp_texture_state.clear(i);
|
current_fp_texture_state.clear(i);
|
||||||
|
|
||||||
if (tex.enabled())
|
if (tex.enabled() && sampler_descriptors[i]->format_class != RSX_FORMAT_CLASS_UNDEFINED)
|
||||||
{
|
{
|
||||||
current_fragment_program.texture_params[i].scale[0] = sampler_descriptors[i]->scale_x;
|
current_fragment_program.texture_params[i].scale[0] = sampler_descriptors[i]->scale_x;
|
||||||
current_fragment_program.texture_params[i].scale[1] = sampler_descriptors[i]->scale_y;
|
current_fragment_program.texture_params[i].scale[1] = sampler_descriptors[i]->scale_y;
|
||||||
|
@ -177,7 +177,14 @@ void VKGSRender::load_texture_env()
|
|||||||
{
|
{
|
||||||
check_heap_status(VK_HEAP_CHECK_TEXTURE_UPLOAD_STORAGE);
|
check_heap_status(VK_HEAP_CHECK_TEXTURE_UPLOAD_STORAGE);
|
||||||
*sampler_state = m_texture_cache.upload_texture(*m_current_command_buffer, tex, m_rtts);
|
*sampler_state = m_texture_cache.upload_texture(*m_current_command_buffer, tex, m_rtts);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*sampler_state = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sampler_state->validate())
|
||||||
|
{
|
||||||
if (sampler_state->is_cyclic_reference)
|
if (sampler_state->is_cyclic_reference)
|
||||||
{
|
{
|
||||||
check_for_cyclic_refs |= true;
|
check_for_cyclic_refs |= true;
|
||||||
@ -295,10 +302,6 @@ void VKGSRender::load_texture_env()
|
|||||||
border_color, compare_enabled, depth_compare_mode);
|
border_color, compare_enabled, depth_compare_mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
*sampler_state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
m_textures_dirty[i] = false;
|
m_textures_dirty[i] = false;
|
||||||
}
|
}
|
||||||
@ -321,7 +324,14 @@ void VKGSRender::load_texture_env()
|
|||||||
{
|
{
|
||||||
check_heap_status(VK_HEAP_CHECK_TEXTURE_UPLOAD_STORAGE);
|
check_heap_status(VK_HEAP_CHECK_TEXTURE_UPLOAD_STORAGE);
|
||||||
*sampler_state = m_texture_cache.upload_texture(*m_current_command_buffer, tex, m_rtts);
|
*sampler_state = m_texture_cache.upload_texture(*m_current_command_buffer, tex, m_rtts);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*sampler_state = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sampler_state->validate())
|
||||||
|
{
|
||||||
if (sampler_state->is_cyclic_reference || sampler_state->external_subresource_desc.do_not_cache)
|
if (sampler_state->is_cyclic_reference || sampler_state->external_subresource_desc.do_not_cache)
|
||||||
{
|
{
|
||||||
check_for_cyclic_refs |= true;
|
check_for_cyclic_refs |= true;
|
||||||
@ -353,8 +363,6 @@ void VKGSRender::load_texture_env()
|
|||||||
VK_FILTER_NEAREST, VK_FILTER_NEAREST, VK_SAMPLER_MIPMAP_MODE_NEAREST, border_color);
|
VK_FILTER_NEAREST, VK_FILTER_NEAREST, VK_SAMPLER_MIPMAP_MODE_NEAREST, border_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
*sampler_state = {};
|
|
||||||
|
|
||||||
m_vertex_textures_dirty[i] = false;
|
m_vertex_textures_dirty[i] = false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user