<p dir="ltr"><br>
On Dec 21, 2015 8:57 PM, "Marek Olšák" <<a href="mailto:maraeo@gmail.com">maraeo@gmail.com</a>> wrote:<br>
><br>
> On Tue, Dec 22, 2015 at 12:10 AM, Roland Scheidegger <<a href="mailto:sroland@vmware.com">sroland@vmware.com</a>> wrote:<br>
> > Am 21.12.2015 um 20:59 schrieb Jose Fonseca:<br>
> >> On 16/12/15 16:18, Roland Scheidegger wrote:<br>
> >>> Am 16.12.2015 um 12:52 schrieb Marek Olšák:<br>
> >>>> This is not well defined in gallium, but r600g and radeonsi use these<br>
> >>>> default swizzles for depth and stencil surfaces and it's probably the<br>
> >>>> only reasonable thing to do:<br>
> >>>><br>
> >>>> Format = Default swizzle<br>
> >>>> Z24X8 = XXXX (Z)<br>
> >>>> Z24S8 = XXXX (Z)<br>
> >>>> X24S8 = YYYY (S)<br>
> >>>> X8Z24 = YYYY (Z)<br>
> >>>> S8Z24 = YYYY (Z)<br>
> >>>> S8X24 = XXXX (S)<br>
> >>>> Z32_S8X24 = XXXX (Z)<br>
> >>>> X32_S8X24 = YYYY (S)<br>
> >>><br>
> >>> I suppose you also get the right border color without any hacks?<br>
> >>> I guess in theory these formats could use replicated swizzles in the<br>
> >>> u_format description, instead of only the one-channel ones. That would<br>
> >>> give the right result without doing anything special in drivers<br>
> >>> following those bits. However, it can't be done consistently, since it<br>
> >>> obviously won't work for depthstencil formats (which are still valid in<br>
> >>> gallium for texturing, albeit it would be possible to change that and<br>
> >>> enforce D24X8 views to be used instead).<br>
> >>> And this wouldn't do anything for the fact you can't get the right bits<br>
> >>> for stencil border color automatically that way (which is more<br>
> >>> problematic since no matter the format swizzling or sampler state<br>
> >>> swizzling it will always be wrong). (FWIW d3d10 decidedly uses the "G"<br>
> >>> channel for stencil, and you'd supposedly get R = B = 0, G = S, A = 1 -<br>
> >>> albeit there's no stencil-only S8 format, and since it's not possible to<br>
> >>> use integer textures with ordinary sampling just ld, there's no sampler,<br>
> >>> no border, no problem there...)<br>
> >><br>
> >> We should do something sensible in u_format. State trackers should set<br>
> >> texture_swizzle to get behavior to match whatever the API happens to<br>
> >> prescribe.<br>
> >><br>
> > It isn't really obvious if it's possible to do something more sensible<br>
> > than what we've got now. The channel swizzle as-is make sense if you<br>
> > look at it from the depth-stencil aspect - 1st component depth, 2nd<br>
> > stencil, the rest undefined. For texturing, indeed it looks like the<br>
> > requirements are different for everybody (d3d9, d3d10, legacy gl, new<br>
> > gl), in particular for stencil (d3d10 will need stencil in green channel<br>
> > with r/b 0 and a 1, gl will need stencil in red channel and god knows<br>
> > what in the remaining channels), therefore requiring the texture_swizzle<br>
> > in state trackers to take care of it really sounds like the only<br>
> > possible solution.<br>
> > I think the only way to make it less hacky would be to require texturing<br>
> > from combined depthstencil surfaces to always use formats which have<br>
> > only either depth or stencil but not both. Since right now sampling<br>
> > depthstencil surfaces means just sampling the depth component. If we'd<br>
> > enforce that such formats have to use a d24x8 format in the view, then<br>
> > we would be able to use swizzles of xxxx (for depth) and yyyy (for<br>
> > stencil) in the u_format descriptions. Albeit we could already do that<br>
> > for s8, x24s8 etc. (everything with just stencil) for stencil. In any<br>
> > case though that would need some more changes, there's code which relies<br>
> > on those components having NONE swizzle to detect if the format contains<br>
> > depth or stencil.<br>
> > And it looks like no matter what we'd still need the state tracker to do<br>
> > border color swizzling for stencil too.<br>
><br>
> Since no GPU can fetch UNORM and UINT with the same sampler AFAIK, the<br>
> only swizzles that make sense are .xxxx and .yyyy (and combinations<br>
> with 0 and 1).</p>
<p dir="ltr">Fwiw you can set these per component on nv50+. Not sure if it'd actually work though.</p>
<p dir="ltr"> -ilia</p>