Commit 5baff5dd authored by Kevin Strasser's avatar Kevin Strasser Committed by Adam Jackson
Browse files

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's avatarKevin Strasser <kevin.strasser@intel.com>
Reviewed-by: Adam Jackson's avatarAdam Jackson <ajax@redhat.com>
Reviewed-by: default avatarMarek Olšák <marek.olsak@amd.com>
Reviewed-by: Emil Velikov's avatarEmil Velikov <emil.l.velikov@gmail.com>
parent f4703f1c
Pipeline #57902 passed with stages
in 24 minutes and 5 seconds
......@@ -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
......@@ -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;
......
......@@ -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;
......
......@@ -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 } } },
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment