<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Mar 29, 2018 at 10:58 AM, Rafael Antognolli <span dir="ltr"><<a href="mailto:rafael.antognolli@intel.com" target="_blank">rafael.antognolli@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The size of the clear color struct (expected by the hardware) is 8<br>
dwords (isl_dev.ss.clear_value_state_<wbr>size here). But we still need to<br>
track the size of the clear color, used when memcopying it to/from the<br>
state buffer. For that we keep isl_dev.ss.clear_value_size.<br>
<br>
v4:<br>
- Add struct to gen11 too (Jason, Jordan)<br>
- Add field for Converted Clear Color to gen11 (Jason)<br>
- Add clear_color_state_offset to differentiate from<br>
clear_value_offset.<br>
- Fix all the places where clear_value_size was used.<br>
<br>
v5 (Jason):<br>
- Split genxml changes to another commit.<br>
- Remove unnecessary gen checks.<br>
- Bring back missing offset increment to init_fast_clear_color().<br>
<br>
[<a href="mailto:jordan.l.justen@intel.com">jordan.l.justen@intel.com</a>: isl_device_init changes]<br>
Signed-off-by: Rafael Antognolli <<a href="mailto:rafael.antognolli@intel.com">rafael.antognolli@intel.com</a>><br>
Signed-off-by: Jordan Justen <<a href="mailto:jordan.l.justen@intel.com">jordan.l.justen@intel.com</a>><br>
---<br>
src/intel/blorp/blorp_genX_<wbr>exec.h | 5 +++--<br>
src/intel/isl/isl.c | 4 ++++<br>
src/intel/isl/isl.h | 6 ++++++<br>
src/intel/vulkan/anv_image.c | 6 +++++-<br>
src/intel/vulkan/anv_private.h | 6 +++++-<br>
src/intel/vulkan/genX_cmd_<wbr>buffer.c | 23 ++++++++++++-----------<br>
6 files changed, 35 insertions(+), 15 deletions(-)<br>
<br>
diff --git a/src/intel/blorp/blorp_genX_<wbr>exec.h b/src/intel/blorp/blorp_genX_<wbr>exec.h<br>
index 992bc9959a1..f3a96fbd58c 100644<br>
--- a/src/intel/blorp/blorp_genX_<wbr>exec.h<br>
+++ b/src/intel/blorp/blorp_genX_<wbr>exec.h<br>
@@ -310,10 +310,11 @@ blorp_emit_vertex_buffers(<wbr>struct blorp_batch *batch,<br>
<br>
uint32_t num_vbs = 2;<br>
if (params->dst_clear_color_as_<wbr>input) {<br>
+ const unsigned clear_color_size =<br>
+ GEN_GEN < 10 ? batch->blorp->isl_dev->ss.<wbr>clear_value_size : 4 * 4;<br>
blorp_fill_vertex_buffer_<wbr>state(batch, vb, num_vbs++,<br>
params->dst.clear_color_addr,<br>
- batch->blorp->isl_dev->ss.<wbr>clear_value_size,<br>
- 0);<br>
+ clear_color_size, 0);<br>
}<br>
<br>
const unsigned num_dwords = 1 + num_vbs * GENX(VERTEX_BUFFER_STATE_<wbr>length);<br>
diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c<br>
index 1a32c028183..875c691b43e 100644<br>
--- a/src/intel/isl/isl.c<br>
+++ b/src/intel/isl/isl.c<br>
@@ -73,6 +73,10 @@ isl_device_init(struct isl_device *dev,<br>
dev->ss.size = RENDER_SURFACE_STATE_length(<wbr>info) * 4;<br>
dev->ss.align = isl_align(dev->ss.size, 32);<br>
<br>
+ dev->ss.clear_color_state_size = CLEAR_COLOR_length(info) * 4;<br>
+ dev->ss.clear_color_state_<wbr>offset =<br>
+ RENDER_SURFACE_STATE_<wbr>ClearValueAddress_start(info) / 32 * 4;<br>
+<br>
dev->ss.clear_value_size =<br>
isl_align(RENDER_SURFACE_<wbr>STATE_RedClearColor_bits(info) +<br>
RENDER_SURFACE_STATE_<wbr>GreenClearColor_bits(info) +<br>
diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h<br>
index 0da6abb71d4..2edf0522e32 100644<br>
--- a/src/intel/isl/isl.h<br>
+++ b/src/intel/isl/isl.h<br>
@@ -963,6 +963,12 @@ struct isl_device {<br>
uint8_t aux_addr_offset;<br>
<br>
/* Rounded up to the nearest dword to simplify GPU memcpy operations. */<br>
+<br>
+ /* size of the state buffer used to store the clear color + extra<br>
+ * additional space used by the hardware */<br>
+ uint8_t clear_color_state_size;<br>
+ uint8_t clear_color_state_offset;<br>
+ /* size of the clear color itself - used to copy it to/from a BO */<br>
uint8_t clear_value_size;<br>
uint8_t clear_value_offset;<br>
} ss;<br>
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c<br>
index b20d791751d..d9b5d266020 100644<br>
--- a/src/intel/vulkan/anv_image.c<br>
+++ b/src/intel/vulkan/anv_image.c<br>
@@ -267,8 +267,12 @@ add_aux_state_tracking_buffer(<wbr>struct anv_image *image,<br>
(image->planes[plane].offset + image->planes[plane].size));<br>
}<br>
<br>
+ const unsigned clear_color_state_size = device->info.gen >= 10 ?<br>
+ device->isl_dev.ss.clear_<wbr>color_state_size :<br>
+ device->isl_dev.ss.clear_<wbr>value_size;<br>
+<br>
/* Clear color and fast clear type */<br>
- unsigned state_size = device->isl_dev.ss.clear_<wbr>value_size + 4;<br>
+ unsigned state_size = clear_color_state_size + 4;<br>
<br>
/* We only need to track compression on CCS_E surfaces. */<br>
if (image->planes[plane].aux_<wbr>usage == ISL_AUX_USAGE_CCS_E) {<br>
diff --git a/src/intel/vulkan/anv_<wbr>private.h b/src/intel/vulkan/anv_<wbr>private.h<br>
index 3c803178c41..08e4362b028 100644<br>
--- a/src/intel/vulkan/anv_<wbr>private.h<br>
+++ b/src/intel/vulkan/anv_<wbr>private.h<br>
@@ -2606,7 +2606,11 @@ anv_image_get_fast_clear_type_<wbr>addr(const struct anv_device *device,<br>
{<br>
struct anv_address addr =<br>
anv_image_get_clear_color_<wbr>addr(device, image, aspect);<br>
- addr.offset += device->isl_dev.ss.clear_<wbr>value_size;<br>
+<br>
+ const unsigned clear_color_state_size = device->info.gen >= 10 ?<br>
+ device->isl_dev.ss.clear_<wbr>color_state_size :<br>
+ device->isl_dev.ss.clear_<wbr>value_size;<br>
+ addr.offset += clear_color_state_size;<br>
return addr;<br>
}<br>
<br>
diff --git a/src/intel/vulkan/genX_cmd_<wbr>buffer.c b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
index b5741fb8dc1..9411854b7e5 100644<br>
--- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
+++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
@@ -826,35 +826,36 @@ init_fast_clear_color(struct anv_cmd_buffer *cmd_buffer,<br>
*/<br>
struct anv_address addr =<br>
anv_image_get_clear_color_<wbr>addr(cmd_buffer->device, image, aspect);<br>
- unsigned i = 0;<br>
- for (; i < cmd_buffer->device->isl_dev.<wbr>ss.clear_value_size; i += 4) {<br>
- anv_batch_emit(&cmd_buffer-><wbr>batch, GENX(MI_STORE_DATA_IMM), sdi) {<br>
- sdi.Address = addr;<br>
<br>
- if (GEN_GEN >= 9) {<br>
+ if (GEN_GEN >= 9) {<br>
+ for (unsigned i = 0; i < 4; i++) {<br>
+ anv_batch_emit(&cmd_buffer-><wbr>batch, GENX(MI_STORE_DATA_IMM), sdi) {<br>
+ sdi.Address = addr;<br></blockquote><div><br></div><div>How about removing "addr.offset += 4" from below and just add<br><br></div><div>sdi.Address.offset += i * 4;<br><br></div><div>here?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
/* MCS buffers on SKL+ can only have 1/0 clear colors. */<br>
assert(image->samples > 1);<br>
sdi.ImmediateData = 0;<br>
- } else if (GEN_VERSIONx10 >= 75) {<br>
+ addr.offset += 4;<br>
+ }<br>
+ }<br>
+ } else {<br>
+ anv_batch_emit(&cmd_buffer-><wbr>batch, GENX(MI_STORE_DATA_IMM), sdi) {<br>
+ sdi.Address = addr;<br>
+ if (GEN_VERSIONx10 >= 75) {<br></blockquote><div><br></div><div>GEN_GEN >= 8 || GEN_IS_HASWELL<br><br></div><div>We try to avoid using the GEN_VERSIONx10 macros directly as we may want to do something else in the future besides multiplying by 10. This also better matches the kind of gen check you would see if you were using devinfo.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
/* Pre-SKL, the dword containing the clear values also contains<br>
* other fields, so we need to initialize those fields to match the<br>
* values that would be in a color attachment.<br>
*/<br>
- assert(i == 0);<br>
sdi.ImmediateData = ISL_CHANNEL_SELECT_RED << 25 |<br>
ISL_CHANNEL_SELECT_GREEN << 22 |<br>
ISL_CHANNEL_SELECT_BLUE << 19 |<br>
ISL_CHANNEL_SELECT_ALPHA << 16;<br>
- } else if (GEN_VERSIONx10 == 70) {<br>
+ } else if (GEN_VERSIONx10 == 70) {<br></blockquote><div><br></div><div>} else {<br><br></div><div>With those three changes made, 4 and 5 are<br><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
/* On IVB, the dword containing the clear values also contains<br>
* other fields that must be zero or can be zero.<br>
*/<br>
- assert(i == 0);<br>
sdi.ImmediateData = 0;<br>
}<br>
}<br>
-<br>
- addr.offset += 4;<br>
}<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.14.3<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>