Mesa (master): st/nine: Track formats compatible with FETCH4
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Mar 2 19:23:45 UTC 2021
Module: Mesa
Branch: master
Commit: d097bdcc781169f337174a4e2d47e7b2e506d491
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d097bdcc781169f337174a4e2d47e7b2e506d491
Author: Axel Davy <davyaxel0 at gmail.com>
Date: Sat Feb 2 19:20:35 2019 +0100
st/nine: Track formats compatible with FETCH4
FETCH4 is a d3d9 extension not much used, as newer
ones were prefered. However it's support is required
to advertise the DF24 format.
Prepares support by tracking compatible formats.
Signed-off-by: Axel Davy <davyaxel0 at gmail.com>
Acked-by: Timur Kristóf <timur.kristof at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9177>
---
src/gallium/frontends/nine/basetexture9.c | 3 ++-
src/gallium/frontends/nine/basetexture9.h | 1 +
src/gallium/frontends/nine/nine_pipe.h | 22 ++++++++++++++++++++++
src/gallium/frontends/nine/nine_state.c | 24 ++++++++++++++----------
src/gallium/frontends/nine/nine_state.h | 1 +
5 files changed, 40 insertions(+), 11 deletions(-)
diff --git a/src/gallium/frontends/nine/basetexture9.c b/src/gallium/frontends/nine/basetexture9.c
index 7c29dbeff88..d0dd4a6d17b 100644
--- a/src/gallium/frontends/nine/basetexture9.c
+++ b/src/gallium/frontends/nine/basetexture9.c
@@ -27,9 +27,9 @@
#include "texture9.h"
#include "cubetexture9.h"
#include "volumetexture9.h"
+#include "nine_pipe.h"
#if defined(DEBUG) || !defined(NDEBUG)
-#include "nine_pipe.h"
#include "nine_dump.h"
#endif
@@ -85,6 +85,7 @@ NineBaseTexture9_ctor( struct NineBaseTexture9 *This,
This->shadow = (This->format != D3DFMT_INTZ && This->format != D3DFMT_DF16 &&
This->format != D3DFMT_DF24) &&
util_format_has_depth(util_format_description(This->base.info.format));
+ This->fetch4_compatible = fetch4_compatible_format(This->format);
list_inithead(&This->list);
list_inithead(&This->list2);
diff --git a/src/gallium/frontends/nine/basetexture9.h b/src/gallium/frontends/nine/basetexture9.h
index e3952cf12a2..f4902c8313b 100644
--- a/src/gallium/frontends/nine/basetexture9.h
+++ b/src/gallium/frontends/nine/basetexture9.h
@@ -42,6 +42,7 @@ struct NineBaseTexture9
int16_t bind_count; /* to Device9->state.texture */
boolean shadow;
+ boolean fetch4_compatible;
uint8_t pstype; /* 0: 2D, 1: 1D, 2: CUBE, 3: 3D */
boolean dirty_mip;
diff --git a/src/gallium/frontends/nine/nine_pipe.h b/src/gallium/frontends/nine/nine_pipe.h
index b5c4f0a3474..f0d8b454237 100644
--- a/src/gallium/frontends/nine/nine_pipe.h
+++ b/src/gallium/frontends/nine/nine_pipe.h
@@ -181,6 +181,28 @@ pipe_to_d3d9_format(enum pipe_format format)
return nine_pipe_to_d3d9_format_map[format];
}
+static inline boolean
+fetch4_compatible_format( D3DFORMAT fmt )
+{
+ /* Basically formats with only red channel are allowed (with some exceptions) */
+ static const D3DFORMAT allowed[] = { /* TODO: list incomplete */
+ D3DFMT_L8,
+ D3DFMT_L16,
+ D3DFMT_R16F,
+ D3DFMT_R32F,
+ D3DFMT_A8,
+ D3DFMT_DF16,
+ D3DFMT_DF24,
+ D3DFMT_INTZ
+ };
+ unsigned i;
+
+ for (i = 0; i < sizeof(allowed)/sizeof(D3DFORMAT); i++) {
+ if (fmt == allowed[i]) { return TRUE; }
+ }
+ return FALSE;
+}
+
/* ATI1 and ATI2 are not officially compressed in d3d9 */
static inline boolean
compressed_format( D3DFORMAT fmt )
diff --git a/src/gallium/frontends/nine/nine_state.c b/src/gallium/frontends/nine/nine_state.c
index a70269c3b32..1730eb9b23f 100644
--- a/src/gallium/frontends/nine/nine_state.c
+++ b/src/gallium/frontends/nine/nine_state.c
@@ -1360,8 +1360,7 @@ NineDevice9_ResolveZ( struct NineDevice9 *device )
static void
nine_context_set_texture_apply(struct NineDevice9 *device,
DWORD stage,
- BOOL enabled,
- BOOL shadow,
+ DWORD fetch4_shadow_enabled,
DWORD lod,
D3DRESOURCETYPE type,
uint8_t pstype,
@@ -1431,8 +1430,7 @@ CSMT_ITEM_NO_WAIT(nine_context_set_render_state,
CSMT_ITEM_NO_WAIT(nine_context_set_texture_apply,
ARG_VAL(DWORD, stage),
- ARG_VAL(BOOL, enabled),
- ARG_VAL(BOOL, shadow),
+ ARG_VAL(DWORD, fetch4_shadow_enabled),
ARG_VAL(DWORD, lod),
ARG_VAL(D3DRESOURCETYPE, type),
ARG_VAL(uint8_t, pstype),
@@ -1441,10 +1439,15 @@ CSMT_ITEM_NO_WAIT(nine_context_set_texture_apply,
ARG_BIND_VIEW(struct pipe_sampler_view, view1))
{
struct nine_context *context = &device->context;
+ uint enabled = fetch4_shadow_enabled & 1;
+ uint shadow = (fetch4_shadow_enabled >> 1) & 1;
+ uint fetch4_compatible = (fetch4_shadow_enabled >> 2) & 1;
context->texture[stage].enabled = enabled;
context->samplers_shadow &= ~(1 << stage);
context->samplers_shadow |= shadow << stage;
+ context->samplers_fetch4 &= ~(1 << stage);
+ context->samplers_fetch4 |= fetch4_compatible << stage;
context->texture[stage].shadow = shadow;
context->texture[stage].lod = lod;
context->texture[stage].type = type;
@@ -1461,8 +1464,7 @@ nine_context_set_texture(struct NineDevice9 *device,
DWORD Stage,
struct NineBaseTexture9 *tex)
{
- BOOL enabled = FALSE;
- BOOL shadow = FALSE;
+ DWORD fetch4_shadow_enabled = 0;
DWORD lod = 0;
D3DRESOURCETYPE type = D3DRTYPE_TEXTURE;
uint8_t pstype = 0;
@@ -1473,8 +1475,9 @@ nine_context_set_texture(struct NineDevice9 *device,
* In that case, the texture is rebound later
* (in NineBaseTexture9_Validate/NineBaseTexture9_UploadSelf). */
if (tex && tex->base.resource) {
- enabled = TRUE;
- shadow = tex->shadow;
+ fetch4_shadow_enabled = 1;
+ fetch4_shadow_enabled |= tex->shadow << 1;
+ fetch4_shadow_enabled |= tex->fetch4_compatible << 2;
lod = tex->managed.lod;
type = tex->base.type;
pstype = tex->pstype;
@@ -1483,8 +1486,9 @@ nine_context_set_texture(struct NineDevice9 *device,
view1 = NineBaseTexture9_GetSamplerView(tex, 1);
}
- nine_context_set_texture_apply(device, Stage, enabled,
- shadow, lod, type, pstype,
+ nine_context_set_texture_apply(device, Stage,
+ fetch4_shadow_enabled,
+ lod, type, pstype,
res, view0, view1);
}
diff --git a/src/gallium/frontends/nine/nine_state.h b/src/gallium/frontends/nine/nine_state.h
index d497a79c49d..7483db61469 100644
--- a/src/gallium/frontends/nine/nine_state.h
+++ b/src/gallium/frontends/nine/nine_state.h
@@ -297,6 +297,7 @@ struct nine_context {
DWORD samp[NINE_MAX_SAMPLERS][NINED3DSAMP_COUNT];
uint32_t samplers_shadow;
+ uint32_t samplers_fetch4;
uint8_t bound_samplers_mask_vs;
uint16_t bound_samplers_mask_ps;
More information about the mesa-commit
mailing list