aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/swrast/s_context.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/swrast/s_context.c')
-rw-r--r--mesalib/src/mesa/swrast/s_context.c105
1 files changed, 20 insertions, 85 deletions
diff --git a/mesalib/src/mesa/swrast/s_context.c b/mesalib/src/mesa/swrast/s_context.c
index def1531d7..792b528ee 100644
--- a/mesalib/src/mesa/swrast/s_context.c
+++ b/mesalib/src/mesa/swrast/s_context.c
@@ -417,84 +417,6 @@ _swrast_validate_blend_func(struct gl_context *ctx, GLuint n, const GLubyte mask
swrast->BlendFunc( ctx, n, mask, src, dst, chanType );
}
-
-/**
- * Make sure we have texture image data for all the textures we may need
- * for subsequent rendering.
- */
-static void
-_swrast_validate_texture_images(struct gl_context *ctx)
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- GLuint u;
-
- if (!swrast->ValidateTextureImage || !ctx->Texture._EnabledUnits) {
- /* no textures enabled, or no way to validate images! */
- return;
- }
-
- for (u = 0; u < ctx->Const.MaxTextureImageUnits; u++) {
- if (ctx->Texture.Unit[u]._ReallyEnabled) {
- struct gl_texture_object *texObj = ctx->Texture.Unit[u]._Current;
- ASSERT(texObj);
- if (texObj) {
- GLuint numFaces = (texObj->Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
- GLuint face;
- for (face = 0; face < numFaces; face++) {
- GLint lvl;
- for (lvl = texObj->BaseLevel; lvl <= texObj->_MaxLevel; lvl++) {
- struct gl_texture_image *texImg = texObj->Image[face][lvl];
- if (texImg && !texImg->Data) {
- swrast->ValidateTextureImage(ctx, texObj, face, lvl);
- ASSERT(texObj->Image[face][lvl]->Data);
- }
- }
- }
- }
- }
- }
-}
-
-
-/**
- * Free the texture image data attached to all currently enabled
- * textures. Meant to be called by device drivers when transitioning
- * from software to hardware rendering.
- */
-void
-_swrast_eject_texture_images(struct gl_context *ctx)
-{
- GLuint u;
-
- if (!ctx->Texture._EnabledUnits) {
- /* no textures enabled */
- return;
- }
-
- for (u = 0; u < ctx->Const.MaxTextureImageUnits; u++) {
- if (ctx->Texture.Unit[u]._ReallyEnabled) {
- struct gl_texture_object *texObj = ctx->Texture.Unit[u]._Current;
- ASSERT(texObj);
- if (texObj) {
- GLuint numFaces = (texObj->Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
- GLuint face;
- for (face = 0; face < numFaces; face++) {
- GLint lvl;
- for (lvl = texObj->BaseLevel; lvl <= texObj->_MaxLevel; lvl++) {
- struct gl_texture_image *texImg = texObj->Image[face][lvl];
- if (texImg && texImg->Data) {
- _mesa_free_texmemory(texImg->Data);
- texImg->Data = NULL;
- }
- }
- }
- }
- }
- }
-}
-
-
-
static void
_swrast_sleep( struct gl_context *ctx, GLbitfield new_state )
{
@@ -640,7 +562,6 @@ _swrast_validate_derived( struct gl_context *ctx )
if (swrast->NewState & (_NEW_TEXTURE | _NEW_PROGRAM)) {
_swrast_update_texture_samplers( ctx );
- _swrast_validate_texture_images(ctx);
}
if (swrast->NewState & (_NEW_COLOR | _NEW_PROGRAM))
@@ -772,6 +693,11 @@ _swrast_CreateContext( struct gl_context *ctx )
{
GLuint i;
SWcontext *swrast = (SWcontext *)CALLOC(sizeof(SWcontext));
+#ifdef _OPENMP
+ const GLint maxThreads = omp_get_max_threads();
+#else
+ const GLint maxThreads = 1;
+#endif
if (SWRAST_DEBUG) {
_mesa_debug(ctx, "_swrast_CreateContext\n");
@@ -806,19 +732,25 @@ _swrast_CreateContext( struct gl_context *ctx )
for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
swrast->TextureSample[i] = NULL;
- swrast->SpanArrays = MALLOC_STRUCT(sw_span_arrays);
+ /* SpanArrays is global and shared by all SWspan instances. However, when
+ * using multiple threads, it is necessary to have one SpanArrays instance
+ * per thread.
+ */
+ swrast->SpanArrays = (SWspanarrays *) MALLOC(maxThreads * sizeof(SWspanarrays));
if (!swrast->SpanArrays) {
FREE(swrast);
return GL_FALSE;
}
- swrast->SpanArrays->ChanType = CHAN_TYPE;
+ for(i = 0; i < maxThreads; i++) {
+ swrast->SpanArrays[i].ChanType = CHAN_TYPE;
#if CHAN_TYPE == GL_UNSIGNED_BYTE
- swrast->SpanArrays->rgba = swrast->SpanArrays->rgba8;
+ swrast->SpanArrays[i].rgba = swrast->SpanArrays[i].rgba8;
#elif CHAN_TYPE == GL_UNSIGNED_SHORT
- swrast->SpanArrays->rgba = swrast->SpanArrays->rgba16;
+ swrast->SpanArrays[i].rgba = swrast->SpanArrays[i].rgba16;
#else
- swrast->SpanArrays->rgba = swrast->SpanArrays->attribs[FRAG_ATTRIB_COL0];
+ swrast->SpanArrays[i].rgba = swrast->SpanArrays[i].attribs[FRAG_ATTRIB_COL0];
#endif
+ }
/* init point span buffer */
swrast->PointSpan.primitive = GL_POINT;
@@ -826,7 +758,10 @@ _swrast_CreateContext( struct gl_context *ctx )
swrast->PointSpan.facing = 0;
swrast->PointSpan.array = swrast->SpanArrays;
- swrast->TexelBuffer = (GLfloat *) MALLOC(ctx->Const.MaxTextureImageUnits *
+ /* TexelBuffer is also global and normally shared by all SWspan instances;
+ * when running with multiple threads, create one per thread.
+ */
+ swrast->TexelBuffer = (GLfloat *) MALLOC(ctx->Const.MaxTextureImageUnits * maxThreads *
MAX_WIDTH * 4 * sizeof(GLfloat));
if (!swrast->TexelBuffer) {
FREE(swrast->SpanArrays);