X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fattrib.c;h=c656845dff9ca4e298b3646a0146d9260173d3f0;hb=c7def2257aae3b73ba37609dfbc0a0f35fa99c81;hp=f55433ea65fa49c7e65a4a4559b7ab511694e128;hpb=f6d7cd4a11e70b816733cff681dde7d03588d1c8;p=mesa.git diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index f55433ea65f..c656845dff9 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -217,7 +217,7 @@ push_attrib(struct gl_context *ctx, struct gl_attrib_node **head, { void *attribute; - attribute = MALLOC(attr_size); + attribute = malloc(attr_size); if (attribute == NULL) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib"); return false; @@ -227,7 +227,7 @@ push_attrib(struct gl_context *ctx, struct gl_attrib_node **head, memcpy(attribute, attr_data, attr_size); } else { - FREE(attribute); + free(attribute); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib"); return false; } @@ -277,7 +277,7 @@ _mesa_PushAttrib(GLbitfield mask) attr->DrawBuffer[i] = ctx->DrawBuffer->ColorDrawBuffer[i]; } else { - FREE(attr); + free(attr); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib"); goto end; } @@ -374,7 +374,7 @@ _mesa_PushAttrib(GLbitfield mask) attr->FragmentProgram = ctx->FragmentProgram.Enabled; if (!save_attrib_data(&head, GL_ENABLE_BIT, attr)) { - FREE(attr); + free(attr); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib"); goto end; } @@ -440,7 +440,7 @@ _mesa_PushAttrib(GLbitfield mask) attr->ReadBuffer = ctx->ReadBuffer->ColorReadBuffer; } else { - FREE(attr); + free(attr); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib"); goto end; } @@ -491,7 +491,7 @@ _mesa_PushAttrib(GLbitfield mask) } if (!save_attrib_data(&head, GL_TEXTURE_BIT, texstate)) { - FREE(texstate); + free(texstate); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib(GL_TEXTURE_BIT)"); goto end; } @@ -1269,15 +1269,19 @@ _mesa_PopAttrib(void) break; case GL_SCISSOR_BIT: { + unsigned i; const struct gl_scissor_attrib *scissor; scissor = (const struct gl_scissor_attrib *) attr->data; - _mesa_set_scissor(ctx, 0, - scissor->ScissorArray[0].X, - scissor->ScissorArray[0].Y, - scissor->ScissorArray[0].Width, - scissor->ScissorArray[0].Height); - _mesa_set_enable(ctx, GL_SCISSOR_TEST, scissor->EnableFlags & 1); + for (i = 0; i < ctx->Const.MaxViewports; i++) { + _mesa_set_scissor(ctx, i, + scissor->ScissorArray[i].X, + scissor->ScissorArray[i].Y, + scissor->ScissorArray[i].Width, + scissor->ScissorArray[i].Height); + _mesa_set_enablei(ctx, GL_SCISSOR_TEST, i, + (scissor->EnableFlags >> i) & 1); + } } break; case GL_STENCIL_BUFFER_BIT: @@ -1353,10 +1357,15 @@ _mesa_PopAttrib(void) break; case GL_VIEWPORT_BIT: { + unsigned i; const struct gl_viewport_attrib *vp; vp = (const struct gl_viewport_attrib *) attr->data; - _mesa_Viewport(vp->X, vp->Y, vp->Width, vp->Height); - _mesa_DepthRange(vp->Near, vp->Far); + + for (i = 0; i < ctx->Const.MaxViewports; i++) { + _mesa_set_viewport(ctx, i, vp[i].X, vp[i].Y, vp[i].Width, + vp[i].Height); + _mesa_set_depth_range(ctx, i, vp[i].Near, vp[i].Far); + } } break; case GL_MULTISAMPLE_BIT_ARB: @@ -1424,13 +1433,13 @@ copy_pixelstore(struct gl_context *ctx, #define GL_CLIENT_UNPACK_BIT (1<<21) /** - * Copy gl_array_object from src to dest. + * Copy gl_vertex_array_object from src to dest. * 'dest' must be in an initialized state. */ static void copy_array_object(struct gl_context *ctx, - struct gl_array_object *dest, - struct gl_array_object *src) + struct gl_vertex_array_object *dest, + struct gl_vertex_array_object *src) { GLuint i; @@ -1448,6 +1457,7 @@ copy_array_object(struct gl_context *ctx, /* _Enabled must be the same than on push */ dest->_Enabled = src->_Enabled; + dest->NewArrays = src->NewArrays; dest->_MaxElement = src->_MaxElement; } @@ -1474,10 +1484,10 @@ copy_array_attrib(struct gl_context *ctx, /* skip RebindArrays */ if (!vbo_deleted) - copy_array_object(ctx, dest->ArrayObj, src->ArrayObj); + copy_array_object(ctx, dest->VAO, src->VAO); /* skip ArrayBufferObj */ - /* skip ElementArrayBufferObj */ + /* skip IndexBufferObj */ } /** @@ -1490,15 +1500,15 @@ save_array_attrib(struct gl_context *ctx, { /* Set the Name, needed for restore, but do never overwrite. * Needs to match value in the object hash. */ - dest->ArrayObj->Name = src->ArrayObj->Name; + dest->VAO->Name = src->VAO->Name; /* And copy all of the rest. */ copy_array_attrib(ctx, dest, src, false); /* Just reference them here */ _mesa_reference_buffer_object(ctx, &dest->ArrayBufferObj, src->ArrayBufferObj); - _mesa_reference_buffer_object(ctx, &dest->ArrayObj->ElementArrayBufferObj, - src->ArrayObj->ElementArrayBufferObj); + _mesa_reference_buffer_object(ctx, &dest->VAO->IndexBufferObj, + src->VAO->IndexBufferObj); } /** @@ -1521,13 +1531,13 @@ restore_array_attrib(struct gl_context *ctx, * The semantics of objects created using APPLE_vertex_array_objects behave * differently. These objects expect to be recreated by pop. Alas. */ - const bool arb_vao = (src->ArrayObj->Name != 0 - && src->ArrayObj->ARBsemantics); + const bool arb_vao = (src->VAO->Name != 0 + && src->VAO->ARBsemantics); - if (arb_vao && !_mesa_IsVertexArray(src->ArrayObj->Name)) + if (arb_vao && !_mesa_IsVertexArray(src->VAO->Name)) return; - _mesa_BindVertexArrayAPPLE(src->ArrayObj->Name); + _mesa_BindVertexArrayAPPLE(src->VAO->Name); /* Restore or recreate the buffer objects by the names ... */ if (!arb_vao @@ -1543,10 +1553,10 @@ restore_array_attrib(struct gl_context *ctx, } if (!arb_vao - || src->ArrayObj->ElementArrayBufferObj->Name == 0 - || _mesa_IsBuffer(src->ArrayObj->ElementArrayBufferObj->Name)) + || src->VAO->IndexBufferObj->Name == 0 + || _mesa_IsBuffer(src->VAO->IndexBufferObj->Name)) _mesa_BindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, - src->ArrayObj->ElementArrayBufferObj->Name); + src->VAO->IndexBufferObj->Name); } /** @@ -1557,15 +1567,15 @@ static bool init_array_attrib_data(struct gl_context *ctx, struct gl_array_attrib *attrib) { - /* Get a non driver gl_array_object. */ - attrib->ArrayObj = CALLOC_STRUCT( gl_array_object ); + /* Get a non driver gl_vertex_array_object. */ + attrib->VAO = CALLOC_STRUCT( gl_vertex_array_object ); - if (attrib->ArrayObj == NULL) { + if (attrib->VAO == NULL) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushClientAttrib"); return false; } - _mesa_initialize_array_object(ctx, attrib->ArrayObj, 0); + _mesa_initialize_vao(ctx, attrib->VAO, 0); return true; } @@ -1580,8 +1590,8 @@ free_array_attrib_data(struct gl_context *ctx, { /* We use a non driver array object, so don't just unref since we would * end up using the drivers DeleteArrayObject function for deletion. */ - _mesa_delete_array_object(ctx, attrib->ArrayObj); - attrib->ArrayObj = 0; + _mesa_delete_vao(ctx, attrib->VAO); + attrib->VAO = 0; _mesa_reference_buffer_object(ctx, &attrib->ArrayBufferObj, NULL); } @@ -1616,7 +1626,7 @@ _mesa_PushClientAttrib(GLbitfield mask) } else { _mesa_error( ctx, GL_OUT_OF_MEMORY, "glPushClientAttrib" ); - FREE(attr); + free(attr); goto end; } @@ -1632,7 +1642,7 @@ _mesa_PushClientAttrib(GLbitfield mask) } else { _mesa_error( ctx, GL_OUT_OF_MEMORY, "glPushClientAttrib" ); - FREE(attr); + free(attr); goto end; } } @@ -1646,7 +1656,7 @@ _mesa_PushClientAttrib(GLbitfield mask) } if (!init_array_attrib_data(ctx, attr)) { - FREE(attr); + free(attr); goto end; } @@ -1656,7 +1666,7 @@ _mesa_PushClientAttrib(GLbitfield mask) else { free_array_attrib_data(ctx, attr); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushClientAttrib"); - FREE(attr); + free(attr); /* goto to keep safe from possible later changes */ goto end; }