summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/common/meta.c13
-rw-r--r--src/mesa/drivers/dri/common/dri_util.c87
-rw-r--r--src/mesa/drivers/dri/common/dri_util.h3
-rw-r--r--src/mesa/drivers/dri/i915/i915_fragprog.c18
-rw-r--r--src/mesa/drivers/dri/i915/i915_program.c22
-rw-r--r--src/mesa/drivers/dri/i915/i915_tex_layout.c2
-rw-r--r--src/mesa/drivers/dri/i965/brw_program.c34
-rw-r--r--src/mesa/drivers/dri/i965/brw_sf_state.c15
-rw-r--r--src/mesa/drivers/dri/i965/brw_tex_layout.c80
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs_emit.c90
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_sampler_state.c8
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_surface_state.c2
-rw-r--r--src/mesa/drivers/dri/intel/intel_screen.c1
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_layout.c8
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_layout.h2
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_screen.c1
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c15
-rw-r--r--src/mesa/drivers/dri/r600/r600_blit.c4
-rw-r--r--src/mesa/drivers/dri/r600/r600_context.c2
-rw-r--r--src/mesa/drivers/dri/r600/r600_tex.c48
-rw-r--r--src/mesa/drivers/dri/r600/r600_tex.h2
-rw-r--r--src/mesa/drivers/dri/r600/r700_assembler.c21
-rw-r--r--src/mesa/drivers/dri/r600/r700_chip.c259
-rw-r--r--src/mesa/drivers/dri/r600/r700_fragprog.c21
-rw-r--r--src/mesa/drivers/dri/r600/r700_state.c5
-rw-r--r--src/mesa/drivers/dri/r600/r700_vertprog.c10
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_bo_legacy.c3
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_queryobj.c4
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_screen.c4
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_screen.h2
-rw-r--r--src/mesa/glapi/gen/ARB_seamless_cube_map.xml2
-rw-r--r--src/mesa/glapi/glapi_getproc.c3
-rw-r--r--src/mesa/glapi/glapi_nop.c20
-rw-r--r--src/mesa/main/debug.c4
-rw-r--r--src/mesa/main/dlist.c2
-rw-r--r--src/mesa/main/enums.c2
-rw-r--r--src/mesa/main/formats.c58
-rw-r--r--src/mesa/main/formats.h14
-rw-r--r--src/mesa/main/framebuffer.c41
-rw-r--r--src/mesa/main/framebuffer.h3
-rw-r--r--src/mesa/main/image.c60
-rw-r--r--src/mesa/main/image.h5
-rw-r--r--src/mesa/main/mipmap.c29
-rw-r--r--src/mesa/main/shaders.c2
-rw-r--r--src/mesa/main/texfetch.c548
-rw-r--r--src/mesa/main/texfetch_tmp.h193
-rw-r--r--src/mesa/main/texformat.c26
-rw-r--r--src/mesa/main/teximage.c46
-rw-r--r--src/mesa/main/texobj.c4
-rw-r--r--src/mesa/main/texstore.c153
-rw-r--r--src/mesa/shader/program_parse.tab.c7
-rw-r--r--src/mesa/shader/program_parse.y7
-rw-r--r--src/mesa/shader/slang/slang_codegen.c2
-rw-r--r--src/mesa/shader/slang/slang_emit.c31
-rw-r--r--src/mesa/shader/slang/slang_ir.c8
-rw-r--r--src/mesa/shader/slang/slang_label.c2
-rw-r--r--src/mesa/shader/slang/slang_link.c10
-rw-r--r--src/mesa/shader/slang/slang_print.c8
-rw-r--r--src/mesa/shader/slang/slang_utility.c2
-rw-r--r--src/mesa/state_tracker/st_atom_framebuffer.c10
-rw-r--r--src/mesa/state_tracker/st_atom_pixeltransfer.c15
-rw-r--r--src/mesa/state_tracker/st_atom_sampler.c9
-rw-r--r--src/mesa/state_tracker/st_atom_texture.c3
-rw-r--r--src/mesa/state_tracker/st_cb_accum.c4
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c22
-rw-r--r--src/mesa/state_tracker/st_cb_blit.c2
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c13
-rw-r--r--src/mesa/state_tracker/st_cb_condrender.c4
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c2
-rw-r--r--src/mesa/state_tracker/st_cb_eglimage.c4
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c43
-rw-r--r--src/mesa/state_tracker/st_cb_feedback.c4
-rw-r--r--src/mesa/state_tracker/st_cb_flush.c4
-rw-r--r--src/mesa/state_tracker/st_cb_queryobj.c10
-rw-r--r--src/mesa/state_tracker/st_cb_rasterpos.c6
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c11
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c283
-rw-r--r--src/mesa/state_tracker/st_context.h1
-rw-r--r--src/mesa/state_tracker/st_debug.c3
-rw-r--r--src/mesa/state_tracker/st_draw.c23
-rw-r--r--src/mesa/state_tracker/st_draw_feedback.c8
-rw-r--r--src/mesa/state_tracker/st_format.c324
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.c147
-rw-r--r--src/mesa/state_tracker/st_gl_api.h9
-rw-r--r--src/mesa/state_tracker/st_manager.c33
-rw-r--r--src/mesa/state_tracker/st_program.c21
-rw-r--r--src/mesa/state_tracker/st_texture.c39
-rw-r--r--src/mesa/state_tracker/st_texture.h24
-rw-r--r--src/mesa/x86-64/xform4.S8
89 files changed, 2199 insertions, 968 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 84a2a5fcb3..ea9e417391 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -424,6 +424,7 @@ _mesa_meta_begin(GLcontext *ctx, GLbitfield state)
if (state & META_SCISSOR) {
save->Scissor = ctx->Scissor; /* struct copy */
+ _mesa_set_enable(ctx, GL_SCISSOR_TEST, GL_FALSE);
}
if (state & META_SHADER) {
@@ -1117,8 +1118,10 @@ blitframebuffer_texture(GLcontext *ctx,
_mesa_BindTexture(target, texObj->Name);
_mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, filter);
_mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, filter);
- _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, srcLevel);
- _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel);
+ if (target != GL_TEXTURE_RECTANGLE_ARB) {
+ _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, srcLevel);
+ _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel);
+ }
_mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
_mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
_mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
@@ -1176,8 +1179,10 @@ blitframebuffer_texture(GLcontext *ctx,
*/
_mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilterSave);
_mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilterSave);
- _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, baseLevelSave);
- _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, maxLevelSave);
+ if (target != GL_TEXTURE_RECTANGLE_ARB) {
+ _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, baseLevelSave);
+ _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, maxLevelSave);
+ }
_mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, wrapSSave);
_mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, wrapTSave);
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index e08005f90b..360c524754 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -31,6 +31,16 @@
#include "dri_util.h"
#include "drm_sarea.h"
#include "utils.h"
+#include "xmlpool.h"
+
+PUBLIC const char __dri2ConfigOptions[] =
+ DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_1)
+ DRI_CONF_SECTION_END
+ DRI_CONF_END;
+
+static const uint __dri2NConfigOptions = 1;
#ifndef GLX_OML_sync_control
typedef GLboolean ( * PFNGLXGETMSCRATEOMLPROC) (__DRIdrawable *drawable, int32_t *numerator, int32_t *denominator);
@@ -143,19 +153,24 @@ static int driBindContext(__DRIcontext *pcp,
{
__DRIscreen *psp = NULL;
- /* Bind the drawable to the context */
+ /*
+ ** Assume error checking is done properly in glXMakeCurrent before
+ ** calling driUnbindContext.
+ */
- if (pcp) {
- psp = pcp->driScreenPriv;
- pcp->driDrawablePriv = pdp;
- pcp->driReadablePriv = prp;
- if (pdp) {
- pdp->driContextPriv = pcp;
- dri_get_drawable(pdp);
- }
- if ( prp && pdp != prp ) {
- dri_get_drawable(prp);
- }
+ if (!pcp)
+ return GL_FALSE;
+
+ /* Bind the drawable to the context */
+ psp = pcp->driScreenPriv;
+ pcp->driDrawablePriv = pdp;
+ pcp->driReadablePriv = prp;
+ if (pdp) {
+ pdp->driContextPriv = pcp;
+ dri_get_drawable(pdp);
+ }
+ if (prp && pdp != prp) {
+ dri_get_drawable(prp);
}
/*
@@ -163,7 +178,6 @@ static int driBindContext(__DRIcontext *pcp,
** initialize the drawable information if has not been done before.
*/
- assert(psp);
if (!psp->dri2.enabled) {
if (pdp && !pdp->pStamp) {
DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
@@ -178,7 +192,6 @@ static int driBindContext(__DRIcontext *pcp,
}
/* Call device-specific MakeCurrent */
-
return (*psp->DriverAPI.MakeCurrent)(pcp, pdp, prp);
}
@@ -467,6 +480,41 @@ dri2CreateNewDrawable(__DRIscreen *screen,
return pdraw;
}
+static int
+dri2ConfigQueryb(__DRIscreen *screen, const char *var, GLboolean *val)
+{
+ if (!driCheckOption(&screen->optionCache, var, DRI_BOOL))
+ return -1;
+
+ *val = driQueryOptionb(&screen->optionCache, var);
+
+ return 0;
+}
+
+static int
+dri2ConfigQueryi(__DRIscreen *screen, const char *var, GLint *val)
+{
+ if (!driCheckOption(&screen->optionCache, var, DRI_INT) &&
+ !driCheckOption(&screen->optionCache, var, DRI_ENUM))
+ return -1;
+
+ *val = driQueryOptioni(&screen->optionCache, var);
+
+ return 0;
+}
+
+static int
+dri2ConfigQueryf(__DRIscreen *screen, const char *var, GLfloat *val)
+{
+ if (!driCheckOption(&screen->optionCache, var, DRI_FLOAT))
+ return -1;
+
+ *val = driQueryOptionf(&screen->optionCache, var);
+
+ return 0;
+}
+
+
static void dri_get_drawable(__DRIdrawable *pdp)
{
pdp->refcount++;
@@ -788,6 +836,7 @@ dri2CreateNewScreen(int scrn, int fd,
static const __DRIextension *emptyExtensionList[] = { NULL };
__DRIscreen *psp;
drmVersionPtr version;
+ driOptionCache options;
if (driDriverAPI.InitScreen2 == NULL)
return NULL;
@@ -821,6 +870,9 @@ dri2CreateNewScreen(int scrn, int fd,
psp->DriverAPI = driDriverAPI;
+ driParseOptionInfo(&options, __dri2ConfigOptions, __dri2NConfigOptions);
+ driParseConfigFiles(&psp->optionCache, &options, psp->myNum, "dri2");
+
return psp;
}
@@ -865,6 +917,13 @@ const __DRIdri2Extension driDRI2Extension = {
dri2CreateNewContextForAPI
};
+const __DRI2configQueryExtension dri2ConfigQueryExtension = {
+ { __DRI2_CONFIG_QUERY, __DRI2_CONFIG_QUERY_VERSION },
+ dri2ConfigQueryb,
+ dri2ConfigQueryi,
+ dri2ConfigQueryf,
+};
+
static int
driFrameTracking(__DRIdrawable *drawable, GLboolean enable)
{
diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h
index 4b7cd414b8..ab6c6e57af 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -51,6 +51,7 @@
#include <drm.h>
#include <drm_sarea.h>
#include <xf86drm.h>
+#include "xmlconfig.h"
#include "main/glheader.h"
#include "main/mtypes.h"
#include "GL/internal/glcore.h"
@@ -71,6 +72,7 @@ extern const __DRIcopySubBufferExtension driCopySubBufferExtension;
extern const __DRIswapControlExtension driSwapControlExtension;
extern const __DRIframeTrackingExtension driFrameTrackingExtension;
extern const __DRImediaStreamCounterExtension driMediaStreamCounterExtension;
+extern const __DRI2configQueryExtension dri2ConfigQueryExtension;
/**
* Used by DRI_VALIDATE_DRAWABLE_INFO
@@ -530,6 +532,7 @@ struct __DRIscreenRec {
/* The lock actually in use, old sarea or DRI2 */
drmLock *lock;
+ driOptionCache optionCache;
unsigned int api_mask;
};
diff --git a/src/mesa/drivers/dri/i915/i915_fragprog.c b/src/mesa/drivers/dri/i915/i915_fragprog.c
index 9f12e2c632..e60157f377 100644
--- a/src/mesa/drivers/dri/i915/i915_fragprog.c
+++ b/src/mesa/drivers/dri/i915/i915_fragprog.c
@@ -359,9 +359,10 @@ upload_program(struct i915_fragment_program *p)
}
if (program->Base.NumInstructions > I915_MAX_INSN) {
- i915_program_error( p, "Exceeded max instructions" );
- return;
- }
+ i915_program_error(p, "Exceeded max instructions (%d out of %d)",
+ program->Base.NumInstructions, I915_MAX_INSN);
+ return;
+ }
/* Not always needed:
*/
@@ -1099,12 +1100,23 @@ translate_program(struct i915_fragment_program *p)
{
struct i915_context *i915 = I915_CONTEXT(p->ctx);
+ if (INTEL_DEBUG & DEBUG_WM) {
+ printf("fp:\n");
+ _mesa_print_program(&p->ctx->FragmentProgram._Current->Base);
+ printf("\n");
+ }
+
i915_init_program(i915, p);
check_wpos(p);
upload_program(p);
fixup_depth_write(p);
i915_fini_program(p);
+ if (INTEL_DEBUG & DEBUG_WM) {
+ printf("i915:\n");
+ i915_disassemble_program(i915->state.Program, i915->state.ProgramSize);
+ }
+
p->translated = 1;
}
diff --git a/src/mesa/drivers/dri/i915/i915_program.c b/src/mesa/drivers/dri/i915/i915_program.c
index 3902c69097..670c713785 100644
--- a/src/mesa/drivers/dri/i915/i915_program.c
+++ b/src/mesa/drivers/dri/i915/i915_program.c
@@ -494,17 +494,25 @@ i915_fini_program(struct i915_fragment_program *p)
GLuint program_size = p->csr - p->program;
GLuint decl_size = p->decl - p->declarations;
- if (p->nr_tex_indirect > I915_MAX_TEX_INDIRECT)
- i915_program_error(p, "Exceeded max nr indirect texture lookups");
+ if (p->nr_tex_indirect > I915_MAX_TEX_INDIRECT) {
+ i915_program_error(p, "Exceeded max nr indirect texture lookups "
+ "(%d out of %d)",
+ p->nr_tex_indirect, I915_MAX_TEX_INDIRECT);
+ }
- if (p->nr_tex_insn > I915_MAX_TEX_INSN)
- i915_program_error(p, "Exceeded max TEX instructions");
+ if (p->nr_tex_insn > I915_MAX_TEX_INSN) {
+ i915_program_error(p, "Exceeded max TEX instructions (%d out of %d)",
+ p->nr_tex_insn, I915_MAX_TEX_INSN);
+ }
if (p->nr_alu_insn > I915_MAX_ALU_INSN)
- i915_program_error(p, "Exceeded max ALU instructions");
+ i915_program_error(p, "Exceeded max ALU instructions (%d out of %d)",
+ p->nr_alu_insn, I915_MAX_ALU_INSN);
- if (p->nr_decl_insn > I915_MAX_DECL_INSN)
- i915_program_error(p, "Exceeded max DECL instructions");
+ if (p->nr_decl_insn > I915_MAX_DECL_INSN) {
+ i915_program_error(p, "Exceeded max DECL instructions (%d out of %d)",
+ p->nr_decl_insn, I915_MAX_DECL_INSN);
+ }
if (p->error) {
p->FragProg.Base.NumNativeInstructions = 0;
diff --git a/src/mesa/drivers/dri/i915/i915_tex_layout.c b/src/mesa/drivers/dri/i915/i915_tex_layout.c
index af9c7ee9b6..6e4512129c 100644
--- a/src/mesa/drivers/dri/i915/i915_tex_layout.c
+++ b/src/mesa/drivers/dri/i915/i915_tex_layout.c
@@ -483,7 +483,7 @@ i945_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt,
case GL_TEXTURE_1D:
case GL_TEXTURE_2D:
case GL_TEXTURE_RECTANGLE_ARB:
- i945_miptree_layout_2d(intel, mt, tiling);
+ i945_miptree_layout_2d(intel, mt, tiling, 1);
break;
default:
_mesa_problem(NULL, "Unexpected tex target in i945_miptree_layout()");
diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c
index 1fd957b3ad..41a1f438df 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -34,6 +34,7 @@
#include "shader/prog_parameter.h"
#include "shader/program.h"
#include "shader/programopt.h"
+#include "shader/shader_api.h"
#include "tnl/tnl.h"
#include "brw_context.h"
@@ -119,12 +120,28 @@ static GLboolean brwIsProgramNative( GLcontext *ctx,
return GL_TRUE;
}
+static void
+shader_error(GLcontext *ctx, struct gl_program *prog, const char *msg)
+{
+ struct gl_shader_program *shader;
+
+ shader = _mesa_lookup_shader_program(ctx, prog->Id);
+
+ if (shader) {
+ if (shader->InfoLog) {
+ free(shader->InfoLog);
+ }
+ shader->InfoLog = _mesa_strdup(msg);
+ shader->LinkStatus = GL_FALSE;
+ }
+}
static GLboolean brwProgramStringNotify( GLcontext *ctx,
GLenum target,
struct gl_program *prog )
{
struct brw_context *brw = brw_context(ctx);
+ int i;
if (target == GL_FRAGMENT_PROGRAM_ARB) {
struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog;
@@ -160,7 +177,22 @@ static GLboolean brwProgramStringNotify( GLcontext *ctx,
_tnl_program_string(ctx, target, prog);
}
- /* XXX check if program is legal, within limits */
+ /* Reject programs with subroutines, which are totally broken at the moment
+ * (all program flows return when any program flow returns, and
+ * the VS also hangs if a function call calls a function.
+ *
+ * See piglit glsl-{vs,fs}-functions-[23] tests.
+ */
+ for (i = 0; i < prog->NumInstructions; i++) {
+ if (prog->Instructions[i].Opcode == OPCODE_CAL) {
+ shader_error(ctx, prog,
+ "i965 driver doesn't yet support uninlined function "
+ "calls. Move to using a single return statement at "
+ "the end of the function to work around it.");
+ return GL_FALSE;
+ }
+ }
+
return GL_TRUE;
}
diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c
index 9712c31afe..1a6c8218fd 100644
--- a/src/mesa/drivers/dri/i965/brw_sf_state.c
+++ b/src/mesa/drivers/dri/i965/brw_sf_state.c
@@ -76,7 +76,20 @@ static void upload_sf_vp(struct brw_context *brw)
* Note that the hardware's coordinates are inclusive, while Mesa's min is
* inclusive but max is exclusive.
*/
- if (render_to_fbo) {
+
+ if (ctx->DrawBuffer->_Xmin == ctx->DrawBuffer->_Xmax ||
+ ctx->DrawBuffer->_Ymin == ctx->DrawBuffer->_Ymax) {
+ /* If the scissor was out of bounds and got clamped to 0
+ * width/height at the bounds, the subtraction of 1 from
+ * maximums could produce a negative number and thus not clip
+ * anything. Instead, just provide a min > max scissor inside
+ * the bounds, which produces the expected no rendering.
+ */
+ sfv.scissor.xmin = 1;
+ sfv.scissor.xmax = 0;
+ sfv.scissor.ymin = 1;
+ sfv.scissor.ymax = 0;
+ } else if (render_to_fbo) {
/* texmemory: Y=0=bottom */
sfv.scissor.xmin = ctx->DrawBuffer->_Xmin;
sfv.scissor.xmax = ctx->DrawBuffer->_Xmax - 1;
diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c b/src/mesa/drivers/dri/i965/brw_tex_layout.c
index 9a215ab8a4..768ccfd79c 100644
--- a/src/mesa/drivers/dri/i965/brw_tex_layout.c
+++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c
@@ -49,74 +49,30 @@ GLboolean brw_miptree_layout(struct intel_context *intel,
switch (mt->target) {
case GL_TEXTURE_CUBE_MAP:
if (intel->gen == 5) {
- GLuint align_h = 2, align_w = 4;
+ GLuint align_h = 2;
GLuint level;
- GLuint x = 0;
- GLuint y = 0;
- GLuint width = mt->width0;
- GLuint height = mt->height0;
GLuint qpitch = 0;
- GLuint y_pitch = 0;
+ int h0, h1, q;
- mt->total_width = mt->width0;
- intel_get_texture_alignment_unit(mt->internal_format, &align_w, &align_h);
- y_pitch = ALIGN(height, align_h);
+ /* On Ironlake, cube maps are finally represented as just a series
+ * of MIPLAYOUT_BELOW 2D textures (like 2D texture arrays), separated
+ * by a pitch of qpitch rows, where qpitch is defined by the equation
+ * given in Volume 1 of the BSpec.
+ */
+ h0 = ALIGN(mt->height0, align_h);
+ h1 = ALIGN(minify(h0), align_h);
+ qpitch = (h0 + h1 + 11 * align_h);
+ if (mt->compressed)
+ qpitch /= 4;
- if (mt->compressed) {
- mt->total_width = ALIGN(mt->width0, align_w);
- }
-
- if (mt->first_level != mt->last_level) {
- GLuint mip1_width;
-
- if (mt->compressed) {
- mip1_width = ALIGN(minify(mt->width0), align_w)
- + ALIGN(minify(minify(mt->width0)), align_w);
- } else {
- mip1_width = ALIGN(minify(mt->width0), align_w)
- + minify(minify(mt->width0));
- }
-
- if (mip1_width > mt->total_width) {
- mt->total_width = mip1_width;
- }
- }
-
- if (mt->compressed) {
- qpitch = (y_pitch + ALIGN(minify(y_pitch), align_h) + 11 * align_h) / 4;
- mt->total_height = (y_pitch + ALIGN(minify(y_pitch), align_h) + 11 * align_h) / 4 * 6;
- } else {
- qpitch = (y_pitch + ALIGN(minify(y_pitch), align_h) + 11 * align_h);
- mt->total_height = (y_pitch + ALIGN(minify(y_pitch), align_h) + 11 * align_h) * 6;
- }
+ i945_miptree_layout_2d(intel, mt, tiling, 6);
for (level = mt->first_level; level <= mt->last_level; level++) {
- GLuint img_height;
- GLuint nr_images = 6;
- GLuint q = 0;
-
- intel_miptree_set_level_info(mt, level, nr_images, x, y, width,
- height, 1);
-
- for (q = 0; q < nr_images; q++)
- intel_miptree_set_image_offset(mt, level, q,
- x, y + q * qpitch);
-
- if (mt->compressed)
- img_height = MAX2(1, height/4);
- else
- img_height = ALIGN(height, align_h);
-
- if (level == mt->first_level + 1) {
- x += ALIGN(width, align_w);
- }
- else {
- y += img_height;
- }
-
- width = minify(width);
- height = minify(height);
+ for (q = 0; q < 6; q++) {
+ intel_miptree_set_image_offset(mt, level, q, 0, q * qpitch);
+ }
}
+ mt->total_height = qpitch * 6;
break;
}
@@ -206,7 +162,7 @@ GLboolean brw_miptree_layout(struct intel_context *intel,
}
default:
- i945_miptree_layout_2d(intel, mt, tiling);
+ i945_miptree_layout_2d(intel, mt, tiling, 1);
break;
}
DBG("%s: %dx%dx%d\n", __FUNCTION__,
diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c
index eeb3f366a4..dc6ab81c4a 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c
@@ -37,6 +37,43 @@
#include "brw_context.h"
#include "brw_vs.h"
+/* Return the SrcReg index of the channels that can be immediate float operands
+ * instead of usage of PROGRAM_CONSTANT values through push/pull.
+ */
+static GLboolean
+brw_vs_arg_can_be_immediate(enum prog_opcode opcode, int arg)
+{
+ int opcode_array[] = {
+ [OPCODE_ADD] = 2,
+ [OPCODE_CMP] = 3,
+ [OPCODE_DP3] = 2,
+ [OPCODE_DP4] = 2,
+ [OPCODE_DPH] = 2,
+ [OPCODE_MAX] = 2,
+ [OPCODE_MIN] = 2,
+ [OPCODE_MUL] = 2,
+ [OPCODE_SEQ] = 2,
+ [OPCODE_SGE] = 2,
+ [OPCODE_SGT] = 2,
+ [OPCODE_SLE] = 2,
+ [OPCODE_SLT] = 2,
+ [OPCODE_SNE] = 2,
+ [OPCODE_XPD] = 2,
+ };
+
+ /* These opcodes get broken down in a way that allow two
+ * args to be immediates.
+ */
+ if (opcode == OPCODE_MAD || opcode == OPCODE_LRP) {
+ if (arg == 1 || arg == 2)
+ return GL_TRUE;
+ }
+
+ if (opcode > ARRAY_SIZE(opcode_array))
+ return GL_FALSE;
+
+ return arg == opcode_array[opcode] - 1;
+}
static struct brw_reg get_tmp( struct brw_vs_compile *c )
{
@@ -453,8 +490,8 @@ static void emit_max( struct brw_compile *p,
struct brw_reg arg0,
struct brw_reg arg1 )
{
- brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, arg0, arg1);
- brw_SEL(p, dst, arg1, arg0);
+ brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_GE, arg0, arg1);
+ brw_SEL(p, dst, arg0, arg1);
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
}
@@ -983,6 +1020,55 @@ get_src_reg( struct brw_vs_compile *c,
const GLint index = inst->SrcReg[argIndex].Index;
const GLboolean relAddr = inst->SrcReg[argIndex].RelAddr;
+ if (brw_vs_arg_can_be_immediate(inst->Opcode, argIndex)) {
+ const struct prog_src_register *src = &inst->SrcReg[argIndex];
+
+ if (src->Swizzle == MAKE_SWIZZLE4(SWIZZLE_ZERO,
+ SWIZZLE_ZERO,
+ SWIZZLE_ZERO,
+ SWIZZLE_ZERO)) {
+ return brw_imm_f(0.0f);
+ } else if (src->Swizzle == MAKE_SWIZZLE4(SWIZZLE_ONE,
+ SWIZZLE_ONE,
+ SWIZZLE_ONE,
+ SWIZZLE_ONE)) {
+ if (src->Negate)
+ return brw_imm_f(-1.0F);
+ else
+ return brw_imm_f(1.0F);
+ } else if (src->File == PROGRAM_CONSTANT) {
+ const struct gl_program_parameter_list *params;
+ float f;
+ int component = -1;
+
+ switch (src->Swizzle) {
+ case SWIZZLE_XXXX:
+ component = 0;
+ break;
+ case SWIZZLE_YYYY:
+ component = 1;
+ break;
+ case SWIZZLE_ZZZZ:
+ component = 2;
+ break;
+ case SWIZZLE_WWWW:
+ component = 3;
+ break;
+ }
+
+ if (component >= 0) {
+ params = c->vp->program.Base.Parameters;
+ f = params->ParameterValues[src->Index][component];
+
+ if (src->Abs)
+ f = fabs(f);
+ if (src->Negate)
+ f = -f;
+ return brw_imm_f(f);
+ }
+ }
+ }
+
switch (file) {
case PROGRAM_TEMPORARY:
case PROGRAM_INPUT:
diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
index d7650af3d9..1582ff1ab6 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
@@ -228,6 +228,8 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
{
GLcontext *ctx = &brw->intel.ctx;
int unit;
+ char *last_entry_end = ((char*)&key->sampler_count) +
+ sizeof(key->sampler_count);
key->sampler_count = 0;
@@ -240,7 +242,9 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
struct gl_texture_image *firstImage =
texObj->Image[0][intelObj->firstLevel];
- memset(entry, 0, sizeof(*entry));
+ memset(last_entry_end, 0,
+ (char*)entry - last_entry_end + sizeof(*entry));
+ last_entry_end = ((char*)entry) + sizeof(*entry);
entry->tex_target = texObj->Target;
@@ -280,6 +284,8 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
key->sampler_count = unit + 1;
}
}
+ struct wm_sampler_entry *entry = &key->sampler[key->sampler_count];
+ memset(last_entry_end, 0, (char*)entry - last_entry_end);
}
/* All samplers must be uploaded in a single contiguous array, which
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 6b9e566886..e51a1a0e26 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -588,7 +588,7 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
tile_base = ((key.draw_y / 32) * (32 * pitch));
tile_base += (key.draw_x - tile_x) / (128 / key.cpp) * 4096;
}
- assert(intel->is_g4x || (tile_x == 0 && tile_y == 0));
+ assert(brw->has_surface_tile_offset || (tile_x == 0 && tile_y == 0));
assert(tile_x % 4 == 0);
assert(tile_y % 2 == 0);
/* Note that the low bits of these fields are missing, so
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index 2b54cda66d..3aed253e24 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -225,6 +225,7 @@ static const __DRIextension *intelScreenExtensions[] = {
&intelTexBufferExtension.base,
&intelFlushExtension.base,
&intelImageExtension.base,
+ &dri2ConfigQueryExtension.base,
NULL
};
diff --git a/src/mesa/drivers/dri/intel/intel_tex_layout.c b/src/mesa/drivers/dri/intel/intel_tex_layout.c
index d132e19e83..d39733b6c5 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_layout.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_layout.c
@@ -63,9 +63,9 @@ void intel_get_texture_alignment_unit(GLenum internalFormat, GLuint *w, GLuint *
}
}
-void i945_miptree_layout_2d( struct intel_context *intel,
- struct intel_mipmap_tree *mt,
- uint32_t tiling )
+void i945_miptree_layout_2d(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ uint32_t tiling, int nr_images)
{
GLuint align_h = 2, align_w = 4;
GLuint level;
@@ -107,7 +107,7 @@ void i945_miptree_layout_2d( struct intel_context *intel,
for ( level = mt->first_level ; level <= mt->last_level ; level++ ) {
GLuint img_height;
- intel_miptree_set_level_info(mt, level, 1, x, y, width,
+ intel_miptree_set_level_info(mt, level, nr_images, x, y, width,
height, 1);
if (mt->compressed)
diff --git a/src/mesa/drivers/dri/intel/intel_tex_layout.h b/src/mesa/drivers/dri/intel/intel_tex_layout.h
index a9ac9e7eb4..1c8c53e545 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_layout.h
+++ b/src/mesa/drivers/dri/intel/intel_tex_layout.h
@@ -40,5 +40,5 @@ static INLINE GLuint minify( GLuint d )
extern void i945_miptree_layout_2d(struct intel_context *intel,
struct intel_mipmap_tree *mt,
- uint32_t tiling);
+ uint32_t tiling, int nr_images);
extern void intel_get_texture_alignment_unit(GLenum, GLuint *, GLuint *);
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
index 18db12f626..78987f633c 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
@@ -236,6 +236,7 @@ static const struct __DRItexBufferExtensionRec nouveau_texbuffer_extension = {
static const __DRIextension *nouveau_screen_extensions[] = {
&nouveau_flush_extension.base,
&nouveau_texbuffer_extension.base,
+ &dri2ConfigQueryExtension.base,
NULL
};
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index 02ba300eb0..fa33be4998 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -1658,20 +1658,21 @@ void r300VapCntl(r300ContextPtr rmesa, GLuint input_count,
(5 << R300_PVS_NUM_CNTLRS_SHIFT) |
(5 << R300_VF_MAX_VTX_NUM_SHIFT));
- if (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV515)
- rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (2 << R300_PVS_NUM_FPUS_SHIFT);
- else if ((rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV530) ||
- (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV560) ||
- (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV570))
+ if ((rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R300) ||
+ (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R350))
+ rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (4 << R300_PVS_NUM_FPUS_SHIFT);
+ else if (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV530)
rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (5 << R300_PVS_NUM_FPUS_SHIFT);
else if ((rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV410) ||
(rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R420))
rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (6 << R300_PVS_NUM_FPUS_SHIFT);
else if ((rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R520) ||
- (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R580))
+ (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R580) ||
+ (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV560) ||
+ (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV570))
rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (8 << R300_PVS_NUM_FPUS_SHIFT);
else
- rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (4 << R300_PVS_NUM_FPUS_SHIFT);
+ rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (2 << R300_PVS_NUM_FPUS_SHIFT);
}
diff --git a/src/mesa/drivers/dri/r600/r600_blit.c b/src/mesa/drivers/dri/r600/r600_blit.c
index 244fdc4ffb..172f85eb26 100644
--- a/src/mesa/drivers/dri/r600/r600_blit.c
+++ b/src/mesa/drivers/dri/r600/r600_blit.c
@@ -344,6 +344,10 @@ set_render_target(context_t *context, struct radeon_bo *bo, gl_format mesa_forma
return;
}
+ /* must be 0 on r7xx */
+ if (context->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV770)
+ CLEARbit(cb_color0_info, BLEND_FLOAT32_bit);
+
SETfield(cb_color0_info, format, CB_COLOR0_INFO__FORMAT_shift,
CB_COLOR0_INFO__FORMAT_mask);
SETfield(cb_color0_info, comp_swap, COMP_SWAP_shift, COMP_SWAP_mask);
diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c
index 9f8923f09d..f4aed4e87f 100644
--- a/src/mesa/drivers/dri/r600/r600_context.c
+++ b/src/mesa/drivers/dri/r600/r600_context.c
@@ -239,7 +239,7 @@ static void r600_init_vtbl(radeonContextPtr radeon)
radeon->vtbl.emit_query_finish = r600_emit_query_finish;
radeon->vtbl.check_blit = r600_check_blit;
radeon->vtbl.blit = r600_blit;
- radeon->vtbl.is_format_renderable = radeonIsFormatRenderable;
+ radeon->vtbl.is_format_renderable = r600IsFormatRenderable;
}
static void r600InitConstValues(GLcontext *ctx, radeonScreenPtr screen)
diff --git a/src/mesa/drivers/dri/r600/r600_tex.c b/src/mesa/drivers/dri/r600/r600_tex.c
index 36a6e6e0a1..41419f8460 100644
--- a/src/mesa/drivers/dri/r600/r600_tex.c
+++ b/src/mesa/drivers/dri/r600/r600_tex.c
@@ -392,6 +392,54 @@ static struct gl_texture_object *r600NewTextureObject(GLcontext * ctx,
return &t->base;
}
+unsigned r600IsFormatRenderable(gl_format mesa_format)
+{
+ switch (mesa_format) {
+ case MESA_FORMAT_RGBA8888:
+ case MESA_FORMAT_SIGNED_RGBA8888:
+ case MESA_FORMAT_RGBA8888_REV:
+ case MESA_FORMAT_SIGNED_RGBA8888_REV:
+ case MESA_FORMAT_ARGB8888:
+ case MESA_FORMAT_XRGB8888:
+ case MESA_FORMAT_ARGB8888_REV:
+ case MESA_FORMAT_XRGB8888_REV:
+ case MESA_FORMAT_RGB565:
+ case MESA_FORMAT_RGB565_REV:
+ case MESA_FORMAT_ARGB4444:
+ case MESA_FORMAT_ARGB4444_REV:
+ case MESA_FORMAT_ARGB1555:
+ case MESA_FORMAT_ARGB1555_REV:
+ case MESA_FORMAT_AL88:
+ case MESA_FORMAT_AL88_REV:
+ case MESA_FORMAT_RGB332:
+ case MESA_FORMAT_A8:
+ case MESA_FORMAT_I8:
+ case MESA_FORMAT_CI8:
+ case MESA_FORMAT_L8:
+ case MESA_FORMAT_RGBA_FLOAT32:
+ case MESA_FORMAT_RGBA_FLOAT16:
+ case MESA_FORMAT_ALPHA_FLOAT32:
+ case MESA_FORMAT_ALPHA_FLOAT16:
+ case MESA_FORMAT_LUMINANCE_FLOAT32:
+ case MESA_FORMAT_LUMINANCE_FLOAT16:
+ case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
+ case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16:
+ case MESA_FORMAT_INTENSITY_FLOAT32: /* X, X, X, X */
+ case MESA_FORMAT_INTENSITY_FLOAT16: /* X, X, X, X */
+ case MESA_FORMAT_X8_Z24:
+ case MESA_FORMAT_S8_Z24:
+ case MESA_FORMAT_Z24_S8:
+ case MESA_FORMAT_Z16:
+ case MESA_FORMAT_Z32:
+ case MESA_FORMAT_SRGBA8:
+ case MESA_FORMAT_SLA8:
+ case MESA_FORMAT_SL8:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
void r600InitTextureFuncs(radeonContextPtr radeon, struct dd_function_table *functions)
{
/* Note: we only plug in the functions we implement in the driver
diff --git a/src/mesa/drivers/dri/r600/r600_tex.h b/src/mesa/drivers/dri/r600/r600_tex.h
index 1d75a2ecd6..771affdfa6 100644
--- a/src/mesa/drivers/dri/r600/r600_tex.h
+++ b/src/mesa/drivers/dri/r600/r600_tex.h
@@ -60,4 +60,6 @@ extern GLboolean r600ValidateBuffers(GLcontext * ctx);
extern void r600InitTextureFuncs(radeonContextPtr radeon, struct dd_function_table *functions);
+unsigned r600IsFormatRenderable(gl_format mesa_format);
+
#endif /* __r600_TEX_H__ */
diff --git a/src/mesa/drivers/dri/r600/r700_assembler.c b/src/mesa/drivers/dri/r600/r700_assembler.c
index 834bcc63e3..0677c54bea 100644
--- a/src/mesa/drivers/dri/r600/r700_assembler.c
+++ b/src/mesa/drivers/dri/r600/r700_assembler.c
@@ -6511,13 +6511,30 @@ GLboolean Process_Vertex_Exports(r700_AssemblerBase *pR700AsmCode,
{
return GL_FALSE;
}
+ export_starting_index++;
+ export_count--;
+ }
+ unBit = 1 << VERT_RESULT_PSIZ;
+ if(OutputsWritten & unBit)
+ {
+ if( GL_FALSE == Process_Export(pR700AsmCode,
+ SQ_EXPORT_POS,
+ export_starting_index,
+ 1,
+ pR700AsmCode->ucVP_OutputMap[VERT_RESULT_PSIZ],
+ GL_FALSE) )
+ {
+ return GL_FALSE;
+ }
export_count--;
+ }
+
+ pR700AsmCode->cf_last_export_ptr->m_Word1.f.cf_inst = SQ_CF_INST_EXPORT_DONE;
- pR700AsmCode->cf_last_export_ptr->m_Word1.f.cf_inst = SQ_CF_INST_EXPORT_DONE;
- }
pR700AsmCode->number_of_exports = export_count;
+ export_starting_index = 0;
unBit = 1 << VERT_RESULT_COL0;
if(OutputsWritten & unBit)
diff --git a/src/mesa/drivers/dri/r600/r700_chip.c b/src/mesa/drivers/dri/r600/r700_chip.c
index 63614b160c..cefda3ac4b 100644
--- a/src/mesa/drivers/dri/r600/r700_chip.c
+++ b/src/mesa/drivers/dri/r600/r700_chip.c
@@ -290,7 +290,7 @@ static void r700SendVTXState(GLcontext *ctx, struct radeon_state_atom *atom)
static void r700SetRenderTarget(context_t *context, int id)
{
R700_CHIP_CONTEXT *r700 = (R700_CHIP_CONTEXT*)(&context->hw);
-
+ uint32_t format = COLOR_8_8_8_8, comp_swap = SWAP_ALT, number_type = NUMBER_UNORM;
struct radeon_renderbuffer *rrb;
unsigned int nPitchInPixel;
@@ -312,22 +312,251 @@ static void r700SetRenderTarget(context_t *context, int id)
SETfield(r700->render_target[id].CB_COLOR0_INFO.u32All, ENDIAN_NONE, ENDIAN_shift, ENDIAN_mask);
SETfield(r700->render_target[id].CB_COLOR0_INFO.u32All, ARRAY_LINEAR_GENERAL,
CB_COLOR0_INFO__ARRAY_MODE_shift, CB_COLOR0_INFO__ARRAY_MODE_mask);
- if(4 == rrb->cpp)
- {
- SETfield(r700->render_target[id].CB_COLOR0_INFO.u32All, COLOR_8_8_8_8,
- CB_COLOR0_INFO__FORMAT_shift, CB_COLOR0_INFO__FORMAT_mask);
- SETfield(r700->render_target[id].CB_COLOR0_INFO.u32All, SWAP_ALT, COMP_SWAP_shift, COMP_SWAP_mask);
- }
- else
- {
- SETfield(r700->render_target[id].CB_COLOR0_INFO.u32All, COLOR_5_6_5,
- CB_COLOR0_INFO__FORMAT_shift, CB_COLOR0_INFO__FORMAT_mask);
- SETfield(r700->render_target[id].CB_COLOR0_INFO.u32All, SWAP_ALT_REV,
- COMP_SWAP_shift, COMP_SWAP_mask);
+
+ switch (rrb->base.Format) {
+ case MESA_FORMAT_RGBA8888:
+ format = COLOR_8_8_8_8;
+ comp_swap = SWAP_STD_REV;
+ number_type = NUMBER_UNORM;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_SIGNED_RGBA8888:
+ format = COLOR_8_8_8_8;
+ comp_swap = SWAP_STD_REV;
+ number_type = NUMBER_SNORM;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_RGBA8888_REV:
+ format = COLOR_8_8_8_8;
+ comp_swap = SWAP_STD;
+ number_type = NUMBER_UNORM;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_SIGNED_RGBA8888_REV:
+ format = COLOR_8_8_8_8;
+ comp_swap = SWAP_STD;
+ number_type = NUMBER_SNORM;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_ARGB8888:
+ case MESA_FORMAT_XRGB8888:
+ format = COLOR_8_8_8_8;
+ comp_swap = SWAP_ALT;
+ number_type = NUMBER_UNORM;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_ARGB8888_REV:
+ case MESA_FORMAT_XRGB8888_REV:
+ format = COLOR_8_8_8_8;
+ comp_swap = SWAP_ALT_REV;
+ number_type = NUMBER_UNORM;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_RGB565:
+ format = COLOR_5_6_5;
+ comp_swap = SWAP_STD_REV;
+ number_type = NUMBER_UNORM;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_RGB565_REV:
+ format = COLOR_5_6_5;
+ comp_swap = SWAP_STD;
+ number_type = NUMBER_UNORM;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_ARGB4444:
+ format = COLOR_4_4_4_4;
+ comp_swap = SWAP_ALT;
+ number_type = NUMBER_UNORM;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_ARGB4444_REV:
+ format = COLOR_4_4_4_4;
+ comp_swap = SWAP_ALT_REV;
+ number_type = NUMBER_UNORM;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_ARGB1555:
+ format = COLOR_1_5_5_5;
+ comp_swap = SWAP_ALT;
+ number_type = NUMBER_UNORM;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_ARGB1555_REV:
+ format = COLOR_1_5_5_5;
+ comp_swap = SWAP_ALT_REV;
+ number_type = NUMBER_UNORM;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_AL88:
+ format = COLOR_8_8;
+ comp_swap = SWAP_STD;
+ number_type = NUMBER_UNORM;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_AL88_REV:
+ format = COLOR_8_8;
+ comp_swap = SWAP_STD_REV;
+ number_type = NUMBER_UNORM;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_RGB332:
+ format = COLOR_3_3_2;
+ comp_swap = SWAP_STD_REV;
+ number_type = NUMBER_UNORM;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_A8:
+ format = COLOR_8;
+ comp_swap = SWAP_ALT_REV;
+ number_type = NUMBER_UNORM;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_I8:
+ case MESA_FORMAT_CI8:
+ format = COLOR_8;
+ comp_swap = SWAP_STD;
+ number_type = NUMBER_UNORM;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_L8:
+ format = COLOR_8;
+ comp_swap = SWAP_ALT;
+ number_type = NUMBER_UNORM;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_RGBA_FLOAT32:
+ format = COLOR_32_32_32_32_FLOAT;
+ comp_swap = SWAP_STD_REV;
+ number_type = NUMBER_FLOAT;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, BLEND_FLOAT32_bit);
+ CLEARbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_RGBA_FLOAT16:
+ format = COLOR_16_16_16_16_FLOAT;
+ comp_swap = SWAP_STD_REV;
+ number_type = NUMBER_FLOAT;
+ CLEARbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_ALPHA_FLOAT32:
+ format = COLOR_32_FLOAT;
+ comp_swap = SWAP_ALT_REV;
+ number_type = NUMBER_FLOAT;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, BLEND_FLOAT32_bit);
+ CLEARbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_ALPHA_FLOAT16:
+ format = COLOR_16_FLOAT;
+ comp_swap = SWAP_ALT_REV;
+ number_type = NUMBER_FLOAT;
+ CLEARbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_LUMINANCE_FLOAT32:
+ format = COLOR_32_FLOAT;
+ comp_swap = SWAP_ALT;
+ number_type = NUMBER_FLOAT;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, BLEND_FLOAT32_bit);
+ CLEARbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_LUMINANCE_FLOAT16:
+ format = COLOR_16_FLOAT;
+ comp_swap = SWAP_ALT;
+ number_type = NUMBER_FLOAT;
+ CLEARbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
+ format = COLOR_32_32_FLOAT;
+ comp_swap = SWAP_ALT_REV;
+ number_type = NUMBER_FLOAT;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, BLEND_FLOAT32_bit);
+ CLEARbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16:
+ format = COLOR_16_16_FLOAT;
+ comp_swap = SWAP_ALT_REV;
+ number_type = NUMBER_FLOAT;
+ CLEARbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_INTENSITY_FLOAT32: /* X, X, X, X */
+ format = COLOR_32_FLOAT;
+ comp_swap = SWAP_STD;
+ number_type = NUMBER_FLOAT;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, BLEND_FLOAT32_bit);
+ CLEARbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_INTENSITY_FLOAT16: /* X, X, X, X */
+ format = COLOR_16_FLOAT;
+ comp_swap = SWAP_STD;
+ number_type = NUMBER_UNORM;
+ CLEARbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_X8_Z24:
+ case MESA_FORMAT_S8_Z24:
+ format = COLOR_8_24;
+ comp_swap = SWAP_STD;
+ number_type = NUMBER_UNORM;
+ SETfield(r700->render_target[id].CB_COLOR0_INFO.u32All, ARRAY_1D_TILED_THIN1,
+ CB_COLOR0_INFO__ARRAY_MODE_shift, CB_COLOR0_INFO__ARRAY_MODE_mask);
+ CLEARbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_Z24_S8:
+ format = COLOR_24_8;
+ comp_swap = SWAP_STD;
+ number_type = NUMBER_UNORM;
+ SETfield(r700->render_target[id].CB_COLOR0_INFO.u32All, ARRAY_1D_TILED_THIN1,
+ CB_COLOR0_INFO__ARRAY_MODE_shift, CB_COLOR0_INFO__ARRAY_MODE_mask);
+ CLEARbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_Z16:
+ format = COLOR_16;
+ comp_swap = SWAP_STD;
+ number_type = NUMBER_UNORM;
+ SETfield(r700->render_target[id].CB_COLOR0_INFO.u32All, ARRAY_1D_TILED_THIN1,
+ CB_COLOR0_INFO__ARRAY_MODE_shift, CB_COLOR0_INFO__ARRAY_MODE_mask);
+ CLEARbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_Z32:
+ format = COLOR_32;
+ comp_swap = SWAP_STD;
+ number_type = NUMBER_UNORM;
+ SETfield(r700->render_target[id].CB_COLOR0_INFO.u32All, ARRAY_1D_TILED_THIN1,
+ CB_COLOR0_INFO__ARRAY_MODE_shift, CB_COLOR0_INFO__ARRAY_MODE_mask);
+ CLEARbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_SRGBA8:
+ format = COLOR_8_8_8_8;
+ comp_swap = SWAP_STD_REV;
+ number_type = NUMBER_SRGB;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_SLA8:
+ format = COLOR_8_8;
+ comp_swap = SWAP_ALT_REV;
+ number_type = NUMBER_SRGB;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ case MESA_FORMAT_SL8:
+ format = COLOR_8;
+ comp_swap = SWAP_ALT_REV;
+ number_type = NUMBER_SRGB;
+ SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+ break;
+ default:
+ _mesa_problem(context->radeon.glCtx, "unexpected format in r700SetRenderTarget()");
+ break;
}
- SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, SOURCE_FORMAT_bit);
+
+ /* must be 0 on r7xx */
+ if (context->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV770)
+ CLEARbit(r700->render_target[id].CB_COLOR0_INFO.u32All, BLEND_FLOAT32_bit);
+
+ SETfield(r700->render_target[id].CB_COLOR0_INFO.u32All, format,
+ CB_COLOR0_INFO__FORMAT_shift, CB_COLOR0_INFO__FORMAT_mask);
+ SETfield(r700->render_target[id].CB_COLOR0_INFO.u32All, comp_swap,
+ COMP_SWAP_shift, COMP_SWAP_mask);
+ SETfield(r700->render_target[id].CB_COLOR0_INFO.u32All, number_type,
+ NUMBER_TYPE_shift, NUMBER_TYPE_mask);
SETbit(r700->render_target[id].CB_COLOR0_INFO.u32All, BLEND_CLAMP_bit);
- SETfield(r700->render_target[id].CB_COLOR0_INFO.u32All, NUMBER_UNORM, NUMBER_TYPE_shift, NUMBER_TYPE_mask);
r700->render_target[id].enabled = GL_TRUE;
}
diff --git a/src/mesa/drivers/dri/r600/r700_fragprog.c b/src/mesa/drivers/dri/r600/r700_fragprog.c
index 84d51e6606..ee4d2828cf 100644
--- a/src/mesa/drivers/dri/r600/r700_fragprog.c
+++ b/src/mesa/drivers/dri/r600/r700_fragprog.c
@@ -560,21 +560,22 @@ GLboolean r700SetupFragmentProgram(GLcontext * ctx)
CLEARbit(r700->SPI_PS_IN_CONTROL_1.u32All, FRONT_FACE_ENA_bit);
}
- /* see if we need any point_sprite replacements */
- for (i = VERT_RESULT_TEX0; i<= VERT_RESULT_TEX7; i++)
+ /* see if we need any point_sprite replacements, also increase num_interp
+ * as there's no vp output for them */
+ for (i = FRAG_ATTRIB_TEX0; i<= FRAG_ATTRIB_TEX7; i++)
{
- if(ctx->Point.CoordReplace[i - VERT_RESULT_TEX0] == GL_TRUE)
+ if(ctx->Point.CoordReplace[i - FRAG_ATTRIB_TEX0] == GL_TRUE) {
+ ui++;
point_sprite = GL_TRUE;
+ }
}
+ if( mesa_fp->Base.InputsRead & (1 << FRAG_ATTRIB_PNTC))
+ ui++;
+
if ((mesa_fp->Base.InputsRead & (1 << FRAG_ATTRIB_PNTC)) || point_sprite)
{
- /* for FRAG_ATTRIB_PNTC we need to increase num_interp */
- if(mesa_fp->Base.InputsRead & (1 << FRAG_ATTRIB_PNTC))
- {
- ui++;
- SETfield(r700->SPI_PS_IN_CONTROL_0.u32All, ui, NUM_INTERP_shift, NUM_INTERP_mask);
- }
+ SETfield(r700->SPI_PS_IN_CONTROL_0.u32All, ui, NUM_INTERP_shift, NUM_INTERP_mask);
SETbit(r700->SPI_INTERP_CONTROL_0.u32All, PNT_SPRITE_ENA_bit);
SETfield(r700->SPI_INTERP_CONTROL_0.u32All, SPI_PNT_SPRITE_SEL_S, PNT_SPRITE_OVRD_X_shift, PNT_SPRITE_OVRD_X_mask);
SETfield(r700->SPI_INTERP_CONTROL_0.u32All, SPI_PNT_SPRITE_SEL_T, PNT_SPRITE_OVRD_Y_shift, PNT_SPRITE_OVRD_Y_mask);
@@ -669,7 +670,7 @@ GLboolean r700SetupFragmentProgram(GLcontext * ctx)
for(i=0; i<8; i++)
{
unBit = 1 << (VERT_RESULT_TEX0 + i);
- if(OutputsWritten & unBit)
+ if((OutputsWritten & unBit) || (ctx->Point.CoordReplace[i] == GL_TRUE))
{
ui = pAsm->uiFP_AttributeMap[FRAG_ATTRIB_TEX0 + i];
SETbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, SEL_CENTROID_bit);
diff --git a/src/mesa/drivers/dri/r600/r700_state.c b/src/mesa/drivers/dri/r600/r700_state.c
index 1da31e7b2b..ac64bbf874 100644
--- a/src/mesa/drivers/dri/r600/r700_state.c
+++ b/src/mesa/drivers/dri/r600/r700_state.c
@@ -253,12 +253,15 @@ void r700UpdateShaderStates(GLcontext * ctx)
static void r700SetDepthState(GLcontext * ctx)
{
+ struct radeon_renderbuffer *rrb;
context_t *context = R700_CONTEXT(ctx);
R700_CHIP_CONTEXT *r700 = (R700_CHIP_CONTEXT*)(&context->hw);
R600_STATECHANGE(context, db);
- if (ctx->Depth.Test)
+ rrb = radeon_get_depthbuffer(&context->radeon);
+
+ if (ctx->Depth.Test && rrb && rrb->bo)
{
SETbit(r700->DB_DEPTH_CONTROL.u32All, Z_ENABLE_bit);
if (ctx->Depth.Mask)
diff --git a/src/mesa/drivers/dri/r600/r700_vertprog.c b/src/mesa/drivers/dri/r600/r700_vertprog.c
index 05c65164d6..14dd2a5482 100644
--- a/src/mesa/drivers/dri/r600/r700_vertprog.c
+++ b/src/mesa/drivers/dri/r600/r700_vertprog.c
@@ -628,6 +628,16 @@ GLboolean r700SetupVertexProgram(GLcontext * ctx)
R600_STATECHANGE(context, spi);
+ if(vp->mesa_program->Base.OutputsWritten & (1 << VERT_RESULT_PSIZ)) {
+ R600_STATECHANGE(context, cl);
+ SETbit(r700->PA_CL_VS_OUT_CNTL.u32All, USE_VTX_POINT_SIZE_bit);
+ SETbit(r700->PA_CL_VS_OUT_CNTL.u32All, VS_OUT_MISC_VEC_ENA_bit);
+ } else if (r700->PA_CL_VS_OUT_CNTL.u32All != 0) {
+ R600_STATECHANGE(context, cl);
+ CLEARbit(r700->PA_CL_VS_OUT_CNTL.u32All, USE_VTX_POINT_SIZE_bit);
+ CLEARbit(r700->PA_CL_VS_OUT_CNTL.u32All, VS_OUT_MISC_VEC_ENA_bit);
+ }
+
SETfield(r700->SPI_VS_OUT_CONFIG.u32All,
vp->r700Shader.nParamExports ? (vp->r700Shader.nParamExports - 1) : 0,
VS_EXPORT_COUNT_shift, VS_EXPORT_COUNT_mask);
diff --git a/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c b/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c
index cf12664bac..78f73bf99c 100644
--- a/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c
+++ b/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c
@@ -618,8 +618,7 @@ static int bo_vram_validate(struct radeon_bo_int *bo,
assert(bo_legacy->tobj->base.memBlock);
- if (bo_legacy->tobj)
- driUpdateTextureLRU(&bo_legacy->tobj->base);
+ driUpdateTextureLRU(&bo_legacy->tobj->base);
if (bo_legacy->dirty || bo_legacy->tobj->base.dirty_images[0]) {
if (IS_R600_CLASS(boml->screen)) {
diff --git a/src/mesa/drivers/dri/radeon/radeon_queryobj.c b/src/mesa/drivers/dri/radeon/radeon_queryobj.c
index 04ce12493e..ab6d02e56b 100644
--- a/src/mesa/drivers/dri/radeon/radeon_queryobj.c
+++ b/src/mesa/drivers/dri/radeon/radeon_queryobj.c
@@ -31,6 +31,8 @@
#include "main/imports.h"
#include "main/simple_list.h"
+#include <inttypes.h>
+
static void radeonQueryGetResult(GLcontext *ctx, struct gl_query_object *q)
{
radeonContextPtr radeon = RADEON_CONTEXT(ctx);
@@ -65,7 +67,7 @@ static void radeonQueryGetResult(GLcontext *ctx, struct gl_query_object *q)
}
radeon_print(RADEON_STATE, RADEON_TRACE,
- "%d start: %llx, end: %llx %lld\n", i, start, end, end - start);
+ "%d start: %" PRIu64 ", end: %" PRIu64 " %" PRIu64 "\n", i, start, end, end - start);
}
} else {
for (i = 0; i < query->curr_offset/sizeof(uint32_t); ++i) {
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c
index fca0f8173b..4f59511a52 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -1137,6 +1137,7 @@ radeonCreateScreen( __DRIscreen *sPriv )
/* pipe overrides */
switch (dri_priv->deviceID) {
case PCI_CHIP_R300_AD: /* 9500 with 1 quadpipe verified by: Reid Linnemann <lreid@cs.okstate.edu> */
+ case PCI_CHIP_R350_AH: /* 9800 SE only have 1 quadpipe */
case PCI_CHIP_RV410_5E4C: /* RV410 SE only have 1 quadpipe */
case PCI_CHIP_RV410_5E4F: /* RV410 SE only have 1 quadpipe */
screen->num_gb_pipes = 1;
@@ -1235,6 +1236,8 @@ radeonCreateScreen( __DRIscreen *sPriv )
screen->extensions[i++] = &r600texOffsetExtension.base;
#endif
+ screen->extensions[i++] = &dri2ConfigQueryExtension.base;
+
screen->extensions[i++] = NULL;
sPriv->extensions = screen->extensions;
@@ -1344,6 +1347,7 @@ radeonCreateScreen2(__DRIscreen *sPriv)
/* pipe overrides */
switch (device_id) {
case PCI_CHIP_R300_AD: /* 9500 with 1 quadpipe verified by: Reid Linnemann <lreid@cs.okstate.edu> */
+ case PCI_CHIP_R350_AH: /* 9800 SE only have 1 quadpipe */
case PCI_CHIP_RV410_5E4C: /* RV410 SE only have 1 quadpipe */
case PCI_CHIP_RV410_5E4F: /* RV410 SE only have 1 quadpipe */
screen->num_gb_pipes = 1;
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.h b/src/mesa/drivers/dri/radeon/radeon_screen.h
index 5e6d432e11..0d7e335fa3 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.h
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.h
@@ -105,7 +105,7 @@ typedef struct radeon_screen {
/* Configuration cache with default values for all contexts */
driOptionCache optionCache;
- const __DRIextension *extensions[16];
+ const __DRIextension *extensions[17];
int num_gb_pipes;
int num_z_pipes;
diff --git a/src/mesa/glapi/gen/ARB_seamless_cube_map.xml b/src/mesa/glapi/gen/ARB_seamless_cube_map.xml
index 3cdc84d2b9..8dc827c5a8 100644
--- a/src/mesa/glapi/gen/ARB_seamless_cube_map.xml
+++ b/src/mesa/glapi/gen/ARB_seamless_cube_map.xml
@@ -3,7 +3,7 @@
<OpenGLAPI>
-<category name="GL_ARB_seamless_cubemap" number="65">
+<category name="GL_ARB_seamless_cube_map" number="65">
<enum name="TEXTURE_CUBE_MAP_SEAMLESS" count="1" value="0x88F4">
<size name="Get" mode="get"/>
</enum>
diff --git a/src/mesa/glapi/glapi_getproc.c b/src/mesa/glapi/glapi_getproc.c
index c73e8dd3b0..ec96ab36f0 100644
--- a/src/mesa/glapi/glapi_getproc.c
+++ b/src/mesa/glapi/glapi_getproc.c
@@ -265,7 +265,8 @@ str_dup(const char *str)
copy = (char*) malloc(strlen(str) + 1);
if (!copy)
return NULL;
- strcpy(copy, str);
+ strncpy(copy, str, strlen(str));
+ copy[strlen(str)] = '\0';
return copy;
}
diff --git a/src/mesa/glapi/glapi_nop.c b/src/mesa/glapi/glapi_nop.c
index df9c587284..4257b1fbce 100644
--- a/src/mesa/glapi/glapi_nop.c
+++ b/src/mesa/glapi/glapi_nop.c
@@ -48,6 +48,26 @@
#include "glapi/glapi.h"
+
+/*
+ * These stubs are kept so that the old DRI drivers still load.
+ */
+PUBLIC void
+_glapi_noop_enable_warnings(GLboolean enable);
+
+PUBLIC void
+_glapi_set_warning_func(_glapi_proc func);
+
+void
+_glapi_noop_enable_warnings(GLboolean enable)
+{
+}
+
+void
+_glapi_set_warning_func(_glapi_proc func)
+{
+}
+
#ifdef DEBUG
/**
diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c
index 9bcfc1008a..526145aecc 100644
--- a/src/mesa/main/debug.c
+++ b/src/mesa/main/debug.c
@@ -315,7 +315,7 @@ write_texture_image(struct gl_texture_object *texObj,
buffer, texObj, img);
/* make filename */
- sprintf(s, "/tmp/tex%u.l%u.f%u.ppm", texObj->Name, level, face);
+ _mesa_snprintf(s, sizeof(s), "/tmp/tex%u.l%u.f%u.ppm", texObj->Name, level, face);
printf(" Writing image level %u to %s\n", level, s);
write_ppm(s, buffer, img->Width, img->Height, 4, 0, 1, 2, GL_FALSE);
@@ -357,7 +357,7 @@ write_renderbuffer_image(const struct gl_renderbuffer *rb)
format, type, &ctx->DefaultPacking, buffer);
/* make filename */
- sprintf(s, "/tmp/renderbuffer%u.ppm", rb->Name);
+ _mesa_snprintf(s, sizeof(s), "/tmp/renderbuffer%u.ppm", rb->Name);
printf(" Writing renderbuffer image to %s\n", s);
write_ppm(s, buffer, rb->Width, rb->Height, 4, 0, 1, 2, GL_TRUE);
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 168c424ea1..3f093cb697 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -7725,7 +7725,7 @@ execute_list(GLcontext *ctx, GLuint list)
default:
{
char msg[1000];
- sprintf(msg, "Error in execute_list: opcode=%d",
+ _mesa_snprintf(msg, sizeof(msg), "Error in execute_list: opcode=%d",
(int) opcode);
_mesa_problem(ctx, msg);
}
diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c
index 162a7b9526..13705b9f67 100644
--- a/src/mesa/main/enums.c
+++ b/src/mesa/main/enums.c
@@ -5581,7 +5581,7 @@ const char *_mesa_lookup_enum_by_nr( int nr )
}
else {
/* this is not re-entrant safe, no big deal here */
- sprintf(token_tmp, "0x%x", nr);
+ _mesa_snprintf(token_tmp, sizeof(token_tmp), "0x%x", nr);
return token_tmp;
}
}
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index d0c9c0028b..b9796e4a42 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -637,6 +637,35 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
0, 0, 0, 0, 0,
1, 1, 2
},
+
+ /* Signed 8 bits / channel */
+ {
+ MESA_FORMAT_SIGNED_R8, /* Name */
+ "MESA_FORMAT_SIGNED_R8", /* StrName */
+ GL_RGBA, /* BaseFormat */
+ GL_SIGNED_NORMALIZED, /* DataType */
+ 8, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
+ 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
+ 1, 1, 1 /* BlockWidth/Height,Bytes */
+ },
+ {
+ MESA_FORMAT_SIGNED_RG88,
+ "MESA_FORMAT_SIGNED_RG88",
+ GL_RGBA,
+ GL_SIGNED_NORMALIZED,
+ 8, 8, 0, 0,
+ 0, 0, 0, 0, 0,
+ 1, 1, 2
+ },
+ {
+ MESA_FORMAT_SIGNED_RGBX8888,
+ "MESA_FORMAT_SIGNED_RGBX8888",
+ GL_RGBA,
+ GL_SIGNED_NORMALIZED,
+ 8, 8, 8, 0,
+ 0, 0, 0, 0, 0,
+ 1, 1, 4 /* 4 bpp, but no alpha */
+ },
{
MESA_FORMAT_SIGNED_RGBA8888,
"MESA_FORMAT_SIGNED_RGBA8888",
@@ -655,6 +684,35 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
0, 0, 0, 0, 0,
1, 1, 4
},
+
+ /* Signed 16 bits / channel */
+ {
+ MESA_FORMAT_SIGNED_R_16,
+ "MESA_FORMAT_SIGNED_R_16",
+ GL_RGBA,
+ GL_SIGNED_NORMALIZED,
+ 16, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 1, 1, 2
+ },
+ {
+ MESA_FORMAT_SIGNED_RG_16,
+ "MESA_FORMAT_SIGNED_RG_16",
+ GL_RGBA,
+ GL_SIGNED_NORMALIZED,
+ 16, 16, 0, 0,
+ 0, 0, 0, 0, 0,
+ 1, 1, 4
+ },
+ {
+ MESA_FORMAT_SIGNED_RGB_16,
+ "MESA_FORMAT_SIGNED_RGB_16",
+ GL_RGBA,
+ GL_SIGNED_NORMALIZED,
+ 16, 16, 16, 0,
+ 0, 0, 0, 0, 0,
+ 1, 1, 6
+ },
{
MESA_FORMAT_SIGNED_RGBA_16,
"MESA_FORMAT_SIGNED_RGBA_16",
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index 0eeeb8b2ba..97e1fc5df4 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -130,13 +130,21 @@ typedef enum
MESA_FORMAT_INTENSITY_FLOAT16,
/*@}*/
+ /* msb <------ TEXEL BITS -----------> lsb */
+ /* ---- ---- ---- ---- ---- ---- ---- ---- */
/**
* \name Signed fixed point texture formats.
*/
/*@{*/
- MESA_FORMAT_DUDV8,
- MESA_FORMAT_SIGNED_RGBA8888,
- MESA_FORMAT_SIGNED_RGBA8888_REV,
+ MESA_FORMAT_DUDV8, /* DUDU DUDU DVDV DVDV */
+ MESA_FORMAT_SIGNED_R8, /* RRRR RRRR */
+ MESA_FORMAT_SIGNED_RG88, /* RRRR RRRR GGGG GGGG */
+ MESA_FORMAT_SIGNED_RGBX8888, /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */
+ MESA_FORMAT_SIGNED_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
+ MESA_FORMAT_SIGNED_RGBA8888_REV,/*AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
+ MESA_FORMAT_SIGNED_R_16,
+ MESA_FORMAT_SIGNED_RG_16,
+ MESA_FORMAT_SIGNED_RGB_16,
MESA_FORMAT_SIGNED_RGBA_16,
/*@}*/
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 5a654e5c2a..31689c8fe8 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -35,6 +35,7 @@
#include "buffers.h"
#include "context.h"
#include "depthstencil.h"
+#include "enums.h"
#include "formats.h"
#include "macros.h"
#include "mtypes.h"
@@ -1019,3 +1020,43 @@ _mesa_get_color_read_type(GLcontext *ctx)
return GL_UNSIGNED_BYTE;
}
}
+
+
+/**
+ * Print framebuffer info to stderr, for debugging.
+ */
+void
+_mesa_print_framebuffer(const struct gl_framebuffer *fb)
+{
+ GLuint i;
+
+ fprintf(stderr, "Mesa Framebuffer %u at %p\n", fb->Name, (void *) fb);
+ fprintf(stderr, " Size: %u x %u Status: %s\n", fb->Width, fb->Height,
+ _mesa_lookup_enum_by_nr(fb->_Status));
+ fprintf(stderr, " Attachments:\n");
+
+ for (i = 0; i < BUFFER_COUNT; i++) {
+ const struct gl_renderbuffer_attachment *att = &fb->Attachment[i];
+ if (att->Type == GL_TEXTURE) {
+ const struct gl_texture_image *texImage;
+ fprintf(stderr,
+ " %2d: Texture %u, level %u, face %u, slice %u, complete %d\n",
+ i, att->Texture->Name, att->TextureLevel, att->CubeMapFace,
+ att->Zoffset, att->Complete);
+ texImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
+ fprintf(stderr, " Size: %u x %u x %u Format %s\n",
+ texImage->Width, texImage->Height, texImage->Depth,
+ _mesa_get_format_name(texImage->TexFormat));
+ }
+ else if (att->Type == GL_RENDERBUFFER) {
+ fprintf(stderr, " %2d: Renderbuffer %u, complete %d\n",
+ i, att->Renderbuffer->Name, att->Complete);
+ fprintf(stderr, " Size: %u x %u Format %s\n",
+ att->Renderbuffer->Width, att->Renderbuffer->Height,
+ _mesa_get_format_name(att->Renderbuffer->Format));
+ }
+ else {
+ fprintf(stderr, " %2d: none\n", i);
+ }
+ }
+}
diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h
index 960513812c..1b6e3b1f0c 100644
--- a/src/mesa/main/framebuffer.h
+++ b/src/mesa/main/framebuffer.h
@@ -91,4 +91,7 @@ _mesa_get_color_read_type(GLcontext *ctx);
extern GLenum
_mesa_get_color_read_format(GLcontext *ctx);
+extern void
+_mesa_print_framebuffer(const struct gl_framebuffer *fb);
+
#endif /* FRAMEBUFFER_H */
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index dc8d97728b..93b01423dc 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -734,6 +734,32 @@ _mesa_is_depthstencil_format(GLenum format)
}
}
+
+/**
+ * Test if the given image format is a depth or stencil format.
+ */
+GLboolean
+_mesa_is_depth_or_stencil_format(GLenum format)
+{
+ switch (format) {
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT16:
+ case GL_DEPTH_COMPONENT24:
+ case GL_DEPTH_COMPONENT32:
+ case GL_STENCIL_INDEX:
+ case GL_STENCIL_INDEX1_EXT:
+ case GL_STENCIL_INDEX4_EXT:
+ case GL_STENCIL_INDEX8_EXT:
+ case GL_STENCIL_INDEX16_EXT:
+ case GL_DEPTH_STENCIL_EXT:
+ case GL_DEPTH24_STENCIL8_EXT:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
/**
* Test if the given image format is a dudv format.
*/
@@ -751,6 +777,40 @@ _mesa_is_dudv_format(GLenum format)
/**
+ * Test if an image format is a supported compressed format.
+ * \param format the internal format token provided by the user.
+ * \return GL_TRUE if compressed, GL_FALSE if uncompressed
+ */
+GLboolean
+_mesa_is_compressed_format(GLcontext *ctx, GLenum format)
+{
+ switch (format) {
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ return ctx->Extensions.EXT_texture_compression_s3tc;
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ return ctx->Extensions.S3_s3tc;
+ case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
+ return ctx->Extensions.EXT_texture_sRGB
+ && ctx->Extensions.EXT_texture_compression_s3tc;
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ return ctx->Extensions.TDFX_texture_compression_FXT1;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
* Return the address of a specific pixel in an image (1D, 2D or 3D).
*
* Pixel unpacking/packing parameters are observed according to \p packing.
diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h
index 9b34be0dfa..48582eb3bb 100644
--- a/src/mesa/main/image.h
+++ b/src/mesa/main/image.h
@@ -73,8 +73,13 @@ extern GLboolean
_mesa_is_depthstencil_format(GLenum format);
extern GLboolean
+_mesa_is_depth_or_stencil_format(GLenum format);
+
+extern GLboolean
_mesa_is_dudv_format(GLenum format);
+extern GLboolean
+_mesa_is_compressed_format(GLcontext *ctx, GLenum format);
extern GLvoid *
_mesa_image_address( GLuint dimensions,
diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index 51f7edfab1..c0c29f7889 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -1581,7 +1581,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
struct gl_texture_image *dstImage;
GLint srcWidth, srcHeight, srcDepth;
GLint dstWidth, dstHeight, dstDepth;
- GLint border, bytesPerTexel;
+ GLint border;
GLboolean nextLevel;
/* get src image parameters */
@@ -1623,33 +1623,24 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
dstImage->FetchTexelc = srcImage->FetchTexelc;
dstImage->FetchTexelf = srcImage->FetchTexelf;
- /* Alloc new teximage data buffer.
- * Setup src and dest data pointers.
- */
- if (_mesa_is_format_compressed(dstImage->TexFormat)) {
- GLuint dstCompressedSize =
- _mesa_format_image_size(dstImage->TexFormat, dstImage->Width,
- dstImage->Height, dstImage->Depth);
- ASSERT(dstCompressedSize > 0);
-
- dstImage->Data = _mesa_alloc_texmemory(dstCompressedSize);
+ /* Alloc new teximage data buffer */
+ {
+ GLuint size = _mesa_format_image_size(dstImage->TexFormat,
+ dstWidth, dstHeight, dstDepth);
+ dstImage->Data = _mesa_alloc_texmemory(size);
if (!dstImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
return;
}
+ }
+
+ /* Setup src and dest data pointers */
+ if (_mesa_is_format_compressed(dstImage->TexFormat)) {
/* srcData and dstData are already set */
ASSERT(srcData);
ASSERT(dstData);
}
else {
- bytesPerTexel = _mesa_get_format_bytes(dstImage->TexFormat);
- ASSERT(dstWidth * dstHeight * dstDepth * bytesPerTexel > 0);
- dstImage->Data = _mesa_alloc_texmemory(dstWidth * dstHeight
- * dstDepth * bytesPerTexel);
- if (!dstImage->Data) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
- return;
- }
srcData = (const GLubyte *) srcImage->Data;
dstData = (GLubyte *) dstImage->Data;
}
diff --git a/src/mesa/main/shaders.c b/src/mesa/main/shaders.c
index f877320d69..863f878fea 100644
--- a/src/mesa/main/shaders.c
+++ b/src/mesa/main/shaders.c
@@ -485,7 +485,7 @@ _mesa_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count,
checksum = _mesa_str_checksum(source);
- sprintf(filename, "newshader_%d", checksum);
+ _mesa_snprintf(filename, sizeof(filename), "newshader_%d", checksum);
newSource = _mesa_read_shader(filename);
if (newSource) {
diff --git a/src/mesa/main/texfetch.c b/src/mesa/main/texfetch.c
index b37039429f..48a22c1945 100644
--- a/src/mesa/main/texfetch.c
+++ b/src/mesa/main/texfetch.c
@@ -115,7 +115,7 @@ static void store_null_texel(struct gl_texture_image *texImage,
* XXX this is somewhat temporary.
*/
static struct {
- GLuint Name;
+ gl_format Name;
FetchTexelFuncF Fetch1D;
FetchTexelFuncF Fetch2D;
FetchTexelFuncF Fetch3D;
@@ -124,222 +124,13 @@ static struct {
texfetch_funcs[MESA_FORMAT_COUNT] =
{
{
- MESA_FORMAT_SRGB8,
- fetch_texel_1d_srgb8,
- fetch_texel_2d_srgb8,
- fetch_texel_3d_srgb8,
- store_texel_srgb8
- },
- {
- MESA_FORMAT_SRGBA8,
- fetch_texel_1d_srgba8,
- fetch_texel_2d_srgba8,
- fetch_texel_3d_srgba8,
- store_texel_srgba8
- },
- {
- MESA_FORMAT_SARGB8,
- fetch_texel_1d_sargb8,
- fetch_texel_2d_sargb8,
- fetch_texel_3d_sargb8,
- store_texel_sargb8
- },
- {
- MESA_FORMAT_SL8,
- fetch_texel_1d_sl8,
- fetch_texel_2d_sl8,
- fetch_texel_3d_sl8,
- store_texel_sl8
- },
- {
- MESA_FORMAT_SLA8,
- fetch_texel_1d_sla8,
- fetch_texel_2d_sla8,
- fetch_texel_3d_sla8,
- store_texel_sla8
- },
- {
- MESA_FORMAT_RGB_FXT1,
- NULL,
- _mesa_fetch_texel_2d_f_rgb_fxt1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RGBA_FXT1,
- NULL,
- _mesa_fetch_texel_2d_f_rgba_fxt1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RGB_DXT1,
- NULL,
- _mesa_fetch_texel_2d_f_rgb_dxt1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RGBA_DXT1,
- NULL,
- _mesa_fetch_texel_2d_f_rgba_dxt1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RGBA_DXT3,
- NULL,
- _mesa_fetch_texel_2d_f_rgba_dxt3,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RGBA_DXT5,
- NULL,
- _mesa_fetch_texel_2d_f_rgba_dxt5,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_SRGB_DXT1,
- NULL,
- _mesa_fetch_texel_2d_f_srgb_dxt1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_SRGBA_DXT1,
- NULL,
- _mesa_fetch_texel_2d_f_srgba_dxt1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_SRGBA_DXT3,
- NULL,
- _mesa_fetch_texel_2d_f_srgba_dxt3,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_SRGBA_DXT5,
- NULL,
- _mesa_fetch_texel_2d_f_srgba_dxt5,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RGBA_FLOAT32,
- fetch_texel_1d_f_rgba_f32,
- fetch_texel_2d_f_rgba_f32,
- fetch_texel_3d_f_rgba_f32,
- store_texel_rgba_f32
- },
- {
- MESA_FORMAT_RGBA_FLOAT16,
- fetch_texel_1d_f_rgba_f16,
- fetch_texel_2d_f_rgba_f16,
- fetch_texel_3d_f_rgba_f16,
- store_texel_rgba_f16
- },
- {
- MESA_FORMAT_RGB_FLOAT32,
- fetch_texel_1d_f_rgb_f32,
- fetch_texel_2d_f_rgb_f32,
- fetch_texel_3d_f_rgb_f32,
- store_texel_rgb_f32
- },
- {
- MESA_FORMAT_RGB_FLOAT16,
- fetch_texel_1d_f_rgb_f16,
- fetch_texel_2d_f_rgb_f16,
- fetch_texel_3d_f_rgb_f16,
- store_texel_rgb_f16
- },
- {
- MESA_FORMAT_ALPHA_FLOAT32,
- fetch_texel_1d_f_alpha_f32,
- fetch_texel_2d_f_alpha_f32,
- fetch_texel_3d_f_alpha_f32,
- store_texel_alpha_f32
- },
- {
- MESA_FORMAT_ALPHA_FLOAT16,
- fetch_texel_1d_f_alpha_f16,
- fetch_texel_2d_f_alpha_f16,
- fetch_texel_3d_f_alpha_f16,
- store_texel_alpha_f16
- },
- {
- MESA_FORMAT_LUMINANCE_FLOAT32,
- fetch_texel_1d_f_luminance_f32,
- fetch_texel_2d_f_luminance_f32,
- fetch_texel_3d_f_luminance_f32,
- store_texel_luminance_f32
- },
- {
- MESA_FORMAT_LUMINANCE_FLOAT16,
- fetch_texel_1d_f_luminance_f16,
- fetch_texel_2d_f_luminance_f16,
- fetch_texel_3d_f_luminance_f16,
- store_texel_luminance_f16
- },
- {
- MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
- fetch_texel_1d_f_luminance_alpha_f32,
- fetch_texel_2d_f_luminance_alpha_f32,
- fetch_texel_3d_f_luminance_alpha_f32,
- store_texel_luminance_alpha_f32
- },
- {
- MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
- fetch_texel_1d_f_luminance_alpha_f16,
- fetch_texel_2d_f_luminance_alpha_f16,
- fetch_texel_3d_f_luminance_alpha_f16,
- store_texel_luminance_alpha_f16
- },
- {
- MESA_FORMAT_INTENSITY_FLOAT32,
- fetch_texel_1d_f_intensity_f32,
- fetch_texel_2d_f_intensity_f32,
- fetch_texel_3d_f_intensity_f32,
- store_texel_intensity_f32
- },
- {
- MESA_FORMAT_INTENSITY_FLOAT16,
- fetch_texel_1d_f_intensity_f16,
- fetch_texel_2d_f_intensity_f16,
- fetch_texel_3d_f_intensity_f16,
- store_texel_intensity_f16
- },
- {
- MESA_FORMAT_DUDV8,
- fetch_texel_1d_dudv8,
- fetch_texel_2d_dudv8,
- fetch_texel_3d_dudv8,
- NULL
- },
- {
- MESA_FORMAT_SIGNED_RGBA8888,
- fetch_texel_1d_signed_rgba8888,
- fetch_texel_2d_signed_rgba8888,
- fetch_texel_3d_signed_rgba8888,
- store_texel_signed_rgba8888
- },
- {
- MESA_FORMAT_SIGNED_RGBA8888_REV,
- fetch_texel_1d_signed_rgba8888_rev,
- fetch_texel_2d_signed_rgba8888_rev,
- fetch_texel_3d_signed_rgba8888_rev,
- store_texel_signed_rgba8888_rev
- },
- {
- MESA_FORMAT_SIGNED_RGBA_16,
- NULL, /* XXX to do */
- NULL,
- NULL,
- NULL
+ MESA_FORMAT_NONE,
+ fetch_null_texelf,
+ fetch_null_texelf,
+ fetch_null_texelf,
+ store_null_texel
},
+
{
MESA_FORMAT_RGBA8888,
fetch_texel_1d_f_rgba8888,
@@ -563,56 +354,313 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
fetch_texel_2d_f_z32,
fetch_texel_3d_f_z32,
store_texel_z32
- }
+ },
+ {
+ MESA_FORMAT_S8,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_SRGB8,
+ fetch_texel_1d_srgb8,
+ fetch_texel_2d_srgb8,
+ fetch_texel_3d_srgb8,
+ store_texel_srgb8
+ },
+ {
+ MESA_FORMAT_SRGBA8,
+ fetch_texel_1d_srgba8,
+ fetch_texel_2d_srgba8,
+ fetch_texel_3d_srgba8,
+ store_texel_srgba8
+ },
+ {
+ MESA_FORMAT_SARGB8,
+ fetch_texel_1d_sargb8,
+ fetch_texel_2d_sargb8,
+ fetch_texel_3d_sargb8,
+ store_texel_sargb8
+ },
+ {
+ MESA_FORMAT_SL8,
+ fetch_texel_1d_sl8,
+ fetch_texel_2d_sl8,
+ fetch_texel_3d_sl8,
+ store_texel_sl8
+ },
+ {
+ MESA_FORMAT_SLA8,
+ fetch_texel_1d_sla8,
+ fetch_texel_2d_sla8,
+ fetch_texel_3d_sla8,
+ store_texel_sla8
+ },
+ {
+ MESA_FORMAT_SRGB_DXT1,
+ NULL,
+ _mesa_fetch_texel_2d_f_srgb_dxt1,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_SRGBA_DXT1,
+ NULL,
+ _mesa_fetch_texel_2d_f_srgba_dxt1,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_SRGBA_DXT3,
+ NULL,
+ _mesa_fetch_texel_2d_f_srgba_dxt3,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_SRGBA_DXT5,
+ NULL,
+ _mesa_fetch_texel_2d_f_srgba_dxt5,
+ NULL,
+ NULL
+ },
+
+ {
+ MESA_FORMAT_RGB_FXT1,
+ NULL,
+ _mesa_fetch_texel_2d_f_rgb_fxt1,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_RGBA_FXT1,
+ NULL,
+ _mesa_fetch_texel_2d_f_rgba_fxt1,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_RGB_DXT1,
+ NULL,
+ _mesa_fetch_texel_2d_f_rgb_dxt1,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_RGBA_DXT1,
+ NULL,
+ _mesa_fetch_texel_2d_f_rgba_dxt1,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_RGBA_DXT3,
+ NULL,
+ _mesa_fetch_texel_2d_f_rgba_dxt3,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_RGBA_DXT5,
+ NULL,
+ _mesa_fetch_texel_2d_f_rgba_dxt5,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_RGBA_FLOAT32,
+ fetch_texel_1d_f_rgba_f32,
+ fetch_texel_2d_f_rgba_f32,
+ fetch_texel_3d_f_rgba_f32,
+ store_texel_rgba_f32
+ },
+ {
+ MESA_FORMAT_RGBA_FLOAT16,
+ fetch_texel_1d_f_rgba_f16,
+ fetch_texel_2d_f_rgba_f16,
+ fetch_texel_3d_f_rgba_f16,
+ store_texel_rgba_f16
+ },
+ {
+ MESA_FORMAT_RGB_FLOAT32,
+ fetch_texel_1d_f_rgb_f32,
+ fetch_texel_2d_f_rgb_f32,
+ fetch_texel_3d_f_rgb_f32,
+ store_texel_rgb_f32
+ },
+ {
+ MESA_FORMAT_RGB_FLOAT16,
+ fetch_texel_1d_f_rgb_f16,
+ fetch_texel_2d_f_rgb_f16,
+ fetch_texel_3d_f_rgb_f16,
+ store_texel_rgb_f16
+ },
+ {
+ MESA_FORMAT_ALPHA_FLOAT32,
+ fetch_texel_1d_f_alpha_f32,
+ fetch_texel_2d_f_alpha_f32,
+ fetch_texel_3d_f_alpha_f32,
+ store_texel_alpha_f32
+ },
+ {
+ MESA_FORMAT_ALPHA_FLOAT16,
+ fetch_texel_1d_f_alpha_f16,
+ fetch_texel_2d_f_alpha_f16,
+ fetch_texel_3d_f_alpha_f16,
+ store_texel_alpha_f16
+ },
+ {
+ MESA_FORMAT_LUMINANCE_FLOAT32,
+ fetch_texel_1d_f_luminance_f32,
+ fetch_texel_2d_f_luminance_f32,
+ fetch_texel_3d_f_luminance_f32,
+ store_texel_luminance_f32
+ },
+ {
+ MESA_FORMAT_LUMINANCE_FLOAT16,
+ fetch_texel_1d_f_luminance_f16,
+ fetch_texel_2d_f_luminance_f16,
+ fetch_texel_3d_f_luminance_f16,
+ store_texel_luminance_f16
+ },
+ {
+ MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
+ fetch_texel_1d_f_luminance_alpha_f32,
+ fetch_texel_2d_f_luminance_alpha_f32,
+ fetch_texel_3d_f_luminance_alpha_f32,
+ store_texel_luminance_alpha_f32
+ },
+ {
+ MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
+ fetch_texel_1d_f_luminance_alpha_f16,
+ fetch_texel_2d_f_luminance_alpha_f16,
+ fetch_texel_3d_f_luminance_alpha_f16,
+ store_texel_luminance_alpha_f16
+ },
+ {
+ MESA_FORMAT_INTENSITY_FLOAT32,
+ fetch_texel_1d_f_intensity_f32,
+ fetch_texel_2d_f_intensity_f32,
+ fetch_texel_3d_f_intensity_f32,
+ store_texel_intensity_f32
+ },
+ {
+ MESA_FORMAT_INTENSITY_FLOAT16,
+ fetch_texel_1d_f_intensity_f16,
+ fetch_texel_2d_f_intensity_f16,
+ fetch_texel_3d_f_intensity_f16,
+ store_texel_intensity_f16
+ },
+ {
+ MESA_FORMAT_DUDV8,
+ fetch_texel_1d_dudv8,
+ fetch_texel_2d_dudv8,
+ fetch_texel_3d_dudv8,
+ NULL
+ },
+ {
+ MESA_FORMAT_SIGNED_R8,
+ fetch_texel_1d_signed_r8,
+ fetch_texel_2d_signed_r8,
+ fetch_texel_3d_signed_r8,
+ store_texel_signed_r8
+ },
+ {
+ MESA_FORMAT_SIGNED_RG88,
+ fetch_texel_1d_signed_rg88,
+ fetch_texel_2d_signed_rg88,
+ fetch_texel_3d_signed_rg88,
+ store_texel_signed_rg88
+ },
+ {
+ MESA_FORMAT_SIGNED_RGBX8888,
+ fetch_texel_1d_signed_rgbx8888,
+ fetch_texel_2d_signed_rgbx8888,
+ fetch_texel_3d_signed_rgbx8888,
+ store_texel_signed_rgbx8888
+ },
+ {
+ MESA_FORMAT_SIGNED_RGBA8888,
+ fetch_texel_1d_signed_rgba8888,
+ fetch_texel_2d_signed_rgba8888,
+ fetch_texel_3d_signed_rgba8888,
+ store_texel_signed_rgba8888
+ },
+ {
+ MESA_FORMAT_SIGNED_RGBA8888_REV,
+ fetch_texel_1d_signed_rgba8888_rev,
+ fetch_texel_2d_signed_rgba8888_rev,
+ fetch_texel_3d_signed_rgba8888_rev,
+ store_texel_signed_rgba8888_rev
+ },
+ {
+ MESA_FORMAT_SIGNED_R_16,
+ fetch_texel_1d_signed_r_16,
+ fetch_texel_2d_signed_r_16,
+ fetch_texel_3d_signed_r_16,
+ store_texel_signed_r_16
+ },
+ {
+ MESA_FORMAT_SIGNED_RG_16,
+ fetch_texel_1d_signed_rg_16,
+ fetch_texel_2d_signed_rg_16,
+ fetch_texel_3d_signed_rg_16,
+ store_texel_signed_rg_16
+ },
+ {
+ MESA_FORMAT_SIGNED_RGB_16,
+ fetch_texel_1d_signed_rgb_16,
+ fetch_texel_2d_signed_rgb_16,
+ fetch_texel_3d_signed_rgb_16,
+ store_texel_signed_rgb_16
+ },
+ {
+ MESA_FORMAT_SIGNED_RGBA_16,
+ fetch_texel_1d_signed_rgba_16,
+ fetch_texel_2d_signed_rgba_16,
+ fetch_texel_3d_signed_rgba_16,
+ store_texel_signed_rgba_16
+ },
};
static FetchTexelFuncF
_mesa_get_texel_fetch_func(gl_format format, GLuint dims)
{
- FetchTexelFuncF f = NULL;
- GLuint i;
- /* XXX replace loop with direct table lookup */
- for (i = 0; i < MESA_FORMAT_COUNT; i++) {
- if (texfetch_funcs[i].Name == format) {
- switch (dims) {
- case 1:
- f = texfetch_funcs[i].Fetch1D;
- break;
- case 2:
- f = texfetch_funcs[i].Fetch2D;
- break;
- case 3:
- f = texfetch_funcs[i].Fetch3D;
- break;
- }
- if (!f)
- f = fetch_null_texelf;
- return f;
- }
+#ifdef DEBUG
+ /* check that the table entries are sorted by format name */
+ gl_format fmt;
+ for (fmt = 0; fmt < MESA_FORMAT_COUNT; fmt++) {
+ assert(texfetch_funcs[fmt].Name == fmt);
+ }
+#endif
+
+ assert(Elements(texfetch_funcs) == MESA_FORMAT_COUNT);
+ assert(format < MESA_FORMAT_COUNT);
+
+ switch (dims) {
+ case 1:
+ return texfetch_funcs[format].Fetch1D;
+ case 2:
+ return texfetch_funcs[format].Fetch2D;
+ case 3:
+ return texfetch_funcs[format].Fetch3D;
+ default:
+ assert(0 && "bad dims in _mesa_get_texel_fetch_func");
+ return NULL;
}
- return NULL;
}
StoreTexelFunc
_mesa_get_texel_store_func(gl_format format)
{
- GLuint i;
- /* XXX replace loop with direct table lookup */
- for (i = 0; i < MESA_FORMAT_COUNT; i++) {
- if (texfetch_funcs[i].Name == format) {
- if (texfetch_funcs[i].StoreTexel)
- return texfetch_funcs[i].StoreTexel;
- else
- return store_null_texel;
- }
- }
- return NULL;
+ assert(format < MESA_FORMAT_COUNT);
+ return texfetch_funcs[format].StoreTexel;
}
-
/**
* Adaptor for fetching a GLchan texel from a float-valued texture.
*/
diff --git a/src/mesa/main/texfetch_tmp.h b/src/mesa/main/texfetch_tmp.h
index e6772c89f3..4df2b19181 100644
--- a/src/mesa/main/texfetch_tmp.h
+++ b/src/mesa/main/texfetch_tmp.h
@@ -1209,16 +1209,86 @@ static void FETCH(dudv8)(const struct gl_texture_image *texImage,
texel[ACOMP] = 0;
}
+
+/* MESA_FORMAT_SIGNED_R8 ***********************************************/
+
+static void FETCH(signed_r8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
+ texel[RCOMP] = BYTE_TO_FLOAT_TEX( s );
+ texel[GCOMP] = 0.0F;
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_signed_r8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLbyte *rgba = (const GLbyte *) texel;
+ GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
+ *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RG88 ***********************************************/
+
+static void FETCH(signed_rg88)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+ texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
+ texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) );
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_signed_rg88(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLbyte *rg = (const GLbyte *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 2);
+ *dst = PACK_COLOR_88(rg[RCOMP], rg[GCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RGBX8888 ***********************************************/
+
+static void FETCH(signed_rgbx8888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
+ texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) );
+ texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
+ texel[ACOMP] = 1.0f;
+}
+
+#if DIM == 3
+static void store_texel_signed_rgbx8888(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLbyte *rgba = (const GLbyte *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], 255);
+}
+#endif
+
+
/* MESA_FORMAT_SIGNED_RGBA8888 ***********************************************/
static void FETCH(signed_rgba8888)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = BYTE_TO_FLOAT_TEX( (s >> 24) );
- texel[GCOMP] = BYTE_TO_FLOAT_TEX( (s >> 16) & 0xff );
- texel[BCOMP] = BYTE_TO_FLOAT_TEX( (s >> 8) & 0xff );
- texel[ACOMP] = BYTE_TO_FLOAT_TEX( (s ) & 0xff );
+ texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
+ texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) );
+ texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
+ texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s ) );
}
#if DIM == 3
@@ -1235,10 +1305,10 @@ static void FETCH(signed_rgba8888_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = BYTE_TO_FLOAT_TEX( (s ) & 0xff );
- texel[GCOMP] = BYTE_TO_FLOAT_TEX( (s >> 8) & 0xff );
- texel[BCOMP] = BYTE_TO_FLOAT_TEX( (s >> 16) & 0xff );
- texel[ACOMP] = BYTE_TO_FLOAT_TEX( (s >> 24) );
+ texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s ) );
+ texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
+ texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) );
+ texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
}
#if DIM == 3
@@ -1253,6 +1323,113 @@ static void store_texel_signed_rgba8888_rev(struct gl_texture_image *texImage,
+/* MESA_FORMAT_SIGNED_R_16 ***********************************************/
+
+static void
+FETCH(signed_r_16)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+ texel[RCOMP] = SHORT_TO_FLOAT_TEX( s );
+ texel[GCOMP] = 0.0F;
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void
+store_texel_signed_r_16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLshort *rgba = (const GLshort *) texel;
+ GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+ *dst = rgba[0];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RG_16 ***********************************************/
+
+static void
+FETCH(signed_rg_16)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
+ texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
+ texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] );
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void
+store_texel_signed_rg_16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLshort *rgba = (const GLshort *) texel;
+ GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RGB_16 ***********************************************/
+
+static void
+FETCH(signed_rgb_16)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 3);
+ texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
+ texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] );
+ texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[3] );
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void
+store_texel_signed_rgb_16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLshort *rgba = (const GLshort *) texel;
+ GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 3);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RGB_16 ***********************************************/
+
+static void
+FETCH(signed_rgba_16)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
+ texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
+ texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] );
+ texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[3] );
+ texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[4] );
+}
+
+#if DIM == 3
+static void
+store_texel_signed_rgba_16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLshort *rgba = (const GLshort *) texel;
+ GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+ dst[3] = rgba[ACOMP];
+}
+#endif
+
+
+
/* MESA_FORMAT_YCBCR *********************************************************/
/* Fetch texel from 1D, 2D or 3D ycbcr texture, return 4 GLfloats.
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index 096945a643..06e6fd92fc 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -294,6 +294,32 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
}
}
+ if (ctx->VersionMajor * 10 + ctx->VersionMinor >= 31) {
+ switch (internalFormat) {
+ case GL_RED_SNORM:
+ case GL_R8_SNORM:
+ return MESA_FORMAT_SIGNED_R8;
+ case GL_RG_SNORM:
+ case GL_RG8_SNORM:
+ return MESA_FORMAT_SIGNED_RG88;
+ case GL_RGB_SNORM:
+ case GL_RGB8_SNORM:
+ return MESA_FORMAT_SIGNED_RGBX8888;
+ case GL_RGBA_SNORM:
+ case GL_RGBA8_SNORM:
+ return MESA_FORMAT_SIGNED_RGBA8888;
+ case GL_R16_SNORM:
+ return MESA_FORMAT_SIGNED_R_16;
+ case GL_RG16_SNORM:
+ return MESA_FORMAT_SIGNED_RG_16;
+ case GL_RGB16_SNORM:
+ return MESA_FORMAT_SIGNED_RGB_16;
+ case GL_RGBA16_SNORM:
+ return MESA_FORMAT_SIGNED_RGBA_16;
+ default:
+ ; /* fall-through */
+ }
+ }
#if FEATURE_EXT_texture_sRGB
if (ctx->Extensions.EXT_texture_sRGB) {
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 0c583ed14d..0b55097bd6 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -359,34 +359,6 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat )
/**
- * Test if it is a supported compressed format.
- *
- * \param internalFormat the internal format token provided by the user.
- *
- * \ret GL_TRUE if \p internalFormat is a supported compressed format, or
- * GL_FALSE otherwise.
- *
- * Currently only GL_COMPRESSED_RGB_FXT1_3DFX and GL_COMPRESSED_RGBA_FXT1_3DFX
- * are supported.
- */
-static GLboolean
-is_compressed_format(GLcontext *ctx, GLenum internalFormat)
-{
- GLint supported[100]; /* 100 should be plenty */
- GLuint i, n;
-
- n = _mesa_get_compressed_formats(ctx, supported, GL_TRUE);
- ASSERT(n < 100);
- for (i = 0; i < n; i++) {
- if ((GLint) internalFormat == supported[i]) {
- return GL_TRUE;
- }
- }
- return GL_FALSE;
-}
-
-
-/**
* For cube map faces, return a face index in [0,5].
* For other targets return 0;
*/
@@ -1308,8 +1280,8 @@ texture_error_check( GLcontext *ctx, GLenum target,
if (type != GL_UNSIGNED_SHORT_8_8_MESA &&
type != GL_UNSIGNED_SHORT_8_8_REV_MESA) {
char message[100];
- sprintf(message,
- "glTexImage%d(format/type YCBCR mismatch", dimensions);
+ _mesa_snprintf(message, sizeof(message),
+ "glTexImage%d(format/type YCBCR mismatch", dimensions);
_mesa_error(ctx, GL_INVALID_ENUM, message);
return GL_TRUE; /* error */
}
@@ -1324,9 +1296,9 @@ texture_error_check( GLcontext *ctx, GLenum target,
if (border != 0) {
if (!isProxy) {
char message[100];
- sprintf(message,
- "glTexImage%d(format=GL_YCBCR_MESA and border=%d)",
- dimensions, border);
+ _mesa_snprintf(message, sizeof(message),
+ "glTexImage%d(format=GL_YCBCR_MESA and border=%d)",
+ dimensions, border);
_mesa_error(ctx, GL_INVALID_VALUE, message);
}
return GL_TRUE;
@@ -1350,7 +1322,7 @@ texture_error_check( GLcontext *ctx, GLenum target,
}
/* additional checks for compressed textures */
- if (is_compressed_format(ctx, internalFormat)) {
+ if (_mesa_is_compressed_format(ctx, internalFormat)) {
if (!target_can_be_compressed(ctx, target) && !isProxy) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glTexImage%d(target)", dimensions);
@@ -1716,7 +1688,7 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions,
return GL_TRUE;
}
- if (is_compressed_format(ctx, internalFormat)) {
+ if (_mesa_is_compressed_format(ctx, internalFormat)) {
if (!target_can_be_compressed(ctx, target)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glCopyTexImage%d(target)", dimensions);
@@ -3114,7 +3086,7 @@ compressed_texture_error_check(GLcontext *ctx, GLint dimensions,
maxTextureSize = 1 << (maxLevels - 1);
/* This will detect any invalid internalFormat value */
- if (!is_compressed_format(ctx, internalFormat))
+ if (!_mesa_is_compressed_format(ctx, internalFormat))
return GL_INVALID_ENUM;
/* This should really never fail */
@@ -3219,7 +3191,7 @@ compressed_subtexture_error_check(GLcontext *ctx, GLint dimensions,
maxTextureSize = 1 << (maxLevels - 1);
/* this will catch any invalid compressed format token */
- if (!is_compressed_format(ctx, format))
+ if (!_mesa_is_compressed_format(ctx, format))
return GL_INVALID_ENUM;
if (width < 1 || width > maxTextureSize)
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 2753b55c36..de37e34039 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -416,7 +416,7 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
*/
if ((baseLevel < 0) || (baseLevel >= MAX_TEXTURE_LEVELS)) {
char s[100];
- sprintf(s, "base level = %d is invalid", baseLevel);
+ _mesa_snprintf(s, sizeof(s), "base level = %d is invalid", baseLevel);
incomplete(t, s);
t->_Complete = GL_FALSE;
return;
@@ -425,7 +425,7 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
/* Always need the base level image */
if (!t->Image[0][baseLevel]) {
char s[100];
- sprintf(s, "Image[baseLevel=%d] == NULL", baseLevel);
+ _mesa_snprintf(s, sizeof(s), "Image[baseLevel=%d] == NULL", baseLevel);
incomplete(t, s);
t->_Complete = GL_FALSE;
return;
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 65e3fcaa95..94c0894de1 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -2551,6 +2551,147 @@ _mesa_texstore_dudv8(TEXSTORE_PARAMS)
return GL_TRUE;
}
+
+/**
+ * Store a texture in MESA_FORMAT_SIGNED_R8 format.
+ */
+static GLboolean
+_mesa_texstore_signed_r8(TEXSTORE_PARAMS)
+{
+ const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+ const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+
+ ASSERT(dstFormat == MESA_FORMAT_SIGNED_R8);
+ ASSERT(texelBytes == 1);
+
+ /* XXX look at adding optimized paths */
+ {
+ /* general path */
+ const GLfloat *tempImage = make_temp_float_image(ctx, dims,
+ baseInternalFormat,
+ baseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLfloat *srcRow = tempImage;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * texelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * texelBytes;
+ for (row = 0; row < srcHeight; row++) {
+ GLubyte *dstB = (GLubyte *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ dstB[col] = FLOAT_TO_BYTE_TEX(srcRow[RCOMP]);
+ }
+ dstRow += dstRowStride;
+ }
+ }
+ free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+/**
+ * Store a texture in MESA_FORMAT_SIGNED_RG88 format.
+ */
+static GLboolean
+_mesa_texstore_signed_rg88(TEXSTORE_PARAMS)
+{
+ const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+ const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+
+ ASSERT(dstFormat == MESA_FORMAT_SIGNED_RG88);
+ ASSERT(texelBytes == 1);
+
+ /* XXX look at adding optimized paths */
+ {
+ /* general path */
+ const GLfloat *tempImage = make_temp_float_image(ctx, dims,
+ baseInternalFormat,
+ baseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLfloat *srcRow = tempImage;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * texelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * texelBytes;
+ for (row = 0; row < srcHeight; row++) {
+ GLushort *dstUS = (GLushort *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_88(FLOAT_TO_BYTE_TEX(srcRow[RCOMP]),
+ FLOAT_TO_BYTE_TEX(srcRow[GCOMP]));
+ }
+ dstRow += dstRowStride;
+ }
+ }
+ free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+/**
+ * Store a texture in MESA_FORMAT_SIGNED_RGBX8888.
+ */
+static GLboolean
+_mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS)
+{
+ const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+ const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+
+ ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBX8888);
+ ASSERT(texelBytes == 4);
+
+ {
+ /* general path */
+ const GLfloat *tempImage = make_temp_float_image(ctx, dims,
+ baseInternalFormat,
+ baseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLfloat *srcRow = tempImage;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * texelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * texelBytes;
+ for (row = 0; row < srcHeight; row++) {
+ GLuint *dstUI = (GLuint *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ dstUI[col] = PACK_COLOR_8888( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]),
+ FLOAT_TO_BYTE_TEX(srcRow[GCOMP]),
+ FLOAT_TO_BYTE_TEX(srcRow[BCOMP]),
+ 0xff );
+ srcRow += 4;
+ }
+ dstRow += dstRowStride;
+ }
+ }
+ free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+
/**
* Store a texture in MESA_FORMAT_SIGNED_RGBA8888 or MESA_FORMAT_SIGNED_RGBA8888_REV
*/
@@ -2672,6 +2813,7 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
return GL_TRUE;
}
+
/**
* Store a combined depth/stencil texture image.
*/
@@ -3197,9 +3339,18 @@ texstore_funcs[MESA_FORMAT_COUNT] =
{ MESA_FORMAT_INTENSITY_FLOAT32, _mesa_texstore_rgba_float32 },
{ MESA_FORMAT_INTENSITY_FLOAT16, _mesa_texstore_rgba_float16 },
{ MESA_FORMAT_DUDV8, _mesa_texstore_dudv8 },
+
+ { MESA_FORMAT_SIGNED_R8, _mesa_texstore_signed_r8 },
+ { MESA_FORMAT_SIGNED_RG88, _mesa_texstore_signed_rg88 },
+ { MESA_FORMAT_SIGNED_RGBX8888, _mesa_texstore_signed_rgbx8888 },
+
{ MESA_FORMAT_SIGNED_RGBA8888, _mesa_texstore_signed_rgba8888 },
{ MESA_FORMAT_SIGNED_RGBA8888_REV, _mesa_texstore_signed_rgba8888 },
- { MESA_FORMAT_SIGNED_RGBA_16, NULL },
+
+ { MESA_FORMAT_SIGNED_R_16, NULL/*_mesa_texstore_signed_r16*/ },
+ { MESA_FORMAT_SIGNED_RG_16, NULL/*_mesa_texstore_signed_rg16*/ },
+ { MESA_FORMAT_SIGNED_RGB_16, NULL/*_mesa_texstore_signed_rgb16*/ },
+ { MESA_FORMAT_SIGNED_RGBA_16, NULL/*_mesa_texstore_signed_rgba16*/ },
};
diff --git a/src/mesa/shader/program_parse.tab.c b/src/mesa/shader/program_parse.tab.c
index e5ef25ec38..99c4b2baa5 100644
--- a/src/mesa/shader/program_parse.tab.c
+++ b/src/mesa/shader/program_parse.tab.c
@@ -5557,7 +5557,6 @@ make_error_string(const char *fmt, ...)
char *str;
va_list args;
- va_start(args, fmt);
/* Call vsnprintf once to determine how large the final string is. Call it
* again to do the actual formatting. from the vsnprintf manual page:
@@ -5566,15 +5565,17 @@ make_error_string(const char *fmt, ...)
* characters printed (not including the trailing '\0' used to end
* output to strings).
*/
+ va_start(args, fmt);
length = 1 + vsnprintf(NULL, 0, fmt, args);
+ va_end(args);
str = malloc(length);
if (str) {
+ va_start(args, fmt);
vsnprintf(str, length, fmt, args);
+ va_end(args);
}
- va_end(args);
-
return str;
}
diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y
index 299e2477e4..06c2db7a07 100644
--- a/src/mesa/shader/program_parse.y
+++ b/src/mesa/shader/program_parse.y
@@ -2596,7 +2596,6 @@ make_error_string(const char *fmt, ...)
char *str;
va_list args;
- va_start(args, fmt);
/* Call vsnprintf once to determine how large the final string is. Call it
* again to do the actual formatting. from the vsnprintf manual page:
@@ -2605,15 +2604,17 @@ make_error_string(const char *fmt, ...)
* characters printed (not including the trailing '\0' used to end
* output to strings).
*/
+ va_start(args, fmt);
length = 1 + vsnprintf(NULL, 0, fmt, args);
+ va_end(args);
str = malloc(length);
if (str) {
+ va_start(args, fmt);
vsnprintf(str, length, fmt, args);
+ va_end(args);
}
- va_end(args);
-
return str;
}
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index fa79632c18..27ac1da9ad 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -1560,7 +1560,7 @@ _slang_gen_function_call(slang_assemble_ctx *A, slang_function *fun,
char name[200];
prevFuncEndLabel = A->curFuncEndLabel;
- sprintf(name, "__endOfFunc_%s_", (char *) fun->header.a_name);
+ _mesa_snprintf(name, sizeof(name), "__endOfFunc_%s_", (char *) fun->header.a_name);
A->curFuncEndLabel = _slang_label_new(name);
assert(A->curFuncEndLabel);
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index 7c0ea0c114..974c4a3131 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -652,30 +652,30 @@ storage_annotation(const slang_ir_node *n, const struct gl_program *prog)
if (st->Index >= 0) {
const GLfloat *val = prog->Parameters->ParameterValues[st->Index];
if (st->Swizzle == SWIZZLE_NOOP)
- sprintf(s, "{%g, %g, %g, %g}", val[0], val[1], val[2], val[3]);
+ _mesa_snprintf(s, sizeof(s), "{%g, %g, %g, %g}", val[0], val[1], val[2], val[3]);
else {
- sprintf(s, "%g", val[GET_SWZ(st->Swizzle, 0)]);
+ _mesa_snprintf(s, sizeof(s), "%g", val[GET_SWZ(st->Swizzle, 0)]);
}
}
break;
case PROGRAM_TEMPORARY:
if (n->Var)
- sprintf(s, "%s", (char *) n->Var->a_name);
+ _mesa_snprintf(s, sizeof(s), "%s", (char *) n->Var->a_name);
else
- sprintf(s, "t[%d]", st->Index);
+ _mesa_snprintf(s, sizeof(s), "t[%d]", st->Index);
break;
case PROGRAM_STATE_VAR:
case PROGRAM_UNIFORM:
- sprintf(s, "%s", prog->Parameters->Parameters[st->Index].Name);
+ _mesa_snprintf(s, sizeof(s), "%s", prog->Parameters->Parameters[st->Index].Name);
break;
case PROGRAM_VARYING:
- sprintf(s, "%s", prog->Varying->Parameters[st->Index].Name);
+ _mesa_snprintf(s, sizeof(s), "%s", prog->Varying->Parameters[st->Index].Name);
break;
case PROGRAM_INPUT:
- sprintf(s, "input[%d]", st->Index);
+ _mesa_snprintf(s, sizeof(s), "input[%d]", st->Index);
break;
case PROGRAM_OUTPUT:
- sprintf(s, "output[%d]", st->Index);
+ _mesa_snprintf(s, sizeof(s), "output[%d]", st->Index);
break;
default:
s[0] = 0;
@@ -752,9 +752,8 @@ instruction_annotation(gl_inst_opcode opcode, char *dstAnnot,
}
s = (char *) malloc(len);
- sprintf(s, "%s = %s %s %s %s", dstAnnot,
- srcAnnot0, operator, srcAnnot1, srcAnnot2);
- assert(strlen(s) < len);
+ _mesa_snprintf(s, len, "%s = %s %s %s %s", dstAnnot,
+ srcAnnot0, operator, srcAnnot1, srcAnnot2);
free(dstAnnot);
free(srcAnnot0);
@@ -2274,11 +2273,11 @@ emit_var_decl(slang_emit_info *emitInfo, slang_ir_node *n)
if (emitInfo->EmitComments) {
/* emit NOP with comment describing the variable's storage location */
char s[1000];
- sprintf(s, "TEMP[%d]%s = variable %s (size %d)",
- n->Store->Index,
- _mesa_swizzle_string(n->Store->Swizzle, 0, GL_FALSE),
- (n->Var ? (char *) n->Var->a_name : "anonymous"),
- n->Store->Size);
+ _mesa_snprintf(s, sizeof(s), "TEMP[%d]%s = variable %s (size %d)",
+ n->Store->Index,
+ _mesa_swizzle_string(n->Store->Swizzle, 0, GL_FALSE),
+ (n->Var ? (char *) n->Var->a_name : "anonymous"),
+ n->Store->Size);
emit_comment(emitInfo, s);
}
return NULL;
diff --git a/src/mesa/shader/slang/slang_ir.c b/src/mesa/shader/slang/slang_ir.c
index 62603503dd..c223004b22 100644
--- a/src/mesa/shader/slang/slang_ir.c
+++ b/src/mesa/shader/slang/slang_ir.c
@@ -340,13 +340,13 @@ storage_string(const slang_ir_storage *st)
assert(Elements(files) == PROGRAM_FILE_MAX);
#if 0
if (st->Size == 1)
- sprintf(s, "%s[%d]", files[st->File], st->Index);
+ _mesa_snprintf(s, "%s[%d]", files[st->File], st->Index);
else
- sprintf(s, "%s[%d..%d]", files[st->File], st->Index,
- st->Index + st->Size - 1);
+ _mesa_snprintf(s, "%s[%d..%d]", files[st->File], st->Index,
+ st->Index + st->Size - 1);
#endif
assert(st->File < (GLint) (sizeof(files) / sizeof(files[0])));
- sprintf(s, "%s[%d]", files[st->File], st->Index);
+ _mesa_snprintf(s, sizeof(s), "%s[%d]", files[st->File], st->Index);
return s;
}
diff --git a/src/mesa/shader/slang/slang_label.c b/src/mesa/shader/slang/slang_label.c
index 225612a936..8e3a8ebc1a 100644
--- a/src/mesa/shader/slang/slang_label.c
+++ b/src/mesa/shader/slang/slang_label.c
@@ -37,7 +37,7 @@ _slang_label_new_unique(const char *name)
free(l);
return NULL;
}
- sprintf(l->Name, "%s_%d", name, id);
+ _mesa_snprintf(l->Name, strlen(name) + 10, "%s_%d", name, id);
id++;
l->Location = -1;
}
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index f71fde1d72..b16778f8ad 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -370,8 +370,9 @@ link_uniform_vars(GLcontext *ctx,
GLuint newSampNum = *numSamplers;
if (newSampNum >= ctx->Const.MaxTextureImageUnits) {
char s[100];
- sprintf(s, "Too many texture samplers (%u, max is %u)",
- newSampNum, ctx->Const.MaxTextureImageUnits);
+ _mesa_snprintf(s, sizeof(s),
+ "Too many texture samplers (%u, max is %u)",
+ newSampNum, ctx->Const.MaxTextureImageUnits);
link_error(shProg, s);
return GL_FALSE;
}
@@ -1028,7 +1029,10 @@ _slang_link(GLcontext *ctx,
if (!vertNotify || !fragNotify) {
/* driver rejected one/both of the vertex/fragment programs */
- link_error(shProg, "Vertex and/or fragment program rejected by driver\n");
+ if (!shProg->InfoLog) {
+ link_error(shProg,
+ "Vertex and/or fragment program rejected by driver\n");
+ }
}
else {
shProg->LinkStatus = (shProg->VertexProgram || shProg->FragmentProgram);
diff --git a/src/mesa/shader/slang/slang_print.c b/src/mesa/shader/slang/slang_print.c
index 3c75523c42..6b34f395fd 100644
--- a/src/mesa/shader/slang/slang_print.c
+++ b/src/mesa/shader/slang/slang_print.c
@@ -813,7 +813,7 @@ static const char *
slang_fq_type_string(const slang_fully_specified_type *t)
{
static char str[1000];
- sprintf(str, "%s %s", slang_type_qual_string(t->qualifier),
+ _mesa_snprintf(str, sizeof(str), "%s %s", slang_type_qual_string(t->qualifier),
slang_type_string(t->specifier.type));
return str;
}
@@ -832,9 +832,9 @@ static char *
slang_var_string(const slang_variable *v)
{
static char str[1000];
- sprintf(str, "%s : %s",
- (char *) v->a_name,
- slang_fq_type_string(&v->type));
+ _mesa_snprintf(str, sizeof(str), "%s : %s",
+ (char *) v->a_name,
+ slang_fq_type_string(&v->type));
return str;
}
#endif
diff --git a/src/mesa/shader/slang/slang_utility.c b/src/mesa/shader/slang/slang_utility.c
index e77404f692..c1d57409a4 100644
--- a/src/mesa/shader/slang/slang_utility.c
+++ b/src/mesa/shader/slang/slang_utility.c
@@ -120,7 +120,7 @@ slang_string_pushi (slang_string *self, GLint i)
{
char buffer[12];
- sprintf (buffer, "%d", i);
+ _mesa_snprintf (buffer, sizeof(buffer), "%d", i);
slang_string_pushs (self, buffer, strlen (buffer));
}
diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c
index 1cd5546337..52c507da3b 100644
--- a/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -153,6 +153,16 @@ update_framebuffer_state( struct st_context *st )
pipe_surface_reference(&framebuffer->zsbuf, NULL);
}
+#ifdef DEBUG
+ /* Make sure the resource binding flags were set properly */
+ for (i = 0; i < framebuffer->nr_cbufs; i++) {
+ assert(framebuffer->cbufs[i]->texture->bind & PIPE_BIND_RENDER_TARGET);
+ }
+ if (framebuffer->zsbuf) {
+ assert(framebuffer->zsbuf->texture->bind & PIPE_BIND_DEPTH_STENCIL);
+ }
+#endif
+
cso_set_framebuffer(st->cso_context, framebuffer);
}
diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c
index e8e67f8030..29c4d092bf 100644
--- a/src/mesa/state_tracker/st_atom_pixeltransfer.c
+++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c
@@ -115,7 +115,8 @@ make_state_key(GLcontext *ctx, struct state_key *key)
static struct pipe_resource *
create_color_map_texture(GLcontext *ctx)
{
- struct pipe_context *pipe = ctx->st->pipe;
+ struct st_context *st = st_context(ctx);
+ struct pipe_context *pipe = st->pipe;
struct pipe_resource *pt;
enum pipe_format format;
const uint texSize = 256; /* simple, and usually perfect */
@@ -125,7 +126,7 @@ create_color_map_texture(GLcontext *ctx)
PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW);
/* create texture for color map/table */
- pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, format, 0,
+ pt = st_texture_create(st, PIPE_TEXTURE_2D, format, 0,
texSize, texSize, 1, PIPE_BIND_SAMPLER_VIEW);
return pt;
}
@@ -137,7 +138,8 @@ create_color_map_texture(GLcontext *ctx)
static void
load_color_map_texture(GLcontext *ctx, struct pipe_resource *pt)
{
- struct pipe_context *pipe = ctx->st->pipe;
+ struct st_context *st = st_context(ctx);
+ struct pipe_context *pipe = st->pipe;
struct pipe_transfer *transfer;
const GLuint rSize = ctx->PixelMaps.RtoR.Size;
const GLuint gSize = ctx->PixelMaps.GtoG.Size;
@@ -185,7 +187,7 @@ load_color_map_texture(GLcontext *ctx, struct pipe_resource *pt)
static struct gl_fragment_program *
get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key)
{
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
struct prog_instruction inst[MAX_INST];
struct gl_program_parameter_list *params;
struct gl_fragment_program *fp;
@@ -256,8 +258,9 @@ get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key)
/* create the colormap/texture now if not already done */
if (!st->pixel_xfer.pixelmap_texture) {
st->pixel_xfer.pixelmap_texture = create_color_map_texture(ctx);
- st->pixel_xfer.pixelmap_sampler_view = st_create_texture_sampler_view(ctx->st->pipe,
- st->pixel_xfer.pixelmap_texture);
+ st->pixel_xfer.pixelmap_sampler_view =
+ st_create_texture_sampler_view(st->pipe,
+ st->pixel_xfer.pixelmap_texture);
}
/* with a little effort, we can do four pixel map look-ups with
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index a8262a5e1a..92fe72d4df 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -194,9 +194,12 @@ update_samplers(struct st_context *st)
sampler->normalized_coords = 1;
sampler->lod_bias = st->ctx->Texture.Unit[su].LodBias;
- sampler->min_lod = MAX2(0.0f, texobj->MinLod);
- sampler->max_lod = MIN2(texobj->MaxLevel - texobj->BaseLevel,
- texobj->MaxLod);
+
+ sampler->min_lod = texobj->BaseLevel + texobj->MinLod;
+ if (sampler->min_lod < texobj->BaseLevel)
+ sampler->min_lod = texobj->BaseLevel;
+
+ sampler->max_lod = MIN2((GLfloat) texobj->MaxLevel, texobj->MaxLod);
if (sampler->max_lod < sampler->min_lod) {
/* The GL spec doesn't seem to specify what to do in this case.
* Swap the values.
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index f4294ac1e6..2575adda8f 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -138,7 +138,6 @@ finalize_textures(struct st_context *st)
const GLuint texUnit = fprog->Base.SamplerUnits[su];
struct gl_texture_object *texObj
= st->ctx->Texture.Unit[texUnit]._Current;
- struct st_texture_object *stObj = st_texture_object(texObj);
if (texObj) {
GLboolean flush, retval;
@@ -149,8 +148,6 @@ finalize_textures(struct st_context *st)
st->missing_textures = GL_TRUE;
continue;
}
-
- stObj->teximage_realloc = TRUE;
}
}
}
diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c
index 2732969d95..0101837f99 100644
--- a/src/mesa/state_tracker/st_cb_accum.c
+++ b/src/mesa/state_tracker/st_cb_accum.c
@@ -223,7 +223,7 @@ accum_return(GLcontext *ctx, GLfloat value,
struct st_renderbuffer *acc_strb,
struct st_renderbuffer *color_strb)
{
- struct pipe_context *pipe = ctx->st->pipe;
+ struct pipe_context *pipe = st_context(ctx)->pipe;
const GLubyte *colormask = ctx->Color.ColorMask[0];
enum pipe_transfer_usage usage;
struct pipe_transfer *color_trans;
@@ -287,7 +287,7 @@ accum_return(GLcontext *ctx, GLfloat value,
static void
st_Accum(GLcontext *ctx, GLenum op, GLfloat value)
{
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
struct st_renderbuffer *acc_strb
= st_renderbuffer(ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer);
struct st_renderbuffer *color_strb
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index 12bba050a6..797c0ba7f5 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -114,6 +114,7 @@ struct bitmap_cache
static struct st_fragment_program *
make_bitmap_fragment_program(GLcontext *ctx, GLuint samplerIndex)
{
+ struct st_context *st = st_context(ctx);
struct st_fragment_program *stfp;
struct gl_program *p;
GLuint ic = 0;
@@ -145,7 +146,7 @@ make_bitmap_fragment_program(GLcontext *ctx, GLuint samplerIndex)
p->Instructions[ic].Opcode = OPCODE_KIL;
p->Instructions[ic].SrcReg[0].File = PROGRAM_TEMPORARY;
- if (ctx->st->bitmap.tex_format == PIPE_FORMAT_L8_UNORM)
+ if (st->bitmap.tex_format == PIPE_FORMAT_L8_UNORM)
p->Instructions[ic].SrcReg[0].Swizzle = SWIZZLE_XXXX;
p->Instructions[ic].SrcReg[0].Index = 0;
@@ -187,7 +188,7 @@ find_free_bit(uint bitfield)
static struct st_fragment_program *
combined_bitmap_fragment_program(GLcontext *ctx)
{
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
struct st_fragment_program *stfp = st->fp;
if (!stfp->bitmap_program) {
@@ -258,7 +259,8 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
const struct gl_pixelstore_attrib *unpack,
const GLubyte *bitmap)
{
- struct pipe_context *pipe = ctx->st->pipe;
+ struct st_context *st = st_context(ctx);
+ struct pipe_context *pipe = st->pipe;
struct pipe_transfer *transfer;
ubyte *dest;
struct pipe_resource *pt;
@@ -272,7 +274,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
/**
* Create texture to hold bitmap pattern.
*/
- pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, ctx->st->bitmap.tex_format,
+ pt = st_texture_create(st, PIPE_TEXTURE_2D, st->bitmap.tex_format,
0, width, height, 1,
PIPE_BIND_SAMPLER_VIEW);
if (!pt) {
@@ -280,7 +282,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
return NULL;
}
- transfer = st_no_flush_get_tex_transfer(st_context(ctx), pt, 0, 0, 0,
+ transfer = st_no_flush_get_tex_transfer(st, pt, 0, 0, 0,
PIPE_TRANSFER_WRITE,
0, 0, width, height);
@@ -288,7 +290,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
/* Put image into texture transfer */
memset(dest, 0xff, height * transfer->stride);
- unpack_bitmap(ctx->st, 0, 0, width, height, unpack, bitmap,
+ unpack_bitmap(st, 0, 0, width, height, unpack, bitmap,
dest, transfer->stride);
_mesa_unmap_pbo_source(ctx, unpack);
@@ -400,9 +402,9 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
struct pipe_sampler_view *sv,
const GLfloat *color)
{
- struct st_context *st = ctx->st;
- struct pipe_context *pipe = ctx->st->pipe;
- struct cso_context *cso = ctx->st->cso_context;
+ struct st_context *st = st_context(ctx);
+ struct pipe_context *pipe = st->pipe;
+ struct cso_context *cso = st->cso_context;
struct st_fragment_program *stfp;
GLuint maxSize;
GLuint offset;
@@ -732,7 +734,7 @@ static void
st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap )
{
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
struct pipe_resource *pt;
if (width == 0 || height == 0)
diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c
index d6fdfaccd6..1c8dc0c07f 100644
--- a/src/mesa/state_tracker/st_cb_blit.c
+++ b/src/mesa/state_tracker/st_cb_blit.c
@@ -68,7 +68,7 @@ st_BlitFramebuffer(GLcontext *ctx,
{
const GLbitfield depthStencil = (GL_DEPTH_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT);
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
const uint pFilter = ((filter == GL_NEAREST)
? PIPE_TEX_MIPFILTER_NEAREST
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 2f77aff7a6..736180ddc6 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -109,11 +109,10 @@ st_destroy_clear(struct st_context *st)
* Coords are clip coords with y=0=bottom.
*/
static void
-draw_quad(GLcontext *ctx,
+draw_quad(struct st_context *st,
float x0, float y0, float x1, float y1, GLfloat z,
const GLfloat color[4])
{
- struct st_context *st = ctx->st;
struct pipe_context *pipe = st->pipe;
/* XXX: Need to improve buffer_write to allow NO_WAIT (as well as
@@ -193,7 +192,7 @@ static void
clear_with_quad(GLcontext *ctx,
GLboolean color, GLboolean depth, GLboolean stencil)
{
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
const struct gl_framebuffer *fb = ctx->DrawBuffer;
const GLfloat fb_width = (GLfloat) fb->Width;
const GLfloat fb_height = (GLfloat) fb->Height;
@@ -295,7 +294,7 @@ clear_with_quad(GLcontext *ctx,
cso_set_vertex_shader_handle(st->cso_context, st->clear.vs);
/* draw quad matching scissor rect (XXX verify coord round-off) */
- draw_quad(ctx, x0, y0, x1, y1,
+ draw_quad(st, x0, y0, x1, y1,
(GLfloat) ctx->Depth.Clear, ctx->Color.ClearColor);
/* Restore pipe state */
@@ -448,7 +447,7 @@ st_Clear(GLcontext *ctx, GLbitfield mask)
{
static const GLbitfield BUFFER_BITS_DS
= (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL);
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
struct gl_renderbuffer *depthRb
= ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
struct gl_renderbuffer *stencilRb
@@ -530,8 +529,8 @@ st_Clear(GLcontext *ctx, GLbitfield mask)
mask & BUFFER_BIT_DEPTH,
mask & BUFFER_BIT_STENCIL);
} else if (clear_buffers)
- ctx->st->pipe->clear(ctx->st->pipe, clear_buffers, ctx->Color.ClearColor,
- ctx->Depth.Clear, ctx->Stencil.Clear);
+ st->pipe->clear(st->pipe, clear_buffers, ctx->Color.ClearColor,
+ ctx->Depth.Clear, ctx->Stencil.Clear);
if (mask & BUFFER_BIT_ACCUM)
st_clear_accum_buffer(ctx,
diff --git a/src/mesa/state_tracker/st_cb_condrender.c b/src/mesa/state_tracker/st_cb_condrender.c
index 8483b93bd8..b509d43b7c 100644
--- a/src/mesa/state_tracker/st_cb_condrender.c
+++ b/src/mesa/state_tracker/st_cb_condrender.c
@@ -51,7 +51,7 @@ st_BeginConditionalRender(GLcontext *ctx, struct gl_query_object *q,
GLenum mode)
{
struct st_query_object *stq = st_query_object(q);
- struct pipe_context *pipe = ctx->st->pipe;
+ struct pipe_context *pipe = st_context(ctx)->pipe;
uint m;
switch (mode) {
@@ -82,7 +82,7 @@ st_BeginConditionalRender(GLcontext *ctx, struct gl_query_object *q,
static void
st_EndConditionalRender(GLcontext *ctx, struct gl_query_object *q)
{
- struct pipe_context *pipe = ctx->st->pipe;
+ struct pipe_context *pipe = st_context(ctx)->pipe;
(void) q;
pipe->render_condition(pipe, NULL, 0);
}
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 2c18ded2ab..e059002f15 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -858,7 +858,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLint dstx, GLint dsty)
{
struct st_renderbuffer *rbDraw = st_renderbuffer(ctx->DrawBuffer->_StencilBuffer);
- struct pipe_context *pipe = ctx->st->pipe;
+ struct pipe_context *pipe = st_context(ctx)->pipe;
enum pipe_transfer_usage usage;
struct pipe_transfer *ptDraw;
ubyte *drawMap;
diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c
index a924f87223..0fa1848e23 100644
--- a/src/mesa/state_tracker/st_cb_eglimage.c
+++ b/src/mesa/state_tracker/st_cb_eglimage.c
@@ -74,7 +74,7 @@ st_egl_image_target_renderbuffer_storage(GLcontext *ctx,
struct gl_renderbuffer *rb,
GLeglImageOES image_handle)
{
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
struct st_renderbuffer *strb = st_renderbuffer(rb);
struct pipe_surface *ps;
unsigned usage;
@@ -138,7 +138,7 @@ st_egl_image_target_texture_2d(GLcontext *ctx, GLenum target,
struct gl_texture_image *texImage,
GLeglImageOES image_handle)
{
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
struct pipe_surface *ps;
unsigned usage;
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 1ba1fe1b97..c02121fbd1 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -64,7 +64,8 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
GLenum internalFormat,
GLuint width, GLuint height)
{
- struct pipe_screen *screen = ctx->st->pipe->screen;
+ struct st_context *st = st_context(ctx);
+ struct pipe_screen *screen = st->pipe->screen;
struct st_renderbuffer *strb = st_renderbuffer(rb);
enum pipe_format format;
@@ -312,23 +313,21 @@ st_render_texture(GLcontext *ctx,
struct gl_framebuffer *fb,
struct gl_renderbuffer_attachment *att)
{
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
- struct pipe_screen *screen = ctx->st->pipe->screen;
+ struct pipe_screen *screen = pipe->screen;
struct st_renderbuffer *strb;
struct gl_renderbuffer *rb;
struct pipe_resource *pt = st_get_texobj_resource(att->Texture);
struct st_texture_object *stObj;
const struct gl_texture_image *texImage;
- GLint pt_level;
/* When would this fail? Perhaps assert? */
if (!pt)
return;
- /* The first gallium texture level = Mesa BaseLevel */
- pt_level = MAX2(0, (GLint) att->TextureLevel - att->Texture->BaseLevel);
- texImage = att->Texture->Image[att->CubeMapFace][pt_level];
+ /* get pointer to texture image we're rendeing to */
+ texImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
/* create new renderbuffer which wraps the texture image */
rb = st_new_renderbuffer(ctx, 0);
@@ -349,7 +348,7 @@ st_render_texture(GLcontext *ctx,
/* point renderbuffer at texobject */
strb->rtt = stObj;
- strb->rtt_level = pt_level;
+ strb->rtt_level = att->TextureLevel;
strb->rtt_face = att->CubeMapFace;
strb->rtt_slice = att->Zoffset;
@@ -403,12 +402,13 @@ static void
st_finish_render_texture(GLcontext *ctx,
struct gl_renderbuffer_attachment *att)
{
+ struct st_context *st = st_context(ctx);
struct st_renderbuffer *strb = st_renderbuffer(att->Renderbuffer);
if (!strb)
return;
- st_flush( ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL );
+ st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL);
strb->rtt = NULL;
@@ -422,23 +422,19 @@ st_finish_render_texture(GLcontext *ctx,
/**
- * Validate a renderbuffer attachment for a particular usage.
+ * Validate a renderbuffer attachment for a particular set of bindings.
*/
-
static GLboolean
st_validate_attachment(struct pipe_screen *screen,
const struct gl_renderbuffer_attachment *att,
- GLuint usage)
+ unsigned bindings)
{
- const struct st_texture_object *stObj =
- st_texture_object(att->Texture);
+ const struct st_texture_object *stObj = st_texture_object(att->Texture);
- /**
- * Only validate texture attachments for now, since
+ /* Only validate texture attachments for now, since
* st_renderbuffer_alloc_storage makes sure that
* the format is supported.
*/
-
if (att->Type != GL_TEXTURE)
return GL_TRUE;
@@ -446,10 +442,10 @@ st_validate_attachment(struct pipe_screen *screen,
return GL_FALSE;
return screen->is_format_supported(screen, stObj->pt->format,
- PIPE_TEXTURE_2D,
- usage, 0);
+ PIPE_TEXTURE_2D, bindings, 0);
}
+
/**
* Check that the framebuffer configuration is valid in terms of what
* the driver can support.
@@ -459,7 +455,8 @@ st_validate_attachment(struct pipe_screen *screen,
static void
st_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
{
- struct pipe_screen *screen = ctx->st->pipe->screen;
+ struct st_context *st = st_context(ctx);
+ struct pipe_screen *screen = st->pipe->screen;
const struct gl_renderbuffer *depthRb =
fb->Attachment[BUFFER_DEPTH].Renderbuffer;
const struct gl_renderbuffer *stencilRb =
@@ -500,6 +497,7 @@ st_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
static void
st_DrawBuffers(GLcontext *ctx, GLsizei count, const GLenum *buffers)
{
+ struct st_context *st = st_context(ctx);
GLframebuffer *fb = ctx->DrawBuffer;
GLuint i;
@@ -509,7 +507,7 @@ st_DrawBuffers(GLcontext *ctx, GLsizei count, const GLenum *buffers)
/* add the renderbuffers on demand */
for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
gl_buffer_index idx = fb->_ColorDrawBufferIndexes[i];
- st_manager_add_color_renderbuffer(ctx->st, fb, idx);
+ st_manager_add_color_renderbuffer(st, fb, idx);
}
}
@@ -520,12 +518,13 @@ st_DrawBuffers(GLcontext *ctx, GLsizei count, const GLenum *buffers)
static void
st_ReadBuffer(GLcontext *ctx, GLenum buffer)
{
+ struct st_context *st = st_context(ctx);
GLframebuffer *fb = ctx->ReadBuffer;
(void) buffer;
/* add the renderbuffer on demand */
- st_manager_add_color_renderbuffer(ctx->st, fb, fb->_ColorReadBufferIndex);
+ st_manager_add_color_renderbuffer(st, fb, fb->_ColorReadBufferIndex);
}
diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c
index 37b1fb55f4..c85d3da84a 100644
--- a/src/mesa/state_tracker/st_cb_feedback.c
+++ b/src/mesa/state_tracker/st_cb_feedback.c
@@ -80,7 +80,7 @@ static void
feedback_vertex(GLcontext *ctx, const struct draw_context *draw,
const struct vertex_header *v)
{
- const struct st_context *st = ctx->st;
+ const struct st_context *st = st_context(ctx);
GLfloat win[4];
const GLfloat *color, *texcoord;
GLuint slot;
@@ -271,7 +271,7 @@ draw_glselect_stage(GLcontext *ctx, struct draw_context *draw)
static void
st_RenderMode(GLcontext *ctx, GLenum newMode )
{
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
struct draw_context *draw = st->draw;
if (newMode == GL_RENDER) {
diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c
index 415e8f3d2a..8c9959f954 100644
--- a/src/mesa/state_tracker/st_cb_flush.c
+++ b/src/mesa/state_tracker/st_cb_flush.c
@@ -115,7 +115,7 @@ void st_finish( struct st_context *st )
*/
static void st_glFlush(GLcontext *ctx)
{
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
/* Don't call st_finish() here. It is not the state tracker's
* responsibilty to inject sleeps in the hope of avoiding buffer
@@ -135,7 +135,7 @@ static void st_glFlush(GLcontext *ctx)
*/
static void st_glFinish(GLcontext *ctx)
{
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
st_finish(st);
diff --git a/src/mesa/state_tracker/st_cb_queryobj.c b/src/mesa/state_tracker/st_cb_queryobj.c
index c66729b124..1896663932 100644
--- a/src/mesa/state_tracker/st_cb_queryobj.c
+++ b/src/mesa/state_tracker/st_cb_queryobj.c
@@ -61,7 +61,7 @@ st_NewQueryObject(GLcontext *ctx, GLuint id)
static void
st_DeleteQuery(GLcontext *ctx, struct gl_query_object *q)
{
- struct pipe_context *pipe = ctx->st->pipe;
+ struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_query_object *stq = st_query_object(q);
if (stq->pq) {
@@ -76,7 +76,7 @@ st_DeleteQuery(GLcontext *ctx, struct gl_query_object *q)
static void
st_BeginQuery(GLcontext *ctx, struct gl_query_object *q)
{
- struct pipe_context *pipe = ctx->st->pipe;
+ struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_query_object *stq = st_query_object(q);
switch (q->Target) {
@@ -96,7 +96,7 @@ st_BeginQuery(GLcontext *ctx, struct gl_query_object *q)
static void
st_EndQuery(GLcontext *ctx, struct gl_query_object *q)
{
- struct pipe_context *pipe = ctx->st->pipe;
+ struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_query_object *stq = st_query_object(q);
pipe->end_query(pipe, stq->pq);
@@ -106,7 +106,7 @@ st_EndQuery(GLcontext *ctx, struct gl_query_object *q)
static void
st_WaitQuery(GLcontext *ctx, struct gl_query_object *q)
{
- struct pipe_context *pipe = ctx->st->pipe;
+ struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_query_object *stq = st_query_object(q);
/* this function should only be called if we don't have a ready result */
@@ -128,7 +128,7 @@ st_WaitQuery(GLcontext *ctx, struct gl_query_object *q)
static void
st_CheckQuery(GLcontext *ctx, struct gl_query_object *q)
{
- struct pipe_context *pipe = ctx->st->pipe;
+ struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_query_object *stq = st_query_object(q);
assert(!q->Ready); /* we should not get called if Ready is TRUE */
q->Ready = pipe->get_query_result(pipe, stq->pq, FALSE, &q->Result);
diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c
index 752b411b5f..843f320027 100644
--- a/src/mesa/state_tracker/st_cb_rasterpos.c
+++ b/src/mesa/state_tracker/st_cb_rasterpos.c
@@ -133,7 +133,7 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim)
{
struct rastpos_stage *rs = rastpos_stage(stage);
GLcontext *ctx = rs->ctx;
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
const GLfloat height = (GLfloat) ctx->DrawBuffer->Height;
const GLuint *outputMapping = st->vertex_result_to_slot;
const GLfloat *pos;
@@ -221,7 +221,7 @@ new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw)
static void
st_RasterPos(GLcontext *ctx, const GLfloat v[4])
{
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
struct draw_context *draw = st->draw;
struct rastpos_stage *rs;
@@ -239,7 +239,7 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4])
draw_set_rasterize_stage(st->draw, st->rastpos_stage);
/* make sure everything's up to date */
- st_validate_state(ctx->st);
+ st_validate_state(st);
/* This will get set only if rastpos_point(), above, gets called */
ctx->Current.RasterPosValid = GL_FALSE;
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index 67c3b9adbb..69950ac44b 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -63,7 +63,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
GLvoid *pixels)
{
struct gl_framebuffer *fb = ctx->ReadBuffer;
- struct pipe_context *pipe = ctx->st->pipe;
+ struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_renderbuffer *strb = st_renderbuffer(fb->_StencilBuffer);
struct pipe_transfer *pt;
ubyte *stmap;
@@ -220,7 +220,7 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb,
/*printf("st_fast_readpixels combo %d\n", (GLint) combo);*/
{
- struct pipe_context *pipe = ctx->st->pipe;
+ struct pipe_context *pipe = st_context(ctx)->pipe;
struct pipe_transfer *trans;
const GLubyte *map;
GLubyte *dst;
@@ -322,7 +322,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
const struct gl_pixelstore_attrib *pack,
GLvoid *dest)
{
- struct pipe_context *pipe = ctx->st->pipe;
+ struct st_context *st = st_context(ctx);
+ struct pipe_context *pipe = st->pipe;
GLfloat temp[MAX_WIDTH][4];
const GLbitfield transferOps = ctx->_ImageTransferState;
GLsizei i, j;
@@ -337,7 +338,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
/* XXX convolution not done yet */
assert((transferOps & IMAGE_CONVOLUTION_BIT) == 0);
- st_validate_state(ctx->st);
+ st_validate_state(st);
/* Do all needed clipping here, so that we can forget about it later */
if (!_mesa_clip_readpixels(ctx, &x, &y, &width, &height, &clippedPacking)) {
@@ -349,7 +350,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
if (!dest)
return;
- st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+ st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL);
if (format == GL_STENCIL_INDEX ||
format == GL_DEPTH_STENCIL) {
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index ed113b5dbc..7e2e533881 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -120,17 +120,18 @@ static void
st_DeleteTextureObject(GLcontext *ctx,
struct gl_texture_object *texObj)
{
+ struct st_context *st = st_context(ctx);
struct st_texture_object *stObj = st_texture_object(texObj);
if (stObj->pt)
pipe_resource_reference(&stObj->pt, NULL);
if (stObj->sampler_view) {
- if (stObj->sampler_view->context != ctx->st->pipe) {
+ if (stObj->sampler_view->context != st->pipe) {
/* Take "ownership" of this texture sampler view by setting
* its context pointer to this context. This avoids potential
* crashes when the texture object is shared among contexts
* and the original/owner context has already been destroyed.
*/
- stObj->sampler_view->context = ctx->st->pipe;
+ stObj->sampler_view->context = st->pipe;
}
pipe_sampler_view_reference(&stObj->sampler_view, NULL);
}
@@ -208,84 +209,108 @@ do_memcpy(void *dest, const void *src, size_t n)
/**
- * Return default texture usage bitmask for the given texture format.
+ * Return default texture resource binding bitmask for the given format.
*/
static GLuint
-default_usage(enum pipe_format fmt)
+default_bindings(struct st_context *st, enum pipe_format format)
{
- GLuint usage = PIPE_BIND_SAMPLER_VIEW;
- if (util_format_is_depth_or_stencil(fmt))
- usage |= PIPE_BIND_DEPTH_STENCIL;
+ struct pipe_screen *screen = st->pipe->screen;
+ const unsigned target = PIPE_TEXTURE_2D;
+ const unsigned geom = 0x0;
+ unsigned bindings;
+
+ if (util_format_is_depth_or_stencil(format))
+ bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_DEPTH_STENCIL;
+ else
+ bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
+
+ if (screen->is_format_supported(screen, format, target, bindings, geom))
+ return bindings;
else
- usage |= PIPE_BIND_RENDER_TARGET;
- return usage;
+ return PIPE_BIND_SAMPLER_VIEW;
+}
+
+
+/** Return number of image dimensions (1, 2 or 3) for a texture target. */
+static GLuint
+get_texture_dims(GLenum target)
+{
+ switch (target) {
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_1D_ARRAY_EXT:
+ return 1;
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ case GL_TEXTURE_RECTANGLE_NV:
+ case GL_TEXTURE_2D_ARRAY_EXT:
+ return 2;
+ case GL_TEXTURE_3D:
+ return 3;
+ default:
+ assert(0 && "invalid texture target in get_texture_dims()");
+ return 1;
+ }
}
/**
- * Allocate a pipe_resource object for the given st_texture_object using
- * the given st_texture_image to guess the mipmap size/levels.
+ * Try to allocate a pipe_resource object for the given st_texture_object.
*
- * [comments...]
- * Otherwise, store it in memory if (Border != 0) or (any dimension ==
- * 1).
- *
- * Otherwise, if max_level >= level >= min_level, create texture with
- * space for images from min_level down to max_level.
+ * We use the given st_texture_image as a clue to determine the size of the
+ * mipmap image at level=0.
*
- * Otherwise, create texture with space for images from (level 0)..(1x1).
- * Consider pruning this texture at a validation if the saving is worth it.
*/
static void
guess_and_alloc_texture(struct st_context *st,
struct st_texture_object *stObj,
const struct st_texture_image *stImage)
{
- GLuint firstLevel;
- GLuint lastLevel;
- GLuint width = stImage->base.Width2; /* size w/out border */
- GLuint height = stImage->base.Height2;
- GLuint depth = stImage->base.Depth2;
- GLuint i, usage;
+ const GLuint dims = get_texture_dims(stObj->base.Target);
+ GLuint level, lastLevel, width, height, depth;
+ GLuint bindings;
enum pipe_format fmt;
DBG("%s\n", __FUNCTION__);
assert(!stObj->pt);
- if (stObj->pt &&
- (GLint) stImage->level > stObj->base.BaseLevel &&
- (stImage->base.Width == 1 ||
- (stObj->base.Target != GL_TEXTURE_1D &&
- stImage->base.Height == 1) ||
- (stObj->base.Target == GL_TEXTURE_3D &&
- stImage->base.Depth == 1)))
- return;
-
- /* If this image disrespects BaseLevel, allocate from level zero.
- * Usually BaseLevel == 0, so it's unlikely to happen.
- */
- if ((GLint) stImage->level < stObj->base.BaseLevel)
- firstLevel = 0;
- else
- firstLevel = stObj->base.BaseLevel;
+ level = stImage->level;
+ width = stImage->base.Width2; /* size w/out border */
+ height = stImage->base.Height2;
+ depth = stImage->base.Depth2;
+ assert(width > 0);
+ assert(height > 0);
+ assert(depth > 0);
- /* Figure out image dimensions at start level.
+ /* Depending on the image's size, we can't always make a guess here.
*/
- for (i = stImage->level; i > firstLevel; i--) {
+ if (level > 0) {
+ if ( (dims >= 1 && width == 1) ||
+ (dims >= 2 && height == 1) ||
+ (dims >= 3 && depth == 1) ) {
+ /* we can't determine the image size at level=0 */
+ stObj->width0 = stObj->height0 = stObj->depth0 = 0;
+ return;
+ }
+ }
+
+ /* grow the image size until we hit level = 0 */
+ while (level > 0) {
if (width != 1)
width <<= 1;
if (height != 1)
height <<= 1;
if (depth != 1)
depth <<= 1;
- }
+ level--;
+ }
- if (width == 0 || height == 0 || depth == 0) {
- /* no texture needed */
- return;
- }
+ assert(level == 0);
+
+ /* At this point, (width x height x depth) is the expected size of
+ * the level=0 mipmap image.
+ */
/* Guess a reasonable value for lastLevel. This is probably going
* to be wrong fairly often and might mean that we have to look at
@@ -297,21 +322,26 @@ guess_and_alloc_texture(struct st_context *st,
stImage->base._BaseFormat == GL_DEPTH_COMPONENT ||
stImage->base._BaseFormat == GL_DEPTH_STENCIL_EXT) &&
!stObj->base.GenerateMipmap &&
- stImage->level == firstLevel) {
+ stImage->level == 0) {
/* only alloc space for a single mipmap level */
- lastLevel = firstLevel;
+ lastLevel = 0;
}
else {
/* alloc space for a full mipmap */
GLuint l2width = util_logbase2(width);
GLuint l2height = util_logbase2(height);
GLuint l2depth = util_logbase2(depth);
- lastLevel = firstLevel + MAX2(MAX2(l2width, l2height), l2depth);
+ lastLevel = MAX2(MAX2(l2width, l2height), l2depth);
}
+ /* Save the level=0 dimensions */
+ stObj->width0 = width;
+ stObj->height0 = height;
+ stObj->depth0 = depth;
+
fmt = st_mesa_format_to_pipe_format(stImage->base.TexFormat);
- usage = default_usage(fmt);
+ bindings = default_bindings(st, fmt);
stObj->pt = st_texture_create(st,
gl_target_to_pipe(stObj->base.Target),
@@ -320,7 +350,7 @@ guess_and_alloc_texture(struct st_context *st,
width,
height,
depth,
- usage);
+ bindings);
DBG("%s - success\n", __FUNCTION__);
}
@@ -381,7 +411,8 @@ compress_with_blit(GLcontext * ctx,
{
const GLuint dstImageOffsets[1] = {0};
struct st_texture_image *stImage = st_texture_image(texImage);
- struct pipe_context *pipe = ctx->st->pipe;
+ struct st_context *st = st_context(ctx);
+ struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
gl_format mesa_format;
struct pipe_resource templ;
@@ -458,7 +489,7 @@ compress_with_blit(GLcontext * ctx,
/* copy / compress image */
- util_blit_pixels_tex(ctx->st->blit,
+ util_blit_pixels_tex(st->blit,
src_view, /* sampler view (src) */
0, 0, /* src x0, y0 */
width, height, /* src x1, y1 */
@@ -493,7 +524,8 @@ st_TexImage(GLcontext * ctx,
struct gl_texture_image *texImage,
GLsizei imageSize, GLboolean compressed_src)
{
- struct pipe_screen *screen = ctx->st->pipe->screen;
+ struct st_context *st = st_context(ctx);
+ struct pipe_screen *screen = st->pipe->screen;
struct st_texture_object *stObj = st_texture_object(texObj);
struct st_texture_image *stImage = st_texture_image(texImage);
GLint postConvWidth, postConvHeight;
@@ -570,15 +602,13 @@ st_TexImage(GLcontext * ctx,
* mipmap. If so, free the old mipmap.
*/
if (stObj->pt) {
- if (stObj->teximage_realloc ||
- level > (GLint) stObj->pt->last_level ||
+ if (level > (GLint) stObj->pt->last_level ||
!st_texture_match_image(stObj->pt, &stImage->base,
stImage->face, stImage->level)) {
DBG("release it\n");
pipe_resource_reference(&stObj->pt, NULL);
assert(!stObj->pt);
pipe_sampler_view_reference(&stObj->sampler_view, NULL);
- stObj->teximage_realloc = FALSE;
}
}
@@ -588,13 +618,13 @@ st_TexImage(GLcontext * ctx,
}
if (!stObj->pt) {
- guess_and_alloc_texture(ctx->st, stObj, stImage);
+ guess_and_alloc_texture(st, stObj, stImage);
if (!stObj->pt) {
/* Probably out of memory.
* Try flushing any pending rendering, then retry.
*/
- st_finish(ctx->st);
- guess_and_alloc_texture(ctx->st, stObj, stImage);
+ st_finish(st);
+ guess_and_alloc_texture(st, stObj, stImage);
if (!stObj->pt) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
return;
@@ -659,7 +689,7 @@ st_TexImage(GLcontext * ctx,
else
transfer_usage = PIPE_TRANSFER_WRITE;
- texImage->Data = st_texture_image_map(ctx->st, stImage, 0,
+ texImage->Data = st_texture_image_map(st, stImage, 0,
transfer_usage, 0, 0,
stImage->base.Width,
stImage->base.Height);
@@ -740,9 +770,9 @@ st_TexImage(GLcontext * ctx,
if (stImage->pt && i + 1 < depth) {
/* unmap this slice */
- st_texture_image_unmap(ctx->st, stImage);
+ st_texture_image_unmap(st, stImage);
/* map next slice of 3D texture */
- texImage->Data = st_texture_image_map(ctx->st, stImage, i + 1,
+ texImage->Data = st_texture_image_map(st, stImage, i + 1,
transfer_usage, 0, 0,
stImage->base.Width,
stImage->base.Height);
@@ -755,7 +785,7 @@ done:
_mesa_unmap_teximage_pbo(ctx, unpack);
if (stImage->pt && texImage->Data) {
- st_texture_image_unmap(ctx->st, stImage);
+ st_texture_image_unmap(st, stImage);
texImage->Data = NULL;
}
}
@@ -832,7 +862,8 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- struct pipe_context *pipe = ctx->st->pipe;
+ struct st_context *st = st_context(ctx);
+ struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
struct st_texture_image *stImage = st_texture_image(texImage);
struct st_texture_object *stObj = st_texture_object(texObj);
@@ -856,7 +887,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
}
/* blit/render/decompress */
- util_blit_pixels_tex(ctx->st->blit,
+ util_blit_pixels_tex(st->blit,
src_view, /* pipe_resource (src) */
0, 0, /* src x0, y0 */
width, height, /* src x1, y1 */
@@ -928,6 +959,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage, GLboolean compressed_dst)
{
+ struct st_context *st = st_context(ctx);
struct st_texture_image *stImage = st_texture_image(texImage);
const GLuint dstImageStride =
_mesa_image_image_stride(&ctx->Pack, texImage->Width, texImage->Height,
@@ -954,14 +986,17 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
*/
unsigned face = _mesa_tex_target_to_face(target);
- st_teximage_flush_before_map(ctx->st, stImage->pt, face, level,
+ st_teximage_flush_before_map(st, stImage->pt, face, level,
PIPE_TRANSFER_READ);
- texImage->Data = st_texture_image_map(ctx->st, stImage, 0,
+ texImage->Data = st_texture_image_map(st, stImage, 0,
PIPE_TRANSFER_READ, 0, 0,
stImage->base.Width,
stImage->base.Height);
- texImage->RowStride = stImage->transfer->stride / util_format_get_blocksize(stImage->pt->format);
+ /* compute stride in texels from stride in bytes */
+ texImage->RowStride = stImage->transfer->stride
+ * util_format_get_blockwidth(stImage->pt->format)
+ / util_format_get_blocksize(stImage->pt->format);
}
else {
/* Otherwise, the image should actually be stored in
@@ -992,9 +1027,9 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
if (stImage->pt && i + 1 < depth) {
/* unmap this slice */
- st_texture_image_unmap(ctx->st, stImage);
+ st_texture_image_unmap(st, stImage);
/* map next slice of 3D texture */
- texImage->Data = st_texture_image_map(ctx->st, stImage, i + 1,
+ texImage->Data = st_texture_image_map(st, stImage, i + 1,
PIPE_TRANSFER_READ, 0, 0,
stImage->base.Width,
stImage->base.Height);
@@ -1006,7 +1041,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
/* Unmap */
if (stImage->pt) {
- st_texture_image_unmap(ctx->st, stImage);
+ st_texture_image_unmap(st, stImage);
texImage->Data = NULL;
}
}
@@ -1044,7 +1079,8 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- struct pipe_screen *screen = ctx->st->pipe->screen;
+ struct st_context *st = st_context(ctx);
+ struct pipe_screen *screen = st->pipe->screen;
struct st_texture_image *stImage = st_texture_image(texImage);
GLuint dstRowStride;
const GLuint srcImageStride =
@@ -1092,9 +1128,9 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
else
transfer_usage = PIPE_TRANSFER_WRITE;
- st_teximage_flush_before_map(ctx->st, stImage->pt, face, level,
+ st_teximage_flush_before_map(st, stImage->pt, face, level,
transfer_usage);
- texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset,
+ texImage->Data = st_texture_image_map(st, stImage, zoffset,
transfer_usage,
xoffset, yoffset,
width, height);
@@ -1122,9 +1158,9 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
if (stImage->pt && i + 1 < depth) {
/* unmap this slice */
- st_texture_image_unmap(ctx->st, stImage);
+ st_texture_image_unmap(st, stImage);
/* map next slice of 3D texture */
- texImage->Data = st_texture_image_map(ctx->st, stImage,
+ texImage->Data = st_texture_image_map(st, stImage,
zoffset + i + 1,
transfer_usage,
xoffset, yoffset,
@@ -1137,7 +1173,7 @@ done:
_mesa_unmap_teximage_pbo(ctx, packing);
if (stImage->pt && texImage->Data) {
- st_texture_image_unmap(ctx->st, stImage);
+ st_texture_image_unmap(st, stImage);
texImage->Data = NULL;
}
}
@@ -1208,6 +1244,7 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
+ struct st_context *st = st_context(ctx);
struct st_texture_image *stImage = st_texture_image(texImage);
int srcBlockStride;
int dstBlockStride;
@@ -1218,9 +1255,9 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
unsigned face = _mesa_tex_target_to_face(target);
pformat = stImage->pt->format;
- st_teximage_flush_before_map(ctx->st, stImage->pt, face, level,
+ st_teximage_flush_before_map(st, stImage->pt, face, level,
PIPE_TRANSFER_WRITE);
- texImage->Data = st_texture_image_map(ctx->st, stImage, 0,
+ texImage->Data = st_texture_image_map(st, stImage, 0,
PIPE_TRANSFER_WRITE,
xoffset, yoffset,
width, height);
@@ -1252,7 +1289,7 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
}
if (stImage->pt) {
- st_texture_image_unmap(ctx->st, stImage);
+ st_texture_image_unmap(st, stImage);
texImage->Data = NULL;
}
}
@@ -1288,7 +1325,8 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level,
GLint srcX, GLint srcY,
GLsizei width, GLsizei height)
{
- struct pipe_context *pipe = ctx->st->pipe;
+ struct st_context *st = st_context(ctx);
+ struct pipe_context *pipe = st->pipe;
struct pipe_transfer *src_trans;
GLvoid *texDest;
enum pipe_transfer_usage transfer_usage;
@@ -1316,10 +1354,10 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level,
else
transfer_usage = PIPE_TRANSFER_WRITE;
- st_teximage_flush_before_map(ctx->st, stImage->pt, 0, 0,
+ st_teximage_flush_before_map(st, stImage->pt, 0, 0,
transfer_usage);
- texDest = st_texture_image_map(ctx->st, stImage, 0, transfer_usage,
+ texDest = st_texture_image_map(st, stImage, 0, transfer_usage,
destX, destY, width, height);
if (baseFormat == GL_DEPTH_COMPONENT ||
@@ -1394,7 +1432,7 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level,
free(tempSrc);
}
- st_texture_image_unmap(ctx->st, stImage);
+ st_texture_image_unmap(st, stImage);
pipe->transfer_destroy(pipe, src_trans);
}
@@ -1490,7 +1528,8 @@ st_copy_texsubimage(GLcontext *ctx,
const GLenum texBaseFormat = texImage->_BaseFormat;
struct gl_framebuffer *fb = ctx->ReadBuffer;
struct st_renderbuffer *strb;
- struct pipe_context *pipe = ctx->st->pipe;
+ struct st_context *st = st_context(ctx);
+ struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
enum pipe_format dest_format, src_format;
GLboolean use_fallback = GL_TRUE;
@@ -1500,11 +1539,11 @@ st_copy_texsubimage(GLcontext *ctx,
GLboolean do_flip = (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP);
/* any rendering in progress must flushed before we grab the fb image */
- st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+ st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL);
/* make sure finalize_textures has been called?
*/
- if (0) st_validate_state(ctx->st);
+ if (0) st_validate_state(st);
/* determine if copying depth or color data */
if (texBaseFormat == GL_DEPTH_COMPONENT ||
@@ -1621,7 +1660,7 @@ st_copy_texsubimage(GLcontext *ctx,
srcY0 = srcY;
srcY1 = srcY0 + height;
}
- util_blit_pixels_writemask(ctx->st->blit,
+ util_blit_pixels_writemask(st->blit,
strb->surface,
st_get_renderbuffer_sampler_view(strb, pipe),
srcX, srcY0,
@@ -1737,12 +1776,26 @@ st_CopyTexSubImage3D(GLcontext * ctx, GLenum target, GLint level,
}
+/**
+ * Copy image data from stImage into the texture object 'stObj' at level
+ * 'dstLevel'.
+ */
static void
copy_image_data_to_texture(struct st_context *st,
struct st_texture_object *stObj,
GLuint dstLevel,
struct st_texture_image *stImage)
{
+ /* debug checks */
+ {
+ const struct gl_texture_image *dstImage =
+ stObj->base.Image[stImage->face][stImage->level];
+ assert(dstImage);
+ assert(dstImage->Width == stImage->base.Width);
+ assert(dstImage->Height == stImage->base.Height);
+ assert(dstImage->Depth == stImage->base.Depth);
+ }
+
if (stImage->pt) {
/* Copy potentially with the blitter:
*/
@@ -1788,10 +1841,12 @@ st_finalize_texture(GLcontext *ctx,
struct gl_texture_object *tObj,
GLboolean *needFlush)
{
+ struct st_context *st = st_context(ctx);
struct st_texture_object *stObj = st_texture_object(tObj);
const GLuint nr_faces = (stObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
- GLuint blockSize, face;
+ GLuint face;
struct st_texture_image *firstImage;
+ enum pipe_format firstImageFormat;
*needFlush = GL_FALSE;
@@ -1806,10 +1861,11 @@ st_finalize_texture(GLcontext *ctx,
stObj->base.MinFilter == GL_NEAREST)
stObj->lastLevel = stObj->base.BaseLevel;
else
- stObj->lastLevel = stObj->base._MaxLevel - stObj->base.BaseLevel;
+ stObj->lastLevel = stObj->base._MaxLevel;
}
firstImage = st_texture_image(stObj->base.Image[0][stObj->base.BaseLevel]);
+ assert(firstImage);
/* If both firstImage and stObj point to a texture which can contain
* all active images, favour firstImage. Note that because of the
@@ -1823,43 +1879,42 @@ st_finalize_texture(GLcontext *ctx,
pipe_sampler_view_reference(&stObj->sampler_view, NULL);
}
- /* bytes per pixel block (blocks are usually 1x1) */
- blockSize = _mesa_get_format_bytes(firstImage->base.TexFormat);
+ /* Find gallium format for the Mesa texture */
+ firstImageFormat = st_mesa_format_to_pipe_format(firstImage->base.TexFormat);
/* If we already have a gallium texture, check that it matches the texture
* object's format, target, size, num_levels, etc.
*/
if (stObj->pt) {
- const enum pipe_format fmt =
- st_mesa_format_to_pipe_format(firstImage->base.TexFormat);
if (stObj->pt->target != gl_target_to_pipe(stObj->base.Target) ||
- stObj->pt->format != fmt ||
- stObj->pt->last_level < stObj->lastLevel ||
- stObj->pt->width0 != firstImage->base.Width2 ||
- stObj->pt->height0 != firstImage->base.Height2 ||
- stObj->pt->depth0 != firstImage->base.Depth2)
+ stObj->pt->format != firstImageFormat ||
+ stObj->pt->last_level != stObj->lastLevel ||
+ stObj->pt->width0 != stObj->width0 ||
+ stObj->pt->height0 != stObj->height0 ||
+ stObj->pt->depth0 != stObj->depth0)
{
+ /* The gallium texture does not match the Mesa texture so delete the
+ * gallium texture now. We'll make a new one below.
+ */
pipe_resource_reference(&stObj->pt, NULL);
pipe_sampler_view_reference(&stObj->sampler_view, NULL);
- ctx->st->dirty.st |= ST_NEW_FRAMEBUFFER;
+ st->dirty.st |= ST_NEW_FRAMEBUFFER;
}
}
/* May need to create a new gallium texture:
*/
if (!stObj->pt) {
- const enum pipe_format fmt =
- st_mesa_format_to_pipe_format(firstImage->base.TexFormat);
- GLuint usage = default_usage(fmt);
+ GLuint bindings = default_bindings(st, firstImageFormat);
- stObj->pt = st_texture_create(ctx->st,
+ stObj->pt = st_texture_create(st,
gl_target_to_pipe(stObj->base.Target),
- fmt,
+ firstImageFormat,
stObj->lastLevel,
- firstImage->base.Width2,
- firstImage->base.Height2,
- firstImage->base.Depth2,
- usage);
+ stObj->width0,
+ stObj->height0,
+ stObj->depth0,
+ bindings);
if (!stObj->pt) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
@@ -1873,12 +1928,12 @@ st_finalize_texture(GLcontext *ctx,
GLuint level;
for (level = 0; level <= stObj->lastLevel; level++) {
struct st_texture_image *stImage =
- st_texture_image(stObj->base.Image[face][stObj->base.BaseLevel + level]);
+ st_texture_image(stObj->base.Image[face][level]);
/* Need to import images in main memory or held in other textures.
*/
if (stImage && stObj->pt != stImage->pt) {
- copy_image_data_to_texture(ctx->st, stObj, level, stImage);
+ copy_image_data_to_texture(st, stObj, level, stImage);
*needFlush = GL_TRUE;
}
}
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index dfee490b54..3637f6e75f 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -201,7 +201,6 @@ struct st_framebuffer
{
GLframebuffer Base;
void *Private;
- GLuint InitWidth, InitHeight;
struct st_framebuffer_iface *iface;
enum st_attachment_type statts[ST_ATTACHMENT_COUNT];
diff --git a/src/mesa/state_tracker/st_debug.c b/src/mesa/state_tracker/st_debug.c
index 5dbabfa5c2..2da27fc4bd 100644
--- a/src/mesa/state_tracker/st_debug.c
+++ b/src/mesa/state_tracker/st_debug.c
@@ -47,6 +47,7 @@ int ST_DEBUG = 0;
static const struct debug_named_value st_debug_flags[] = {
{ "mesa", DEBUG_MESA },
{ "tgsi", DEBUG_TGSI },
+ { "constants",DEBUG_CONSTANTS },
{ "pipe", DEBUG_PIPE },
{ "tex", DEBUG_TEX },
{ "fallback", DEBUG_FALLBACK },
@@ -75,7 +76,7 @@ void
st_print_current(void)
{
GET_CURRENT_CONTEXT(ctx);
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
#if 0
int i;
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index a3620359db..4137596bd4 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -347,7 +347,8 @@ setup_interleaved_attribs(GLcontext *ctx,
struct pipe_vertex_buffer *vbuffer,
struct pipe_vertex_element velements[])
{
- struct pipe_context *pipe = ctx->st->pipe;
+ struct st_context *st = st_context(ctx);
+ struct pipe_context *pipe = st->pipe;
GLuint attr;
const GLubyte *offset0 = NULL;
@@ -412,7 +413,8 @@ setup_non_interleaved_attribs(GLcontext *ctx,
struct pipe_vertex_buffer vbuffer[],
struct pipe_vertex_element velements[])
{
- struct pipe_context *pipe = ctx->st->pipe;
+ struct st_context *st = st_context(ctx);
+ struct pipe_context *pipe = st->pipe;
GLuint attr;
for (attr = 0; attr < vpv->num_inputs; attr++) {
@@ -543,7 +545,8 @@ st_draw_vbo(GLcontext *ctx,
GLuint min_index,
GLuint max_index)
{
- struct pipe_context *pipe = ctx->st->pipe;
+ struct st_context *st = st_context(ctx);
+ struct pipe_context *pipe = st->pipe;
const struct st_vertex_program *vp;
const struct st_vp_varient *vpv;
struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS];
@@ -566,16 +569,16 @@ st_draw_vbo(GLcontext *ctx,
vertDataEdgeFlags = arrays[VERT_ATTRIB_EDGEFLAG]->BufferObj &&
arrays[VERT_ATTRIB_EDGEFLAG]->BufferObj->Name;
- if (vertDataEdgeFlags != ctx->st->vertdata_edgeflags) {
- ctx->st->vertdata_edgeflags = vertDataEdgeFlags;
- ctx->st->dirty.st |= ST_NEW_EDGEFLAGS_DATA;
+ if (vertDataEdgeFlags != st->vertdata_edgeflags) {
+ st->vertdata_edgeflags = vertDataEdgeFlags;
+ st->dirty.st |= ST_NEW_EDGEFLAGS_DATA;
}
- st_validate_state(ctx->st);
+ st_validate_state(st);
/* must get these after state validation! */
- vp = ctx->st->vp;
- vpv = ctx->st->vp_varient;
+ vp = st->vp;
+ vpv = st->vp_varient;
#if 0
if (MESA_VERBOSE & VERBOSE_GLSL) {
@@ -624,7 +627,7 @@ st_draw_vbo(GLcontext *ctx,
#endif
pipe->set_vertex_buffers(pipe, num_vbuffers, vbuffer);
- cso_set_vertex_elements(ctx->st->cso_context, num_velements, velements);
+ cso_set_vertex_elements(st->cso_context, num_velements, velements);
if (num_vbuffers == 0 || num_velements == 0)
return;
diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c
index 0889f1a522..a1f70e8693 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -55,7 +55,7 @@ static void
set_feedback_vertex_format(GLcontext *ctx)
{
#if 0
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
struct vertex_info vinfo;
GLuint i;
@@ -99,7 +99,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
GLuint min_index,
GLuint max_index)
{
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
struct draw_context *draw = st->draw;
const struct st_vertex_program *vp;
@@ -115,13 +115,13 @@ st_feedback_draw_vbo(GLcontext *ctx,
assert(draw);
- st_validate_state(ctx->st);
+ st_validate_state(st);
if (!index_bounds_valid)
vbo_get_minmax_index(ctx, prims, ib, &min_index, &max_index);
/* must get these after state validation! */
- vp = ctx->st->vp;
+ vp = st->vp;
vs = &st->vp_varient->tgsi;
if (!st->vp_varient->draw_shader) {
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 8a366d834e..d7d2be6d45 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -36,6 +36,7 @@
#include "main/context.h"
#include "main/texstore.h"
#include "main/enums.h"
+#include "main/image.h"
#include "main/macros.h"
#include "pipe/p_context.h"
@@ -160,6 +161,10 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat)
return PIPE_FORMAT_S8_USCALED_Z24_UNORM;
case MESA_FORMAT_S8_Z24:
return PIPE_FORMAT_Z24_UNORM_S8_USCALED;
+ case MESA_FORMAT_Z24_X8:
+ return PIPE_FORMAT_X8Z24_UNORM;
+ case MESA_FORMAT_X8_Z24:
+ return PIPE_FORMAT_Z24X8_UNORM;
case MESA_FORMAT_YCBCR:
return PIPE_FORMAT_UYVY;
#if FEATURE_texture_s3tc
@@ -299,6 +304,28 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
/**
+ * Return first supported format from the given list.
+ */
+static enum pipe_format
+find_supported_format(struct pipe_screen *screen,
+ const enum pipe_format formats[],
+ uint num_formats,
+ enum pipe_texture_target target,
+ unsigned tex_usage,
+ unsigned geom_flags)
+{
+ uint i;
+ for (i = 0; i < num_formats; i++) {
+ if (screen->is_format_supported(screen, formats[i], target,
+ tex_usage, geom_flags)) {
+ return formats[i];
+ }
+ }
+ return PIPE_FORMAT_NONE;
+}
+
+
+/**
* Find an RGBA format supported by the context/winsys.
*/
static enum pipe_format
@@ -313,15 +340,11 @@ default_rgba_format(struct pipe_screen *screen,
PIPE_FORMAT_A8B8G8R8_UNORM,
PIPE_FORMAT_B5G6R5_UNORM
};
- uint i;
- for (i = 0; i < Elements(colorFormats); i++) {
- if (screen->is_format_supported( screen, colorFormats[i], target, tex_usage, geom_flags )) {
- return colorFormats[i];
- }
- }
- return PIPE_FORMAT_NONE;
+ return find_supported_format(screen, colorFormats, Elements(colorFormats),
+ target, tex_usage, geom_flags);
}
+
/**
* Find an RGB format supported by the context/winsys.
*/
@@ -340,13 +363,8 @@ default_rgb_format(struct pipe_screen *screen,
PIPE_FORMAT_A8B8G8R8_UNORM,
PIPE_FORMAT_B5G6R5_UNORM
};
- uint i;
- for (i = 0; i < Elements(colorFormats); i++) {
- if (screen->is_format_supported( screen, colorFormats[i], target, tex_usage, geom_flags )) {
- return colorFormats[i];
- }
- }
- return PIPE_FORMAT_NONE;
+ return find_supported_format(screen, colorFormats, Elements(colorFormats),
+ target, tex_usage, geom_flags);
}
/**
@@ -363,115 +381,72 @@ default_srgba_format(struct pipe_screen *screen,
PIPE_FORMAT_A8R8G8B8_SRGB,
PIPE_FORMAT_A8B8G8R8_SRGB,
};
- uint i;
- for (i = 0; i < Elements(colorFormats); i++) {
- if (screen->is_format_supported( screen, colorFormats[i], target, tex_usage, geom_flags )) {
- return colorFormats[i];
- }
- }
- return PIPE_FORMAT_NONE;
-}
-
-/**
- * Search list of formats for first RGBA format with >8 bits/channel.
- */
-static enum pipe_format
-default_deep_rgba_format(struct pipe_screen *screen,
- enum pipe_texture_target target,
- unsigned tex_usage,
- unsigned geom_flags)
-{
- if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_SNORM, target, tex_usage, geom_flags)) {
- return PIPE_FORMAT_R16G16B16A16_SNORM;
- }
- if (tex_usage & PIPE_BIND_RENDER_TARGET)
- return default_rgba_format(screen, target, tex_usage, geom_flags);
- else
- return PIPE_FORMAT_NONE;
-}
-
-
-/**
- * Find an Z format supported by the context/winsys.
- */
-static enum pipe_format
-default_depth_format(struct pipe_screen *screen,
- enum pipe_texture_target target,
- unsigned tex_usage,
- unsigned geom_flags)
-{
- static const enum pipe_format zFormats[] = {
- PIPE_FORMAT_Z16_UNORM,
- PIPE_FORMAT_Z32_UNORM,
- PIPE_FORMAT_Z24_UNORM_S8_USCALED,
- PIPE_FORMAT_S8_USCALED_Z24_UNORM
- };
- uint i;
- for (i = 0; i < Elements(zFormats); i++) {
- if (screen->is_format_supported( screen, zFormats[i], target, tex_usage, geom_flags )) {
- return zFormats[i];
- }
- }
- return PIPE_FORMAT_NONE;
+ return find_supported_format(screen, colorFormats, Elements(colorFormats),
+ target, tex_usage, geom_flags);
}
/**
* Given an OpenGL internalFormat value for a texture or surface, return
* the best matching PIPE_FORMAT_x, or PIPE_FORMAT_NONE if there's no match.
+ * This is called during glTexImage2D, for example.
+ *
+ * The bindings parameter typically has PIPE_BIND_SAMPLER_VIEW set, plus
+ * either PIPE_BINDING_RENDER_TARGET or PIPE_BINDING_DEPTH_STENCIL if
+ * we want render-to-texture ability.
+ *
+ * \param internalFormat the user value passed to glTexImage2D
* \param target one of PIPE_TEXTURE_x
- * \param tex_usage either PIPE_BIND_RENDER_TARGET
- * or PIPE_BIND_SAMPLER_VIEW
+ * \param bindings bitmask of PIPE_BIND_x flags.
*/
enum pipe_format
st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
- enum pipe_texture_target target, unsigned tex_usage)
+ enum pipe_texture_target target, unsigned bindings)
{
- unsigned geom_flags = 0;
+ unsigned geom_flags = 0; /* we don't care about POT vs. NPOT here, yet */
switch (internalFormat) {
case 4:
case GL_RGBA:
- case GL_COMPRESSED_RGBA:
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
- return default_rgba_format( screen, target, tex_usage, geom_flags );
+ return default_rgba_format( screen, target, bindings, geom_flags );
case 3:
case GL_RGB:
- case GL_COMPRESSED_RGB:
- return default_rgb_format( screen, target, tex_usage, geom_flags );
+ return default_rgb_format( screen, target, bindings, geom_flags );
case GL_RGBA16:
- if (tex_usage & PIPE_BIND_RENDER_TARGET)
- return default_deep_rgba_format( screen, target, tex_usage, geom_flags );
- else
- return default_rgba_format( screen, target, tex_usage, geom_flags );
+ return default_rgba_format( screen, target, bindings, geom_flags );
case GL_RGBA4:
case GL_RGBA2:
- if (screen->is_format_supported( screen, PIPE_FORMAT_B4G4R4A4_UNORM, target, tex_usage, geom_flags ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_B4G4R4A4_UNORM,
+ target, bindings, geom_flags ))
return PIPE_FORMAT_B4G4R4A4_UNORM;
- return default_rgba_format( screen, target, tex_usage, geom_flags );
+ return default_rgba_format( screen, target, bindings, geom_flags );
case GL_RGB5_A1:
- if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM, target, tex_usage, geom_flags ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM,
+ target, bindings, geom_flags ))
return PIPE_FORMAT_B5G5R5A1_UNORM;
- return default_rgba_format( screen, target, tex_usage, geom_flags );
+ return default_rgba_format( screen, target, bindings, geom_flags );
case GL_RGB8:
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- return default_rgb_format( screen, target, tex_usage, geom_flags );
+ return default_rgb_format( screen, target, bindings, geom_flags );
case GL_RGB5:
case GL_RGB4:
case GL_R3_G3_B2:
- if (screen->is_format_supported( screen, PIPE_FORMAT_B5G6R5_UNORM, target, tex_usage, geom_flags ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_B5G6R5_UNORM,
+ target, bindings, geom_flags ))
return PIPE_FORMAT_B5G6R5_UNORM;
- if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM, target, tex_usage, geom_flags ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM,
+ target, bindings, geom_flags ))
return PIPE_FORMAT_B5G5R5A1_UNORM;
- return default_rgba_format( screen, target, tex_usage, geom_flags );
+ return default_rgba_format( screen, target, bindings, geom_flags );
case GL_ALPHA:
case GL_ALPHA4:
@@ -479,9 +454,10 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
case GL_ALPHA12:
case GL_ALPHA16:
case GL_COMPRESSED_ALPHA:
- if (screen->is_format_supported( screen, PIPE_FORMAT_A8_UNORM, target, tex_usage, geom_flags ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_A8_UNORM, target,
+ bindings, geom_flags ))
return PIPE_FORMAT_A8_UNORM;
- return default_rgba_format( screen, target, tex_usage, geom_flags );
+ return default_rgba_format( screen, target, bindings, geom_flags );
case 1:
case GL_LUMINANCE:
@@ -490,9 +466,10 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
case GL_LUMINANCE12:
case GL_LUMINANCE16:
case GL_COMPRESSED_LUMINANCE:
- if (screen->is_format_supported( screen, PIPE_FORMAT_L8_UNORM, target, tex_usage, geom_flags ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_L8_UNORM, target,
+ bindings, geom_flags ))
return PIPE_FORMAT_L8_UNORM;
- return default_rgba_format( screen, target, tex_usage, geom_flags );
+ return default_rgba_format( screen, target, bindings, geom_flags );
case 2:
case GL_LUMINANCE_ALPHA:
@@ -503,9 +480,10 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
case GL_LUMINANCE12_ALPHA12:
case GL_LUMINANCE16_ALPHA16:
case GL_COMPRESSED_LUMINANCE_ALPHA:
- if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_UNORM, target, tex_usage, geom_flags ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_UNORM, target,
+ bindings, geom_flags ))
return PIPE_FORMAT_L8A8_UNORM;
- return default_rgba_format( screen, target, tex_usage, geom_flags );
+ return default_rgba_format( screen, target, bindings, geom_flags );
case GL_INTENSITY:
case GL_INTENSITY4:
@@ -513,36 +491,73 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
case GL_INTENSITY12:
case GL_INTENSITY16:
case GL_COMPRESSED_INTENSITY:
- if (screen->is_format_supported( screen, PIPE_FORMAT_I8_UNORM, target, tex_usage, geom_flags ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_I8_UNORM, target,
+ bindings, geom_flags ))
return PIPE_FORMAT_I8_UNORM;
- return default_rgba_format( screen, target, tex_usage, geom_flags );
+ return default_rgba_format( screen, target, bindings, geom_flags );
case GL_YCBCR_MESA:
if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY,
- target, tex_usage, geom_flags)) {
+ target, bindings, geom_flags)) {
return PIPE_FORMAT_UYVY;
}
if (screen->is_format_supported(screen, PIPE_FORMAT_YUYV,
- target, tex_usage, geom_flags)) {
+ target, bindings, geom_flags)) {
return PIPE_FORMAT_YUYV;
}
return PIPE_FORMAT_NONE;
+ case GL_COMPRESSED_RGB:
+ /* can only sample from compressed formats */
+ if (bindings & ~PIPE_BIND_SAMPLER_VIEW)
+ return PIPE_FORMAT_NONE;
+ else if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGB,
+ target, bindings, geom_flags))
+ return PIPE_FORMAT_DXT1_RGB;
+ else
+ return default_rgb_format(screen, target, bindings, geom_flags);
+
+ case GL_COMPRESSED_RGBA:
+ /* can only sample from compressed formats */
+ if (bindings & ~PIPE_BIND_SAMPLER_VIEW)
+ return PIPE_FORMAT_NONE;
+ else if (screen->is_format_supported(screen, PIPE_FORMAT_DXT3_RGBA,
+ target, bindings, geom_flags))
+ return PIPE_FORMAT_DXT3_RGBA;
+ else
+ return default_rgba_format(screen, target, bindings, geom_flags);
+
case GL_RGB_S3TC:
case GL_RGB4_S3TC:
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- return PIPE_FORMAT_DXT1_RGB;
+ if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGB,
+ target, bindings, geom_flags))
+ return PIPE_FORMAT_DXT1_RGB;
+ else
+ return PIPE_FORMAT_NONE;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- return PIPE_FORMAT_DXT1_RGBA;
+ if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGBA,
+ target, bindings, geom_flags))
+ return PIPE_FORMAT_DXT1_RGBA;
+ else
+ return PIPE_FORMAT_NONE;
case GL_RGBA_S3TC:
case GL_RGBA4_S3TC:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- return PIPE_FORMAT_DXT3_RGBA;
+ if (screen->is_format_supported(screen, PIPE_FORMAT_DXT3_RGBA,
+ target, bindings, geom_flags))
+ return PIPE_FORMAT_DXT3_RGBA;
+ else
+ return PIPE_FORMAT_NONE;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- return PIPE_FORMAT_DXT5_RGBA;
+ if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
+ target, bindings, geom_flags))
+ return PIPE_FORMAT_DXT5_RGBA;
+ else
+ return PIPE_FORMAT_NONE;
#if 0
case GL_COMPRESSED_RGB_FXT1_3DFX:
@@ -552,42 +567,60 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
#endif
case GL_DEPTH_COMPONENT16:
- if (screen->is_format_supported( screen, PIPE_FORMAT_Z16_UNORM, target, tex_usage, geom_flags ))
+ if (screen->is_format_supported(screen, PIPE_FORMAT_Z16_UNORM, target,
+ bindings, geom_flags))
return PIPE_FORMAT_Z16_UNORM;
/* fall-through */
case GL_DEPTH_COMPONENT24:
- if (screen->is_format_supported( screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, target, tex_usage, geom_flags ))
+ if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
+ target, bindings, geom_flags))
return PIPE_FORMAT_Z24_UNORM_S8_USCALED;
- if (screen->is_format_supported( screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, target, tex_usage, geom_flags ))
+ if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
+ target, bindings, geom_flags))
return PIPE_FORMAT_S8_USCALED_Z24_UNORM;
/* fall-through */
case GL_DEPTH_COMPONENT32:
- if (screen->is_format_supported( screen, PIPE_FORMAT_Z32_UNORM, target, tex_usage, geom_flags ))
+ if (screen->is_format_supported(screen, PIPE_FORMAT_Z32_UNORM,
+ target, bindings, geom_flags))
return PIPE_FORMAT_Z32_UNORM;
/* fall-through */
case GL_DEPTH_COMPONENT:
- return default_depth_format( screen, target, tex_usage, geom_flags );
+ {
+ static const enum pipe_format formats[] = {
+ PIPE_FORMAT_Z16_UNORM,
+ PIPE_FORMAT_Z32_UNORM,
+ PIPE_FORMAT_Z24_UNORM_S8_USCALED,
+ PIPE_FORMAT_S8_USCALED_Z24_UNORM
+ };
+ return find_supported_format(screen, formats, Elements(formats),
+ target, bindings, geom_flags);
+ }
case GL_STENCIL_INDEX:
case GL_STENCIL_INDEX1_EXT:
case GL_STENCIL_INDEX4_EXT:
case GL_STENCIL_INDEX8_EXT:
case GL_STENCIL_INDEX16_EXT:
- if (screen->is_format_supported( screen, PIPE_FORMAT_S8_USCALED, target, tex_usage, geom_flags ))
- return PIPE_FORMAT_S8_USCALED;
- if (screen->is_format_supported( screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, target, tex_usage, geom_flags ))
- return PIPE_FORMAT_Z24_UNORM_S8_USCALED;
- if (screen->is_format_supported( screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, target, tex_usage, geom_flags ))
- return PIPE_FORMAT_S8_USCALED_Z24_UNORM;
- return PIPE_FORMAT_NONE;
+ {
+ static const enum pipe_format formats[] = {
+ PIPE_FORMAT_S8_USCALED,
+ PIPE_FORMAT_Z24_UNORM_S8_USCALED,
+ PIPE_FORMAT_S8_USCALED_Z24_UNORM
+ };
+ return find_supported_format(screen, formats, Elements(formats),
+ target, bindings, geom_flags);
+ }
case GL_DEPTH_STENCIL_EXT:
case GL_DEPTH24_STENCIL8_EXT:
- if (screen->is_format_supported( screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, target, tex_usage, geom_flags ))
- return PIPE_FORMAT_Z24_UNORM_S8_USCALED;
- if (screen->is_format_supported( screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, target, tex_usage, geom_flags ))
- return PIPE_FORMAT_S8_USCALED_Z24_UNORM;
- return PIPE_FORMAT_NONE;
+ {
+ static const enum pipe_format formats[] = {
+ PIPE_FORMAT_Z24_UNORM_S8_USCALED,
+ PIPE_FORMAT_S8_USCALED_Z24_UNORM
+ };
+ return find_supported_format(screen, formats, Elements(formats),
+ target, bindings, geom_flags);
+ }
case GL_SRGB_EXT:
case GL_SRGB8_EXT:
@@ -595,7 +628,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
case GL_COMPRESSED_SRGB_ALPHA_EXT:
case GL_SRGB_ALPHA_EXT:
case GL_SRGB8_ALPHA8_EXT:
- return default_srgba_format( screen, target, tex_usage, geom_flags );
+ return default_srgba_format( screen, target, bindings, geom_flags );
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
return PIPE_FORMAT_DXT1_SRGB;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
@@ -609,15 +642,17 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
case GL_SLUMINANCE8_ALPHA8_EXT:
case GL_COMPRESSED_SLUMINANCE_EXT:
case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
- if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_SRGB, target, tex_usage, geom_flags ))
+ if (screen->is_format_supported(screen, PIPE_FORMAT_L8A8_SRGB,
+ target, bindings, geom_flags))
return PIPE_FORMAT_L8A8_SRGB;
- return default_srgba_format( screen, target, tex_usage, geom_flags );
+ return default_srgba_format( screen, target, bindings, geom_flags );
case GL_SLUMINANCE_EXT:
case GL_SLUMINANCE8_EXT:
- if (screen->is_format_supported( screen, PIPE_FORMAT_L8_SRGB, target, tex_usage, geom_flags ))
+ if (screen->is_format_supported(screen, PIPE_FORMAT_L8_SRGB,
+ target, bindings, geom_flags))
return PIPE_FORMAT_L8_SRGB;
- return default_srgba_format( screen, target, tex_usage, geom_flags );
+ return default_srgba_format( screen, target, bindings, geom_flags );
default:
return PIPE_FORMAT_NONE;
@@ -625,27 +660,6 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
}
-static GLboolean
-is_depth_or_stencil_format(GLenum internalFormat)
-{
- switch (internalFormat) {
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_COMPONENT16:
- case GL_DEPTH_COMPONENT24:
- case GL_DEPTH_COMPONENT32:
- case GL_STENCIL_INDEX:
- case GL_STENCIL_INDEX1_EXT:
- case GL_STENCIL_INDEX4_EXT:
- case GL_STENCIL_INDEX8_EXT:
- case GL_STENCIL_INDEX16_EXT:
- case GL_DEPTH_STENCIL_EXT:
- case GL_DEPTH24_STENCIL8_EXT:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
/**
* Called by FBO code to choose a PIPE_FORMAT_ for drawing surfaces.
*/
@@ -654,7 +668,7 @@ st_choose_renderbuffer_format(struct pipe_screen *screen,
GLenum internalFormat)
{
uint usage;
- if (is_depth_or_stencil_format(internalFormat))
+ if (_mesa_is_depth_or_stencil_format(internalFormat))
usage = PIPE_BIND_DEPTH_STENCIL;
else
usage = PIPE_BIND_RENDER_TARGET;
@@ -669,15 +683,35 @@ gl_format
st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
GLenum format, GLenum type)
{
+ struct pipe_screen *screen = st_context(ctx)->pipe->screen;
enum pipe_format pFormat;
+ uint bindings;
(void) format;
(void) type;
- pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat,
- PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW);
- if (pFormat == PIPE_FORMAT_NONE)
+ /* GL textures may wind up being render targets, but we don't know
+ * that in advance. Specify potential render target flags now.
+ */
+ if (_mesa_is_depth_format(internalFormat) ||
+ _mesa_is_depthstencil_format(internalFormat))
+ bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_DEPTH_STENCIL;
+ else
+ bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
+
+ pFormat = st_choose_format(screen, internalFormat,
+ PIPE_TEXTURE_2D, bindings);
+
+ if (pFormat == PIPE_FORMAT_NONE) {
+ /* try choosing format again, this time without render target bindings */
+ pFormat = st_choose_format(screen, internalFormat,
+ PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW);
+ }
+
+ if (pFormat == PIPE_FORMAT_NONE) {
+ /* no luck at all */
return MESA_FORMAT_NONE;
+ }
return st_pipe_format_to_mesa_format(pFormat);
}
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index 5b7a962037..a015c4bb58 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -27,27 +27,19 @@
#include "main/imports.h"
-#include "main/macros.h"
#include "main/mipmap.h"
#include "main/teximage.h"
#include "main/texformat.h"
-#include "shader/prog_instruction.h"
-
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_gen_mipmap.h"
-#include "util/u_math.h"
-
-#include "cso_cache/cso_cache.h"
-#include "cso_cache/cso_context.h"
#include "st_debug.h"
#include "st_context.h"
#include "st_gen_mipmap.h"
-#include "st_texture.h"
#include "st_cb_texture.h"
#include "st_inlines.h"
@@ -102,11 +94,48 @@ st_render_mipmap(struct st_context *st,
}
+/**
+ * Helper function to decompress an image. The result is a 32-bpp RGBA
+ * image with stride==width.
+ */
+static void
+decompress_image(enum pipe_format format,
+ const uint8_t *src, uint8_t *dst,
+ unsigned width, unsigned height)
+{
+ const struct util_format_description *desc = util_format_description(format);
+ const uint dst_stride = 4 * width;
+ const uint src_stride = util_format_get_stride(format, width);
+
+ desc->unpack_rgba_8unorm(dst, dst_stride, src, src_stride, width, height);
+}
+
+
+/**
+ * Helper function to compress an image. The source is a 32-bpp RGBA image
+ * with stride==width.
+ */
+static void
+compress_image(enum pipe_format format,
+ const uint8_t *src, uint8_t *dst,
+ unsigned width, unsigned height)
+{
+ const struct util_format_description *desc = util_format_description(format);
+ const uint dst_stride = util_format_get_stride(format, width);
+ const uint src_stride = 4 * width;
+
+ desc->pack_rgba_8unorm(dst, dst_stride, src, src_stride, width, height);
+}
+
+
+/**
+ * Software fallback for generate mipmap levels.
+ */
static void
fallback_generate_mipmap(GLcontext *ctx, GLenum target,
struct gl_texture_object *texObj)
{
- struct pipe_context *pipe = ctx->st->pipe;
+ struct pipe_context *pipe = st_context(ctx)->pipe;
struct pipe_resource *pt = st_get_texobj_resource(texObj);
const uint baseLevel = texObj->BaseLevel;
const uint lastLevel = pt->last_level;
@@ -114,17 +143,34 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
uint dstLevel;
GLenum datatype;
GLuint comps;
+ GLboolean compressed;
if (ST_DEBUG & DEBUG_FALLBACK)
debug_printf("%s: fallback processing\n", __FUNCTION__);
assert(target != GL_TEXTURE_3D); /* not done yet */
- _mesa_format_to_type_and_comps(texObj->Image[face][baseLevel]->TexFormat,
- &datatype, &comps);
+ compressed =
+ _mesa_is_format_compressed(texObj->Image[face][baseLevel]->TexFormat);
+
+ if (compressed) {
+ datatype = GL_UNSIGNED_BYTE;
+ comps = 4;
+ }
+ else {
+ _mesa_format_to_type_and_comps(texObj->Image[face][baseLevel]->TexFormat,
+ &datatype, &comps);
+ assert(comps > 0 && "bad texture format in fallback_generate_mipmap()");
+ }
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
const uint srcLevel = dstLevel - 1;
+ const uint srcWidth = u_minify(pt->width0, srcLevel);
+ const uint srcHeight = u_minify(pt->height0, srcLevel);
+ const uint srcDepth = u_minify(pt->depth0, srcLevel);
+ const uint dstWidth = u_minify(pt->width0, dstLevel);
+ const uint dstHeight = u_minify(pt->height0, dstLevel);
+ const uint dstDepth = u_minify(pt->depth0, dstLevel);
struct pipe_transfer *srcTrans, *dstTrans;
const ubyte *srcData;
ubyte *dstData;
@@ -133,14 +179,13 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
srcTrans = st_cond_flush_get_tex_transfer(st_context(ctx), pt, face,
srcLevel, zslice,
PIPE_TRANSFER_READ, 0, 0,
- u_minify(pt->width0, srcLevel),
- u_minify(pt->height0, srcLevel));
+ srcWidth, srcHeight);
+
dstTrans = st_cond_flush_get_tex_transfer(st_context(ctx), pt, face,
dstLevel, zslice,
PIPE_TRANSFER_WRITE, 0, 0,
- u_minify(pt->width0, dstLevel),
- u_minify(pt->height0, dstLevel));
+ dstWidth, dstHeight);
srcData = (ubyte *) pipe_transfer_map(pipe, srcTrans);
dstData = (ubyte *) pipe_transfer_map(pipe, dstTrans);
@@ -148,18 +193,49 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
srcStride = srcTrans->stride / util_format_get_blocksize(srcTrans->resource->format);
dstStride = dstTrans->stride / util_format_get_blocksize(dstTrans->resource->format);
- _mesa_generate_mipmap_level(target, datatype, comps,
- 0 /*border*/,
- u_minify(pt->width0, srcLevel),
- u_minify(pt->height0, srcLevel),
- u_minify(pt->depth0, srcLevel),
- srcData,
- srcStride, /* stride in texels */
- u_minify(pt->width0, dstLevel),
- u_minify(pt->height0, dstLevel),
- u_minify(pt->depth0, dstLevel),
- dstData,
- dstStride); /* stride in texels */
+ if (compressed) {
+ const enum pipe_format format = pt->format;
+ const uint bw = util_format_get_blockwidth(format);
+ const uint bh = util_format_get_blockheight(format);
+ const uint srcWidth2 = align(srcWidth, bw);
+ const uint srcHeight2 = align(srcHeight, bh);
+ const uint dstWidth2 = align(dstWidth, bw);
+ const uint dstHeight2 = align(dstHeight, bh);
+ uint8_t *srcTemp, *dstTemp;
+
+ assert(comps == 4);
+
+ srcTemp = malloc(srcWidth2 * srcHeight2 * comps + 000);
+ dstTemp = malloc(dstWidth2 * dstHeight2 * comps + 000);
+
+ /* decompress the src image: srcData -> srcTemp */
+ decompress_image(format, srcData, srcTemp, srcWidth, srcHeight);
+
+ _mesa_generate_mipmap_level(target, datatype, comps,
+ 0 /*border*/,
+ srcWidth2, srcHeight2, srcDepth,
+ srcTemp,
+ srcWidth2, /* stride in texels */
+ dstWidth2, dstHeight2, dstDepth,
+ dstTemp,
+ dstWidth2); /* stride in texels */
+
+ /* compress the new image: dstTemp -> dstData */
+ compress_image(format, dstTemp, dstData, dstWidth2, dstHeight2);
+
+ free(srcTemp);
+ free(dstTemp);
+ }
+ else {
+ _mesa_generate_mipmap_level(target, datatype, comps,
+ 0 /*border*/,
+ srcWidth, srcHeight, srcDepth,
+ srcData,
+ srcStride, /* stride in texels */
+ dstWidth, dstHeight, dstDepth,
+ dstData,
+ dstStride); /* stride in texels */
+ }
pipe_transfer_unmap(pipe, srcTrans);
pipe_transfer_unmap(pipe, dstTrans);
@@ -174,7 +250,7 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
* Compute the expected number of mipmap levels in the texture given
* the width/height/depth of the base image and the GL_TEXTURE_BASE_LEVEL/
* GL_TEXTURE_MAX_LEVEL settings. This will tell us how many mipmap
- * level should be generated.
+ * levels should be generated.
*/
static GLuint
compute_num_levels(GLcontext *ctx,
@@ -207,11 +283,14 @@ compute_num_levels(GLcontext *ctx,
}
+/**
+ * Called via ctx->Driver.GenerateMipmap().
+ */
void
st_generate_mipmap(GLcontext *ctx, GLenum target,
struct gl_texture_object *texObj)
{
- struct st_context *st = ctx->st;
+ struct st_context *st = st_context(ctx);
struct st_texture_object *stObj = st_texture_object(texObj);
struct pipe_resource *pt = st_get_texobj_resource(texObj);
const uint baseLevel = texObj->BaseLevel;
@@ -263,10 +342,10 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
assert(lastLevel <= pt->last_level);
- /* Recall that the Mesa BaseLevel image is stored in the gallium
- * texture's level[0] position. So pass baseLevel=0 here.
+ /* Try to generate the mipmap by rendering/texturing. If that fails,
+ * use the software fallback.
*/
- if (!st_render_mipmap(st, target, stObj, 0, lastLevel)) {
+ if (!st_render_mipmap(st, target, stObj, baseLevel, lastLevel)) {
fallback_generate_mipmap(ctx, target, texObj);
}
@@ -298,7 +377,9 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
dstImage->TexFormat = srcImage->TexFormat;
- stImage = (struct st_texture_image *) dstImage;
+ stImage = st_texture_image(dstImage);
+ stImage->level = dstLevel;
+
pipe_resource_reference(&stImage->pt, pt);
}
}
diff --git a/src/mesa/state_tracker/st_gl_api.h b/src/mesa/state_tracker/st_gl_api.h
new file mode 100644
index 0000000000..52c3fa0b41
--- /dev/null
+++ b/src/mesa/state_tracker/st_gl_api.h
@@ -0,0 +1,9 @@
+
+#ifndef ST_GL_API_H
+#define ST_GL_API_H
+
+#include "state_tracker/st_api.h"
+
+struct st_api * st_gl_api_create(void);
+
+#endif
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index 5cf17fe530..44d59d4476 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -26,7 +26,7 @@
* Chia-I Wu <olv@lunarg.com>
*/
-#include "state_tracker/st_api.h"
+#include "state_tracker/st_gl_api.h"
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
@@ -692,7 +692,6 @@ st_api_get_proc_address(struct st_api *stapi, const char *procname)
static void
st_api_destroy(struct st_api *stapi)
{
- FREE(stapi);
}
/**
@@ -791,24 +790,22 @@ st_manager_add_color_renderbuffer(struct st_context *st, GLframebuffer *fb,
return TRUE;
}
+struct st_api st_gl_api = {
+ st_api_destroy,
+ st_api_get_proc_address,
+ st_api_is_visual_supported,
+ st_api_create_context,
+ st_api_make_current,
+ st_api_get_current,
+};
+
/**
- * Create an st_api to manage the state tracker.
+ * Return the st_api for this state tracker. This might either be GL, GLES1,
+ * GLES2 that mostly depends on the build and link options. But these
+ * functions remain the same either way.
*/
struct st_api *
-st_manager_create_api(void)
+st_gl_api_create(void)
{
- struct st_api *stapi;
-
- stapi = CALLOC_STRUCT(st_api);
- if (stapi) {
- stapi->destroy = st_api_destroy;
- stapi->get_proc_address = st_api_get_proc_address;
- stapi->is_visual_supported = st_api_is_visual_supported;
-
- stapi->create_context = st_api_create_context;
- stapi->make_current = st_api_make_current;
- stapi->get_current = st_api_get_current;
- }
-
- return stapi;
+ return &st_gl_api;
}
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 6e8c446f78..772a2ee17c 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -217,6 +217,12 @@ st_translate_vertex_program(struct st_context *st,
num_outputs++;
}
+ if (ST_DEBUG & DEBUG_MESA) {
+ _mesa_print_program(&stvp->Base.Base);
+ _mesa_print_program_parameters(st->ctx, &stvp->Base.Base);
+ debug_printf("\n");
+ }
+
error =
st_translate_mesa_program(st->ctx,
TGSI_PROCESSOR_VERTEX,
@@ -246,11 +252,6 @@ st_translate_vertex_program(struct st_context *st,
vpv->driver_shader = pipe->create_vs_state(pipe, &vpv->tgsi);
- if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) {
- _mesa_print_program(&stvp->Base.Base);
- debug_printf("\n");
- }
-
if (ST_DEBUG & DEBUG_TGSI) {
tgsi_dump( vpv->tgsi.tokens, 0 );
debug_printf("\n");
@@ -423,6 +424,11 @@ st_translate_fragment_program(struct st_context *st,
if (ureg == NULL)
return;
+ if (ST_DEBUG & DEBUG_MESA) {
+ _mesa_print_program(&stfp->Base.Base);
+ _mesa_print_program_parameters(st->ctx, &stfp->Base.Base);
+ debug_printf("\n");
+ }
error =
st_translate_mesa_program(st->ctx,
@@ -445,11 +451,6 @@ st_translate_fragment_program(struct st_context *st,
ureg_destroy( ureg );
stfp->driver_shader = pipe->create_fs_state(pipe, &stfp->tgsi);
- if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) {
- _mesa_print_program(&stfp->Base.Base);
- debug_printf("\n");
- }
-
if (ST_DEBUG & DEBUG_TGSI) {
tgsi_dump( stfp->tgsi.tokens, 0/*TGSI_DUMP_VERBOSE*/ );
debug_printf("\n");
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index 70ba239d07..722f60e425 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -142,42 +142,6 @@ st_texture_match_image(const struct pipe_resource *pt,
}
-#if 000
-/* Although we use the image_offset[] array to store relative offsets
- * to cube faces, Mesa doesn't know anything about this and expects
- * each cube face to be treated as a separate image.
- *
- * These functions present that view to mesa:
- */
-const GLuint *
-st_texture_depth_offsets(struct pipe_resource *pt, GLuint level)
-{
- static const GLuint zero = 0;
-
- if (pt->target != PIPE_TEXTURE_3D || pt->level[level].nr_images == 1)
- return &zero;
- else
- return pt->level[level].image_offset;
-}
-
-
-/**
- * Return the offset to the given mipmap texture image within the
- * texture memory buffer, in bytes.
- */
-GLuint
-st_texture_image_offset(const struct pipe_resource * pt,
- GLuint face, GLuint level)
-{
- if (pt->target == PIPE_TEXTURE_CUBE)
- return (pt->level[level].level_offset +
- pt->level[level].image_offset[face] * pt->cpp);
- else
- return pt->level[level].level_offset;
-}
-#endif
-
-
/**
* Map a teximage in a mipmap texture.
* \param row_stride returns row stride in bytes
@@ -305,6 +269,9 @@ st_texture_image_copy(struct pipe_context *pipe,
struct pipe_surface *dst_surface;
GLuint i;
+ assert(src->width0 == dst->width0);
+ assert(src->height0 == dst->height0);
+
for (i = 0; i < depth; i++) {
GLuint srcLevel;
diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
index 416468478b..447f091db1 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -38,6 +38,9 @@
struct pipe_resource;
+/**
+ * Subclass of gl_texure_image.
+ */
struct st_texture_image
{
struct gl_texture_image base;
@@ -57,7 +60,9 @@ struct st_texture_image
};
-
+/**
+ * Subclass of gl_texure_object.
+ */
struct st_texture_object
{
struct gl_texture_object base; /* The "parent" object */
@@ -66,6 +71,9 @@ struct st_texture_object
*/
GLuint lastLevel;
+ /** The size of the level=0 mipmap image */
+ GLuint width0, height0, depth0;
+
/* On validation any active images held in main memory or in other
* textures will be copied to this texture and the old storage freed.
*/
@@ -76,8 +84,6 @@ struct st_texture_object
*/
struct pipe_sampler_view *sampler_view;
- GLboolean teximage_realloc;
-
/* True if there is/was a surface bound to this texture object. It helps
* track whether the texture object is surface based or not.
*/
@@ -185,18 +191,6 @@ extern const GLuint *
st_texture_depth_offsets(struct pipe_resource *pt, GLuint level);
-/* Return the linear offset of an image relative to the start of its region.
- */
-extern GLuint
-st_texture_image_offset(const struct pipe_resource *pt,
- GLuint face, GLuint level);
-
-extern GLuint
-st_texture_texel_offset(const struct pipe_resource * pt,
- GLuint face, GLuint level,
- GLuint col, GLuint row, GLuint img);
-
-
/* Upload an image into a texture
*/
extern void
diff --git a/src/mesa/x86-64/xform4.S b/src/mesa/x86-64/xform4.S
index 805969127d..e52a6118c3 100644
--- a/src/mesa/x86-64/xform4.S
+++ b/src/mesa/x86-64/xform4.S
@@ -30,6 +30,7 @@
.align 16
.globl _mesa_x86_64_cpuid
+.hidden _mesa_x86_64_cpuid
_mesa_x86_64_cpuid:
pushq %rbx
movl (%rdi), %eax
@@ -46,6 +47,7 @@ _mesa_x86_64_cpuid:
.align 16
.globl _mesa_x86_64_transform_points4_general
+.hidden _mesa_x86_64_transform_points4_general
_mesa_x86_64_transform_points4_general:
/*
* rdi = dest
@@ -121,6 +123,7 @@ p4_constants:
.text
.align 16
.globl _mesa_x86_64_transform_points4_3d
+.hidden _mesa_x86_64_transform_points4_3d
/*
* this is slower than _mesa_x86_64_transform_points4_general
* because it ensures that the last matrix row (or is it column?) is 0,0,0,1
@@ -192,6 +195,7 @@ p4_3d_done:
.align 16
.globl _mesa_x86_64_transform_points4_identity
+.hidden _mesa_x86_64_transform_points4_identity
_mesa_x86_64_transform_points4_identity:
movl V4F_COUNT(%rdx), %ecx /* count */
@@ -220,6 +224,7 @@ p4_identity_done:
.align 16
.globl _mesa_3dnow_transform_points4_3d_no_rot
+.hidden _mesa_3dnow_transform_points4_3d_no_rot
_mesa_3dnow_transform_points4_3d_no_rot:
movl V4F_COUNT(%rdx), %ecx /* count */
@@ -284,6 +289,7 @@ p4_3d_no_rot_done:
.align 16
.globl _mesa_3dnow_transform_points4_perspective
+.hidden _mesa_3dnow_transform_points4_perspective
_mesa_3dnow_transform_points4_perspective:
movl V4F_COUNT(%rdx), %ecx /* count */
@@ -350,6 +356,7 @@ p4_perspective_done:
.align 16
.globl _mesa_3dnow_transform_points4_2d_no_rot
+.hidden _mesa_3dnow_transform_points4_2d_no_rot
_mesa_3dnow_transform_points4_2d_no_rot:
movl V4F_COUNT(%rdx), %ecx /* count */
@@ -405,6 +412,7 @@ p4_2d_no_rot_done:
.align 16
.globl _mesa_3dnow_transform_points4_2d
+.hidden _mesa_3dnow_transform_points4_2d
_mesa_3dnow_transform_points4_2d:
movl V4F_COUNT(%rdx), %ecx /* count */