{
}
+void nouveauClearBuffer(GLcontext *ctx, nouveau_renderbuffer_t *buffer,
+ int fill, int mask)
+{
+ nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+ int dimensions;
+
+ if (!buffer) {
+ return;
+ }
+
+ /* FIXME: only support 32 bits atm */
+
+ /* Surface that we will work on */
+ nouveauObjectOnSubchannel(nmesa, NvSubCtxSurf2D, NvCtxSurf2D);
+
+ BEGIN_RING_SIZE(NvSubCtxSurf2D, NV10_CONTEXT_SURFACES_2D_FORMAT, 4);
+ OUT_RING(0x0b); /* Y32 color format */
+ OUT_RING((buffer->pitch<<16)|buffer->pitch);
+ OUT_RING(buffer->offset);
+ OUT_RING(buffer->offset);
+
+ /* Now clear a rectangle */
+ dimensions = ((buffer->mesa.Height)<<16) | (buffer->mesa.Width);
+
+ nouveauObjectOnSubchannel(nmesa, NvSubGdiRectText, NvGdiRectText);
+
+ BEGIN_RING_SIZE(NvSubGdiRectText, NV04_GDI_RECTANGLE_TEXT_OPERATION, 1);
+ OUT_RING(3); /* SRCCOPY */
+
+ BEGIN_RING_SIZE(NvSubGdiRectText, NV04_GDI_RECTANGLE_TEXT_BLOCK_LEVEL1_TL, 5);
+ OUT_RING(0); /* top left */
+ OUT_RING(dimensions); /* bottom right */
+ OUT_RING(fill);
+ OUT_RING(0); /* top left */
+ OUT_RING(dimensions); /* bottom right */
+}
#include "framebuffer.h"
#include "utils.h"
+#include "colormac.h"
/* Wrapper for DRM_NOUVEAU_GETPARAM ioctl */
GLboolean nouveauDRMGetParam(nouveauContextPtr nmesa,
/* glClear */
static void nouveauClear( GLcontext *ctx, GLbitfield mask )
{
- // XXX we really should do something here...
+ uint32_t clear_value;
+ nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+
+ /* FIXME: should we clear front buffer, even if asked to do it? */
+ if (mask & (BUFFER_BIT_FRONT_LEFT|BUFFER_BIT_BACK_LEFT)) {
+ GLubyte c[4];
+ int color_bits = 32;
+ int color_mask = 0xffffffff;
+
+ UNCLAMPED_FLOAT_TO_RGBA_CHAN(c,ctx->Color.ClearColor);
+ clear_value = PACK_COLOR_8888(c[3],c[0],c[1],c[2]);
+
+ if (ctx->DrawBuffer) {
+ /* FIXME: find correct color buffer, instead of [0][0] */
+ if (ctx->DrawBuffer->_ColorDrawBuffers[0][0]) {
+ color_bits = ctx->DrawBuffer->_ColorDrawBuffers[0][0]->RedBits;
+ color_bits += ctx->DrawBuffer->_ColorDrawBuffers[0][0]->GreenBits;
+ color_bits += ctx->DrawBuffer->_ColorDrawBuffers[0][0]->BlueBits;
+ color_bits += ctx->DrawBuffer->_ColorDrawBuffers[0][0]->AlphaBits;
+ }
+ }
+
+ if (color_bits<24) {
+ clear_value = PACK_COLOR_565(c[0],c[1],c[2]);
+ color_mask = 0xffff;
+ }
+
+ nouveauClearBuffer(ctx, nmesa->color_buffer,
+ clear_value, color_mask);
+ }
+
+ if (mask & (BUFFER_BIT_DEPTH)) {
+ int depth_bits = 24;
+ int depth_mask;
+ if (ctx->DrawBuffer) {
+ if (ctx->DrawBuffer->_DepthBuffer) {
+ depth_bits = ctx->DrawBuffer->_DepthBuffer->DepthBits;
+ }
+ }
+
+ switch(depth_bits) {
+ case 16:
+ clear_value = (uint32_t) (ctx->Depth.Clear * 32767.0);
+ depth_mask = 0xffff;
+ break;
+ default:
+ clear_value = ((uint32_t) (ctx->Depth.Clear * 16777215.0)) << 8;
+ depth_mask = 0xffffff00;
+ break;
+ }
+
+ nouveauClearBuffer(ctx, nmesa->depth_buffer,
+ clear_value, depth_mask);
+ }
+
+ if (mask & (BUFFER_BIT_STENCIL)) {
+ int stencil_bits = 0;
+ if (ctx->DrawBuffer) {
+ if (ctx->DrawBuffer->_StencilBuffer) {
+ stencil_bits = ctx->DrawBuffer->_StencilBuffer->StencilBits;
+ }
+ }
+
+ if (stencil_bits>0) {
+ nouveauClearBuffer(ctx, nmesa->depth_buffer,
+ ctx->Stencil.Clear, (1<<stencil_bits)-1);
+ }
+ }
}
void nouveauDriverInitFunctions( struct dd_function_table *functions )
OUT_RING_CACHE(dfactorRGB);
}
-static void nv10ClearBuffer(GLcontext *ctx, nouveau_renderbuffer_t *buffer, int fill, int mask)
-{
- nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
- int dimensions;
-
- if (!buffer) {
- return;
- }
-
- /* Surface that we will work on */
- nouveauObjectOnSubchannel(nmesa, NvSubCtxSurf2D, NvCtxSurf2D);
-
- BEGIN_RING_SIZE(NvSubCtxSurf2D, NV10_CONTEXT_SURFACES_2D_FORMAT, 4);
- OUT_RING(0x0b); /* Y32 color format */
- OUT_RING((buffer->pitch<<16)|buffer->pitch);
- OUT_RING(buffer->offset);
- OUT_RING(buffer->offset);
-
- /* Now clear a rectangle */
- dimensions = ((buffer->mesa.Height)<<16) | (buffer->mesa.Width);
-
- nouveauObjectOnSubchannel(nmesa, NvSubGdiRectText, NvGdiRectText);
-
- BEGIN_RING_SIZE(NvSubGdiRectText, NV04_GDI_RECTANGLE_TEXT_OPERATION, 1);
- OUT_RING(3); /* SRCCOPY */
-
- BEGIN_RING_SIZE(NvSubGdiRectText, NV04_GDI_RECTANGLE_TEXT_BLOCK_LEVEL1_TL, 5);
- OUT_RING(0); /* top left */
- OUT_RING(dimensions); /* bottom right */
- OUT_RING(fill);
- OUT_RING(0); /* top left */
- OUT_RING(dimensions); /* bottom right */
-}
-
-static void nv10Clear(GLcontext *ctx, GLbitfield mask)
-{
- nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
- if (mask & (BUFFER_BIT_FRONT_LEFT|BUFFER_BIT_BACK_LEFT)) {
- nv10ClearBuffer(ctx, nmesa->color_buffer,
- nmesa->clear_color_value, 0xffffffff);
- }
- /* FIXME: check depth bits */
- if (mask & (BUFFER_BIT_DEPTH)) {
- nv10ClearBuffer(ctx, nmesa->depth_buffer,
- nmesa->clear_value, 0xffffff00);
- }
- /* FIXME: check about stencil? */
- if (mask & (BUFFER_BIT_STENCIL)) {
- nv10ClearBuffer(ctx, nmesa->depth_buffer,
- nmesa->clear_value, 0x000000ff);
- }
-}
-
static void nv10ClearColor(GLcontext *ctx, const GLfloat color[4])
{
- nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
- GLubyte c[4];
- UNCLAMPED_FLOAT_TO_RGBA_CHAN(c,color);
- nmesa->clear_color_value = PACK_COLOR_8888(c[3],c[0],c[1],c[2]);
+ /* Not for NV10 */
}
static void nv10ClearDepth(GLcontext *ctx, GLclampd d)
{
- nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-/* switch (ctx->DrawBuffer->_DepthBuffer->DepthBits) {
- case 16:
- nmesa->clear_value = (uint32_t)(d*0x7FFF);
- break;
- case 24:*/
- nmesa->clear_value = ((nmesa->clear_value&0x000000FF) |
- (((uint32_t)(d*0xFFFFFF))<<8));
-/* break;
- }*/
+ /* Not for NV10 */
}
static void nv10ClearStencil(GLcontext *ctx, GLint s)
{
- nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-/* if (ctx->DrawBuffer->_DepthBuffer->DepthBits == 24) {*/
- nmesa->clear_value = ((nmesa->clear_value&0xFFFFFF00)|
- (s&0x000000FF));
-/* }*/
+ /* Not for NV10 */
}
static void nv10ClipPlane(GLcontext *ctx, GLenum plane, const GLfloat *equation)
func->BlendColor = nv10BlendColor;
func->BlendEquationSeparate = nv10BlendEquationSeparate;
func->BlendFuncSeparate = nv10BlendFuncSeparate;
- func->Clear = nv10Clear;
- func->ClearColor = nv10ClearColor;
- func->ClearDepth = nv10ClearDepth;
- func->ClearStencil = nv10ClearStencil;
+/* func->Clear = nv10Clear;*/ /* Not for NV10 */
+ func->ClearColor = nv10ClearColor; /* Not for NV10 */
+ func->ClearDepth = nv10ClearDepth; /* Not for NV10 */
+ func->ClearStencil = nv10ClearStencil; /* Not for NV10 */
func->ClipPlane = nv10ClipPlane;
func->ColorMask = nv10ColorMask;
func->ColorMaterial = nv10ColorMaterial;