<p dir="ltr">It's driver-internal and perfectly legal. It will also not work this way for depth/stencil textures...</p>
<p dir="ltr">NAK</p>
<div class="gmail_quote">On Mar 26, 2016 10:59 PM, "Edward O'Callaghan" <<a href="mailto:eocallaghan@alterapraxis.com">eocallaghan@alterapraxis.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This was the wrong way to force a resource format, fix it in nv50.<br>
<br>
NOTE: Needs testing from someone with nv hw.<br>
<br>
Signed-off-by: Edward O'Callaghan <<a href="mailto:eocallaghan@alterapraxis.com">eocallaghan@alterapraxis.com</a>><br>
---<br>
src/gallium/drivers/nouveau/nv50/nv50_surface.c | 67 ++++++++++++-------------<br>
1 file changed, 33 insertions(+), 34 deletions(-)<br>
<br>
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_surface.c b/src/gallium/drivers/nouveau/nv50/nv50_surface.c<br>
index 68b0e18..c3e97cc 100644<br>
--- a/src/gallium/drivers/nouveau/nv50/nv50_surface.c<br>
+++ b/src/gallium/drivers/nouveau/nv50/nv50_surface.c<br>
@@ -447,11 +447,43 @@ nv50_clear_texture(struct pipe_context *pipe,<br>
const void *data)<br>
{<br>
struct pipe_surface tmpl = {{0}}, *sf;<br>
+ union pipe_color_union color;<br>
+<br>
+ switch (util_format_get_blocksizebits(res->format)) {<br>
+ case 128:<br>
+ tmpl.format = PIPE_FORMAT_R32G32B32A32_UINT;<br>
+ memcpy(&color.ui, data, 128 / 8);<br>
+ break;<br>
+ case 64:<br>
+ tmpl.format = PIPE_FORMAT_R32G32_UINT;<br>
+ memcpy(&color.ui, data, 64 / 8);<br>
+ memset(&color.ui[2], 0, 64 / 8);<br>
+ break;<br>
+ case 32:<br>
+ tmpl.format = PIPE_FORMAT_R32_UINT;<br>
+ memcpy(&color.ui, data, 32 / 8);<br>
+ memset(&color.ui[1], 0, 96 / 8);<br>
+ break;<br>
+ case 16:<br>
+ tmpl.format = PIPE_FORMAT_R16_UINT;<br>
+ color.ui[0] = util_cpu_to_le32(<br>
+ util_le16_to_cpu(*(unsigned short *)data));<br>
+ memset(&color.ui[1], 0, 96 / 8);<br>
+ break;<br>
+ case 8:<br>
+ tmpl.format = PIPE_FORMAT_R8_UINT;<br>
+ color.ui[0] = util_cpu_to_le32(*(unsigned char *)data);<br>
+ memset(&color.ui[1], 0, 96 / 8);<br>
+ break;<br>
+ default:<br>
+ assert(!"Unknown texel element size");<br>
+ return;<br>
+ }<br>
<br>
- tmpl.format = res->format;<br>
tmpl.u.tex.first_layer = box->z;<br>
tmpl.u.tex.last_layer = box->z + box->depth - 1;<br>
tmpl.u.tex.level = level;<br>
+<br>
sf = pipe->create_surface(pipe, res, &tmpl);<br>
if (!sf)<br>
return;<br>
@@ -474,39 +506,6 @@ nv50_clear_texture(struct pipe_context *pipe,<br>
pipe->clear_depth_stencil(pipe, sf, clear, depth, stencil,<br>
box->x, box->y, box->width, box->height);<br>
} else {<br>
- union pipe_color_union color;<br>
-<br>
- switch (util_format_get_blocksizebits(res->format)) {<br>
- case 128:<br>
- sf->format = PIPE_FORMAT_R32G32B32A32_UINT;<br>
- memcpy(&color.ui, data, 128 / 8);<br>
- break;<br>
- case 64:<br>
- sf->format = PIPE_FORMAT_R32G32_UINT;<br>
- memcpy(&color.ui, data, 64 / 8);<br>
- memset(&color.ui[2], 0, 64 / 8);<br>
- break;<br>
- case 32:<br>
- sf->format = PIPE_FORMAT_R32_UINT;<br>
- memcpy(&color.ui, data, 32 / 8);<br>
- memset(&color.ui[1], 0, 96 / 8);<br>
- break;<br>
- case 16:<br>
- sf->format = PIPE_FORMAT_R16_UINT;<br>
- color.ui[0] = util_cpu_to_le32(<br>
- util_le16_to_cpu(*(unsigned short *)data));<br>
- memset(&color.ui[1], 0, 96 / 8);<br>
- break;<br>
- case 8:<br>
- sf->format = PIPE_FORMAT_R8_UINT;<br>
- color.ui[0] = util_cpu_to_le32(*(unsigned char *)data);<br>
- memset(&color.ui[1], 0, 96 / 8);<br>
- break;<br>
- default:<br>
- assert(!"Unknown texel element size");<br>
- return;<br>
- }<br>
-<br>
pipe->clear_render_target(pipe, sf, &color,<br>
box->x, box->y, box->width, box->height);<br>
}<br>
--<br>
2.5.5<br>
<br>
_______________________________________________<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/mailman/listinfo/mesa-dev</a><br>
</blockquote></div>