EEVEE Next: Ensure correct resource usage flags for Metal #110219

Merged
Clément Foucault merged 2 commits from Jason-Fielder/blender:EEVEENext_MetalUsageFlags_Jul17 into main 2023-07-18 19:18:40 +02:00
2 changed files with 30 additions and 19 deletions

View File

@ -168,7 +168,7 @@ void DepthOfField::sync()
* the reduced buffers. Color needs to be signed format here. See note in shader for
* explanation. Do not use texture pool because of needs mipmaps. */
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT |
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW;
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW | GPU_TEXTURE_USAGE_SHADER_WRITE;
reduced_color_tx_.ensure_2d(GPU_RGBA16F, reduce_size, usage, nullptr, DOF_MIP_COUNT);
reduced_coc_tx_.ensure_2d(GPU_R16F, reduce_size, usage, nullptr, DOF_MIP_COUNT);
reduced_color_tx_.ensure_mip_views();
@ -582,6 +582,8 @@ void DepthOfField::render(View &view,
Manager &drw = *inst_.manager;
eGPUTextureUsage usage_readwrite = GPU_TEXTURE_USAGE_SHADER_READ |
GPU_TEXTURE_USAGE_SHADER_WRITE;
{
DRW_stats_group_start("Setup");
{
@ -594,7 +596,7 @@ void DepthOfField::render(View &view,
}
}
{
setup_color_tx_.acquire(half_res, GPU_RGBA16F);
setup_color_tx_.acquire(half_res, GPU_RGBA16F, usage_readwrite);
setup_coc_tx_.acquire(half_res, GPU_R16F);
drw.submit(setup_ps_, view);
@ -625,10 +627,10 @@ void DepthOfField::render(View &view,
DRW_stats_group_start("Tile Prepare");
/* WARNING: If format changes, make sure dof_tile_* GLSL constants are properly encoded. */
tiles_fg_tx_.previous().acquire(tile_res, GPU_R11F_G11F_B10F);
tiles_bg_tx_.previous().acquire(tile_res, GPU_R11F_G11F_B10F);
tiles_fg_tx_.current().acquire(tile_res, GPU_R11F_G11F_B10F);
tiles_bg_tx_.current().acquire(tile_res, GPU_R11F_G11F_B10F);
tiles_fg_tx_.previous().acquire(tile_res, GPU_R11F_G11F_B10F, usage_readwrite);

This should be fixed too. You might have not loaded scene with high enough radius, but both should be writable.

This should be fixed too. You might have not loaded scene with high enough radius, but both should be writable.
tiles_bg_tx_.previous().acquire(tile_res, GPU_R11F_G11F_B10F, usage_readwrite);
tiles_fg_tx_.current().acquire(tile_res, GPU_R11F_G11F_B10F, usage_readwrite);
tiles_bg_tx_.current().acquire(tile_res, GPU_R11F_G11F_B10F, usage_readwrite);
drw.submit(tiles_flatten_ps_, view);
@ -669,7 +671,7 @@ void DepthOfField::render(View &view,
DRW_stats_group_end();
}
downsample_tx_.acquire(quarter_res, GPU_RGBA16F);
downsample_tx_.acquire(quarter_res, GPU_RGBA16F, usage_readwrite);
drw.submit(downsample_ps_, view);
@ -694,8 +696,8 @@ void DepthOfField::render(View &view,
PassSimple &filter_ps = is_background ? filter_bg_ps_ : filter_fg_ps_;
PassSimple &scatter_ps = is_background ? scatter_bg_ps_ : scatter_fg_ps_;
color_tx.current().acquire(half_res, GPU_RGBA16F);
weight_tx.current().acquire(half_res, GPU_R16F);
color_tx.current().acquire(half_res, GPU_RGBA16F, usage_readwrite);
weight_tx.current().acquire(half_res, GPU_R16F, usage_readwrite);
occlusion_tx_.acquire(half_res, GPU_RG16F);
drw.submit(gather_ps, view);
@ -705,8 +707,8 @@ void DepthOfField::render(View &view,
color_tx.swap();
weight_tx.swap();
color_tx.current().acquire(half_res, GPU_RGBA16F);
weight_tx.current().acquire(half_res, GPU_R16F);
color_tx.current().acquire(half_res, GPU_RGBA16F, usage_readwrite);
weight_tx.current().acquire(half_res, GPU_R16F, usage_readwrite);
drw.submit(filter_ps, view);
@ -732,8 +734,8 @@ void DepthOfField::render(View &view,
bokeh_gather_lut_tx_.release();
bokeh_scatter_lut_tx_.release();
hole_fill_color_tx_.acquire(half_res, GPU_RGBA16F);
hole_fill_weight_tx_.acquire(half_res, GPU_R16F);
hole_fill_color_tx_.acquire(half_res, GPU_RGBA16F, usage_readwrite);
hole_fill_weight_tx_.acquire(half_res, GPU_R16F, usage_readwrite);
drw.submit(hole_fill_ps_, view);

View File

@ -75,16 +75,24 @@ void RenderBuffers::acquire(int2 extent)
/* Only RG16F when only doing only reprojection or motion blur. */
eGPUTextureFormat vector_format = do_vector_render_pass ? GPU_RGBA16F : GPU_RG16F;
eGPUTextureUsage usage_attachment_read_write = GPU_TEXTURE_USAGE_ATTACHMENT |
GPU_TEXTURE_USAGE_SHADER_READ |
GPU_TEXTURE_USAGE_SHADER_WRITE;
/* TODO(fclem): Make vector pass allocation optional if no TAA or motion blur is needed. */
vector_tx.acquire(extent, vector_format);
vector_tx.acquire(
extent, vector_format, usage_attachment_read_write | GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW);
int color_len = data.color_len + data.aovs.color_len;
int value_len = data.value_len + data.aovs.value_len;
rp_color_tx.ensure_2d_array(
color_format, (color_len > 0) ? extent : int2(1), math::max(1, color_len));
rp_value_tx.ensure_2d_array(
float_format, (value_len > 0) ? extent : int2(1), math::max(1, value_len));
rp_color_tx.ensure_2d_array(color_format,
(color_len > 0) ? extent : int2(1),
math::max(1, color_len),
usage_attachment_read_write);
fclem marked this conversation as resolved

rp_color_tx and rp_value_tx do not need attachment flag.

rp_color_tx and rp_value_tx do not need attachment flag.
rp_value_tx.ensure_2d_array(float_format,
(value_len > 0) ? extent : int2(1),
math::max(1, value_len),
usage_attachment_read_write);
eGPUTextureFormat cryptomatte_format = GPU_R32F;
const int cryptomatte_layer_len = inst_.film.cryptomatte_layer_max_get();
@ -98,7 +106,8 @@ void RenderBuffers::acquire(int2 extent)
pass_extent(static_cast<eViewLayerEEVEEPassType>(EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT |
EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET |
EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL)),
cryptomatte_format);
cryptomatte_format,
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_SHADER_WRITE);

cryptomatte_tx do not need attachment flag.

cryptomatte_tx do not need attachment flag.
}
void RenderBuffers::release()