strb->Base.Height = height;
strb->Base.Format = st_pipe_format_to_mesa_format(format);
strb->Base._BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
- strb->Base.DataType = st_format_datatype(format);
strb->format = format;
strb->defined = GL_FALSE; /* undefined contents now */
strb->Base.NumSamples = samples;
strb->Base.Format = st_pipe_format_to_mesa_format(format);
strb->Base._BaseFormat = _mesa_get_format_base_format(strb->Base.Format);
- strb->Base.DataType = st_format_datatype(format);
strb->format = format;
strb->software = sw;
strb->format = pt->format;
strb->Base.Format = st_pipe_format_to_mesa_format(pt->format);
- strb->Base.DataType = st_format_datatype(pt->format);
/*
printf("RENDER TO TEXTURE obj=%p pt=%p surf=%p %d x %d\n",
#include "st_format.h"
-static GLuint
-format_max_bits(enum pipe_format format)
-{
- GLuint size = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0);
-
- size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 1));
- size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 2));
- size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3));
- size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0));
- size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1));
- return size;
-}
-
-
-/**
- * Return basic GL datatype for the given gallium format.
- */
-GLenum
-st_format_datatype(enum pipe_format format)
-{
- const struct util_format_description *desc;
- int i;
-
- desc = util_format_description(format);
- assert(desc);
-
- /* Find the first non-VOID channel. */
- for (i = 0; i < 4; i++) {
- if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) {
- break;
- }
- }
-
- if (desc->layout == UTIL_FORMAT_LAYOUT_PLAIN) {
- if (format == PIPE_FORMAT_B5G5R5A1_UNORM ||
- format == PIPE_FORMAT_B5G6R5_UNORM) {
- return GL_UNSIGNED_SHORT;
- }
- else if (format == PIPE_FORMAT_R11G11B10_FLOAT ||
- format == PIPE_FORMAT_R9G9B9E5_FLOAT) {
- return GL_FLOAT;
- }
- else if (format == PIPE_FORMAT_Z24_UNORM_S8_UINT ||
- format == PIPE_FORMAT_S8_UINT_Z24_UNORM ||
- format == PIPE_FORMAT_Z24X8_UNORM ||
- format == PIPE_FORMAT_X8Z24_UNORM) {
- return GL_UNSIGNED_INT_24_8;
- }
- else if (format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) {
- return GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
- }
- else {
- const GLuint size = format_max_bits(format);
-
- assert(i < 4);
- if (i == 4)
- return GL_NONE;
-
- if (size == 8) {
- if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
- return GL_UNSIGNED_BYTE;
- else
- return GL_BYTE;
- }
- else if (size == 16) {
- if (desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT)
- return GL_HALF_FLOAT;
- if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
- return GL_UNSIGNED_SHORT;
- else
- return GL_SHORT;
- }
- else if (size <= 32) {
- if (desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT)
- return GL_FLOAT;
- if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
- return GL_UNSIGNED_INT;
- else
- return GL_INT;
- }
- else {
- assert(size == 64);
- assert(desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT);
- return GL_DOUBLE;
- }
- }
- }
- else if (format == PIPE_FORMAT_UYVY) {
- return GL_UNSIGNED_SHORT;
- }
- else if (format == PIPE_FORMAT_YUYV) {
- return GL_UNSIGNED_SHORT;
- }
- else {
- /* probably a compressed format, unsupported anyway */
- return GL_NONE;
- }
-}
-
-
/**
* Translate Mesa format to Gallium format.
*/