diff options
author | Brian <[email protected]> | 2007-08-10 08:34:18 +0100 |
---|---|---|
committer | Brian <[email protected]> | 2007-08-10 08:34:18 +0100 |
commit | a25dd4d407a9ed797d4b9841c62f33efdfa07847 (patch) | |
tree | 46801af9f3866c3b68d8b7697a2b7cb4b0c5494e /src/mesa/state_tracker | |
parent | d2bfdae860022b2cef2fff2de25440ba0e8f1d2b (diff) |
code movement
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_cb_fbo.c | 71 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_teximage.c | 238 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_teximage.h | 26 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_texture.c | 150 |
4 files changed, 219 insertions, 266 deletions
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 67e239fd6d9..8443c9ea1b1 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -46,75 +46,6 @@ #include "st_cb_teximage.h" -struct pipe_format_info -{ - GLuint format; - GLenum base_format; - GLubyte red_bits; - GLubyte green_bits; - GLubyte blue_bits; - GLubyte alpha_bits; - GLubyte luminance_bits; - GLubyte intensity_bits; - GLubyte depth_bits; - GLubyte stencil_bits; - GLubyte size; /**< in bytes */ -}; - - -/* - * XXX temporary here - */ -static const struct pipe_format_info * -pipe_get_format_info(GLuint format) -{ - static const struct pipe_format_info info[] = { - { - PIPE_FORMAT_U_R8_G8_B8_A8, /* format */ - GL_RGBA, /* base_format */ - 8, 8, 8, 8, 0, 0, /* color bits */ - 0, 0, /* depth, stencil */ - 4 /* size in bytes */ - }, - { - PIPE_FORMAT_U_A8_R8_G8_B8, - GL_RGBA, /* base_format */ - 8, 8, 8, 8, 0, 0, /* color bits */ - 0, 0, /* depth, stencil */ - 4 /* size in bytes */ - }, - { - PIPE_FORMAT_U_A1_R5_G5_B5, - GL_RGBA, /* base_format */ - 5, 5, 5, 1, 0, 0, /* color bits */ - 0, 0, /* depth, stencil */ - 2 /* size in bytes */ - }, - { - PIPE_FORMAT_U_R5_G6_B5, - GL_RGBA, /* base_format */ - 5, 6, 5, 0, 0, 0, /* color bits */ - 0, 0, /* depth, stencil */ - 2 /* size in bytes */ - }, - /* XXX lots more */ - { - PIPE_FORMAT_S8_Z24, - GL_DEPTH_STENCIL_EXT, /* base_format */ - 0, 0, 0, 0, 0, 0, /* color bits */ - 24, 8, /* depth, stencil */ - 4 /* size in bytes */ - } - }; - GLuint i; - - for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) { - if (info[i].format == format) - return info + i; - } - return NULL; -} - /** * gl_renderbuffer::AllocStorage() @@ -128,7 +59,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, struct st_renderbuffer *strb = st_renderbuffer(rb); const GLuint pipeFormat = st_choose_pipe_format(pipe, internalFormat, GL_NONE, GL_NONE); - const struct pipe_format_info *info = pipe_get_format_info(pipeFormat); + const struct pipe_format_info *info = st_get_format_info(pipeFormat); GLuint cpp, pitch; assert(info); diff --git a/src/mesa/state_tracker/st_cb_teximage.c b/src/mesa/state_tracker/st_cb_teximage.c index 39c93676954..c54602db5d3 100644 --- a/src/mesa/state_tracker/st_cb_teximage.c +++ b/src/mesa/state_tracker/st_cb_teximage.c @@ -34,6 +34,8 @@ #include "main/imports.h" #include "main/context.h" #include "main/texstore.h" +#include "main/texformat.h" +#include "main/enums.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" @@ -42,6 +44,60 @@ +/* + * XXX temporary here + */ +const struct pipe_format_info * +st_get_format_info(GLuint format) +{ + static const struct pipe_format_info info[] = { + { + PIPE_FORMAT_U_R8_G8_B8_A8, /* format */ + GL_RGBA, /* base_format */ + 8, 8, 8, 8, 0, 0, /* color bits */ + 0, 0, /* depth, stencil */ + 4 /* size in bytes */ + }, + { + PIPE_FORMAT_U_A8_R8_G8_B8, + GL_RGBA, /* base_format */ + 8, 8, 8, 8, 0, 0, /* color bits */ + 0, 0, /* depth, stencil */ + 4 /* size in bytes */ + }, + { + PIPE_FORMAT_U_A1_R5_G5_B5, + GL_RGBA, /* base_format */ + 5, 5, 5, 1, 0, 0, /* color bits */ + 0, 0, /* depth, stencil */ + 2 /* size in bytes */ + }, + { + PIPE_FORMAT_U_R5_G6_B5, + GL_RGBA, /* base_format */ + 5, 6, 5, 0, 0, 0, /* color bits */ + 0, 0, /* depth, stencil */ + 2 /* size in bytes */ + }, + /* XXX lots more */ + { + PIPE_FORMAT_S8_Z24, + GL_DEPTH_STENCIL_EXT, /* base_format */ + 0, 0, 0, 0, 0, 0, /* color bits */ + 24, 8, /* depth, stencil */ + 4 /* size in bytes */ + } + }; + GLuint i; + + for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) { + if (info[i].format == format) + return info + i; + } + return NULL; +} + + /** * Search list of formats for first RGBA format. @@ -285,58 +341,152 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, -static void -st_teximage2d(GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - /* probably nothing here: use core Mesa TexImage2D fallback to - * save teximage in main memory. - * Later, when we have a complete texobj and are ready to render, - * create the pipe texture object / mipmap-tree. - */ - - _mesa_store_teximage2d(ctx, target, level, internalFormat, - width, height, border, format, type, pixels, - packing, texObj, texImage); -} - - -static void -st_texsubimage2d(GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) +/* It works out that this function is fine for all the supported + * hardware. However, there is still a need to map the formats onto + * hardware descriptors. + */ +/* Note that the i915 can actually support many more formats than + * these if we take the step of simply swizzling the colors + * immediately after sampling... + */ +const struct gl_texture_format * +st_ChooseTextureFormat(GLcontext * ctx, GLint internalFormat, + GLenum format, GLenum type) { #if 0 - struct pipe_mipmap_tree *mt = texObj->DriverData; + struct intel_context *intel = intel_context(ctx); + const GLboolean do32bpt = (intel->intelScreen->front.cpp == 4); +#else + const GLboolean do32bpt = 1; #endif - /* 1. find the region which stores this texture object. - * 2. convert texels to pipe format if needed. - * 3. replace texdata in the texture region. - */ -} + switch (internalFormat) { + case 4: + case GL_RGBA: + case GL_COMPRESSED_RGBA: + if (format == GL_BGRA) { + if (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) { + return &_mesa_texformat_argb8888; + } + else if (type == GL_UNSIGNED_SHORT_4_4_4_4_REV) { + return &_mesa_texformat_argb4444; + } + else if (type == GL_UNSIGNED_SHORT_1_5_5_5_REV) { + return &_mesa_texformat_argb1555; + } + } + return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444; + case 3: + case GL_RGB: + case GL_COMPRESSED_RGB: + if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) { + return &_mesa_texformat_rgb565; + } + return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565; + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444; -void st_init_cb_teximage( struct st_context *st ) -{ - struct dd_function_table *functions = &st->ctx->Driver; + case GL_RGBA4: + case GL_RGBA2: + return &_mesa_texformat_argb4444; - functions->TexImage2D = st_teximage2d; - functions->TexSubImage2D = st_texsubimage2d; -} + case GL_RGB5_A1: + return &_mesa_texformat_argb1555; + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + return &_mesa_texformat_argb8888; -void st_destroy_cb_teximage( struct st_context *st ) -{ + case GL_RGB5: + case GL_RGB4: + case GL_R3_G3_B2: + return &_mesa_texformat_rgb565; + + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + case GL_COMPRESSED_ALPHA: + return &_mesa_texformat_a8; + + case 1: + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + case GL_COMPRESSED_LUMINANCE: + return &_mesa_texformat_l8; + + case 2: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + case GL_COMPRESSED_LUMINANCE_ALPHA: + return &_mesa_texformat_al88; + + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_INTENSITY12: + case GL_INTENSITY16: + case GL_COMPRESSED_INTENSITY: + return &_mesa_texformat_i8; + + case GL_YCBCR_MESA: + if (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE) + return &_mesa_texformat_ycbcr; + else + return &_mesa_texformat_ycbcr_rev; + + case GL_COMPRESSED_RGB_FXT1_3DFX: + return &_mesa_texformat_rgb_fxt1; + case GL_COMPRESSED_RGBA_FXT1_3DFX: + return &_mesa_texformat_rgba_fxt1; + + case GL_RGB_S3TC: + case GL_RGB4_S3TC: + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + return &_mesa_texformat_rgb_dxt1; + + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + return &_mesa_texformat_rgba_dxt1; + + case GL_RGBA_S3TC: + case GL_RGBA4_S3TC: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + return &_mesa_texformat_rgba_dxt3; + + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + return &_mesa_texformat_rgba_dxt5; + + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: + return &_mesa_texformat_z16; + + case GL_DEPTH_STENCIL_EXT: + case GL_DEPTH24_STENCIL8_EXT: + return &_mesa_texformat_z24_s8; + + default: + fprintf(stderr, "unexpected texture format %s in %s\n", + _mesa_lookup_enum_by_nr(internalFormat), __FUNCTION__); + return NULL; + } + + return NULL; /* never get here */ } diff --git a/src/mesa/state_tracker/st_cb_teximage.h b/src/mesa/state_tracker/st_cb_teximage.h index 462128a844a..452ae59d6d3 100644 --- a/src/mesa/state_tracker/st_cb_teximage.h +++ b/src/mesa/state_tracker/st_cb_teximage.h @@ -30,14 +30,34 @@ #define ST_CB_TEXIMAGE_H +struct pipe_format_info +{ + GLuint format; + GLenum base_format; + GLubyte red_bits; + GLubyte green_bits; + GLubyte blue_bits; + GLubyte alpha_bits; + GLubyte luminance_bits; + GLubyte intensity_bits; + GLubyte depth_bits; + GLubyte stencil_bits; + GLubyte size; /**< in bytes */ +}; + + +extern const struct pipe_format_info * +st_get_format_info(GLuint format); + + extern GLuint st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, GLenum format, GLenum type); -extern void st_init_cb_teximage( struct st_context *st ); - -extern void st_destroy_cb_teximage( struct st_context *st ); +extern const struct gl_texture_format * +st_ChooseTextureFormat(GLcontext * ctx, GLint internalFormat, + GLenum format, GLenum type); #endif /* ST_CB_TEXIMAGE_H */ diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 6b361b0a4b6..6850d602e24 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -38,6 +38,7 @@ #include "state_tracker/st_context.h" #include "state_tracker/st_cb_texture.h" +#include "state_tracker/st_cb_teximage.h" #include "state_tracker/st_mipmap_tree.h" #include "pipe/p_context.h" @@ -152,155 +153,6 @@ compressed_num_bytes(GLuint mesaFormat) } -/* It works out that this function is fine for all the supported - * hardware. However, there is still a need to map the formats onto - * hardware descriptors. - */ -/* Note that the i915 can actually support many more formats than - * these if we take the step of simply swizzling the colors - * immediately after sampling... - */ -static const struct gl_texture_format * -st_ChooseTextureFormat(GLcontext * ctx, GLint internalFormat, - GLenum format, GLenum type) -{ -#if 0 - struct intel_context *intel = intel_context(ctx); - const GLboolean do32bpt = (intel->intelScreen->front.cpp == 4); -#else - const GLboolean do32bpt = 1; -#endif - - switch (internalFormat) { - case 4: - case GL_RGBA: - case GL_COMPRESSED_RGBA: - if (format == GL_BGRA) { - if (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) { - return &_mesa_texformat_argb8888; - } - else if (type == GL_UNSIGNED_SHORT_4_4_4_4_REV) { - return &_mesa_texformat_argb4444; - } - else if (type == GL_UNSIGNED_SHORT_1_5_5_5_REV) { - return &_mesa_texformat_argb1555; - } - } - return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444; - - case 3: - case GL_RGB: - case GL_COMPRESSED_RGB: - if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) { - return &_mesa_texformat_rgb565; - } - return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565; - - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444; - - case GL_RGBA4: - case GL_RGBA2: - return &_mesa_texformat_argb4444; - - case GL_RGB5_A1: - return &_mesa_texformat_argb1555; - - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return &_mesa_texformat_argb8888; - - case GL_RGB5: - case GL_RGB4: - case GL_R3_G3_B2: - return &_mesa_texformat_rgb565; - - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - case GL_COMPRESSED_ALPHA: - return &_mesa_texformat_a8; - - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - case GL_COMPRESSED_LUMINANCE: - return &_mesa_texformat_l8; - - case 2: - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - case GL_COMPRESSED_LUMINANCE_ALPHA: - return &_mesa_texformat_al88; - - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - case GL_COMPRESSED_INTENSITY: - return &_mesa_texformat_i8; - - case GL_YCBCR_MESA: - if (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE) - return &_mesa_texformat_ycbcr; - else - return &_mesa_texformat_ycbcr_rev; - - case GL_COMPRESSED_RGB_FXT1_3DFX: - return &_mesa_texformat_rgb_fxt1; - case GL_COMPRESSED_RGBA_FXT1_3DFX: - return &_mesa_texformat_rgba_fxt1; - - case GL_RGB_S3TC: - case GL_RGB4_S3TC: - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - return &_mesa_texformat_rgb_dxt1; - - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - return &_mesa_texformat_rgba_dxt1; - - case GL_RGBA_S3TC: - case GL_RGBA4_S3TC: - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - return &_mesa_texformat_rgba_dxt3; - - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - return &_mesa_texformat_rgba_dxt5; - - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16: - case GL_DEPTH_COMPONENT24: - case GL_DEPTH_COMPONENT32: - return &_mesa_texformat_z16; - - case GL_DEPTH_STENCIL_EXT: - case GL_DEPTH24_STENCIL8_EXT: - return &_mesa_texformat_z24_s8; - - default: - fprintf(stderr, "unexpected texture format %s in %s\n", - _mesa_lookup_enum_by_nr(internalFormat), __FUNCTION__); - return NULL; - } - - return NULL; /* never get here */ -} static GLboolean |