nvc0: replace use of explicit default_tsc with entry 0

This was used for implementing FBFETCH. However that uses TXF, which
doesn't do much with a TSC. The only important bit is that sRGB-decoding
works as expected, which we can achieve since all samplers we ever
generate enable sRGB-decoding. Always point to entry 0 in the TSC table,
and ensure that even before it ever gets initialized, the sRGB-decoding
enable bit is set.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
This commit is contained in:
Ilia Mirkin 2018-12-02 12:27:23 -05:00
parent 5f9085638a
commit 4aeaf89aa7
6 changed files with 25 additions and 22 deletions

View file

@ -478,6 +478,16 @@ nvc0_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
util_dynarray_init(&nvc0->global_residents, NULL);
// Make sure that the first TSC entry has SRGB conversion bit set, since we
// use it as a fallback on Fermi for TXF, and on Kepler+ generations for
// FBFETCH handling (which also uses TXF).
//
// NOTE: Preliminary testing suggests that this isn't necessary at all at
// least on GM20x (untested on Kepler). However this is ~free, so no reason
// not to do it.
if (!screen->tsc.entries[0])
nvc0_upload_tsc0(nvc0);
return pipe;
out_err:

View file

@ -365,6 +365,7 @@ bool nve4_validate_tsc(struct nvc0_context *nvc0, int s);
void nvc0_validate_suf(struct nvc0_context *nvc0, int s);
void nvc0_validate_textures(struct nvc0_context *);
void nvc0_validate_samplers(struct nvc0_context *);
void nvc0_upload_tsc0(struct nvc0_context *);
void nve4_set_tex_handles(struct nvc0_context *);
void nvc0_validate_surfaces(struct nvc0_context *);
void nve4_set_surface_info(struct nouveau_pushbuf *,

View file

@ -628,7 +628,6 @@ nvc0_screen_destroy(struct pipe_screen *pscreen)
nouveau_heap_destroy(&screen->lib_code);
nouveau_heap_destroy(&screen->text_heap);
FREE(screen->default_tsc);
FREE(screen->tic.entries);
nouveau_object_del(&screen->eng3d);
@ -1387,9 +1386,6 @@ nvc0_screen_create(struct nouveau_device *dev)
if (!nvc0_blitter_create(screen))
goto fail;
screen->default_tsc = CALLOC_STRUCT(nv50_tsc_entry);
screen->default_tsc->tsc[0] = G80_TSC_0_SRGB_CONVERSION;
nouveau_fence_new(&screen->base, &screen->base.fence.current);
return &screen->base;

View file

@ -89,8 +89,6 @@ struct nvc0_screen {
struct nvc0_blitter *blitter;
struct nv50_tsc_entry *default_tsc;
struct {
void **entries;
int next;

View file

@ -1,4 +1,4 @@
#include "util/u_format.h"
#include "util/u_framebuffer.h"
#include "util/u_math.h"
#include "util/u_viewport.h"
@ -831,20 +831,6 @@ nvc0_validate_fbread(struct nvc0_context *nvc0)
pipe_sampler_view_reference(&nvc0->fbtexture, NULL);
nvc0->fbtexture = new_view;
if (screen->default_tsc->id < 0) {
struct nv50_tsc_entry *tsc = nv50_tsc_entry(screen->default_tsc);
tsc->id = nvc0_screen_tsc_alloc(screen, tsc);
nvc0->base.push_data(&nvc0->base, screen->txc, 65536 + tsc->id * 32,
NV_VRAM_DOMAIN(&screen->base), 32, tsc->tsc);
screen->tsc.lock[tsc->id / 32] |= 1 << (tsc->id % 32);
IMMED_NVC0(push, NVC0_3D(TSC_FLUSH), 0);
if (screen->base.class_3d < NVE4_3D_CLASS) {
BEGIN_NVC0(push, NVC0_3D(BIND_TSC2(0)), 1);
PUSH_DATA (push, (tsc->id << 12) | 1);
}
}
if (new_view) {
struct nv50_tic_entry *tic = nv50_tic_entry(new_view);
assert(tic->id < 0);
@ -860,7 +846,7 @@ nvc0_validate_fbread(struct nvc0_context *nvc0)
PUSH_DATA (push, screen->uniform_bo->offset + NVC0_CB_AUX_INFO(4));
BEGIN_1IC0(push, NVC0_3D(CB_POS), 1 + 1);
PUSH_DATA (push, NVC0_CB_AUX_FB_TEX_INFO);
PUSH_DATA (push, (screen->default_tsc->id << 20) | tic->id);
PUSH_DATA (push, (0 << 20) | tic->id);
} else {
BEGIN_NVC0(push, NVC0_3D(BIND_TIC2(0)), 1);
PUSH_DATA (push, (tic->id << 9) | 1);

View file

@ -728,6 +728,18 @@ void nvc0_validate_samplers(struct nvc0_context *nvc0)
nvc0->dirty_cp |= NVC0_NEW_CP_SAMPLERS;
}
void
nvc0_upload_tsc0(struct nvc0_context *nvc0)
{
struct nouveau_pushbuf *push = nvc0->base.pushbuf;
u32 data[8] = { G80_TSC_0_SRGB_CONVERSION };
nvc0->base.push_data(&nvc0->base, nvc0->screen->txc,
65536 /*+ tsc->id * 32*/,
NV_VRAM_DOMAIN(&nvc0->screen->base), 32, data);
BEGIN_NVC0(push, NVC0_3D(TSC_FLUSH), 1);
PUSH_DATA (push, 0);
}
/* Upload the "diagonal" entries for the possible texture sources ($t == $s).
* At some point we might want to get a list of the combinations used by a
* shader and fill in those entries instead of having it extract the handles.