util: Revert unsolicited, untested, unreviewed, and broken changes to format support.
Not all is bad, but I'm afraid I'll have to throw the baby with the water given they are all tied to together.
This commit is contained in:
@@ -30,8 +30,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
|
||||||
|
#include "util/u_half.h"
|
||||||
#include "util/u_format.h"
|
#include "util/u_format.h"
|
||||||
#include "util/u_format_tests.h"
|
#include "util/u_format_tests.h"
|
||||||
|
#include "util/u_format_s3tc.h"
|
||||||
|
|
||||||
|
|
||||||
static boolean
|
static boolean
|
||||||
@@ -352,8 +354,10 @@ test_one(test_func_t func, const char *suffix)
|
|||||||
|
|
||||||
format_desc = util_format_description(test->format);
|
format_desc = util_format_description(test->format);
|
||||||
|
|
||||||
if (!util_format_is_supported(test->format))
|
if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC &&
|
||||||
|
!util_format_s3tc_enabled) {
|
||||||
skip = TRUE;
|
skip = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (test->format != last_format) {
|
if (test->format != last_format) {
|
||||||
printf("%s util_format_%s_%s ...\n",
|
printf("%s util_format_%s_%s ...\n",
|
||||||
@@ -400,6 +404,8 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
boolean success;
|
boolean success;
|
||||||
|
|
||||||
|
util_format_s3tc_init();
|
||||||
|
|
||||||
success = test_all();
|
success = test_all();
|
||||||
|
|
||||||
return success ? 0 : 1;
|
return success ? 0 : 1;
|
||||||
|
@@ -33,8 +33,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "u_format.h"
|
#include "u_format.h"
|
||||||
#include "u_format_s3tc.h"
|
|
||||||
#include "u_half.h"
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -117,3 +115,4 @@ util_format_write_4ub(enum pipe_format format, const uint8_t *src, unsigned src_
|
|||||||
|
|
||||||
format_desc->pack_8unorm(dst_row, dst_stride, src_row, src_stride, w, h);
|
format_desc->pack_8unorm(dst_row, dst_stride, src_row, src_stride, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,7 +32,6 @@
|
|||||||
|
|
||||||
#include "pipe/p_format.h"
|
#include "pipe/p_format.h"
|
||||||
#include "util/u_debug.h"
|
#include "util/u_debug.h"
|
||||||
#include "util/u_format_s3tc.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -168,13 +167,6 @@ struct util_format_description
|
|||||||
*/
|
*/
|
||||||
unsigned is_mixed:1;
|
unsigned is_mixed:1;
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether the pack/unpack functions actually work.
|
|
||||||
*
|
|
||||||
* Call util_format_is_supported instead of using this directly.
|
|
||||||
*/
|
|
||||||
unsigned is_supported:1;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Input channel description.
|
* Input channel description.
|
||||||
*
|
*
|
||||||
@@ -514,20 +506,6 @@ util_format_get_nr_components(enum pipe_format format)
|
|||||||
* Format access functions.
|
* Format access functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static INLINE boolean
|
|
||||||
util_format_is_supported(enum pipe_format format)
|
|
||||||
{
|
|
||||||
const struct util_format_description *desc = util_format_description(format);
|
|
||||||
|
|
||||||
if(!desc)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if(desc->layout == UTIL_FORMAT_LAYOUT_S3TC)
|
|
||||||
util_format_s3tc_init();
|
|
||||||
|
|
||||||
return desc->is_supported;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
util_format_read_4f(enum pipe_format format,
|
util_format_read_4f(enum pipe_format format,
|
||||||
float *dst, unsigned dst_stride,
|
float *dst, unsigned dst_stride,
|
||||||
|
@@ -34,129 +34,59 @@
|
|||||||
#define DXTN_LIBNAME "libtxc_dxtn.so"
|
#define DXTN_LIBNAME "libtxc_dxtn.so"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
|
||||||
util_format_dxt1_rgb_fetch_stub( int src_stride,
|
|
||||||
const uint8_t *src,
|
|
||||||
int col, int row,
|
|
||||||
uint8_t *dst )
|
|
||||||
{
|
|
||||||
util_format_s3tc_init();
|
|
||||||
util_format_dxt1_rgb_fetch(src_stride, src, col, row, dst);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
boolean util_format_s3tc_enabled = FALSE;
|
||||||
util_format_dxt1_rgba_fetch_stub( int src_stride,
|
|
||||||
const uint8_t *src,
|
|
||||||
int col, int row,
|
|
||||||
uint8_t *dst )
|
|
||||||
{
|
|
||||||
util_format_s3tc_init();
|
|
||||||
util_format_dxt1_rgba_fetch(src_stride, src, col, row, dst);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
util_format_dxtn_fetch_t util_format_dxt1_rgb_fetch = NULL;
|
||||||
util_format_dxt3_rgba_fetch_stub( int src_stride,
|
util_format_dxtn_fetch_t util_format_dxt1_rgba_fetch = NULL;
|
||||||
const uint8_t *src,
|
util_format_dxtn_fetch_t util_format_dxt3_rgba_fetch = NULL;
|
||||||
int col, int row,
|
util_format_dxtn_fetch_t util_format_dxt5_rgba_fetch = NULL;
|
||||||
uint8_t *dst )
|
|
||||||
{
|
|
||||||
util_format_s3tc_init();
|
|
||||||
util_format_dxt3_rgba_fetch(src_stride, src, col, row, dst);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
util_format_dxtn_pack_t util_format_dxtn_pack = NULL;
|
||||||
util_format_dxt5_rgba_fetch_stub( int src_stride,
|
|
||||||
const uint8_t *src,
|
|
||||||
int col, int row,
|
|
||||||
uint8_t *dst )
|
|
||||||
{
|
|
||||||
util_format_s3tc_init();
|
|
||||||
util_format_dxt5_rgba_fetch(src_stride, src, col, row, dst);
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
void util_format_dxtn_pack_stub( int src_comps,
|
|
||||||
int width, int height,
|
|
||||||
const uint8_t *src,
|
|
||||||
enum util_format_dxtn dst_format,
|
|
||||||
uint8_t *dst,
|
|
||||||
int dst_stride)
|
|
||||||
{
|
|
||||||
util_format_s3tc_init();
|
|
||||||
util_format_dxtn_pack_stub(src_comps, width, height, src, dst_format, dst, dst_stride);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean util_format_s3tc_inited = FALSE;
|
|
||||||
|
|
||||||
util_format_dxtn_fetch_t util_format_dxt1_rgb_fetch = util_format_dxt1_rgb_fetch_stub;
|
|
||||||
util_format_dxtn_fetch_t util_format_dxt1_rgba_fetch = util_format_dxt1_rgba_fetch_stub;
|
|
||||||
util_format_dxtn_fetch_t util_format_dxt3_rgba_fetch = util_format_dxt3_rgba_fetch_stub;
|
|
||||||
util_format_dxtn_fetch_t util_format_dxt5_rgba_fetch = util_format_dxt5_rgba_fetch_stub;
|
|
||||||
|
|
||||||
util_format_dxtn_pack_t util_format_dxtn_pack = util_format_dxtn_pack_stub;
|
|
||||||
|
|
||||||
static void
|
|
||||||
nop(void)
|
|
||||||
{}
|
|
||||||
|
|
||||||
#define is_nop(f) ((void*)(f) == (void*)nop)
|
|
||||||
|
|
||||||
static util_dl_proc
|
|
||||||
get_proc_address_or_nop(struct util_dl_library *library,
|
|
||||||
const char *procname)
|
|
||||||
{
|
|
||||||
if(library) {
|
|
||||||
util_dl_proc proc = util_dl_get_proc_address(library, procname);
|
|
||||||
if(proc)
|
|
||||||
return proc;
|
|
||||||
}
|
|
||||||
return (util_dl_proc)nop;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
util_format_s3tc_do_init(void)
|
util_format_s3tc_init(void)
|
||||||
{
|
{
|
||||||
struct util_dl_library *library;
|
static struct util_dl_library *
|
||||||
|
library = NULL;
|
||||||
|
|
||||||
library = util_dl_open(DXTN_LIBNAME);
|
if (util_format_s3tc_enabled)
|
||||||
util_format_dxt1_rgb_fetch = (util_format_dxtn_fetch_t)
|
return;
|
||||||
get_proc_address_or_nop(library, "fetch_2d_texel_rgb_dxt1");
|
|
||||||
util_format_dxt1_rgba_fetch = (util_format_dxtn_fetch_t)
|
|
||||||
get_proc_address_or_nop(library, "fetch_2d_texel_rgba_dxt1");
|
|
||||||
util_format_dxt3_rgba_fetch = (util_format_dxtn_fetch_t)
|
|
||||||
get_proc_address_or_nop(library, "fetch_2d_texel_rgba_dxt3");
|
|
||||||
util_format_dxt5_rgba_fetch = (util_format_dxtn_fetch_t)
|
|
||||||
get_proc_address_or_nop(library, "fetch_2d_texel_rgba_dxt5");
|
|
||||||
util_format_dxtn_pack = (util_format_dxtn_pack_t)
|
|
||||||
get_proc_address_or_nop(library, "tx_compress_dxtn");
|
|
||||||
|
|
||||||
if (!library)
|
if (!library) {
|
||||||
debug_printf("couldn't open " DXTN_LIBNAME ", software DXTn "
|
library = util_dl_open(DXTN_LIBNAME);
|
||||||
"compression/decompression unavailable\n");
|
if (!library) {
|
||||||
else {
|
debug_printf("couldn't open " DXTN_LIBNAME ", software DXTn "
|
||||||
if (!is_nop(util_format_dxt1_rgb_fetch) &&
|
"compression/decompression unavailable");
|
||||||
!is_nop(util_format_dxt1_rgba_fetch) &&
|
}
|
||||||
!is_nop(util_format_dxt3_rgba_fetch) &&
|
else {
|
||||||
!is_nop(util_format_dxt5_rgba_fetch) &&
|
util_format_dxt1_rgb_fetch = (util_format_dxtn_fetch_t)
|
||||||
!is_nop(util_format_dxtn_pack)) {
|
util_dl_get_proc_address(library, "fetch_2d_texel_rgb_dxt1");
|
||||||
debug_printf("software DXTn compression/decompression available\n");
|
util_format_dxt1_rgba_fetch = (util_format_dxtn_fetch_t)
|
||||||
} else
|
util_dl_get_proc_address(library, "fetch_2d_texel_rgba_dxt1");
|
||||||
debug_printf("couldn't reference all symbols in "
|
util_format_dxt3_rgba_fetch = (util_format_dxtn_fetch_t)
|
||||||
DXTN_LIBNAME ", software DXTn compression/decompression "
|
util_dl_get_proc_address(library, "fetch_2d_texel_rgba_dxt3");
|
||||||
"unavailable or partially available\n");
|
util_format_dxt5_rgba_fetch = (util_format_dxtn_fetch_t)
|
||||||
|
util_dl_get_proc_address(library, "fetch_2d_texel_rgba_dxt5");
|
||||||
|
util_format_dxtn_pack = (util_format_dxtn_pack_t)
|
||||||
|
util_dl_get_proc_address(library, "tx_compress_dxtn");
|
||||||
|
|
||||||
|
if (util_format_dxt1_rgb_fetch ||
|
||||||
|
util_format_dxt1_rgba_fetch ||
|
||||||
|
util_format_dxt3_rgba_fetch ||
|
||||||
|
util_format_dxt5_rgba_fetch ||
|
||||||
|
util_format_dxtn_pack) {
|
||||||
|
util_format_s3tc_enabled = TRUE;
|
||||||
|
debug_printf("software DXTn compression/decompression available");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
debug_printf("couldn't reference all symbols in "
|
||||||
|
DXTN_LIBNAME ", software DXTn compression/decompression "
|
||||||
|
"unavailable");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DO(n, a, A) \
|
|
||||||
((struct util_format_description *)util_format_description(PIPE_FORMAT_DXT##n##_SRGB##A))->is_supported = \
|
|
||||||
((struct util_format_description *)util_format_description(PIPE_FORMAT_DXT##n##_RGB##A))->is_supported = \
|
|
||||||
!is_nop(util_format_dxt##n##_rgb##a##_fetch);
|
|
||||||
|
|
||||||
DO(1,,);
|
|
||||||
DO(1,a,A);
|
|
||||||
DO(3,a,A);
|
|
||||||
DO(5,a,A);
|
|
||||||
|
|
||||||
#undef DO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -167,69 +97,85 @@ util_format_s3tc_do_init(void)
|
|||||||
void
|
void
|
||||||
util_format_dxt1_rgb_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
|
util_format_dxt1_rgb_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||||
{
|
{
|
||||||
util_format_dxt1_rgb_fetch(0, src, i, j, dst);
|
if (util_format_dxt1_rgb_fetch) {
|
||||||
|
util_format_dxt1_rgb_fetch(0, src, i, j, dst);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
util_format_dxt1_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
|
util_format_dxt1_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||||
{
|
{
|
||||||
util_format_dxt1_rgba_fetch(0, src, i, j, dst);
|
if (util_format_dxt1_rgba_fetch) {
|
||||||
|
util_format_dxt1_rgba_fetch(0, src, i, j, dst);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
util_format_dxt3_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
|
util_format_dxt3_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||||
{
|
{
|
||||||
util_format_dxt3_rgba_fetch(0, src, i, j, dst);
|
if (util_format_dxt3_rgba_fetch) {
|
||||||
|
util_format_dxt3_rgba_fetch(0, src, i, j, dst);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
util_format_dxt5_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
|
util_format_dxt5_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||||
{
|
{
|
||||||
util_format_dxt5_rgba_fetch(0, src, i, j, dst);
|
if (util_format_dxt5_rgba_fetch) {
|
||||||
|
util_format_dxt5_rgba_fetch(0, src, i, j, dst);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
util_format_dxt1_rgb_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
|
util_format_dxt1_rgb_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||||
{
|
{
|
||||||
uint8_t tmp[4];
|
if (util_format_dxt1_rgb_fetch) {
|
||||||
util_format_dxt1_rgb_fetch(0, src, i, j, tmp);
|
uint8_t tmp[4];
|
||||||
dst[0] = ubyte_to_float(tmp[0]);
|
util_format_dxt1_rgb_fetch(0, src, i, j, tmp);
|
||||||
dst[1] = ubyte_to_float(tmp[1]);
|
dst[0] = ubyte_to_float(tmp[0]);
|
||||||
dst[2] = ubyte_to_float(tmp[2]);
|
dst[1] = ubyte_to_float(tmp[1]);
|
||||||
dst[3] = 1.0;
|
dst[2] = ubyte_to_float(tmp[2]);
|
||||||
|
dst[3] = 1.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
util_format_dxt1_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
|
util_format_dxt1_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||||
{
|
{
|
||||||
uint8_t tmp[4];
|
if (util_format_dxt1_rgba_fetch) {
|
||||||
util_format_dxt1_rgba_fetch(0, src, i, j, tmp);
|
uint8_t tmp[4];
|
||||||
dst[0] = ubyte_to_float(tmp[0]);
|
util_format_dxt1_rgba_fetch(0, src, i, j, tmp);
|
||||||
dst[1] = ubyte_to_float(tmp[1]);
|
dst[0] = ubyte_to_float(tmp[0]);
|
||||||
dst[2] = ubyte_to_float(tmp[2]);
|
dst[1] = ubyte_to_float(tmp[1]);
|
||||||
dst[3] = ubyte_to_float(tmp[3]);
|
dst[2] = ubyte_to_float(tmp[2]);
|
||||||
|
dst[3] = ubyte_to_float(tmp[3]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
util_format_dxt3_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
|
util_format_dxt3_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||||
{
|
{
|
||||||
uint8_t tmp[4];
|
if (util_format_dxt3_rgba_fetch) {
|
||||||
util_format_dxt3_rgba_fetch(0, src, i, j, tmp);
|
uint8_t tmp[4];
|
||||||
dst[0] = ubyte_to_float(tmp[0]);
|
util_format_dxt3_rgba_fetch(0, src, i, j, tmp);
|
||||||
dst[1] = ubyte_to_float(tmp[1]);
|
dst[0] = ubyte_to_float(tmp[0]);
|
||||||
dst[2] = ubyte_to_float(tmp[2]);
|
dst[1] = ubyte_to_float(tmp[1]);
|
||||||
dst[3] = ubyte_to_float(tmp[3]);
|
dst[2] = ubyte_to_float(tmp[2]);
|
||||||
|
dst[3] = ubyte_to_float(tmp[3]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
util_format_dxt5_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
|
util_format_dxt5_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||||
{
|
{
|
||||||
uint8_t tmp[4];
|
if (util_format_dxt5_rgba_fetch) {
|
||||||
util_format_dxt5_rgba_fetch(0, src, i, j, tmp);
|
uint8_t tmp[4];
|
||||||
dst[0] = ubyte_to_float(tmp[0]);
|
util_format_dxt5_rgba_fetch(0, src, i, j, tmp);
|
||||||
dst[1] = ubyte_to_float(tmp[1]);
|
dst[0] = ubyte_to_float(tmp[0]);
|
||||||
dst[2] = ubyte_to_float(tmp[2]);
|
dst[1] = ubyte_to_float(tmp[1]);
|
||||||
dst[3] = ubyte_to_float(tmp[3]);
|
dst[2] = ubyte_to_float(tmp[2]);
|
||||||
|
dst[3] = ubyte_to_float(tmp[3]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -240,7 +186,7 @@ util_format_dxt5_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, un
|
|||||||
void
|
void
|
||||||
util_format_dxt1_rgb_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
util_format_dxt1_rgb_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
if (!is_nop(util_format_dxt1_rgb_fetch)) {
|
if (util_format_dxt1_rgb_fetch) {
|
||||||
unsigned x, y, i, j;
|
unsigned x, y, i, j;
|
||||||
for(y = 0; y < height; y += 4) {
|
for(y = 0; y < height; y += 4) {
|
||||||
const uint8_t *src = src_row;
|
const uint8_t *src = src_row;
|
||||||
@@ -261,7 +207,7 @@ util_format_dxt1_rgb_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const
|
|||||||
void
|
void
|
||||||
util_format_dxt1_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
util_format_dxt1_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
if (!is_nop(util_format_dxt1_rgba_fetch)) {
|
if (util_format_dxt1_rgba_fetch) {
|
||||||
unsigned x, y, i, j;
|
unsigned x, y, i, j;
|
||||||
for(y = 0; y < height; y += 4) {
|
for(y = 0; y < height; y += 4) {
|
||||||
const uint8_t *src = src_row;
|
const uint8_t *src = src_row;
|
||||||
@@ -282,7 +228,7 @@ util_format_dxt1_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const
|
|||||||
void
|
void
|
||||||
util_format_dxt3_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
util_format_dxt3_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
if (!is_nop(util_format_dxt3_rgba_fetch)) {
|
if (util_format_dxt3_rgba_fetch) {
|
||||||
unsigned x, y, i, j;
|
unsigned x, y, i, j;
|
||||||
for(y = 0; y < height; y += 4) {
|
for(y = 0; y < height; y += 4) {
|
||||||
const uint8_t *src = src_row;
|
const uint8_t *src = src_row;
|
||||||
@@ -303,7 +249,7 @@ util_format_dxt3_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const
|
|||||||
void
|
void
|
||||||
util_format_dxt5_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
util_format_dxt5_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
if (is_nop(util_format_dxt5_rgba_fetch)) {
|
if (util_format_dxt5_rgba_fetch) {
|
||||||
unsigned x, y, i, j;
|
unsigned x, y, i, j;
|
||||||
for(y = 0; y < height; y += 4) {
|
for(y = 0; y < height; y += 4) {
|
||||||
const uint8_t *src = src_row;
|
const uint8_t *src = src_row;
|
||||||
@@ -324,7 +270,7 @@ util_format_dxt5_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const
|
|||||||
void
|
void
|
||||||
util_format_dxt1_rgb_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
util_format_dxt1_rgb_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
if (is_nop(util_format_dxt1_rgb_fetch)) {
|
if (util_format_dxt1_rgb_fetch) {
|
||||||
unsigned x, y, i, j;
|
unsigned x, y, i, j;
|
||||||
for(y = 0; y < height; y += 4) {
|
for(y = 0; y < height; y += 4) {
|
||||||
const uint8_t *src = src_row;
|
const uint8_t *src = src_row;
|
||||||
@@ -350,7 +296,7 @@ util_format_dxt1_rgb_unpack_float(float *dst_row, unsigned dst_stride, const uin
|
|||||||
void
|
void
|
||||||
util_format_dxt1_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
util_format_dxt1_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
if (!is_nop(util_format_dxt1_rgba_fetch)) {
|
if (util_format_dxt1_rgba_fetch) {
|
||||||
unsigned x, y, i, j;
|
unsigned x, y, i, j;
|
||||||
for(y = 0; y < height; y += 4) {
|
for(y = 0; y < height; y += 4) {
|
||||||
const uint8_t *src = src_row;
|
const uint8_t *src = src_row;
|
||||||
@@ -376,7 +322,7 @@ util_format_dxt1_rgba_unpack_float(float *dst_row, unsigned dst_stride, const ui
|
|||||||
void
|
void
|
||||||
util_format_dxt3_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
util_format_dxt3_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
if (!is_nop(util_format_dxt3_rgba_fetch)) {
|
if (util_format_dxt3_rgba_fetch) {
|
||||||
unsigned x, y, i, j;
|
unsigned x, y, i, j;
|
||||||
for(y = 0; y < height; y += 4) {
|
for(y = 0; y < height; y += 4) {
|
||||||
const uint8_t *src = src_row;
|
const uint8_t *src = src_row;
|
||||||
@@ -402,7 +348,7 @@ util_format_dxt3_rgba_unpack_float(float *dst_row, unsigned dst_stride, const ui
|
|||||||
void
|
void
|
||||||
util_format_dxt5_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
util_format_dxt5_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
if (!is_nop(util_format_dxt5_rgba_fetch)) {
|
if (util_format_dxt5_rgba_fetch) {
|
||||||
unsigned x, y, i, j;
|
unsigned x, y, i, j;
|
||||||
for(y = 0; y < height; y += 4) {
|
for(y = 0; y < height; y += 4) {
|
||||||
const uint8_t *src = src_row;
|
const uint8_t *src = src_row;
|
||||||
@@ -433,7 +379,7 @@ util_format_dxt5_rgba_unpack_float(float *dst_row, unsigned dst_stride, const ui
|
|||||||
void
|
void
|
||||||
util_format_dxt1_rgb_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
util_format_dxt1_rgb_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
if (!is_nop(util_format_dxtn_pack)) {
|
if (util_format_dxtn_pack) {
|
||||||
unsigned x, y, i, j, k;
|
unsigned x, y, i, j, k;
|
||||||
for(y = 0; y < height; y += 4) {
|
for(y = 0; y < height; y += 4) {
|
||||||
const uint8_t *src = src_row;
|
const uint8_t *src = src_row;
|
||||||
@@ -460,7 +406,7 @@ util_format_dxt1_rgb_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const ui
|
|||||||
void
|
void
|
||||||
util_format_dxt1_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
util_format_dxt1_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
if (!is_nop(util_format_dxtn_pack)) {
|
if (util_format_dxtn_pack) {
|
||||||
unsigned x, y, i, j, k;
|
unsigned x, y, i, j, k;
|
||||||
for(y = 0; y < height; y += 4) {
|
for(y = 0; y < height; y += 4) {
|
||||||
const uint8_t *src = src_row;
|
const uint8_t *src = src_row;
|
||||||
@@ -487,7 +433,7 @@ util_format_dxt1_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const u
|
|||||||
void
|
void
|
||||||
util_format_dxt3_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
util_format_dxt3_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
if (!is_nop(util_format_dxtn_pack)) {
|
if (util_format_dxtn_pack) {
|
||||||
unsigned x, y, i, j, k;
|
unsigned x, y, i, j, k;
|
||||||
for(y = 0; y < height; y += 4) {
|
for(y = 0; y < height; y += 4) {
|
||||||
const uint8_t *src = src_row;
|
const uint8_t *src = src_row;
|
||||||
@@ -514,7 +460,7 @@ util_format_dxt3_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const u
|
|||||||
void
|
void
|
||||||
util_format_dxt5_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
util_format_dxt5_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
if (!is_nop(util_format_dxtn_pack)) {
|
if (util_format_dxtn_pack) {
|
||||||
unsigned x, y, i, j, k;
|
unsigned x, y, i, j, k;
|
||||||
for(y = 0; y < height; y += 4) {
|
for(y = 0; y < height; y += 4) {
|
||||||
const uint8_t *src = src_row;
|
const uint8_t *src = src_row;
|
||||||
@@ -541,7 +487,7 @@ util_format_dxt5_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const u
|
|||||||
void
|
void
|
||||||
util_format_dxt1_rgb_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
|
util_format_dxt1_rgb_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
if (!is_nop(util_format_dxtn_pack)) {
|
if (util_format_dxtn_pack) {
|
||||||
unsigned x, y, i, j, k;
|
unsigned x, y, i, j, k;
|
||||||
for(y = 0; y < height; y += 4) {
|
for(y = 0; y < height; y += 4) {
|
||||||
const float *src = src_row;
|
const float *src = src_row;
|
||||||
@@ -568,7 +514,7 @@ util_format_dxt1_rgb_pack_float(uint8_t *dst_row, unsigned dst_stride, const flo
|
|||||||
void
|
void
|
||||||
util_format_dxt1_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
|
util_format_dxt1_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
if (!is_nop(util_format_dxtn_pack)) {
|
if (util_format_dxtn_pack) {
|
||||||
unsigned x, y, i, j, k;
|
unsigned x, y, i, j, k;
|
||||||
for(y = 0; y < height; y += 4) {
|
for(y = 0; y < height; y += 4) {
|
||||||
const float *src = src_row;
|
const float *src = src_row;
|
||||||
@@ -595,7 +541,7 @@ util_format_dxt1_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const fl
|
|||||||
void
|
void
|
||||||
util_format_dxt3_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
|
util_format_dxt3_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
if (!is_nop(util_format_dxtn_pack)) {
|
if (util_format_dxtn_pack) {
|
||||||
unsigned x, y, i, j, k;
|
unsigned x, y, i, j, k;
|
||||||
for(y = 0; y < height; y += 4) {
|
for(y = 0; y < height; y += 4) {
|
||||||
const float *src = src_row;
|
const float *src = src_row;
|
||||||
@@ -622,7 +568,7 @@ util_format_dxt3_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const fl
|
|||||||
void
|
void
|
||||||
util_format_dxt5_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
|
util_format_dxt5_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
if (!is_nop(util_format_dxtn_pack)) {
|
if (util_format_dxtn_pack) {
|
||||||
unsigned x, y, i, j, k;
|
unsigned x, y, i, j, k;
|
||||||
for(y = 0; y < height; y += 4) {
|
for(y = 0; y < height; y += 4) {
|
||||||
const float *src = src_row;
|
const float *src = src_row;
|
||||||
|
@@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "pipe/p_compiler.h"
|
#include "pipe/p_compiler.h"
|
||||||
#include "util/u_inline_init.h"
|
|
||||||
|
|
||||||
|
|
||||||
enum util_format_dxtn {
|
enum util_format_dxtn {
|
||||||
@@ -66,7 +65,8 @@ extern util_format_dxtn_fetch_t util_format_dxt5_rgba_fetch;
|
|||||||
extern util_format_dxtn_pack_t util_format_dxtn_pack;
|
extern util_format_dxtn_pack_t util_format_dxtn_pack;
|
||||||
|
|
||||||
|
|
||||||
UTIL_INLINE_INIT(util_format_s3tc)
|
void
|
||||||
|
util_format_s3tc_init(void);
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -92,7 +92,7 @@ def write_format_table(formats):
|
|||||||
u_format_pack.generate(formats)
|
u_format_pack.generate(formats)
|
||||||
|
|
||||||
for format in formats:
|
for format in formats:
|
||||||
print 'struct util_format_description'
|
print 'const struct util_format_description'
|
||||||
print 'util_format_%s_description = {' % (format.short_name(),)
|
print 'util_format_%s_description = {' % (format.short_name(),)
|
||||||
print " %s," % (format.name,)
|
print " %s," % (format.name,)
|
||||||
print " \"%s\"," % (format.name,)
|
print " \"%s\"," % (format.name,)
|
||||||
@@ -103,7 +103,6 @@ def write_format_table(formats):
|
|||||||
print " %s,\t/* is_array */" % (bool_map(format.is_array()),)
|
print " %s,\t/* is_array */" % (bool_map(format.is_array()),)
|
||||||
print " %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),)
|
print " %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),)
|
||||||
print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),)
|
print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),)
|
||||||
print " %s,\t/* is_supported */" % ("TRUE" if u_format_pack.is_format_supported(format) else "FALSE",)
|
|
||||||
print " {"
|
print " {"
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
channel = format.channels[i]
|
channel = format.channels[i]
|
||||||
|
@@ -1,15 +0,0 @@
|
|||||||
#ifndef U_INLINE_INIT_H_
|
|
||||||
#define U_INLINE_INIT_H_
|
|
||||||
|
|
||||||
#define UTIL_INLINE_INIT(m) \
|
|
||||||
extern boolean m##_inited; \
|
|
||||||
extern void m##_do_init(void); \
|
|
||||||
static INLINE void m##_init(void) \
|
|
||||||
{ \
|
|
||||||
if(!m##_inited) { \
|
|
||||||
m##_do_init(); \
|
|
||||||
m##_inited = TRUE; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* U_INLINE_INIT_H_ */
|
|
@@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
#include "draw/draw_context.h"
|
#include "draw/draw_context.h"
|
||||||
#include "pipe/p_defines.h"
|
#include "pipe/p_defines.h"
|
||||||
#include "util/u_format.h"
|
|
||||||
|
|
||||||
#include "nv50_context.h"
|
#include "nv50_context.h"
|
||||||
#include "nv50_screen.h"
|
#include "nv50_screen.h"
|
||||||
|
@@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "util/u_memory.h"
|
#include "util/u_memory.h"
|
||||||
#include "util/u_format.h"
|
|
||||||
#include "util/u_format_s3tc.h"
|
#include "util/u_format_s3tc.h"
|
||||||
#include "pipe/p_defines.h"
|
#include "pipe/p_defines.h"
|
||||||
#include "pipe/p_screen.h"
|
#include "pipe/p_screen.h"
|
||||||
@@ -156,9 +155,25 @@ softpipe_is_format_supported( struct pipe_screen *screen,
|
|||||||
target == PIPE_TEXTURE_3D ||
|
target == PIPE_TEXTURE_3D ||
|
||||||
target == PIPE_TEXTURE_CUBE);
|
target == PIPE_TEXTURE_CUBE);
|
||||||
|
|
||||||
if(!util_format_is_supported(format))
|
switch(format) {
|
||||||
|
case PIPE_FORMAT_YUYV:
|
||||||
|
case PIPE_FORMAT_UYVY:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
case PIPE_FORMAT_DXT1_RGB:
|
||||||
|
case PIPE_FORMAT_DXT1_RGBA:
|
||||||
|
case PIPE_FORMAT_DXT3_RGBA:
|
||||||
|
case PIPE_FORMAT_DXT5_RGBA:
|
||||||
|
return util_format_s3tc_enabled;
|
||||||
|
|
||||||
|
case PIPE_FORMAT_Z32_FLOAT:
|
||||||
|
case PIPE_FORMAT_NONE:
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if(tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
|
if(tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
|
||||||
PIPE_TEXTURE_USAGE_SCANOUT |
|
PIPE_TEXTURE_USAGE_SCANOUT |
|
||||||
PIPE_TEXTURE_USAGE_SHARED)) {
|
PIPE_TEXTURE_USAGE_SHARED)) {
|
||||||
@@ -166,6 +181,8 @@ softpipe_is_format_supported( struct pipe_screen *screen,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* XXX: this is often a lie. Pull in logic from llvmpipe to fix.
|
||||||
|
*/
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,6 +241,8 @@ softpipe_create_screen(struct sw_winsys *winsys)
|
|||||||
screen->base.context_create = softpipe_create_context;
|
screen->base.context_create = softpipe_create_context;
|
||||||
screen->base.flush_frontbuffer = softpipe_flush_frontbuffer;
|
screen->base.flush_frontbuffer = softpipe_flush_frontbuffer;
|
||||||
|
|
||||||
|
util_format_s3tc_init();
|
||||||
|
|
||||||
softpipe_init_screen_texture_funcs(&screen->base);
|
softpipe_init_screen_texture_funcs(&screen->base);
|
||||||
softpipe_init_screen_buffer_funcs(&screen->base);
|
softpipe_init_screen_buffer_funcs(&screen->base);
|
||||||
softpipe_init_screen_fence_funcs(&screen->base);
|
softpipe_init_screen_fence_funcs(&screen->base);
|
||||||
|
Reference in New Issue
Block a user