2015-08-20 22:59:19 -07:00
|
|
|
/*
|
|
|
|
* Copyright © 2015 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include "anv_private.h"
|
2016-10-19 16:37:03 -07:00
|
|
|
#include "vk_format_info.h"
|
2015-08-20 22:59:19 -07:00
|
|
|
|
2016-02-20 09:08:27 -08:00
|
|
|
#include "genxml/gen_macros.h"
|
|
|
|
#include "genxml/genX_pack.h"
|
2015-11-16 12:29:07 -08:00
|
|
|
|
2017-07-06 21:20:15 -07:00
|
|
|
#if GEN_GEN == 7 && !GEN_IS_HASWELL
|
2017-07-06 21:18:03 -07:00
|
|
|
static int64_t
|
2015-11-16 12:10:11 -08:00
|
|
|
clamp_int64(int64_t x, int64_t min, int64_t max)
|
|
|
|
{
|
|
|
|
if (x < min)
|
|
|
|
return min;
|
|
|
|
else if (x < max)
|
|
|
|
return x;
|
|
|
|
else
|
|
|
|
return max;
|
|
|
|
}
|
|
|
|
|
2016-03-30 17:13:01 -07:00
|
|
|
void
|
|
|
|
gen7_cmd_buffer_emit_scissor(struct anv_cmd_buffer *cmd_buffer)
|
2015-11-16 12:10:11 -08:00
|
|
|
{
|
2018-08-21 20:43:57 -05:00
|
|
|
struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
|
2017-12-15 16:48:53 -08:00
|
|
|
uint32_t count = cmd_buffer->state.gfx.dynamic.scissor.count;
|
|
|
|
const VkRect2D *scissors = cmd_buffer->state.gfx.dynamic.scissor.scissors;
|
2015-11-16 12:10:11 -08:00
|
|
|
struct anv_state scissor_state =
|
2016-01-26 22:10:11 -08:00
|
|
|
anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, count * 8, 32);
|
2015-11-16 12:10:11 -08:00
|
|
|
|
|
|
|
for (uint32_t i = 0; i < count; i++) {
|
|
|
|
const VkRect2D *s = &scissors[i];
|
|
|
|
|
|
|
|
/* Since xmax and ymax are inclusive, we have to have xmax < xmin or
|
|
|
|
* ymax < ymin for empty clips. In case clip x, y, width height are all
|
|
|
|
* 0, the clamps below produce 0 for xmin, ymin, xmax, ymax, which isn't
|
|
|
|
* what we want. Just special case empty clips and produce a canonical
|
|
|
|
* empty clip. */
|
|
|
|
static const struct GEN7_SCISSOR_RECT empty_scissor = {
|
|
|
|
.ScissorRectangleYMin = 1,
|
|
|
|
.ScissorRectangleXMin = 1,
|
|
|
|
.ScissorRectangleYMax = 0,
|
|
|
|
.ScissorRectangleXMax = 0
|
|
|
|
};
|
|
|
|
|
|
|
|
const int max = 0xffff;
|
2019-02-12 19:19:13 +01:00
|
|
|
|
|
|
|
uint32_t y_min = s->offset.y;
|
|
|
|
uint32_t x_min = s->offset.x;
|
|
|
|
uint32_t y_max = s->offset.y + s->extent.height - 1;
|
|
|
|
uint32_t x_max = s->offset.x + s->extent.width - 1;
|
|
|
|
|
|
|
|
/* Do this math using int64_t so overflow gets clamped correctly. */
|
|
|
|
if (cmd_buffer->level == VK_COMMAND_BUFFER_LEVEL_PRIMARY) {
|
|
|
|
y_min = clamp_int64((uint64_t) y_min,
|
|
|
|
cmd_buffer->state.render_area.offset.y, max);
|
|
|
|
x_min = clamp_int64((uint64_t) x_min,
|
|
|
|
cmd_buffer->state.render_area.offset.x, max);
|
|
|
|
y_max = clamp_int64((uint64_t) y_max, 0,
|
|
|
|
cmd_buffer->state.render_area.offset.y +
|
|
|
|
cmd_buffer->state.render_area.extent.height - 1);
|
|
|
|
x_max = clamp_int64((uint64_t) x_max, 0,
|
|
|
|
cmd_buffer->state.render_area.offset.x +
|
|
|
|
cmd_buffer->state.render_area.extent.width - 1);
|
|
|
|
} else if (fb) {
|
|
|
|
y_min = clamp_int64((uint64_t) y_min, 0, max);
|
|
|
|
x_min = clamp_int64((uint64_t) x_min, 0, max);
|
|
|
|
y_max = clamp_int64((uint64_t) y_max, 0, fb->height - 1);
|
|
|
|
x_max = clamp_int64((uint64_t) x_max, 0, fb->width - 1);
|
|
|
|
}
|
|
|
|
|
2015-11-16 12:10:11 -08:00
|
|
|
struct GEN7_SCISSOR_RECT scissor = {
|
2019-02-12 19:19:13 +01:00
|
|
|
.ScissorRectangleYMin = y_min,
|
|
|
|
.ScissorRectangleXMin = x_min,
|
|
|
|
.ScissorRectangleYMax = y_max,
|
|
|
|
.ScissorRectangleXMax = x_max
|
2015-11-16 12:10:11 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
if (s->extent.width <= 0 || s->extent.height <= 0) {
|
2016-01-26 22:10:11 -08:00
|
|
|
GEN7_SCISSOR_RECT_pack(NULL, scissor_state.map + i * 8,
|
2015-11-16 12:10:11 -08:00
|
|
|
&empty_scissor);
|
|
|
|
} else {
|
2016-01-26 22:10:11 -08:00
|
|
|
GEN7_SCISSOR_RECT_pack(NULL, scissor_state.map + i * 8, &scissor);
|
2015-11-16 12:10:11 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-18 17:03:00 -07:00
|
|
|
anv_batch_emit(&cmd_buffer->batch,
|
|
|
|
GEN7_3DSTATE_SCISSOR_STATE_POINTERS, ssp) {
|
2016-04-18 16:33:46 -07:00
|
|
|
ssp.ScissorRectPointer = scissor_state.offset;
|
|
|
|
}
|
2015-11-16 12:10:11 -08:00
|
|
|
}
|
2016-02-20 09:08:27 -08:00
|
|
|
#endif
|
2015-11-16 12:10:11 -08:00
|
|
|
|
2019-05-13 16:33:22 +01:00
|
|
|
static uint32_t vk_to_gen_index_type(VkIndexType type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case VK_INDEX_TYPE_UINT8_EXT:
|
|
|
|
return INDEX_BYTE;
|
|
|
|
case VK_INDEX_TYPE_UINT16:
|
|
|
|
return INDEX_WORD;
|
|
|
|
case VK_INDEX_TYPE_UINT32:
|
|
|
|
return INDEX_DWORD;
|
|
|
|
default:
|
|
|
|
unreachable("invalid index type");
|
|
|
|
}
|
|
|
|
}
|
2015-08-20 22:59:19 -07:00
|
|
|
|
2019-05-13 16:33:22 +01:00
|
|
|
static uint32_t restart_index_for_type(VkIndexType type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case VK_INDEX_TYPE_UINT8_EXT:
|
|
|
|
return UINT8_MAX;
|
|
|
|
case VK_INDEX_TYPE_UINT16:
|
|
|
|
return UINT16_MAX;
|
|
|
|
case VK_INDEX_TYPE_UINT32:
|
|
|
|
return UINT32_MAX;
|
|
|
|
default:
|
|
|
|
unreachable("invalid index type");
|
|
|
|
}
|
|
|
|
}
|
2015-11-17 07:07:02 -08:00
|
|
|
|
|
|
|
void genX(CmdBindIndexBuffer)(
|
2015-11-30 11:48:08 -08:00
|
|
|
VkCommandBuffer commandBuffer,
|
2015-08-20 22:59:19 -07:00
|
|
|
VkBuffer _buffer,
|
|
|
|
VkDeviceSize offset,
|
|
|
|
VkIndexType indexType)
|
|
|
|
{
|
2015-11-30 11:48:08 -08:00
|
|
|
ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
|
2015-08-20 22:59:19 -07:00
|
|
|
ANV_FROM_HANDLE(anv_buffer, buffer, _buffer);
|
|
|
|
|
2017-12-15 16:38:10 -08:00
|
|
|
cmd_buffer->state.gfx.dirty |= ANV_CMD_DIRTY_INDEX_BUFFER;
|
2016-02-20 09:08:27 -08:00
|
|
|
if (GEN_IS_HASWELL)
|
2019-05-13 16:33:22 +01:00
|
|
|
cmd_buffer->state.restart_index = restart_index_for_type(indexType);
|
2017-12-15 16:55:54 -08:00
|
|
|
cmd_buffer->state.gfx.gen7.index_buffer = buffer;
|
2019-05-13 16:33:22 +01:00
|
|
|
cmd_buffer->state.gfx.gen7.index_type = vk_to_gen_index_type(indexType);
|
2017-12-15 16:55:54 -08:00
|
|
|
cmd_buffer->state.gfx.gen7.index_offset = offset;
|
2015-08-20 22:59:19 -07:00
|
|
|
}
|
|
|
|
|
2016-10-19 16:37:03 -07:00
|
|
|
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;
|
|
|
|
|
2018-06-26 09:22:20 -07:00
|
|
|
if (!subpass->depth_stencil_attachment)
|
2016-10-19 16:37:03 -07:00
|
|
|
return D16_UNORM;
|
|
|
|
|
|
|
|
struct anv_render_pass_attachment *att =
|
2018-06-26 09:22:20 -07:00
|
|
|
&pass->attachments[subpass->depth_stencil_attachment->attachment];
|
2016-10-19 16:37:03 -07:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-08 16:54:07 -08:00
|
|
|
void
|
|
|
|
genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
|
|
|
|
{
|
2020-03-03 15:31:50 -08:00
|
|
|
struct anv_graphics_pipeline *pipeline = cmd_buffer->state.gfx.pipeline;
|
2017-12-15 16:48:53 -08:00
|
|
|
struct anv_dynamic_state *d = &cmd_buffer->state.gfx.dynamic;
|
2016-03-08 16:54:07 -08:00
|
|
|
|
2020-05-29 10:20:18 +03:00
|
|
|
static const uint32_t vk_to_gen_cullmode[] = {
|
|
|
|
[VK_CULL_MODE_NONE] = CULLMODE_NONE,
|
|
|
|
[VK_CULL_MODE_FRONT_BIT] = CULLMODE_FRONT,
|
|
|
|
[VK_CULL_MODE_BACK_BIT] = CULLMODE_BACK,
|
|
|
|
[VK_CULL_MODE_FRONT_AND_BACK] = CULLMODE_BOTH
|
|
|
|
};
|
|
|
|
static const uint32_t vk_to_gen_front_face[] = {
|
|
|
|
[VK_FRONT_FACE_COUNTER_CLOCKWISE] = 1,
|
|
|
|
[VK_FRONT_FACE_CLOCKWISE] = 0
|
|
|
|
};
|
|
|
|
|
2017-12-15 16:38:10 -08:00
|
|
|
if (cmd_buffer->state.gfx.dirty & (ANV_CMD_DIRTY_PIPELINE |
|
|
|
|
ANV_CMD_DIRTY_RENDER_TARGETS |
|
|
|
|
ANV_CMD_DIRTY_DYNAMIC_LINE_WIDTH |
|
2020-05-29 10:20:18 +03:00
|
|
|
ANV_CMD_DIRTY_DYNAMIC_DEPTH_BIAS |
|
|
|
|
ANV_CMD_DIRTY_DYNAMIC_CULL_MODE |
|
|
|
|
ANV_CMD_DIRTY_DYNAMIC_FRONT_FACE)) {
|
2016-02-20 09:08:27 -08:00
|
|
|
uint32_t sf_dw[GENX(3DSTATE_SF_length)];
|
|
|
|
struct GENX(3DSTATE_SF) sf = {
|
|
|
|
GENX(3DSTATE_SF_header),
|
2016-10-19 16:37:03 -07:00
|
|
|
.DepthBufferSurfaceFormat = get_depth_format(cmd_buffer),
|
2017-12-15 16:47:56 -08:00
|
|
|
.LineWidth = d->line_width,
|
|
|
|
.GlobalDepthOffsetConstant = d->depth_bias.bias,
|
|
|
|
.GlobalDepthOffsetScale = d->depth_bias.slope,
|
2020-05-29 10:20:18 +03:00
|
|
|
.GlobalDepthOffsetClamp = d->depth_bias.clamp,
|
|
|
|
.FrontWinding = vk_to_gen_front_face[d->front_face],
|
|
|
|
.CullMode = vk_to_gen_cullmode[d->cull_mode],
|
2015-10-06 17:21:44 -07:00
|
|
|
};
|
2016-02-20 09:08:27 -08:00
|
|
|
GENX(3DSTATE_SF_pack)(NULL, sf_dw, &sf);
|
2015-10-06 17:21:44 -07:00
|
|
|
|
|
|
|
anv_batch_emit_merge(&cmd_buffer->batch, sf_dw, pipeline->gen7.sf);
|
2015-08-20 22:59:19 -07:00
|
|
|
}
|
|
|
|
|
2017-12-15 16:38:10 -08:00
|
|
|
if (cmd_buffer->state.gfx.dirty & (ANV_CMD_DIRTY_DYNAMIC_BLEND_CONSTANTS |
|
|
|
|
ANV_CMD_DIRTY_DYNAMIC_STENCIL_REFERENCE)) {
|
2015-10-06 17:21:44 -07:00
|
|
|
struct anv_state cc_state =
|
|
|
|
anv_cmd_buffer_alloc_dynamic_state(cmd_buffer,
|
2016-02-20 09:08:27 -08:00
|
|
|
GENX(COLOR_CALC_STATE_length) * 4,
|
2015-12-30 10:37:50 -08:00
|
|
|
64);
|
2016-02-20 09:08:27 -08:00
|
|
|
struct GENX(COLOR_CALC_STATE) cc = {
|
2017-12-15 16:47:56 -08:00
|
|
|
.BlendConstantColorRed = d->blend_constants[0],
|
|
|
|
.BlendConstantColorGreen = d->blend_constants[1],
|
|
|
|
.BlendConstantColorBlue = d->blend_constants[2],
|
|
|
|
.BlendConstantColorAlpha = d->blend_constants[3],
|
2016-03-04 12:22:32 -08:00
|
|
|
.StencilReferenceValue = d->stencil_reference.front & 0xff,
|
2016-05-31 22:15:38 -07:00
|
|
|
.BackfaceStencilReferenceValue = d->stencil_reference.back & 0xff,
|
2015-10-06 17:21:44 -07:00
|
|
|
};
|
2016-02-20 09:08:27 -08:00
|
|
|
GENX(COLOR_CALC_STATE_pack)(NULL, cc_state.map, &cc);
|
2015-08-20 22:59:19 -07:00
|
|
|
|
2016-04-18 17:03:00 -07:00
|
|
|
anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_CC_STATE_POINTERS), ccp) {
|
2016-04-18 16:33:46 -07:00
|
|
|
ccp.ColorCalcStatePointer = cc_state.offset;
|
|
|
|
}
|
2015-08-20 22:59:19 -07:00
|
|
|
}
|
|
|
|
|
2019-05-22 22:44:59 -05:00
|
|
|
if (cmd_buffer->state.gfx.dirty & ANV_CMD_DIRTY_DYNAMIC_LINE_STIPPLE) {
|
|
|
|
anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_LINE_STIPPLE), ls) {
|
|
|
|
ls.LineStipplePattern = d->line_stipple.pattern;
|
|
|
|
ls.LineStippleInverseRepeatCount =
|
|
|
|
1.0f / MAX2(1, d->line_stipple.factor);
|
|
|
|
ls.LineStippleRepeatCount = d->line_stipple.factor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-15 16:38:10 -08:00
|
|
|
if (cmd_buffer->state.gfx.dirty & (ANV_CMD_DIRTY_PIPELINE |
|
|
|
|
ANV_CMD_DIRTY_RENDER_TARGETS |
|
|
|
|
ANV_CMD_DIRTY_DYNAMIC_STENCIL_COMPARE_MASK |
|
|
|
|
ANV_CMD_DIRTY_DYNAMIC_STENCIL_WRITE_MASK)) {
|
2016-02-20 09:08:27 -08:00
|
|
|
uint32_t depth_stencil_dw[GENX(DEPTH_STENCIL_STATE_length)];
|
2015-10-06 17:21:44 -07:00
|
|
|
|
2016-02-20 09:08:27 -08:00
|
|
|
struct GENX(DEPTH_STENCIL_STATE) depth_stencil = {
|
2016-03-01 11:02:12 -08:00
|
|
|
.StencilTestMask = d->stencil_compare_mask.front & 0xff,
|
|
|
|
.StencilWriteMask = d->stencil_write_mask.front & 0xff,
|
2015-10-06 17:21:44 -07:00
|
|
|
|
2016-03-01 11:02:12 -08:00
|
|
|
.BackfaceStencilTestMask = d->stencil_compare_mask.back & 0xff,
|
|
|
|
.BackfaceStencilWriteMask = d->stencil_write_mask.back & 0xff,
|
2016-12-07 20:31:12 -08:00
|
|
|
|
|
|
|
.StencilBufferWriteEnable =
|
|
|
|
(d->stencil_write_mask.front || d->stencil_write_mask.back) &&
|
|
|
|
pipeline->writes_stencil,
|
2015-10-06 17:21:44 -07:00
|
|
|
};
|
2016-02-20 09:08:27 -08:00
|
|
|
GENX(DEPTH_STENCIL_STATE_pack)(NULL, depth_stencil_dw, &depth_stencil);
|
2015-10-06 17:21:44 -07:00
|
|
|
|
|
|
|
struct anv_state ds_state =
|
|
|
|
anv_cmd_buffer_merge_dynamic(cmd_buffer, depth_stencil_dw,
|
|
|
|
pipeline->gen7.depth_stencil_state,
|
2016-02-20 09:08:27 -08:00
|
|
|
GENX(DEPTH_STENCIL_STATE_length), 64);
|
2015-08-20 22:59:19 -07:00
|
|
|
|
2016-04-18 17:03:00 -07:00
|
|
|
anv_batch_emit(&cmd_buffer->batch,
|
|
|
|
GENX(3DSTATE_DEPTH_STENCIL_STATE_POINTERS), dsp) {
|
2016-04-18 16:33:46 -07:00
|
|
|
dsp.PointertoDEPTH_STENCIL_STATE = ds_state.offset;
|
|
|
|
}
|
2015-08-20 22:59:19 -07:00
|
|
|
}
|
|
|
|
|
2017-12-15 16:55:54 -08:00
|
|
|
if (cmd_buffer->state.gfx.gen7.index_buffer &&
|
2017-12-15 16:38:10 -08:00
|
|
|
cmd_buffer->state.gfx.dirty & (ANV_CMD_DIRTY_PIPELINE |
|
|
|
|
ANV_CMD_DIRTY_INDEX_BUFFER)) {
|
2017-12-15 16:55:54 -08:00
|
|
|
struct anv_buffer *buffer = cmd_buffer->state.gfx.gen7.index_buffer;
|
|
|
|
uint32_t offset = cmd_buffer->state.gfx.gen7.index_offset;
|
2015-08-20 22:59:19 -07:00
|
|
|
|
2016-02-20 09:08:27 -08:00
|
|
|
#if GEN_IS_HASWELL
|
2016-04-18 17:03:00 -07:00
|
|
|
anv_batch_emit(&cmd_buffer->batch, GEN75_3DSTATE_VF, vf) {
|
2016-04-18 16:33:46 -07:00
|
|
|
vf.IndexedDrawCutIndexEnable = pipeline->primitive_restart;
|
|
|
|
vf.CutIndex = cmd_buffer->state.restart_index;
|
|
|
|
}
|
2016-02-20 09:08:27 -08:00
|
|
|
#endif
|
2015-11-17 07:07:02 -08:00
|
|
|
|
2016-04-18 17:03:00 -07:00
|
|
|
anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_INDEX_BUFFER), ib) {
|
2016-02-20 09:08:27 -08:00
|
|
|
#if !GEN_IS_HASWELL
|
2016-04-18 16:33:46 -07:00
|
|
|
ib.CutIndexEnable = pipeline->primitive_restart;
|
2016-02-20 09:08:27 -08:00
|
|
|
#endif
|
2017-12-15 16:55:54 -08:00
|
|
|
ib.IndexFormat = cmd_buffer->state.gfx.gen7.index_type;
|
genxml: Consistently use a numeric "MOCS" field
When we first started using genxml, we decided to represent MOCS as an
actual structure, and pack values. However, in many places, it was more
convenient to use a numeric value rather than treating it as a struct,
so we added secondary setters in a bunch of places as well.
We were not entirely consistent, either. Some places only had one.
Gen6 had both kinds of setters for STATE_BASE_ADDRESS, but newer gens
only had the struct-based setters. The names were sometimes "Constant
Buffer Object Control State" instead of "Memory", making it harder to
find. Many had prefixes like "Vertex Buffer MOCS"...in a vertex buffer
packet...which is a bit redundant.
On modern hardware, MOCS is simply an index into a table, but we were
still carrying around the structure with an "Index to MOCS Table" field,
in addition to the direct numeric setters. This is clunky - we really
just want a number on new hardware.
This patch eliminates the struct-based setters, and makes the numeric
setters be consistently called "MOCS". We leave the struct definition
around on Gen7-8 for reference purposes, but it is unused.
v2: Drop bonus "Depth Buffer MOCS" fields on Gen7.5 and Gen9
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
2018-12-11 00:34:11 -08:00
|
|
|
ib.MOCS = anv_mocs_for_bo(cmd_buffer->device,
|
2018-07-09 14:21:33 -07:00
|
|
|
buffer->address.bo);
|
2016-04-18 16:33:46 -07:00
|
|
|
|
2018-05-30 18:05:54 -07:00
|
|
|
ib.BufferStartingAddress = anv_address_add(buffer->address,
|
|
|
|
offset);
|
|
|
|
ib.BufferEndingAddress = anv_address_add(buffer->address,
|
|
|
|
buffer->size);
|
2016-04-18 16:33:46 -07:00
|
|
|
}
|
2015-08-20 22:59:19 -07:00
|
|
|
}
|
|
|
|
|
2020-06-16 08:37:26 +03:00
|
|
|
static const uint32_t vk_to_gen_primitive_type[] = {
|
|
|
|
[VK_PRIMITIVE_TOPOLOGY_POINT_LIST] = _3DPRIM_POINTLIST,
|
|
|
|
[VK_PRIMITIVE_TOPOLOGY_LINE_LIST] = _3DPRIM_LINELIST,
|
|
|
|
[VK_PRIMITIVE_TOPOLOGY_LINE_STRIP] = _3DPRIM_LINESTRIP,
|
|
|
|
[VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST] = _3DPRIM_TRILIST,
|
|
|
|
[VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP] = _3DPRIM_TRISTRIP,
|
|
|
|
[VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN] = _3DPRIM_TRIFAN,
|
|
|
|
[VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY] = _3DPRIM_LINELIST_ADJ,
|
|
|
|
[VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY] = _3DPRIM_LINESTRIP_ADJ,
|
|
|
|
[VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY] = _3DPRIM_TRILIST_ADJ,
|
|
|
|
[VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY] = _3DPRIM_TRISTRIP_ADJ,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (cmd_buffer->state.gfx.dirty & (ANV_CMD_DIRTY_PIPELINE |
|
|
|
|
ANV_CMD_DIRTY_DYNAMIC_PRIMITIVE_TOPOLOGY)) {
|
|
|
|
uint32_t topology;
|
|
|
|
if (anv_pipeline_has_stage(pipeline, MESA_SHADER_TESS_EVAL))
|
|
|
|
topology = d->primitive_topology;
|
|
|
|
else
|
|
|
|
topology = vk_to_gen_primitive_type[d->primitive_topology];
|
|
|
|
|
|
|
|
cmd_buffer->state.gfx.primitive_topology = topology;
|
|
|
|
}
|
|
|
|
|
2017-12-15 16:38:10 -08:00
|
|
|
cmd_buffer->state.gfx.dirty = 0;
|
2015-08-20 22:59:19 -07:00
|
|
|
}
|
|
|
|
|
2016-12-06 17:52:14 -08:00
|
|
|
void
|
|
|
|
genX(cmd_buffer_enable_pma_fix)(struct anv_cmd_buffer *cmd_buffer,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
/* The NP PMA fix doesn't exist on gen7 */
|
|
|
|
}
|