1b8e80941Smrg/* 2b8e80941Smrg * Copyright (c) 2011-2013 Luc Verhaegen <libv@skynet.be> 3b8e80941Smrg * Copyright (c) 2017-2019 Lima Project 4b8e80941Smrg * 5b8e80941Smrg * Permission is hereby granted, free of charge, to any person obtaining a 6b8e80941Smrg * copy of this software and associated documentation files (the "Software"), 7b8e80941Smrg * to deal in the Software without restriction, including without limitation 8b8e80941Smrg * the rights to use, copy, modify, merge, publish, distribute, sub license, 9b8e80941Smrg * and/or sell copies of the Software, and to permit persons to whom the 10b8e80941Smrg * Software is furnished to do so, subject to the following conditions: 11b8e80941Smrg * 12b8e80941Smrg * The above copyright notice and this permission notice (including the 13b8e80941Smrg * next paragraph) shall be included in all copies or substantial portions 14b8e80941Smrg * of the Software. 15b8e80941Smrg * 16b8e80941Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17b8e80941Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18b8e80941Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 19b8e80941Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20b8e80941Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21b8e80941Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22b8e80941Smrg * DEALINGS IN THE SOFTWARE. 23b8e80941Smrg * 24b8e80941Smrg */ 25b8e80941Smrg 26b8e80941Smrg#include "util/u_memory.h" 27b8e80941Smrg#include "util/u_inlines.h" 28b8e80941Smrg#include "util/u_helpers.h" 29b8e80941Smrg#include "util/u_debug.h" 30b8e80941Smrg 31b8e80941Smrg#include "pipe/p_state.h" 32b8e80941Smrg 33b8e80941Smrg#include "lima_screen.h" 34b8e80941Smrg#include "lima_context.h" 35b8e80941Smrg#include "lima_resource.h" 36b8e80941Smrg 37b8e80941Smrgstatic void 38b8e80941Smrglima_set_framebuffer_state(struct pipe_context *pctx, 39b8e80941Smrg const struct pipe_framebuffer_state *framebuffer) 40b8e80941Smrg{ 41b8e80941Smrg struct lima_context *ctx = lima_context(pctx); 42b8e80941Smrg 43b8e80941Smrg /* submit need framebuffer info, flush before change it */ 44b8e80941Smrg lima_flush(ctx); 45b8e80941Smrg 46b8e80941Smrg struct lima_context_framebuffer *fb = &ctx->framebuffer; 47b8e80941Smrg 48b8e80941Smrg fb->base.samples = framebuffer->samples; 49b8e80941Smrg 50b8e80941Smrg fb->base.nr_cbufs = framebuffer->nr_cbufs; 51b8e80941Smrg pipe_surface_reference(&fb->base.cbufs[0], framebuffer->cbufs[0]); 52b8e80941Smrg pipe_surface_reference(&fb->base.zsbuf, framebuffer->zsbuf); 53b8e80941Smrg 54b8e80941Smrg /* need align here? */ 55b8e80941Smrg fb->base.width = framebuffer->width; 56b8e80941Smrg fb->base.height = framebuffer->height; 57b8e80941Smrg 58b8e80941Smrg int width = align(framebuffer->width, 16) >> 4; 59b8e80941Smrg int height = align(framebuffer->height, 16) >> 4; 60b8e80941Smrg if (fb->tiled_w != width || fb->tiled_h != height) { 61b8e80941Smrg fb->tiled_w = width; 62b8e80941Smrg fb->tiled_h = height; 63b8e80941Smrg 64b8e80941Smrg fb->shift_h = 0; 65b8e80941Smrg fb->shift_w = 0; 66b8e80941Smrg 67b8e80941Smrg int limit = ctx->plb_max_blk; 68b8e80941Smrg while ((width * height) > limit) { 69b8e80941Smrg if (width >= height) { 70b8e80941Smrg width = (width + 1) >> 1; 71b8e80941Smrg fb->shift_w++; 72b8e80941Smrg } else { 73b8e80941Smrg height = (height + 1) >> 1; 74b8e80941Smrg fb->shift_h++; 75b8e80941Smrg } 76b8e80941Smrg } 77b8e80941Smrg 78b8e80941Smrg fb->block_w = width; 79b8e80941Smrg fb->block_h = height; 80b8e80941Smrg 81b8e80941Smrg fb->shift_min = MIN3(fb->shift_w, fb->shift_h, 2); 82b8e80941Smrg 83b8e80941Smrg debug_printf("fb dim change tiled=%d/%d block=%d/%d shift=%d/%d/%d\n", 84b8e80941Smrg fb->tiled_w, fb->tiled_h, fb->block_w, fb->block_h, 85b8e80941Smrg fb->shift_w, fb->shift_h, fb->shift_min); 86b8e80941Smrg } 87b8e80941Smrg 88b8e80941Smrg ctx->dirty |= LIMA_CONTEXT_DIRTY_FRAMEBUFFER; 89b8e80941Smrg} 90b8e80941Smrg 91b8e80941Smrgstatic void 92b8e80941Smrglima_set_polygon_stipple(struct pipe_context *pctx, 93b8e80941Smrg const struct pipe_poly_stipple *stipple) 94b8e80941Smrg{ 95b8e80941Smrg 96b8e80941Smrg} 97b8e80941Smrg 98b8e80941Smrgstatic void * 99b8e80941Smrglima_create_depth_stencil_alpha_state(struct pipe_context *pctx, 100b8e80941Smrg const struct pipe_depth_stencil_alpha_state *cso) 101b8e80941Smrg{ 102b8e80941Smrg struct lima_depth_stencil_alpha_state *so; 103b8e80941Smrg 104b8e80941Smrg so = CALLOC_STRUCT(lima_depth_stencil_alpha_state); 105b8e80941Smrg if (!so) 106b8e80941Smrg return NULL; 107b8e80941Smrg 108b8e80941Smrg so->base = *cso; 109b8e80941Smrg 110b8e80941Smrg return so; 111b8e80941Smrg} 112b8e80941Smrg 113b8e80941Smrgstatic void 114b8e80941Smrglima_bind_depth_stencil_alpha_state(struct pipe_context *pctx, void *hwcso) 115b8e80941Smrg{ 116b8e80941Smrg struct lima_context *ctx = lima_context(pctx); 117b8e80941Smrg 118b8e80941Smrg ctx->zsa = hwcso; 119b8e80941Smrg ctx->dirty |= LIMA_CONTEXT_DIRTY_ZSA; 120b8e80941Smrg} 121b8e80941Smrg 122b8e80941Smrgstatic void 123b8e80941Smrglima_delete_depth_stencil_alpha_state(struct pipe_context *pctx, void *hwcso) 124b8e80941Smrg{ 125b8e80941Smrg FREE(hwcso); 126b8e80941Smrg} 127b8e80941Smrg 128b8e80941Smrgstatic void * 129b8e80941Smrglima_create_rasterizer_state(struct pipe_context *pctx, 130b8e80941Smrg const struct pipe_rasterizer_state *cso) 131b8e80941Smrg{ 132b8e80941Smrg struct lima_rasterizer_state *so; 133b8e80941Smrg 134b8e80941Smrg so = CALLOC_STRUCT(lima_rasterizer_state); 135b8e80941Smrg if (!so) 136b8e80941Smrg return NULL; 137b8e80941Smrg 138b8e80941Smrg so->base = *cso; 139b8e80941Smrg 140b8e80941Smrg return so; 141b8e80941Smrg} 142b8e80941Smrg 143b8e80941Smrgstatic void 144b8e80941Smrglima_bind_rasterizer_state(struct pipe_context *pctx, void *hwcso) 145b8e80941Smrg{ 146b8e80941Smrg struct lima_context *ctx = lima_context(pctx); 147b8e80941Smrg 148b8e80941Smrg ctx->rasterizer = hwcso; 149b8e80941Smrg ctx->dirty |= LIMA_CONTEXT_DIRTY_RASTERIZER; 150b8e80941Smrg} 151b8e80941Smrg 152b8e80941Smrgstatic void 153b8e80941Smrglima_delete_rasterizer_state(struct pipe_context *pctx, void *hwcso) 154b8e80941Smrg{ 155b8e80941Smrg FREE(hwcso); 156b8e80941Smrg} 157b8e80941Smrg 158b8e80941Smrgstatic void * 159b8e80941Smrglima_create_blend_state(struct pipe_context *pctx, 160b8e80941Smrg const struct pipe_blend_state *cso) 161b8e80941Smrg{ 162b8e80941Smrg struct lima_blend_state *so; 163b8e80941Smrg 164b8e80941Smrg so = CALLOC_STRUCT(lima_blend_state); 165b8e80941Smrg if (!so) 166b8e80941Smrg return NULL; 167b8e80941Smrg 168b8e80941Smrg so->base = *cso; 169b8e80941Smrg 170b8e80941Smrg return so; 171b8e80941Smrg} 172b8e80941Smrg 173b8e80941Smrgstatic void 174b8e80941Smrglima_bind_blend_state(struct pipe_context *pctx, void *hwcso) 175b8e80941Smrg{ 176b8e80941Smrg struct lima_context *ctx = lima_context(pctx); 177b8e80941Smrg 178b8e80941Smrg ctx->blend = hwcso; 179b8e80941Smrg ctx->dirty |= LIMA_CONTEXT_DIRTY_BLEND; 180b8e80941Smrg} 181b8e80941Smrg 182b8e80941Smrgstatic void 183b8e80941Smrglima_delete_blend_state(struct pipe_context *pctx, void *hwcso) 184b8e80941Smrg{ 185b8e80941Smrg FREE(hwcso); 186b8e80941Smrg} 187b8e80941Smrg 188b8e80941Smrgstatic void * 189b8e80941Smrglima_create_vertex_elements_state(struct pipe_context *pctx, unsigned num_elements, 190b8e80941Smrg const struct pipe_vertex_element *elements) 191b8e80941Smrg{ 192b8e80941Smrg struct lima_vertex_element_state *so; 193b8e80941Smrg 194b8e80941Smrg so = CALLOC_STRUCT(lima_vertex_element_state); 195b8e80941Smrg if (!so) 196b8e80941Smrg return NULL; 197b8e80941Smrg 198b8e80941Smrg memcpy(so->pipe, elements, sizeof(*elements) * num_elements); 199b8e80941Smrg so->num_elements = num_elements; 200b8e80941Smrg 201b8e80941Smrg return so; 202b8e80941Smrg} 203b8e80941Smrg 204b8e80941Smrgstatic void 205b8e80941Smrglima_bind_vertex_elements_state(struct pipe_context *pctx, void *hwcso) 206b8e80941Smrg{ 207b8e80941Smrg struct lima_context *ctx = lima_context(pctx); 208b8e80941Smrg 209b8e80941Smrg ctx->vertex_elements = hwcso; 210b8e80941Smrg ctx->dirty |= LIMA_CONTEXT_DIRTY_VERTEX_ELEM; 211b8e80941Smrg} 212b8e80941Smrg 213b8e80941Smrgstatic void 214b8e80941Smrglima_delete_vertex_elements_state(struct pipe_context *pctx, void *hwcso) 215b8e80941Smrg{ 216b8e80941Smrg FREE(hwcso); 217b8e80941Smrg} 218b8e80941Smrg 219b8e80941Smrgstatic void 220b8e80941Smrglima_set_vertex_buffers(struct pipe_context *pctx, 221b8e80941Smrg unsigned start_slot, unsigned count, 222b8e80941Smrg const struct pipe_vertex_buffer *vb) 223b8e80941Smrg{ 224b8e80941Smrg struct lima_context *ctx = lima_context(pctx); 225b8e80941Smrg struct lima_context_vertex_buffer *so = &ctx->vertex_buffers; 226b8e80941Smrg 227b8e80941Smrg util_set_vertex_buffers_mask(so->vb + start_slot, &so->enabled_mask, 228b8e80941Smrg vb, start_slot, count); 229b8e80941Smrg so->count = util_last_bit(so->enabled_mask); 230b8e80941Smrg 231b8e80941Smrg ctx->dirty |= LIMA_CONTEXT_DIRTY_VERTEX_BUFF; 232b8e80941Smrg} 233b8e80941Smrg 234b8e80941Smrgstatic void 235b8e80941Smrglima_set_viewport_states(struct pipe_context *pctx, 236b8e80941Smrg unsigned start_slot, 237b8e80941Smrg unsigned num_viewports, 238b8e80941Smrg const struct pipe_viewport_state *viewport) 239b8e80941Smrg{ 240b8e80941Smrg struct lima_context *ctx = lima_context(pctx); 241b8e80941Smrg 242b8e80941Smrg /* reverse calculate the parameter of glViewport */ 243b8e80941Smrg ctx->viewport.x = viewport->translate[0] - viewport->scale[0]; 244b8e80941Smrg ctx->viewport.y = fabsf(viewport->translate[1] - fabsf(viewport->scale[1])); 245b8e80941Smrg ctx->viewport.width = viewport->scale[0] * 2; 246b8e80941Smrg ctx->viewport.height = fabsf(viewport->scale[1] * 2); 247b8e80941Smrg 248b8e80941Smrg /* reverse calculate the parameter of glDepthRange */ 249b8e80941Smrg ctx->viewport.near = viewport->translate[2] - viewport->scale[2]; 250b8e80941Smrg ctx->viewport.far = viewport->translate[2] + viewport->scale[2]; 251b8e80941Smrg 252b8e80941Smrg ctx->viewport.transform = *viewport; 253b8e80941Smrg ctx->dirty |= LIMA_CONTEXT_DIRTY_VIEWPORT; 254b8e80941Smrg} 255b8e80941Smrg 256b8e80941Smrgstatic void 257b8e80941Smrglima_set_scissor_states(struct pipe_context *pctx, 258b8e80941Smrg unsigned start_slot, 259b8e80941Smrg unsigned num_scissors, 260b8e80941Smrg const struct pipe_scissor_state *scissor) 261b8e80941Smrg{ 262b8e80941Smrg struct lima_context *ctx = lima_context(pctx); 263b8e80941Smrg 264b8e80941Smrg ctx->scissor = *scissor; 265b8e80941Smrg ctx->dirty |= LIMA_CONTEXT_DIRTY_SCISSOR; 266b8e80941Smrg} 267b8e80941Smrg 268b8e80941Smrgstatic void 269b8e80941Smrglima_set_blend_color(struct pipe_context *pctx, 270b8e80941Smrg const struct pipe_blend_color *blend_color) 271b8e80941Smrg{ 272b8e80941Smrg struct lima_context *ctx = lima_context(pctx); 273b8e80941Smrg 274b8e80941Smrg ctx->blend_color = *blend_color; 275b8e80941Smrg ctx->dirty |= LIMA_CONTEXT_DIRTY_BLEND_COLOR; 276b8e80941Smrg} 277b8e80941Smrg 278b8e80941Smrgstatic void 279b8e80941Smrglima_set_stencil_ref(struct pipe_context *pctx, 280b8e80941Smrg const struct pipe_stencil_ref *stencil_ref) 281b8e80941Smrg{ 282b8e80941Smrg struct lima_context *ctx = lima_context(pctx); 283b8e80941Smrg 284b8e80941Smrg ctx->stencil_ref = *stencil_ref; 285b8e80941Smrg ctx->dirty |= LIMA_CONTEXT_DIRTY_STENCIL_REF; 286b8e80941Smrg} 287b8e80941Smrg 288b8e80941Smrgstatic void 289b8e80941Smrglima_set_constant_buffer(struct pipe_context *pctx, 290b8e80941Smrg enum pipe_shader_type shader, uint index, 291b8e80941Smrg const struct pipe_constant_buffer *cb) 292b8e80941Smrg{ 293b8e80941Smrg struct lima_context *ctx = lima_context(pctx); 294b8e80941Smrg struct lima_context_constant_buffer *so = ctx->const_buffer + shader; 295b8e80941Smrg 296b8e80941Smrg assert(index == 0); 297b8e80941Smrg 298b8e80941Smrg if (unlikely(!cb)) { 299b8e80941Smrg so->buffer = NULL; 300b8e80941Smrg so->size = 0; 301b8e80941Smrg } else { 302b8e80941Smrg assert(!cb->buffer); 303b8e80941Smrg 304b8e80941Smrg so->buffer = cb->user_buffer + cb->buffer_offset; 305b8e80941Smrg so->size = cb->buffer_size; 306b8e80941Smrg } 307b8e80941Smrg 308b8e80941Smrg so->dirty = true; 309b8e80941Smrg ctx->dirty |= LIMA_CONTEXT_DIRTY_CONST_BUFF; 310b8e80941Smrg 311b8e80941Smrg} 312b8e80941Smrg 313b8e80941Smrgstatic void * 314b8e80941Smrglima_create_sampler_state(struct pipe_context *pctx, 315b8e80941Smrg const struct pipe_sampler_state *cso) 316b8e80941Smrg{ 317b8e80941Smrg struct lima_sampler_state *so = CALLOC_STRUCT(lima_sampler_state); 318b8e80941Smrg if (!so) 319b8e80941Smrg return NULL; 320b8e80941Smrg 321b8e80941Smrg memcpy(so, cso, sizeof(*cso)); 322b8e80941Smrg 323b8e80941Smrg return so; 324b8e80941Smrg} 325b8e80941Smrg 326b8e80941Smrgstatic void 327b8e80941Smrglima_sampler_state_delete(struct pipe_context *pctx, void *sstate) 328b8e80941Smrg{ 329b8e80941Smrg free(sstate); 330b8e80941Smrg} 331b8e80941Smrg 332b8e80941Smrgstatic void 333b8e80941Smrglima_sampler_states_bind(struct pipe_context *pctx, 334b8e80941Smrg enum pipe_shader_type shader, unsigned start, 335b8e80941Smrg unsigned nr, void **hwcso) 336b8e80941Smrg{ 337b8e80941Smrg struct lima_context *ctx = lima_context(pctx); 338b8e80941Smrg struct lima_texture_stateobj *lima_tex = &ctx->tex_stateobj; 339b8e80941Smrg unsigned i; 340b8e80941Smrg unsigned new_nr = 0; 341b8e80941Smrg 342b8e80941Smrg assert(start == 0); 343b8e80941Smrg 344b8e80941Smrg for (i = 0; i < nr; i++) { 345b8e80941Smrg if (hwcso[i]) 346b8e80941Smrg new_nr = i + 1; 347b8e80941Smrg lima_tex->samplers[i] = hwcso[i]; 348b8e80941Smrg } 349b8e80941Smrg 350b8e80941Smrg for (; i < lima_tex->num_samplers; i++) { 351b8e80941Smrg lima_tex->samplers[i] = NULL; 352b8e80941Smrg } 353b8e80941Smrg 354b8e80941Smrg lima_tex->num_samplers = new_nr; 355b8e80941Smrg ctx->dirty |= LIMA_CONTEXT_DIRTY_TEXTURES; 356b8e80941Smrg} 357b8e80941Smrg 358b8e80941Smrgstatic struct pipe_sampler_view * 359b8e80941Smrglima_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc, 360b8e80941Smrg const struct pipe_sampler_view *cso) 361b8e80941Smrg{ 362b8e80941Smrg struct lima_sampler_view *so = CALLOC_STRUCT(lima_sampler_view); 363b8e80941Smrg 364b8e80941Smrg if (!so) 365b8e80941Smrg return NULL; 366b8e80941Smrg 367b8e80941Smrg so->base = *cso; 368b8e80941Smrg 369b8e80941Smrg pipe_reference(NULL, &prsc->reference); 370b8e80941Smrg so->base.texture = prsc; 371b8e80941Smrg so->base.reference.count = 1; 372b8e80941Smrg so->base.context = pctx; 373b8e80941Smrg 374b8e80941Smrg return &so->base; 375b8e80941Smrg} 376b8e80941Smrg 377b8e80941Smrgstatic void 378b8e80941Smrglima_sampler_view_destroy(struct pipe_context *pctx, 379b8e80941Smrg struct pipe_sampler_view *pview) 380b8e80941Smrg{ 381b8e80941Smrg struct lima_sampler_view *view = lima_sampler_view(pview); 382b8e80941Smrg 383b8e80941Smrg pipe_resource_reference(&pview->texture, NULL); 384b8e80941Smrg 385b8e80941Smrg free(view); 386b8e80941Smrg} 387b8e80941Smrg 388b8e80941Smrgstatic void 389b8e80941Smrglima_set_sampler_views(struct pipe_context *pctx, 390b8e80941Smrg enum pipe_shader_type shader, 391b8e80941Smrg unsigned start, unsigned nr, 392b8e80941Smrg struct pipe_sampler_view **views) 393b8e80941Smrg{ 394b8e80941Smrg struct lima_context *ctx = lima_context(pctx); 395b8e80941Smrg struct lima_texture_stateobj *lima_tex = &ctx->tex_stateobj; 396b8e80941Smrg int i; 397b8e80941Smrg unsigned new_nr = 0; 398b8e80941Smrg 399b8e80941Smrg assert(start == 0); 400b8e80941Smrg 401b8e80941Smrg for (i = 0; i < nr; i++) { 402b8e80941Smrg if (views[i]) 403b8e80941Smrg new_nr = i + 1; 404b8e80941Smrg pipe_sampler_view_reference(&lima_tex->textures[i], views[i]); 405b8e80941Smrg } 406b8e80941Smrg 407b8e80941Smrg for (; i < lima_tex->num_textures; i++) { 408b8e80941Smrg pipe_sampler_view_reference(&lima_tex->textures[i], NULL); 409b8e80941Smrg } 410b8e80941Smrg 411b8e80941Smrg lima_tex->num_textures = new_nr; 412b8e80941Smrg ctx->dirty |= LIMA_CONTEXT_DIRTY_TEXTURES; 413b8e80941Smrg} 414b8e80941Smrg 415b8e80941Smrgstatic boolean 416b8e80941Smrglima_set_damage_region(struct pipe_context *pctx, unsigned num_rects, int *rects) 417b8e80941Smrg{ 418b8e80941Smrg struct lima_context *ctx = lima_context(pctx); 419b8e80941Smrg struct lima_damage_state *damage = &ctx->damage; 420b8e80941Smrg int i; 421b8e80941Smrg 422b8e80941Smrg if (damage->region) 423b8e80941Smrg ralloc_free(damage->region); 424b8e80941Smrg 425b8e80941Smrg if (!num_rects) { 426b8e80941Smrg damage->region = NULL; 427b8e80941Smrg damage->num_region = 0; 428b8e80941Smrg return true; 429b8e80941Smrg } 430b8e80941Smrg 431b8e80941Smrg damage->region = ralloc_size(ctx, sizeof(*damage->region) * num_rects); 432b8e80941Smrg if (!damage->region) { 433b8e80941Smrg damage->num_region = 0; 434b8e80941Smrg return false; 435b8e80941Smrg } 436b8e80941Smrg 437b8e80941Smrg for (i = 0; i < num_rects; i++) { 438b8e80941Smrg struct pipe_scissor_state *r = damage->region + i; 439b8e80941Smrg /* region in tile unit */ 440b8e80941Smrg r->minx = rects[i * 4] >> 4; 441b8e80941Smrg r->miny = rects[i * 4 + 1] >> 4; 442b8e80941Smrg r->maxx = (rects[i * 4] + rects[i * 4 + 2] + 0xf) >> 4; 443b8e80941Smrg r->maxy = (rects[i * 4 + 1] + rects[i * 4 + 3] + 0xf) >> 4; 444b8e80941Smrg } 445b8e80941Smrg 446b8e80941Smrg /* is region aligned to tiles? */ 447b8e80941Smrg damage->aligned = true; 448b8e80941Smrg for (i = 0; i < num_rects * 4; i++) { 449b8e80941Smrg if (rects[i] & 0xf) { 450b8e80941Smrg damage->aligned = false; 451b8e80941Smrg break; 452b8e80941Smrg } 453b8e80941Smrg } 454b8e80941Smrg 455b8e80941Smrg damage->num_region = num_rects; 456b8e80941Smrg return true; 457b8e80941Smrg} 458b8e80941Smrg 459b8e80941Smrgstatic void 460b8e80941Smrglima_set_sample_mask(struct pipe_context *pctx, 461b8e80941Smrg unsigned sample_mask) 462b8e80941Smrg{ 463b8e80941Smrg} 464b8e80941Smrg 465b8e80941Smrgvoid 466b8e80941Smrglima_state_init(struct lima_context *ctx) 467b8e80941Smrg{ 468b8e80941Smrg ctx->base.set_framebuffer_state = lima_set_framebuffer_state; 469b8e80941Smrg ctx->base.set_polygon_stipple = lima_set_polygon_stipple; 470b8e80941Smrg ctx->base.set_viewport_states = lima_set_viewport_states; 471b8e80941Smrg ctx->base.set_scissor_states = lima_set_scissor_states; 472b8e80941Smrg ctx->base.set_blend_color = lima_set_blend_color; 473b8e80941Smrg ctx->base.set_stencil_ref = lima_set_stencil_ref; 474b8e80941Smrg 475b8e80941Smrg ctx->base.set_vertex_buffers = lima_set_vertex_buffers; 476b8e80941Smrg ctx->base.set_constant_buffer = lima_set_constant_buffer; 477b8e80941Smrg 478b8e80941Smrg ctx->base.create_depth_stencil_alpha_state = lima_create_depth_stencil_alpha_state; 479b8e80941Smrg ctx->base.bind_depth_stencil_alpha_state = lima_bind_depth_stencil_alpha_state; 480b8e80941Smrg ctx->base.delete_depth_stencil_alpha_state = lima_delete_depth_stencil_alpha_state; 481b8e80941Smrg 482b8e80941Smrg ctx->base.create_rasterizer_state = lima_create_rasterizer_state; 483b8e80941Smrg ctx->base.bind_rasterizer_state = lima_bind_rasterizer_state; 484b8e80941Smrg ctx->base.delete_rasterizer_state = lima_delete_rasterizer_state; 485b8e80941Smrg 486b8e80941Smrg ctx->base.create_blend_state = lima_create_blend_state; 487b8e80941Smrg ctx->base.bind_blend_state = lima_bind_blend_state; 488b8e80941Smrg ctx->base.delete_blend_state = lima_delete_blend_state; 489b8e80941Smrg 490b8e80941Smrg ctx->base.create_vertex_elements_state = lima_create_vertex_elements_state; 491b8e80941Smrg ctx->base.bind_vertex_elements_state = lima_bind_vertex_elements_state; 492b8e80941Smrg ctx->base.delete_vertex_elements_state = lima_delete_vertex_elements_state; 493b8e80941Smrg 494b8e80941Smrg ctx->base.create_sampler_state = lima_create_sampler_state; 495b8e80941Smrg ctx->base.delete_sampler_state = lima_sampler_state_delete; 496b8e80941Smrg ctx->base.bind_sampler_states = lima_sampler_states_bind; 497b8e80941Smrg 498b8e80941Smrg ctx->base.create_sampler_view = lima_create_sampler_view; 499b8e80941Smrg ctx->base.sampler_view_destroy = lima_sampler_view_destroy; 500b8e80941Smrg ctx->base.set_sampler_views = lima_set_sampler_views; 501b8e80941Smrg 502b8e80941Smrg ctx->base.set_sample_mask = lima_set_sample_mask; 503b8e80941Smrg} 504b8e80941Smrg 505b8e80941Smrgvoid 506b8e80941Smrglima_state_fini(struct lima_context *ctx) 507b8e80941Smrg{ 508b8e80941Smrg struct lima_context_vertex_buffer *so = &ctx->vertex_buffers; 509b8e80941Smrg 510b8e80941Smrg util_set_vertex_buffers_mask(so->vb, &so->enabled_mask, NULL, 511b8e80941Smrg 0, ARRAY_SIZE(so->vb)); 512b8e80941Smrg 513b8e80941Smrg pipe_surface_reference(&ctx->framebuffer.base.cbufs[0], NULL); 514b8e80941Smrg pipe_surface_reference(&ctx->framebuffer.base.zsbuf, NULL); 515b8e80941Smrg} 516