aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin Strasser <[email protected]>2019-01-24 17:29:31 -0800
committerAdam Jackson <[email protected]>2019-08-21 18:36:57 +0000
commit5baff5dd3c30baae75e5b121d3091a3b80435d1b (patch)
treebb481fc8dd07048c5902e8bb10c13fc1b1d53cb0 /src
parentf4703f1c10246b4e4813635569ff00475c00f418 (diff)
gallium: Add buffer and configs handling or fp16 formats
Expose configs when allow_fp16_configs has been enabled and DRI_LOADER_CAP_FP16 is set in the loader. Also, make kms_swrast_dri respect format bpp, to allow for allocating buffers wider than 32 bpp. Make fp16 opt-in for gallium. Signed-off-by: Kevin Strasser <[email protected]> Reviewed-by: Adam Jackson <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/pipe-loader/driinfo_gallium.h1
-rw-r--r--src/gallium/state_trackers/dri/dri2.c18
-rw-r--r--src/gallium/state_trackers/dri/dri_drawable.c3
-rw-r--r--src/gallium/state_trackers/dri/dri_helpers.c6
-rw-r--r--src/gallium/state_trackers/dri/dri_screen.c23
5 files changed, 51 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
index 8ccb6a0b454..fee8fca6420 100644
--- a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
+++ b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
@@ -38,4 +38,5 @@ DRI_CONF_SECTION_MISCELLANEOUS
DRI_CONF_ALWAYS_HAVE_DEPTH_BUFFER("false")
DRI_CONF_GLSL_ZERO_INIT("false")
DRI_CONF_ALLOW_RGB10_CONFIGS("true")
+ DRI_CONF_ALLOW_FP16_CONFIGS("false")
DRI_CONF_SECTION_END
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 2b43de9df5d..11ce1978724 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -153,6 +153,12 @@ dri2_drawable_get_buffers(struct dri_drawable *drawable,
* may occur as the stvis->color_format.
*/
switch(format) {
+ case PIPE_FORMAT_R16G16B16A16_FLOAT:
+ depth = 64;
+ break;
+ case PIPE_FORMAT_R16G16B16X16_FLOAT:
+ depth = 48;
+ break;
case PIPE_FORMAT_B10G10R10A2_UNORM:
case PIPE_FORMAT_R10G10B10A2_UNORM:
case PIPE_FORMAT_BGRA8888_UNORM:
@@ -231,6 +237,12 @@ dri_image_drawable_get_buffers(struct dri_drawable *drawable,
}
switch (pf) {
+ case PIPE_FORMAT_R16G16B16A16_FLOAT:
+ image_format = __DRI_IMAGE_FORMAT_ABGR16161616F;
+ break;
+ case PIPE_FORMAT_R16G16B16X16_FLOAT:
+ image_format = __DRI_IMAGE_FORMAT_XBGR16161616F;
+ break;
case PIPE_FORMAT_B5G5R5A1_UNORM:
image_format = __DRI_IMAGE_FORMAT_ARGB1555;
break;
@@ -304,6 +316,12 @@ dri2_allocate_buffer(__DRIscreen *sPriv,
bind |= PIPE_BIND_SHARED;
switch (format) {
+ case 64:
+ pf = PIPE_FORMAT_R16G16B16A16_FLOAT;
+ break;
+ case 48:
+ pf = PIPE_FORMAT_R16G16B16X16_FLOAT;
+ break;
case 32:
pf = PIPE_FORMAT_BGRA8888_UNORM;
break;
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c
index f27396195ec..b99d1e9de51 100644
--- a/src/gallium/state_trackers/dri/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -260,6 +260,9 @@ dri_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
if (format == __DRI_TEXTURE_FORMAT_RGB) {
/* only need to cover the formats recognized by dri_fill_st_visual */
switch (internal_format) {
+ case PIPE_FORMAT_R16G16B16A16_FLOAT:
+ internal_format = PIPE_FORMAT_R16G16B16X16_FLOAT;
+ break;
case PIPE_FORMAT_B10G10R10A2_UNORM:
internal_format = PIPE_FORMAT_B10G10R10X2_UNORM;
break;
diff --git a/src/gallium/state_trackers/dri/dri_helpers.c b/src/gallium/state_trackers/dri/dri_helpers.c
index c6a898f121e..2cbae68f809 100644
--- a/src/gallium/state_trackers/dri/dri_helpers.c
+++ b/src/gallium/state_trackers/dri/dri_helpers.c
@@ -380,6 +380,12 @@ dri2_create_from_texture(__DRIcontext *context, int target, unsigned texture,
}
static const struct dri2_format_mapping dri2_format_table[] = {
+ { __DRI_IMAGE_FOURCC_ABGR16161616F, __DRI_IMAGE_FORMAT_ABGR16161616F,
+ __DRI_IMAGE_COMPONENTS_RGBA, PIPE_FORMAT_R16G16B16A16_FLOAT, 1,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_ABGR16161616F, 4 } } },
+ { __DRI_IMAGE_FOURCC_XBGR16161616F, __DRI_IMAGE_FORMAT_XBGR16161616F,
+ __DRI_IMAGE_COMPONENTS_RGB, PIPE_FORMAT_R16G16B16X16_FLOAT, 1,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_XBGR16161616F, 4 } } },
{ __DRI_IMAGE_FOURCC_ARGB2101010, __DRI_IMAGE_FORMAT_ARGB2101010,
__DRI_IMAGE_COMPONENTS_RGBA, PIPE_FORMAT_B10G10R10A2_UNORM, 1,
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_ARGB2101010, 4 } } },
diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
index 9672b500d66..9317be29b3a 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -127,6 +127,8 @@ dri_fill_in_modes(struct dri_screen *screen)
MESA_FORMAT_B8G8R8A8_SRGB,
MESA_FORMAT_B8G8R8X8_SRGB,
MESA_FORMAT_B5G6R5_UNORM,
+ MESA_FORMAT_RGBA_FLOAT16,
+ MESA_FORMAT_RGBX_FLOAT16,
/* The 32-bit RGBA format must not precede the 32-bit BGRA format.
* Likewise for RGBX and BGRX. Otherwise, the GLX client and the GLX
@@ -159,6 +161,8 @@ dri_fill_in_modes(struct dri_screen *screen)
PIPE_FORMAT_BGRA8888_SRGB,
PIPE_FORMAT_BGRX8888_SRGB,
PIPE_FORMAT_B5G6R5_UNORM,
+ PIPE_FORMAT_R16G16B16A16_FLOAT,
+ PIPE_FORMAT_R16G16B16X16_FLOAT,
PIPE_FORMAT_RGBA8888_UNORM,
PIPE_FORMAT_RGBX8888_UNORM,
};
@@ -174,6 +178,7 @@ dri_fill_in_modes(struct dri_screen *screen)
bool mixed_color_depth;
bool allow_rgba_ordering;
bool allow_rgb10;
+ bool allow_fp16;
static const GLenum back_buffer_modes[] = {
__DRI_ATTRIB_SWAP_NONE, __DRI_ATTRIB_SWAP_UNDEFINED,
@@ -192,6 +197,8 @@ dri_fill_in_modes(struct dri_screen *screen)
allow_rgba_ordering = dri_loader_get_cap(screen, DRI_LOADER_CAP_RGBA_ORDERING);
allow_rgb10 = driQueryOptionb(&screen->dev->option_cache, "allow_rgb10_configs");
+ allow_fp16 = driQueryOptionb(&screen->dev->option_cache, "allow_fp16_configs");
+ allow_fp16 &= dri_loader_get_cap(screen, DRI_LOADER_CAP_FP16);
msaa_samples_max = (screen->st_api->feature_mask & ST_API_FEATURE_MS_VISUALS_MASK)
? MSAA_VISUAL_MAX_SAMPLES : 1;
@@ -258,6 +265,11 @@ dri_fill_in_modes(struct dri_screen *screen)
mesa_formats[format] == MESA_FORMAT_R10G10B10X2_UNORM))
continue;
+ if (!allow_fp16 &&
+ (mesa_formats[format] == MESA_FORMAT_RGBA_FLOAT16 ||
+ mesa_formats[format] == MESA_FORMAT_RGBX_FLOAT16))
+ continue;
+
if (!p_screen->is_format_supported(p_screen, pipe_formats[format],
PIPE_TEXTURE_2D, 0, 0,
PIPE_BIND_RENDER_TARGET |
@@ -322,6 +334,17 @@ dri_fill_st_visual(struct st_visual *stvis,
/* Deduce the color format. */
switch (mode->redMask) {
+ case 0:
+ /* Formats > 32 bpp */
+ assert(mode->floatMode);
+ if (mode->alphaShift > -1) {
+ assert(mode->alphaShift == 48);
+ stvis->color_format = PIPE_FORMAT_R16G16B16A16_FLOAT;
+ } else {
+ stvis->color_format = PIPE_FORMAT_R16G16B16X16_FLOAT;
+ }
+ break;
+
case 0x3FF00000:
if (mode->alphaMask) {
assert(mode->alphaMask == 0xC0000000);