static void nv10_zclear(struct gl_context *ctx, GLbitfield *buffers) { /* * Pre-nv17 cards don't have native support for fast Z clears, * but in some cases we can still "clear" the Z buffer without * actually blitting to it if we're willing to sacrifice a few * bits of depth precision. * * Each time a clear is requested we modify the viewport * transform in such a way that the old contents of the depth * buffer are clamped to the requested clear value when * they're read by the GPU. */ struct nouveau_context *nctx = to_nouveau_context(ctx); struct gl_framebuffer *fb = ctx->DrawBuffer; struct nouveau_framebuffer *nfb = to_nouveau_framebuffer(fb); struct nouveau_surface *s = &to_nouveau_renderbuffer( fb->Attachment[BUFFER_DEPTH].Renderbuffer)->surface; if (nv10_use_viewport_zclear(ctx)) { int x, y, w, h; float z = ctx->Depth.Clear; uint32_t value = pack_zs_f(s->format, z, 0); get_scissors(fb, &x, &y, &w, &h); *buffers &= ~BUFFER_BIT_DEPTH; if (use_fast_zclear(ctx, *buffers)) { if (nfb->hierz.clear_value != value) { /* Don't fast clear if we're changing * the depth value. */ nfb->hierz.clear_value = value; } else if (z == 0.0) { nctx->hierz.clear_seq++; context_dirty(ctx, ZCLEAR); if ((nctx->hierz.clear_seq & 7) != 0 && nctx->hierz.clear_seq != 1) /* We didn't wrap around -- no need to * clear the depth buffer for real. */ return; } else if (z == 1.0) { nctx->hierz.clear_seq--; context_dirty(ctx, ZCLEAR); if ((nctx->hierz.clear_seq & 7) != 7) /* No wrap around */ return; } } value = pack_zs_f(s->format, (z + (nctx->hierz.clear_seq & 7)) / 8, 0); context_drv(ctx)->surface_fill(ctx, s, ~0, value, x, y, w, h); } }
void nv20_emit_framebuffer(struct gl_context *ctx, int emit) { struct nouveau_pushbuf *push = context_push(ctx); struct gl_framebuffer *fb = ctx->DrawBuffer; struct nouveau_surface *s; unsigned rt_format = NV20_3D_RT_FORMAT_TYPE_LINEAR; unsigned rt_pitch = 0, zeta_pitch = 0; unsigned bo_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR; if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) return; PUSH_RESET(push, BUFCTX_FB); /* Render target */ if (fb->_ColorDrawBuffers[0]) { s = &to_nouveau_renderbuffer( fb->_ColorDrawBuffers[0])->surface; rt_format |= get_rt_format(s->format); rt_pitch = s->pitch; BEGIN_NV04(push, NV20_3D(COLOR_OFFSET), 1); PUSH_MTHDl(push, NV20_3D(COLOR_OFFSET), BUFCTX_FB, s->bo, 0, bo_flags); } /* depth/stencil */ if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) { s = &to_nouveau_renderbuffer( fb->Attachment[BUFFER_DEPTH].Renderbuffer)->surface; rt_format |= get_rt_format(s->format); zeta_pitch = s->pitch; BEGIN_NV04(push, NV20_3D(ZETA_OFFSET), 1); PUSH_MTHDl(push, NV20_3D(ZETA_OFFSET), BUFCTX_FB, s->bo, 0, bo_flags); if (context_chipset(ctx) >= 0x25) setup_hierz_buffer(ctx); } else { rt_format |= get_rt_format(MESA_FORMAT_S8_UINT_Z24_UNORM); zeta_pitch = rt_pitch; } BEGIN_NV04(push, NV20_3D(RT_FORMAT), 2); PUSH_DATA (push, rt_format); PUSH_DATA (push, zeta_pitch << 16 | rt_pitch); /* Recompute the viewport/scissor state. */ context_dirty(ctx, VIEWPORT); context_dirty(ctx, SCISSOR); context_dirty(ctx, DEPTH); }
static void nouveau_light(struct gl_context *ctx, GLenum light, GLenum pname, const GLfloat *params) { switch (pname) { case GL_AMBIENT: context_dirty(ctx, MATERIAL_FRONT_AMBIENT); context_dirty(ctx, MATERIAL_BACK_AMBIENT); break; case GL_DIFFUSE: context_dirty(ctx, MATERIAL_FRONT_DIFFUSE); context_dirty(ctx, MATERIAL_BACK_DIFFUSE); break; case GL_SPECULAR: context_dirty(ctx, MATERIAL_FRONT_SPECULAR); context_dirty(ctx, MATERIAL_BACK_SPECULAR); break; case GL_SPOT_CUTOFF: case GL_POSITION: context_dirty(ctx, MODELVIEW); context_dirty(ctx, LIGHT_ENABLE); context_dirty_i(ctx, LIGHT_SOURCE, light - GL_LIGHT0); break; default: context_dirty_i(ctx, LIGHT_SOURCE, light - GL_LIGHT0); break; } }
void nv20_emit_framebuffer(GLcontext *ctx, int emit) { struct nouveau_channel *chan = context_chan(ctx); struct nouveau_grobj *kelvin = context_eng3d(ctx); struct nouveau_bo_context *bctx = context_bctx(ctx, FRAMEBUFFER); struct gl_framebuffer *fb = ctx->DrawBuffer; struct nouveau_surface *s; unsigned rt_format = NV20TCL_RT_FORMAT_TYPE_LINEAR; unsigned rt_pitch = 0, zeta_pitch = 0; unsigned bo_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR; if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) return; /* Render target */ if (fb->_ColorDrawBuffers[0]) { s = &to_nouveau_renderbuffer( fb->_ColorDrawBuffers[0])->surface; rt_format |= get_rt_format(s->format); rt_pitch = s->pitch; nouveau_bo_markl(bctx, kelvin, NV20TCL_COLOR_OFFSET, s->bo, 0, bo_flags); } /* depth/stencil */ if (fb->_DepthBuffer) { s = &to_nouveau_renderbuffer( fb->_DepthBuffer->Wrapped)->surface; rt_format |= get_rt_format(s->format); zeta_pitch = s->pitch; nouveau_bo_markl(bctx, kelvin, NV20TCL_ZETA_OFFSET, s->bo, 0, bo_flags); } else { rt_format |= get_rt_format(MESA_FORMAT_Z24_S8); zeta_pitch = rt_pitch; } BEGIN_RING(chan, kelvin, NV20TCL_RT_FORMAT, 2); OUT_RING(chan, rt_format); OUT_RING(chan, zeta_pitch << 16 | rt_pitch); /* Recompute the viewport/scissor state. */ context_dirty(ctx, VIEWPORT); context_dirty(ctx, SCISSOR); }
void nv04_emit_framebuffer(struct gl_context *ctx, int emit) { struct nouveau_pushbuf *push = context_push(ctx); struct gl_framebuffer *fb = ctx->DrawBuffer; struct nouveau_surface *s; uint32_t rt_format = NV04_CONTEXT_SURFACES_3D_FORMAT_TYPE_PITCH; uint32_t rt_pitch = 0, zeta_pitch = 0; unsigned bo_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR; if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) return; PUSH_RESET(push, BUFCTX_FB); /* Render target */ if (fb->_ColorDrawBuffers[0]) { s = &to_nouveau_renderbuffer( fb->_ColorDrawBuffers[0])->surface; rt_format |= get_rt_format(s->format); zeta_pitch = rt_pitch = s->pitch; BEGIN_NV04(push, NV04_SF3D(OFFSET_COLOR), 1); PUSH_MTHDl(push, NV04_SF3D(OFFSET_COLOR), BUFCTX_FB, s->bo, 0, bo_flags); } /* depth/stencil */ if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) { s = &to_nouveau_renderbuffer( fb->Attachment[BUFFER_DEPTH].Renderbuffer)->surface; zeta_pitch = s->pitch; BEGIN_NV04(push, NV04_SF3D(OFFSET_ZETA), 1); PUSH_MTHDl(push, NV04_SF3D(OFFSET_ZETA), BUFCTX_FB, s->bo, 0, bo_flags); } BEGIN_NV04(push, NV04_SF3D(FORMAT), 1); PUSH_DATA (push, rt_format); BEGIN_NV04(push, NV04_SF3D(PITCH), 1); PUSH_DATA (push, zeta_pitch << 16 | rt_pitch); /* Recompute the scissor state. */ context_dirty(ctx, SCISSOR); context_dirty(ctx, CONTROL); }
static void nv17_zclear(struct gl_context *ctx, GLbitfield *buffers) { struct nouveau_context *nctx = to_nouveau_context(ctx); struct nouveau_pushbuf *push = context_push(ctx); struct nouveau_framebuffer *nfb = to_nouveau_framebuffer( ctx->DrawBuffer); struct nouveau_surface *s = &to_nouveau_renderbuffer( nfb->base.Attachment[BUFFER_DEPTH].Renderbuffer)->surface; /* Clear the hierarchical depth buffer */ BEGIN_NV04(push, NV17_3D(HIERZ_FILL_VALUE), 1); PUSH_DATA (push, pack_zs_f(s->format, ctx->Depth.Clear, 0)); BEGIN_NV04(push, NV17_3D(HIERZ_BUFFER_CLEAR), 1); PUSH_DATA (push, 1); /* Mark the depth buffer as cleared */ if (use_fast_zclear(ctx, *buffers)) { if (nctx->hierz.clear_seq) *buffers &= ~BUFFER_BIT_DEPTH; nfb->hierz.clear_value = pack_zs_f(s->format, ctx->Depth.Clear, 0); nctx->hierz.clear_seq++; context_dirty(ctx, ZCLEAR); } }
static void nouveau_bind_framebuffer(struct gl_context *ctx, GLenum target, struct gl_framebuffer *dfb, struct gl_framebuffer *rfb) { context_dirty(ctx, FRAMEBUFFER); }
static void nouveau_render_texture(struct gl_context *ctx, struct gl_framebuffer *fb, struct gl_renderbuffer_attachment *att) { struct gl_renderbuffer *rb = att->Renderbuffer; struct gl_texture_image *ti = att->Texture->Image[att->CubeMapFace][att->TextureLevel]; /* Allocate a renderbuffer object for the texture if we * haven't already done so. */ if (!rb) { rb = nouveau_renderbuffer_new(ctx, ~0); assert(rb); rb->AllocStorage = NULL; _mesa_reference_renderbuffer(&att->Renderbuffer, rb); } /* Update the renderbuffer fields from the texture. */ set_renderbuffer_format(rb, get_tex_format(ti)); rb->Width = ti->Width; rb->Height = ti->Height; nouveau_surface_ref(&to_nouveau_teximage(ti)->surface, &to_nouveau_renderbuffer(rb)->surface); context_dirty(ctx, FRAMEBUFFER); }
void nv10_emit_viewport(struct gl_context *ctx, int emit) { struct nouveau_channel *chan = context_chan(ctx); struct nouveau_grobj *celsius = context_eng3d(ctx); struct gl_viewport_attrib *vp = &ctx->Viewport; struct gl_framebuffer *fb = ctx->DrawBuffer; float a[4] = {}; get_viewport_translate(ctx, a); a[0] -= 2048; a[1] -= 2048; if (nv10_use_viewport_zclear(ctx)) a[2] = nv10_transform_depth(ctx, (vp->Far + vp->Near) / 2); BEGIN_RING(chan, celsius, NV10_3D_VIEWPORT_TRANSLATE_X, 4); OUT_RINGp(chan, a, 4); BEGIN_RING(chan, celsius, NV10_3D_VIEWPORT_CLIP_HORIZ(0), 1); OUT_RING(chan, (fb->Width - 1) << 16 | 0x08000800); BEGIN_RING(chan, celsius, NV10_3D_VIEWPORT_CLIP_VERT(0), 1); OUT_RING(chan, (fb->Height - 1) << 16 | 0x08000800); context_dirty(ctx, PROJECTION); }
static void nv17_zclear(struct gl_context *ctx, GLbitfield *buffers) { struct nouveau_context *nctx = to_nouveau_context(ctx); struct nouveau_channel *chan = context_chan(ctx); struct nouveau_grobj *celsius = context_eng3d(ctx); struct nouveau_framebuffer *nfb = to_nouveau_framebuffer( ctx->DrawBuffer); struct nouveau_surface *s = &to_nouveau_renderbuffer( nfb->base.Attachment[BUFFER_DEPTH].Renderbuffer)->surface; /* Clear the hierarchical depth buffer */ BEGIN_RING(chan, celsius, NV17_3D_HIERZ_FILL_VALUE, 1); OUT_RING(chan, pack_zs_f(s->format, ctx->Depth.Clear, 0)); BEGIN_RING(chan, celsius, NV17_3D_HIERZ_BUFFER_CLEAR, 1); OUT_RING(chan, 1); /* Mark the depth buffer as cleared */ if (use_fast_zclear(ctx, *buffers)) { if (nctx->hierz.clear_seq) *buffers &= ~BUFFER_BIT_DEPTH; nfb->hierz.clear_value = pack_zs_f(s->format, ctx->Depth.Clear, 0); nctx->hierz.clear_seq++; context_dirty(ctx, ZCLEAR); } }
static void nouveau_framebuffer_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, GLenum attachment, struct gl_renderbuffer *rb) { _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb); context_dirty(ctx, FRAMEBUFFER); }
void nv04_emit_scissor(GLcontext *ctx, int emit) { struct nouveau_channel *chan = context_chan(ctx); struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw; struct nouveau_grobj *surf3d = hw->surf3d; int x, y, w, h; get_scissors(ctx->DrawBuffer, &x, &y, &w, &h); BEGIN_RING(chan, surf3d, NV04_CONTEXT_SURFACES_3D_CLIP_HORIZONTAL, 2); OUT_RING(chan, w << 16 | x); OUT_RING(chan, h << 16 | y); /* Messing with surf3d invalidates some engine state. */ context_dirty(ctx, CONTROL); context_dirty(ctx, BLEND); }
static void nouveau_update_state(struct gl_context *ctx, GLbitfield new_state) { int i; if (new_state & (_NEW_PROJECTION | _NEW_MODELVIEW)) context_dirty(ctx, PROJECTION); if (new_state & _NEW_MODELVIEW) context_dirty(ctx, MODELVIEW); if (new_state & _NEW_TEXTURE_MATRIX) { for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) context_dirty_i(ctx, TEX_MAT, i); } if (new_state & _NEW_CURRENT_ATTRIB && new_state & _NEW_LIGHT) { context_dirty(ctx, MATERIAL_FRONT_AMBIENT); context_dirty(ctx, MATERIAL_BACK_AMBIENT); context_dirty(ctx, MATERIAL_FRONT_DIFFUSE); context_dirty(ctx, MATERIAL_BACK_DIFFUSE); context_dirty(ctx, MATERIAL_FRONT_SPECULAR); context_dirty(ctx, MATERIAL_BACK_SPECULAR); context_dirty(ctx, MATERIAL_FRONT_SHININESS); context_dirty(ctx, MATERIAL_BACK_SHININESS); } if (new_state & _NEW_TEXTURE) { for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { if (ctx->Texture.Unit[i].Sampler) context_dirty_i(ctx, TEX_OBJ, i); } } _swrast_InvalidateState(ctx, new_state); _tnl_InvalidateState(ctx, new_state); nouveau_state_emit(ctx); }
void nv04_emit_tex_env(struct gl_context *ctx, int emit) { const int i = emit - NOUVEAU_STATE_TEX_ENV0; struct nouveau_channel *chan = context_chan(ctx); struct nouveau_grobj *fahrenheit = nv04_context_engine(ctx); struct combiner_state rc_a = {}, rc_c = {}; if (!nv04_mtex_engine(fahrenheit)) { context_dirty(ctx, BLEND); return; } /* Compute the new combiner state. */ if (ctx->Texture.Unit[i]._ReallyEnabled) { INIT_COMBINER(A, ctx, &rc_a, i); setup_combiner(&rc_a); INIT_COMBINER(RGB, ctx, &rc_c, i); setup_combiner(&rc_c); } else { if (i == 0) { INPUT_SRC(&rc_a, 0, PRIMARY_COLOR, 0); INPUT_SRC(&rc_c, 0, PRIMARY_COLOR, 0); } else { INPUT_SRC(&rc_a, 0, PREVIOUS, 0); INPUT_SRC(&rc_c, 0, PREVIOUS, 0); } INPUT_SRC(&rc_a, 1, ZERO, INVERT); INPUT_SRC(&rc_c, 1, ZERO, INVERT); INPUT_SRC(&rc_a, 2, ZERO, 0); INPUT_SRC(&rc_c, 2, ZERO, 0); INPUT_SRC(&rc_a, 3, ZERO, 0); INPUT_SRC(&rc_c, 3, ZERO, 0); UNSIGNED_OP(&rc_a); UNSIGNED_OP(&rc_c); } /* Write the register combiner state out to the hardware. */ BEGIN_RING(chan, fahrenheit, NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA(i), 2); OUT_RING(chan, rc_a.hw); OUT_RING(chan, rc_c.hw); BEGIN_RING(chan, fahrenheit, NV04_MULTITEX_TRIANGLE_COMBINE_FACTOR, 1); OUT_RING(chan, pack_rgba_f(MESA_FORMAT_ARGB8888, ctx->Texture.Unit[0].EnvColor)); }
static void nouveau_color_material(struct gl_context *ctx, GLenum face, GLenum mode) { context_dirty(ctx, COLOR_MATERIAL); context_dirty(ctx, MATERIAL_FRONT_AMBIENT); context_dirty(ctx, MATERIAL_BACK_AMBIENT); context_dirty(ctx, MATERIAL_FRONT_DIFFUSE); context_dirty(ctx, MATERIAL_BACK_DIFFUSE); context_dirty(ctx, MATERIAL_FRONT_SPECULAR); context_dirty(ctx, MATERIAL_BACK_SPECULAR); }
static void nouveau_render_texture(struct gl_context *ctx, struct gl_framebuffer *fb, struct gl_renderbuffer_attachment *att) { struct gl_renderbuffer *rb = att->Renderbuffer; struct gl_texture_image *ti = rb->TexImage; /* Update the renderbuffer fields from the texture. */ nouveau_surface_ref(&to_nouveau_teximage(ti)->surface, &to_nouveau_renderbuffer(rb)->surface); context_dirty(ctx, FRAMEBUFFER); }
static void nouveau_tex_gen(struct gl_context *ctx, GLenum coord, GLenum pname, const GLfloat *params) { switch (pname) { case GL_TEXTURE_GEN_MODE: context_dirty_i(ctx, TEX_GEN, ctx->Texture.CurrentUnit); context_dirty(ctx, MODELVIEW); break; default: context_dirty_i(ctx, TEX_GEN, ctx->Texture.CurrentUnit); break; } }
void nv04_emit_framebuffer(GLcontext *ctx, int emit) { struct nouveau_channel *chan = context_chan(ctx); struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw; struct nouveau_grobj *surf3d = hw->surf3d; struct nouveau_bo_context *bctx = context_bctx(ctx, FRAMEBUFFER); struct gl_framebuffer *fb = ctx->DrawBuffer; struct nouveau_surface *s; uint32_t rt_format = NV04_CONTEXT_SURFACES_3D_FORMAT_TYPE_PITCH; uint32_t rt_pitch = 0, zeta_pitch = 0; unsigned bo_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR; if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) return; /* Render target */ if (fb->_NumColorDrawBuffers) { s = &to_nouveau_renderbuffer( fb->_ColorDrawBuffers[0])->surface; rt_format |= get_rt_format(s->format); zeta_pitch = rt_pitch = s->pitch; nouveau_bo_markl(bctx, surf3d, NV04_CONTEXT_SURFACES_3D_OFFSET_COLOR, s->bo, 0, bo_flags); } /* depth/stencil */ if (fb->_DepthBuffer) { s = &to_nouveau_renderbuffer( fb->_DepthBuffer->Wrapped)->surface; zeta_pitch = s->pitch; nouveau_bo_markl(bctx, surf3d, NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA, s->bo, 0, bo_flags); } BEGIN_RING(chan, surf3d, NV04_CONTEXT_SURFACES_3D_FORMAT, 1); OUT_RING(chan, rt_format); BEGIN_RING(chan, surf3d, NV04_CONTEXT_SURFACES_3D_PITCH, 1); OUT_RING(chan, zeta_pitch << 16 | rt_pitch); /* Recompute the scissor state. */ context_dirty(ctx, SCISSOR); }
static GLboolean nouveau_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height) { struct nouveau_surface *s = &to_nouveau_renderbuffer(rb)->surface; if (!set_renderbuffer_format(rb, internalFormat)) return GL_FALSE; rb->Width = width; rb->Height = height; nouveau_surface_alloc(ctx, s, TILED, NOUVEAU_BO_VRAM | NOUVEAU_BO_MAP, rb->Format, width, height); context_dirty(ctx, FRAMEBUFFER); return GL_TRUE; }
void nv20_emit_viewport(struct gl_context *ctx, int emit) { struct nouveau_pushbuf *push = context_push(ctx); struct gl_framebuffer *fb = ctx->DrawBuffer; float a[4] = {}; get_viewport_translate(ctx, a); BEGIN_NV04(push, NV20_3D(VIEWPORT_TRANSLATE_X), 4); PUSH_DATAp(push, a, 4); BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_HORIZ(0)), 1); PUSH_DATA (push, (fb->Width - 1) << 16); BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_VERT(0)), 1); PUSH_DATA (push, (fb->Height - 1) << 16); context_dirty(ctx, PROJECTION); }
static GLboolean use_fast_zclear(struct gl_context *ctx, GLbitfield buffers) { struct nouveau_context *nctx = to_nouveau_context(ctx); struct gl_framebuffer *fb = ctx->DrawBuffer; if (buffers & BUFFER_BIT_STENCIL) { /* * The stencil test is bypassed when fast Z clears are * enabled. */ nctx->hierz.clear_blocked = GL_TRUE; context_dirty(ctx, ZCLEAR); return GL_FALSE; } return !nctx->hierz.clear_blocked && fb->_Xmax == fb->Width && fb->_Xmin == 0 && fb->_Ymax == fb->Height && fb->_Ymin == 0; }
void nv20_emit_viewport(GLcontext *ctx, int emit) { struct nouveau_channel *chan = context_chan(ctx); struct nouveau_grobj *kelvin = context_eng3d(ctx); struct gl_framebuffer *fb = ctx->DrawBuffer; float a[4] = {}; get_viewport_translate(ctx, a); BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_TRANSLATE_X, 4); OUT_RINGp(chan, a, 4); BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(0), 1); OUT_RING(chan, (fb->Width - 1) << 16); BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_VERT(0), 1); OUT_RING(chan, (fb->Height - 1) << 16); context_dirty(ctx, PROJECTION); }
void nv10_emit_zclear(struct gl_context *ctx, int emit) { struct nouveau_context *nctx = to_nouveau_context(ctx); struct nouveau_channel *chan = context_chan(ctx); struct nouveau_grobj *celsius = context_eng3d(ctx); struct nouveau_framebuffer *nfb = to_nouveau_framebuffer(ctx->DrawBuffer); if (nfb->hierz.bo) { BEGIN_RING(chan, celsius, NV17_3D_ZCLEAR_ENABLE, 2); OUT_RINGb(chan, !nctx->hierz.clear_blocked); OUT_RING(chan, nfb->hierz.clear_value | (nctx->hierz.clear_seq & 0xff)); } else { BEGIN_RING(chan, celsius, NV10_3D_DEPTH_RANGE_NEAR, 2); OUT_RINGf(chan, nv10_transform_depth(ctx, 0)); OUT_RINGf(chan, nv10_transform_depth(ctx, 1)); context_dirty(ctx, VIEWPORT); } }
static void nouveau_cull_face(struct gl_context *ctx, GLenum mode) { context_dirty(ctx, CULL_FACE); }
void nv04_defer_blend(struct gl_context *ctx, int emit) { context_dirty(ctx, BLEND); }
void nv04_defer_control(struct gl_context *ctx, int emit) { context_dirty(ctx, CONTROL); }
static void nouveau_front_face(struct gl_context *ctx, GLenum mode) { context_dirty(ctx, FRONT_FACE); }
static void nouveau_depth_func(struct gl_context *ctx, GLenum func) { context_dirty(ctx, DEPTH); }
void nv10_emit_framebuffer(struct gl_context *ctx, int emit) { struct nouveau_channel *chan = context_chan(ctx); struct nouveau_grobj *celsius = context_eng3d(ctx); struct nouveau_bo_context *bctx = context_bctx(ctx, FRAMEBUFFER); struct gl_framebuffer *fb = ctx->DrawBuffer; struct nouveau_surface *s; unsigned rt_format = NV10_3D_RT_FORMAT_TYPE_LINEAR; unsigned rt_pitch = 0, zeta_pitch = 0; unsigned bo_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR; if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) return; /* At least nv11 seems to get sad if we don't do this before * swapping RTs.*/ if (context_chipset(ctx) < 0x17) { int i; for (i = 0; i < 6; i++) { BEGIN_RING(chan, celsius, NV04_GRAPH_NOP, 1); OUT_RING(chan, 0); } } /* Render target */ if (fb->_ColorDrawBuffers[0]) { s = &to_nouveau_renderbuffer( fb->_ColorDrawBuffers[0])->surface; rt_format |= get_rt_format(s->format); zeta_pitch = rt_pitch = s->pitch; nouveau_bo_markl(bctx, celsius, NV10_3D_COLOR_OFFSET, s->bo, 0, bo_flags); } /* depth/stencil */ if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) { s = &to_nouveau_renderbuffer( fb->Attachment[BUFFER_DEPTH].Renderbuffer)->surface; rt_format |= get_rt_format(s->format); zeta_pitch = s->pitch; nouveau_bo_markl(bctx, celsius, NV10_3D_ZETA_OFFSET, s->bo, 0, bo_flags); if (context_chipset(ctx) >= 0x17) { setup_hierz_buffer(ctx); context_dirty(ctx, ZCLEAR); } } BEGIN_RING(chan, celsius, NV10_3D_RT_FORMAT, 2); OUT_RING(chan, rt_format); OUT_RING(chan, zeta_pitch << 16 | rt_pitch); context_dirty(ctx, VIEWPORT); context_dirty(ctx, SCISSOR); }
void nv20_emit_tex_obj(GLcontext *ctx, int emit) { const int i = emit - NOUVEAU_STATE_TEX_OBJ0; struct nouveau_channel *chan = context_chan(ctx); struct nouveau_grobj *kelvin = context_eng3d(ctx); struct nouveau_bo_context *bctx = context_bctx_i(ctx, TEXTURE, i); const int bo_flags = NOUVEAU_BO_RD | NOUVEAU_BO_GART | NOUVEAU_BO_VRAM; struct gl_texture_object *t; struct nouveau_surface *s; struct gl_texture_image *ti; uint32_t tx_format, tx_filter, tx_wrap, tx_enable; if (!ctx->Texture.Unit[i]._ReallyEnabled) { BEGIN_RING(chan, kelvin, NV20TCL_TX_ENABLE(i), 1); OUT_RING(chan, 0); context_dirty(ctx, TEX_SHADER); return; } t = ctx->Texture.Unit[i]._Current; s = &to_nouveau_texture(t)->surfaces[t->BaseLevel]; ti = t->Image[0][t->BaseLevel]; if (!nouveau_texture_validate(ctx, t)) return; /* Recompute the texturing registers. */ tx_format = ti->DepthLog2 << 28 | ti->HeightLog2 << 24 | ti->WidthLog2 << 20 | NV20TCL_TX_FORMAT_DIMS_2D | NV20TCL_TX_FORMAT_NO_BORDER | 1 << 16; tx_wrap = nvgl_wrap_mode(t->WrapR) << 16 | nvgl_wrap_mode(t->WrapT) << 8 | nvgl_wrap_mode(t->WrapS) << 0; tx_filter = nvgl_filter_mode(t->MagFilter) << 24 | nvgl_filter_mode(t->MinFilter) << 16 | 2 << 12; tx_enable = NV20TCL_TX_ENABLE_ENABLE | log2i(t->MaxAnisotropy) << 4; if (t->Target == GL_TEXTURE_RECTANGLE) { BEGIN_RING(chan, kelvin, NV20TCL_TX_NPOT_PITCH(i), 1); OUT_RING(chan, s->pitch << 16); BEGIN_RING(chan, kelvin, NV20TCL_TX_NPOT_SIZE(i), 1); OUT_RING(chan, s->width << 16 | s->height); tx_format |= get_tex_format_rect(ti); } else { tx_format |= get_tex_format_pot(ti); } if (t->MinFilter != GL_NEAREST && t->MinFilter != GL_LINEAR) { int lod_min = t->MinLod; int lod_max = MIN2(t->MaxLod, t->_MaxLambda); int lod_bias = t->LodBias + ctx->Texture.Unit[i].LodBias; lod_max = CLAMP(lod_max, 0, 15); lod_min = CLAMP(lod_min, 0, 15); lod_bias = CLAMP(lod_bias, 0, 15); tx_format |= NV20TCL_TX_FORMAT_MIPMAP; tx_filter |= lod_bias << 8; tx_enable |= lod_min << 26 | lod_max << 14; } /* Write it to the hardware. */ nouveau_bo_mark(bctx, kelvin, NV20TCL_TX_FORMAT(i), s->bo, tx_format, 0, NV20TCL_TX_FORMAT_DMA0, NV20TCL_TX_FORMAT_DMA1, bo_flags | NOUVEAU_BO_OR); nouveau_bo_markl(bctx, kelvin, NV20TCL_TX_OFFSET(i), s->bo, 0, bo_flags); BEGIN_RING(chan, kelvin, NV20TCL_TX_WRAP(i), 1); OUT_RING(chan, tx_wrap); BEGIN_RING(chan, kelvin, NV20TCL_TX_FILTER(i), 1); OUT_RING(chan, tx_filter); BEGIN_RING(chan, kelvin, NV20TCL_TX_ENABLE(i), 1); OUT_RING(chan, tx_enable); context_dirty(ctx, TEX_SHADER); }