anv/cmd_buffer: Stop relying on the framebuffer for 3DSTATE_SF on gen7
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
This commit is contained in:
parent
d2b4a9da03
commit
6614234fc9
|
@ -28,6 +28,7 @@
|
|||
#include <fcntl.h>
|
||||
|
||||
#include "anv_private.h"
|
||||
#include "vk_format_info.h"
|
||||
|
||||
#include "genxml/gen_macros.h"
|
||||
#include "genxml/genX_pack.h"
|
||||
|
@ -121,6 +122,36 @@ void genX(CmdBindIndexBuffer)(
|
|||
cmd_buffer->state.gen7.index_offset = offset;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
get_depth_format(struct anv_cmd_buffer *cmd_buffer)
|
||||
{
|
||||
const struct anv_render_pass *pass = cmd_buffer->state.pass;
|
||||
const struct anv_subpass *subpass = cmd_buffer->state.subpass;
|
||||
|
||||
if (subpass->depth_stencil_attachment >= pass->attachment_count)
|
||||
return D16_UNORM;
|
||||
|
||||
struct anv_render_pass_attachment *att =
|
||||
&pass->attachments[subpass->depth_stencil_attachment];
|
||||
|
||||
switch (att->format) {
|
||||
case VK_FORMAT_D16_UNORM:
|
||||
case VK_FORMAT_D16_UNORM_S8_UINT:
|
||||
return D16_UNORM;
|
||||
|
||||
case VK_FORMAT_X8_D24_UNORM_PACK32:
|
||||
case VK_FORMAT_D24_UNORM_S8_UINT:
|
||||
return D24_UNORM_X8_UINT;
|
||||
|
||||
case VK_FORMAT_D32_SFLOAT:
|
||||
case VK_FORMAT_D32_SFLOAT_S8_UINT:
|
||||
return D32_FLOAT;
|
||||
|
||||
default:
|
||||
return D16_UNORM;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
|
||||
{
|
||||
|
@ -130,20 +161,10 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
|
|||
ANV_CMD_DIRTY_RENDER_TARGETS |
|
||||
ANV_CMD_DIRTY_DYNAMIC_LINE_WIDTH |
|
||||
ANV_CMD_DIRTY_DYNAMIC_DEPTH_BIAS)) {
|
||||
|
||||
const struct anv_image_view *iview =
|
||||
anv_cmd_buffer_get_depth_stencil_view(cmd_buffer);
|
||||
const struct anv_image *image = iview ? iview->image : NULL;
|
||||
const bool has_depth =
|
||||
image && (image->aspects & VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||
const uint32_t depth_format = has_depth ?
|
||||
isl_surf_get_depth_format(&cmd_buffer->device->isl_dev,
|
||||
&image->depth_surface.isl) : D16_UNORM;
|
||||
|
||||
uint32_t sf_dw[GENX(3DSTATE_SF_length)];
|
||||
struct GENX(3DSTATE_SF) sf = {
|
||||
GENX(3DSTATE_SF_header),
|
||||
.DepthBufferSurfaceFormat = depth_format,
|
||||
.DepthBufferSurfaceFormat = get_depth_format(cmd_buffer),
|
||||
.LineWidth = cmd_buffer->state.dynamic.line_width,
|
||||
.GlobalDepthOffsetConstant = cmd_buffer->state.dynamic.depth_bias.bias,
|
||||
.GlobalDepthOffsetScale = cmd_buffer->state.dynamic.depth_bias.slope,
|
||||
|
|
Loading…
Reference in New Issue