14c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller/* 24c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * Copyright 2010 Christoph Bumiller 34c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * 44c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * Permission is hereby granted, free of charge, to any person obtaining a 54c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * copy of this software and associated documentation files (the "Software"), 64c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * to deal in the Software without restriction, including without limitation 74c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * the rights to use, copy, modify, merge, publish, distribute, sublicense, 84c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * and/or sell copies of the Software, and to permit persons to whom the 94c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * Software is furnished to do so, subject to the following conditions: 104c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * 114c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * The above copyright notice and this permission notice shall be included in 124c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * all copies or substantial portions of the Software. 134c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * 144c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 154c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 164c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 174c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 184c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 194c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 204c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * SOFTWARE. 214c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller */ 224c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 234c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller#include "pipe/p_defines.h" 244c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller#include "util/u_inlines.h" 25588fa884d212eba5ffbc69fda75db37d7c77214cMarek Olšák#include "util/u_transfer.h" 264c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 274c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller#include "tgsi/tgsi_parse.h" 284c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 294c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller#include "nvc0_stateobj.h" 304c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller#include "nvc0_context.h" 314c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 324c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller#include "nvc0_3d.xml.h" 33e4c968cdbbdc020afbf869d12b536c0a0dbf9de8Christoph Bumiller#include "nv50/nv50_texture.xml.h" 344c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 354c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller#include "nouveau/nouveau_gldefs.h" 364c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 374c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic INLINE uint32_t 384c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_colormask(unsigned mask) 394c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 404c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller uint32_t ret = 0; 414c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 424c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller if (mask & PIPE_MASK_R) 434c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller ret |= 0x0001; 444c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller if (mask & PIPE_MASK_G) 454c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller ret |= 0x0010; 464c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller if (mask & PIPE_MASK_B) 474c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller ret |= 0x0100; 484c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller if (mask & PIPE_MASK_A) 494c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller ret |= 0x1000; 504c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 514c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller return ret; 524c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 534c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 543903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller#define NVC0_BLEND_FACTOR_CASE(a, b) \ 553903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller case PIPE_BLENDFACTOR_##a: return NV50_3D_BLEND_FACTOR_##b 563903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller 574c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic INLINE uint32_t 584c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_blend_fac(unsigned factor) 594c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 603903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller switch (factor) { 613903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(ONE, ONE); 623903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(SRC_COLOR, SRC_COLOR); 633903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(SRC_ALPHA, SRC_ALPHA); 643903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(DST_ALPHA, DST_ALPHA); 653903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(DST_COLOR, DST_COLOR); 663903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(SRC_ALPHA_SATURATE, SRC_ALPHA_SATURATE); 673903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(CONST_COLOR, CONSTANT_COLOR); 683903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(CONST_ALPHA, CONSTANT_ALPHA); 693903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(SRC1_COLOR, SRC1_COLOR); 703903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(SRC1_ALPHA, SRC1_ALPHA); 713903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(ZERO, ZERO); 723903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(INV_SRC_COLOR, ONE_MINUS_SRC_COLOR); 733903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(INV_SRC_ALPHA, ONE_MINUS_SRC_ALPHA); 743903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(INV_DST_ALPHA, ONE_MINUS_DST_ALPHA); 753903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(INV_DST_COLOR, ONE_MINUS_DST_COLOR); 763903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(INV_CONST_COLOR, ONE_MINUS_CONSTANT_COLOR); 773903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(INV_CONST_ALPHA, ONE_MINUS_CONSTANT_ALPHA); 783903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(INV_SRC1_COLOR, ONE_MINUS_SRC1_COLOR); 793903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller NVC0_BLEND_FACTOR_CASE(INV_SRC1_ALPHA, ONE_MINUS_SRC1_ALPHA); 803903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller default: 813903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller return NV50_3D_BLEND_FACTOR_ZERO; 823903e25a2cd6c198581021242897b1952d2afea0Christoph Bumiller } 834c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 844c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 854c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void * 864c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_blend_state_create(struct pipe_context *pipe, 874c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller const struct pipe_blend_state *cso) 884c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 891a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller struct nvc0_blend_stateobj *so = CALLOC_STRUCT(nvc0_blend_stateobj); 901a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller int i; 911a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller int r; /* reference */ 921a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller uint32_t ms; 931a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller uint8_t blend_en = 0; 941a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller boolean indep_masks = FALSE; 951a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller boolean indep_funcs = FALSE; 961a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller 971a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller so->pipe = *cso; 981a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller 991a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller /* check which states actually have differing values */ 1001a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller if (cso->independent_blend_enable) { 1011a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller for (r = 0; r < 8 && !cso->rt[r].blend_enable; ++r); 1021a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller blend_en |= 1 << r; 1031a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller for (i = r + 1; i < 8; ++i) { 1041a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller if (!cso->rt[i].blend_enable) 1051a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller continue; 1061a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller blend_en |= 1 << i; 1071a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller if (cso->rt[i].rgb_func != cso->rt[r].rgb_func || 1081a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller cso->rt[i].rgb_src_factor != cso->rt[r].rgb_src_factor || 1091a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller cso->rt[i].rgb_dst_factor != cso->rt[r].rgb_dst_factor || 1101a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller cso->rt[i].alpha_func != cso->rt[r].alpha_func || 1111a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller cso->rt[i].alpha_src_factor != cso->rt[r].alpha_src_factor || 1121a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller cso->rt[i].alpha_dst_factor != cso->rt[r].alpha_dst_factor) { 1131a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller indep_funcs = TRUE; 1141a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller break; 1151a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller } 1161a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller } 1171a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller for (; i < 8; ++i) 1181a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller blend_en |= (cso->rt[i].blend_enable ? 1 : 0) << i; 1191a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller 1201a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller for (i = 1; i < 8; ++i) { 1211a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller if (cso->rt[i].colormask != cso->rt[0].colormask) { 1221a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller indep_masks = TRUE; 1231a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller break; 1241a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller } 1251a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller } 1261a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller } else { 1271a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller r = 0; 1281a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller if (cso->rt[0].blend_enable) 1291a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller blend_en = 0xff; 1301a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller } 1311a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller 1321a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller if (cso->logicop_enable) { 1331a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_BEGIN_3D(so, LOGIC_OP_ENABLE, 2); 1341a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_DATA (so, 1); 1351a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_DATA (so, nvgl_logicop_func(cso->logicop_func)); 1361a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller 1371a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_IMMED_3D(so, MACRO_BLEND_ENABLES, 0); 1381a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller } else { 1391a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_IMMED_3D(so, LOGIC_OP_ENABLE, 0); 1401a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller 1411a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_IMMED_3D(so, BLEND_INDEPENDENT, indep_funcs); 1421a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_IMMED_3D(so, MACRO_BLEND_ENABLES, blend_en); 1431a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller if (indep_funcs) { 1441a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller for (i = 0; i < 8; ++i) { 1451a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller if (cso->rt[i].blend_enable) { 1461a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_BEGIN_3D(so, IBLEND_EQUATION_RGB(i), 6); 1471a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_DATA (so, nvgl_blend_eqn(cso->rt[i].rgb_func)); 1481a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_DATA (so, nvc0_blend_fac(cso->rt[i].rgb_src_factor)); 1491a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_DATA (so, nvc0_blend_fac(cso->rt[i].rgb_dst_factor)); 1501a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_DATA (so, nvgl_blend_eqn(cso->rt[i].alpha_func)); 1511a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_DATA (so, nvc0_blend_fac(cso->rt[i].alpha_src_factor)); 1521a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_DATA (so, nvc0_blend_fac(cso->rt[i].alpha_dst_factor)); 1531a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller } 1541a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller } 1551a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller } else 1561a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller if (blend_en) { 1571a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_BEGIN_3D(so, BLEND_EQUATION_RGB, 5); 1581a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_DATA (so, nvgl_blend_eqn(cso->rt[r].rgb_func)); 1591a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_DATA (so, nvc0_blend_fac(cso->rt[r].rgb_src_factor)); 1601a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_DATA (so, nvc0_blend_fac(cso->rt[r].rgb_dst_factor)); 1611a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_DATA (so, nvgl_blend_eqn(cso->rt[r].alpha_func)); 1621a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_DATA (so, nvc0_blend_fac(cso->rt[r].alpha_src_factor)); 1631a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_BEGIN_3D(so, BLEND_FUNC_DST_ALPHA, 1); 1641a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_DATA (so, nvc0_blend_fac(cso->rt[r].alpha_dst_factor)); 1651a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller } 1661a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller 1671a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_IMMED_3D(so, COLOR_MASK_COMMON, !indep_masks); 1681a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller if (indep_masks) { 1691a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_BEGIN_3D(so, COLOR_MASK(0), 8); 1701a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller for (i = 0; i < 8; ++i) 1714c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA(so, nvc0_colormask(cso->rt[i].colormask)); 1721a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller } else { 1731a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_BEGIN_3D(so, COLOR_MASK(0), 1); 1741a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_DATA (so, nvc0_colormask(cso->rt[0].colormask)); 1751a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller } 1761a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller } 1774c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 1781a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller ms = 0; 1791a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller if (cso->alpha_to_coverage) 1801a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller ms |= NVC0_3D_MULTISAMPLE_CTRL_ALPHA_TO_COVERAGE; 1811a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller if (cso->alpha_to_one) 1821a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller ms |= NVC0_3D_MULTISAMPLE_CTRL_ALPHA_TO_ONE; 183b2dcf880e8bcd61be59602f5a2d18c77a5fc60c1Christoph Bumiller 1841a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_BEGIN_3D(so, MULTISAMPLE_CTRL, 1); 1851a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller SB_DATA (so, ms); 186b2dcf880e8bcd61be59602f5a2d18c77a5fc60c1Christoph Bumiller 1871a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller assert(so->size <= (sizeof(so->state) / sizeof(so->state[0]))); 1881a21e36b6818991ced32d0e3d1acc1fea0d936ceChristoph Bumiller return so; 1894c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 1904c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 1914c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 1924c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_blend_state_bind(struct pipe_context *pipe, void *hwcso) 1934c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 1944c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 1954c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 1964c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->blend = hwcso; 1974c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->dirty |= NVC0_NEW_BLEND; 1984c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 1994c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 2004c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 2014c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_blend_state_delete(struct pipe_context *pipe, void *hwcso) 2024c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 2034c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller FREE(hwcso); 2044c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 2054c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 206843d5391c3b7b80ff2087ce7e6440417aab623ccChristoph Bumiller/* NOTE: ignoring line_last_pixel, using FALSE (set on screen init) */ 2074c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void * 2084c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_rasterizer_state_create(struct pipe_context *pipe, 2094c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller const struct pipe_rasterizer_state *cso) 2104c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 2114c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_rasterizer_stateobj *so; 212d9f1310e519ac8182329fcd3e6c357d44d110955Christoph Bumiller uint32_t reg; 2134c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 2144c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller so = CALLOC_STRUCT(nvc0_rasterizer_stateobj); 2154c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller if (!so) 2164c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller return NULL; 2174c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller so->pipe = *cso; 218d047168d81cfeb39a98f3ae16416872facc6237cChristoph Bumiller 219e7845e319679e3539274c37e9c16692a2dfe59feChristoph Bumiller /* Scissor enables are handled in scissor state, we will not want to 220e7845e319679e3539274c37e9c16692a2dfe59feChristoph Bumiller * always emit 16 commands, one for each scissor rectangle, here. 221e7845e319679e3539274c37e9c16692a2dfe59feChristoph Bumiller */ 2224c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 2234c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_BEGIN_3D(so, SHADE_MODEL, 1); 2244c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, cso->flatshade ? NVC0_3D_SHADE_MODEL_FLAT : 2254c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller NVC0_3D_SHADE_MODEL_SMOOTH); 2262c20aae23393a3f6899f1775df47697ce65fc6caChristoph Bumiller SB_IMMED_3D(so, PROVOKING_VERTEX_LAST, !cso->flatshade_first); 2272c20aae23393a3f6899f1775df47697ce65fc6caChristoph Bumiller SB_IMMED_3D(so, VERTEX_TWO_SIDE_ENABLE, cso->light_twoside); 2284c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 2298f060df60d1f5ad63a341e39f2ec5a0c3c452cf5Christoph Bumiller SB_IMMED_3D(so, VERT_COLOR_CLAMP_EN, cso->clamp_vertex_color); 2308f060df60d1f5ad63a341e39f2ec5a0c3c452cf5Christoph Bumiller SB_BEGIN_3D(so, FRAG_COLOR_CLAMP_EN, 1); 2318f060df60d1f5ad63a341e39f2ec5a0c3c452cf5Christoph Bumiller SB_DATA (so, cso->clamp_fragment_color ? 0x11111111 : 0x00000000); 2328f060df60d1f5ad63a341e39f2ec5a0c3c452cf5Christoph Bumiller 233b2dcf880e8bcd61be59602f5a2d18c77a5fc60c1Christoph Bumiller SB_IMMED_3D(so, MULTISAMPLE_ENABLE, cso->multisample); 234b2dcf880e8bcd61be59602f5a2d18c77a5fc60c1Christoph Bumiller 2352c20aae23393a3f6899f1775df47697ce65fc6caChristoph Bumiller SB_IMMED_3D(so, LINE_SMOOTH_ENABLE, cso->line_smooth); 236843d5391c3b7b80ff2087ce7e6440417aab623ccChristoph Bumiller if (cso->line_smooth) 237843d5391c3b7b80ff2087ce7e6440417aab623ccChristoph Bumiller SB_BEGIN_3D(so, LINE_WIDTH_SMOOTH, 1); 238843d5391c3b7b80ff2087ce7e6440417aab623ccChristoph Bumiller else 239843d5391c3b7b80ff2087ce7e6440417aab623ccChristoph Bumiller SB_BEGIN_3D(so, LINE_WIDTH_ALIASED, 1); 240843d5391c3b7b80ff2087ce7e6440417aab623ccChristoph Bumiller SB_DATA (so, fui(cso->line_width)); 2414c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 242d9ef97696770c8a6b04e4adf9a813614f9b3c741Christoph Bumiller SB_IMMED_3D(so, LINE_STIPPLE_ENABLE, cso->line_stipple_enable); 2434c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller if (cso->line_stipple_enable) { 2444c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_BEGIN_3D(so, LINE_STIPPLE_PATTERN, 1); 2454c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, (cso->line_stipple_pattern << 8) | 2464c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller cso->line_stipple_factor); 2474c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 2484c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller } 2494c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 2502c20aae23393a3f6899f1775df47697ce65fc6caChristoph Bumiller SB_IMMED_3D(so, VP_POINT_SIZE_EN, cso->point_size_per_vertex); 2514c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller if (!cso->point_size_per_vertex) { 2524c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_BEGIN_3D(so, POINT_SIZE, 1); 2534c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, fui(cso->point_size)); 2544c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller } 255d9f1310e519ac8182329fcd3e6c357d44d110955Christoph Bumiller 256d9f1310e519ac8182329fcd3e6c357d44d110955Christoph Bumiller reg = (cso->sprite_coord_mode == PIPE_SPRITE_COORD_UPPER_LEFT) ? 257d9f1310e519ac8182329fcd3e6c357d44d110955Christoph Bumiller NVC0_3D_POINT_COORD_REPLACE_COORD_ORIGIN_UPPER_LEFT : 258d9f1310e519ac8182329fcd3e6c357d44d110955Christoph Bumiller NVC0_3D_POINT_COORD_REPLACE_COORD_ORIGIN_LOWER_LEFT; 259d9f1310e519ac8182329fcd3e6c357d44d110955Christoph Bumiller 260d9f1310e519ac8182329fcd3e6c357d44d110955Christoph Bumiller SB_BEGIN_3D(so, POINT_COORD_REPLACE, 1); 261d9f1310e519ac8182329fcd3e6c357d44d110955Christoph Bumiller SB_DATA (so, ((cso->sprite_coord_enable & 0xff) << 3) | reg); 2622c20aae23393a3f6899f1775df47697ce65fc6caChristoph Bumiller SB_IMMED_3D(so, POINT_SPRITE_ENABLE, cso->point_quad_rasterization); 263370ae0bd614fcbf9c4c0424fb5c41f2cfbc17b3eChristoph Bumiller SB_IMMED_3D(so, POINT_SMOOTH_ENABLE, cso->point_smooth); 2644c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 2657a40ae4a31f3ab526706fdfda7631d54f094512aChristoph Bumiller SB_BEGIN_3D(so, MACRO_POLYGON_MODE_FRONT, 1); 2664c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, nvgl_polygon_mode(cso->fill_front)); 2677a40ae4a31f3ab526706fdfda7631d54f094512aChristoph Bumiller SB_BEGIN_3D(so, MACRO_POLYGON_MODE_BACK, 1); 2684c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, nvgl_polygon_mode(cso->fill_back)); 2692c20aae23393a3f6899f1775df47697ce65fc6caChristoph Bumiller SB_IMMED_3D(so, POLYGON_SMOOTH_ENABLE, cso->poly_smooth); 2704c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 271dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller SB_BEGIN_3D(so, CULL_FACE_ENABLE, 3); 272dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller SB_DATA (so, cso->cull_face != PIPE_FACE_NONE); 273dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller SB_DATA (so, cso->front_ccw ? NVC0_3D_FRONT_FACE_CCW : 274dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller NVC0_3D_FRONT_FACE_CW); 275dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller switch (cso->cull_face) { 276dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller case PIPE_FACE_FRONT_AND_BACK: 277dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller SB_DATA(so, NVC0_3D_CULL_FACE_FRONT_AND_BACK); 278dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller break; 279dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller case PIPE_FACE_FRONT: 280dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller SB_DATA(so, NVC0_3D_CULL_FACE_FRONT); 281dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller break; 282dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller case PIPE_FACE_BACK: 283dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller default: 284dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller SB_DATA(so, NVC0_3D_CULL_FACE_BACK); 285dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller break; 2864c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller } 2874c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 2882c20aae23393a3f6899f1775df47697ce65fc6caChristoph Bumiller SB_IMMED_3D(so, POLYGON_STIPPLE_ENABLE, cso->poly_stipple_enable); 2894c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_BEGIN_3D(so, POLYGON_OFFSET_POINT_ENABLE, 3); 2904c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, cso->offset_point); 2914c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, cso->offset_line); 2924c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, cso->offset_tri); 2934c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 2944c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller if (cso->offset_point || cso->offset_line || cso->offset_tri) { 2954c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_BEGIN_3D(so, POLYGON_OFFSET_FACTOR, 1); 2964c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, fui(cso->offset_scale)); 2974c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_BEGIN_3D(so, POLYGON_OFFSET_UNITS, 1); 2981579017b08f28d460e17de65bcc8ba17ba695c37Christoph Bumiller SB_DATA (so, fui(cso->offset_units * 2.0f)); 299b3fa0d311e553ec815d58e58a30aa8b3927e4afdChristoph Bumiller SB_BEGIN_3D(so, POLYGON_OFFSET_CLAMP, 1); 300b3fa0d311e553ec815d58e58a30aa8b3927e4afdChristoph Bumiller SB_DATA (so, fui(cso->offset_clamp)); 3014c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller } 3024c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 303dc4c821f0817a3db716f965692fb701079f66340Marek Olšák if (cso->depth_clip) 304dc4c821f0817a3db716f965692fb701079f66340Marek Olšák reg = NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK1_UNK1; 305dc4c821f0817a3db716f965692fb701079f66340Marek Olšák else 306dc4c821f0817a3db716f965692fb701079f66340Marek Olšák reg = 307dc4c821f0817a3db716f965692fb701079f66340Marek Olšák NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK1_UNK1 | 308dc4c821f0817a3db716f965692fb701079f66340Marek Olšák NVC0_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_NEAR | 309dc4c821f0817a3db716f965692fb701079f66340Marek Olšák NVC0_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_FAR | 310dc4c821f0817a3db716f965692fb701079f66340Marek Olšák NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK12_UNK2; 311dc4c821f0817a3db716f965692fb701079f66340Marek Olšák 312dc4c821f0817a3db716f965692fb701079f66340Marek Olšák SB_BEGIN_3D(so, VIEW_VOLUME_CLIP_CTRL, 1); 313dc4c821f0817a3db716f965692fb701079f66340Marek Olšák SB_DATA (so, reg); 314dc4c821f0817a3db716f965692fb701079f66340Marek Olšák 315d9ef97696770c8a6b04e4adf9a813614f9b3c741Christoph Bumiller assert(so->size <= (sizeof(so->state) / sizeof(so->state[0]))); 3164c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller return (void *)so; 3174c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 3184c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 3194c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 3204c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_rasterizer_state_bind(struct pipe_context *pipe, void *hwcso) 3214c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 3224c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 3234c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 3244c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->rast = hwcso; 3254c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->dirty |= NVC0_NEW_RASTERIZER; 3264c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 3274c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 3284c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 3294c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso) 3304c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 3314c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller FREE(hwcso); 3324c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 3334c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 3344c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void * 3354c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_zsa_state_create(struct pipe_context *pipe, 3364c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller const struct pipe_depth_stencil_alpha_state *cso) 3374c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 3384c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_zsa_stateobj *so = CALLOC_STRUCT(nvc0_zsa_stateobj); 3394c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 3404c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller so->pipe = *cso; 3414c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 342f0ee7d8bb46ac7694693f3fb8cd0f15c422f1befChristoph Bumiller SB_IMMED_3D(so, DEPTH_TEST_ENABLE, cso->depth.enabled); 3434c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller if (cso->depth.enabled) { 344f0ee7d8bb46ac7694693f3fb8cd0f15c422f1befChristoph Bumiller SB_IMMED_3D(so, DEPTH_WRITE_ENABLE, cso->depth.writemask); 3454c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_BEGIN_3D(so, DEPTH_TEST_FUNC, 1); 3464c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, nvgl_comparison_op(cso->depth.func)); 3474c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller } 3484c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 3494c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller if (cso->stencil[0].enabled) { 350293a8d1b600cd5bd89b3c4c0b6c2bb245d9bd80fChristoph Bumiller SB_BEGIN_3D(so, STENCIL_ENABLE, 5); 3514c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, 1); 3524c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, nvgl_stencil_op(cso->stencil[0].fail_op)); 3534c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, nvgl_stencil_op(cso->stencil[0].zfail_op)); 3544c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, nvgl_stencil_op(cso->stencil[0].zpass_op)); 3554c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, nvgl_comparison_op(cso->stencil[0].func)); 356293a8d1b600cd5bd89b3c4c0b6c2bb245d9bd80fChristoph Bumiller SB_BEGIN_3D(so, STENCIL_FRONT_FUNC_MASK, 2); 3574c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, cso->stencil[0].valuemask); 358293a8d1b600cd5bd89b3c4c0b6c2bb245d9bd80fChristoph Bumiller SB_DATA (so, cso->stencil[0].writemask); 3594c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller } else { 360293a8d1b600cd5bd89b3c4c0b6c2bb245d9bd80fChristoph Bumiller SB_IMMED_3D(so, STENCIL_ENABLE, 0); 3614c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller } 3624c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 3634c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller if (cso->stencil[1].enabled) { 364293a8d1b600cd5bd89b3c4c0b6c2bb245d9bd80fChristoph Bumiller assert(cso->stencil[0].enabled); 3654c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_BEGIN_3D(so, STENCIL_TWO_SIDE_ENABLE, 5); 3664c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, 1); 3674c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, nvgl_stencil_op(cso->stencil[1].fail_op)); 3684c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, nvgl_stencil_op(cso->stencil[1].zfail_op)); 3694c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, nvgl_stencil_op(cso->stencil[1].zpass_op)); 3704c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, nvgl_comparison_op(cso->stencil[1].func)); 3714c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_BEGIN_3D(so, STENCIL_BACK_MASK, 2); 3724c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, cso->stencil[1].writemask); 3734c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, cso->stencil[1].valuemask); 374293a8d1b600cd5bd89b3c4c0b6c2bb245d9bd80fChristoph Bumiller } else 375293a8d1b600cd5bd89b3c4c0b6c2bb245d9bd80fChristoph Bumiller if (cso->stencil[0].enabled) { 3762c20aae23393a3f6899f1775df47697ce65fc6caChristoph Bumiller SB_IMMED_3D(so, STENCIL_TWO_SIDE_ENABLE, 0); 3774c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller } 378f0ee7d8bb46ac7694693f3fb8cd0f15c422f1befChristoph Bumiller 379f0ee7d8bb46ac7694693f3fb8cd0f15c422f1befChristoph Bumiller SB_IMMED_3D(so, ALPHA_TEST_ENABLE, cso->alpha.enabled); 3804c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller if (cso->alpha.enabled) { 3814c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_BEGIN_3D(so, ALPHA_TEST_REF, 2); 3824c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, fui(cso->alpha.ref_value)); 3834c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller SB_DATA (so, nvgl_comparison_op(cso->alpha.func)); 3844c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller } 3854c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 386d9ef97696770c8a6b04e4adf9a813614f9b3c741Christoph Bumiller assert(so->size <= (sizeof(so->state) / sizeof(so->state[0]))); 3874c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller return (void *)so; 3884c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 3894c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 3904c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 3914c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_zsa_state_bind(struct pipe_context *pipe, void *hwcso) 3924c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 3934c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 3944c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 3954c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->zsa = hwcso; 3964c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->dirty |= NVC0_NEW_ZSA; 3974c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 3984c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 3994c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 4004c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_zsa_state_delete(struct pipe_context *pipe, void *hwcso) 4014c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 4024c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller FREE(hwcso); 4034c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 4044c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 4054c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller/* ====================== SAMPLERS AND TEXTURES ================================ 4064c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller */ 4074c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 4084c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller#define NV50_TSC_WRAP_CASE(n) \ 4094c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller case PIPE_TEX_WRAP_##n: return NV50_TSC_WRAP_##n 4104c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 4114c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic INLINE unsigned 4124c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernv50_tsc_wrap_mode(unsigned wrap) 4134c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 4144c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller switch (wrap) { 4154c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller NV50_TSC_WRAP_CASE(REPEAT); 4164c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller NV50_TSC_WRAP_CASE(MIRROR_REPEAT); 4174c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller NV50_TSC_WRAP_CASE(CLAMP_TO_EDGE); 4184c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller NV50_TSC_WRAP_CASE(CLAMP_TO_BORDER); 4194c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller NV50_TSC_WRAP_CASE(CLAMP); 4204c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller NV50_TSC_WRAP_CASE(MIRROR_CLAMP_TO_EDGE); 4214c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller NV50_TSC_WRAP_CASE(MIRROR_CLAMP_TO_BORDER); 4224c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller NV50_TSC_WRAP_CASE(MIRROR_CLAMP); 4234c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller default: 4244c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller NOUVEAU_ERR("unknown wrap mode: %d\n", wrap); 4254c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller return NV50_TSC_WRAP_REPEAT; 4264c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller } 4274c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 4284c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 4294c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 4304c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_sampler_state_delete(struct pipe_context *pipe, void *hwcso) 4314c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 4324c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller unsigned s, i; 4334c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 4344c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller for (s = 0; s < 5; ++s) 4354c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller for (i = 0; i < nvc0_context(pipe)->num_samplers[s]; ++i) 4364c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller if (nvc0_context(pipe)->samplers[s][i] == hwcso) 4374c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0_context(pipe)->samplers[s][i] = NULL; 4384c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 4391f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller nvc0_screen_tsc_free(nvc0_context(pipe)->screen, nv50_tsc_entry(hwcso)); 4404c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 4414c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller FREE(hwcso); 4424c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 4434c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 4444c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic INLINE void 4454c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_stage_sampler_states_bind(struct nvc0_context *nvc0, int s, 4464c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller unsigned nr, void **hwcso) 4474c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 4484c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller unsigned i; 4494c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 4504c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller for (i = 0; i < nr; ++i) { 4511f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller struct nv50_tsc_entry *old = nvc0->samplers[s][i]; 4524c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 453784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller if (hwcso[i] == old) 454784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller continue; 455784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller nvc0->samplers_dirty[s] |= 1 << i; 456784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller 4571f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller nvc0->samplers[s][i] = nv50_tsc_entry(hwcso[i]); 4584c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller if (old) 4594c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0_screen_tsc_unlock(nvc0->screen, old); 4604c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller } 461784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller for (; i < nvc0->num_samplers[s]; ++i) { 462784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller if (nvc0->samplers[s][i]) { 4634c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0_screen_tsc_unlock(nvc0->screen, nvc0->samplers[s][i]); 464784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller nvc0->samplers[s][i] = NULL; 465784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller } 466784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller } 4674c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 4684c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->num_samplers[s] = nr; 4694c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 4704c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->dirty |= NVC0_NEW_SAMPLERS; 4714c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 4724c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 4734c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 4744c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_vp_sampler_states_bind(struct pipe_context *pipe, unsigned nr, void **s) 4754c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 4764c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0_stage_sampler_states_bind(nvc0_context(pipe), 0, nr, s); 4774c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 4784c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 4794c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 4804c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_fp_sampler_states_bind(struct pipe_context *pipe, unsigned nr, void **s) 4814c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 4824c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0_stage_sampler_states_bind(nvc0_context(pipe), 4, nr, s); 4834c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 4844c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 4854c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 4864c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_gp_sampler_states_bind(struct pipe_context *pipe, unsigned nr, void **s) 4874c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 4884c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0_stage_sampler_states_bind(nvc0_context(pipe), 3, nr, s); 4894c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 4904c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 4914c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller/* NOTE: only called when not referenced anywhere, won't be bound */ 4924c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 4934c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_sampler_view_destroy(struct pipe_context *pipe, 4944c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct pipe_sampler_view *view) 4954c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 4964c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller pipe_resource_reference(&view->texture, NULL); 4974c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 4981f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller nvc0_screen_tic_free(nvc0_context(pipe)->screen, nv50_tic_entry(view)); 4994c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5001f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller FREE(nv50_tic_entry(view)); 5014c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 5024c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5034c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic INLINE void 5044c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_stage_set_sampler_views(struct nvc0_context *nvc0, int s, 5054c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller unsigned nr, 5064c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct pipe_sampler_view **views) 5074c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 5084c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller unsigned i; 5094c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5104c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller for (i = 0; i < nr; ++i) { 5111f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller struct nv50_tic_entry *old = nv50_tic_entry(nvc0->textures[s][i]); 512784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller 513784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller if (views[i] == nvc0->textures[s][i]) 514784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller continue; 515784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller nvc0->textures_dirty[s] |= 1 << i; 516784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller 517784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller if (old) { 518784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_TEX(s, i)); 5194c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0_screen_tic_unlock(nvc0->screen, old); 520784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller } 5214c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5224c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller pipe_sampler_view_reference(&nvc0->textures[s][i], views[i]); 5234c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller } 5244c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5254c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller for (i = nr; i < nvc0->num_textures[s]; ++i) { 5261f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller struct nv50_tic_entry *old = nv50_tic_entry(nvc0->textures[s][i]); 527784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller if (old) { 528784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_TEX(s, i)); 529784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller nvc0_screen_tic_unlock(nvc0->screen, old); 530784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller pipe_sampler_view_reference(&nvc0->textures[s][i], NULL); 531784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller } 5324c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller } 5334c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5344c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->num_textures[s] = nr; 5354c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5364c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->dirty |= NVC0_NEW_TEXTURES; 5374c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 5384c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5394c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 5404c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_vp_set_sampler_views(struct pipe_context *pipe, 5414c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller unsigned nr, 5424c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct pipe_sampler_view **views) 5434c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 5444c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0_stage_set_sampler_views(nvc0_context(pipe), 0, nr, views); 5454c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 5464c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5474c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 5484c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_fp_set_sampler_views(struct pipe_context *pipe, 5494c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller unsigned nr, 5504c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct pipe_sampler_view **views) 5514c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 5524c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0_stage_set_sampler_views(nvc0_context(pipe), 4, nr, views); 5534c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 5544c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5554c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 5564c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_gp_set_sampler_views(struct pipe_context *pipe, 5574c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller unsigned nr, 5584c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct pipe_sampler_view **views) 5594c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 5604c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0_stage_set_sampler_views(nvc0_context(pipe), 3, nr, views); 5614c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 5624c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5634c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller/* ============================= SHADERS ======================================= 5644c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller */ 5654c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5664c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void * 5674c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_sp_state_create(struct pipe_context *pipe, 5684c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller const struct pipe_shader_state *cso, unsigned type) 5694c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 5704c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_program *prog; 5714c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5724c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller prog = CALLOC_STRUCT(nvc0_program); 5734c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller if (!prog) 5744c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller return NULL; 5754c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5764c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller prog->type = type; 57714bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller 57814bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller if (cso->tokens) 57914bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller prog->pipe.tokens = tgsi_dup_tokens(cso->tokens); 58014bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller 58114bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller if (cso->stream_output.num_outputs) 58214bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller prog->pipe.stream_output = cso->stream_output; 5834c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5844c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller return (void *)prog; 5854c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 5864c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5874c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 5884c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_sp_state_delete(struct pipe_context *pipe, void *hwcso) 5894c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 5904c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_program *prog = (struct nvc0_program *)hwcso; 5914c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5924c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0_program_destroy(nvc0_context(pipe), prog); 5934c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5944c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller FREE((void *)prog->pipe.tokens); 5954c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller FREE(prog); 5964c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 5974c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 5984c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void * 5994c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_vp_state_create(struct pipe_context *pipe, 6004c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller const struct pipe_shader_state *cso) 6014c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 6024c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller return nvc0_sp_state_create(pipe, cso, PIPE_SHADER_VERTEX); 6034c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 6044c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 6054c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 6064c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_vp_state_bind(struct pipe_context *pipe, void *hwcso) 6074c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 6084c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 6094c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 6104c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->vertprog = hwcso; 6114c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->dirty |= NVC0_NEW_VERTPROG; 6124c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 6134c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 6144c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void * 6154c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_fp_state_create(struct pipe_context *pipe, 6164c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller const struct pipe_shader_state *cso) 6174c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 6184c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller return nvc0_sp_state_create(pipe, cso, PIPE_SHADER_FRAGMENT); 6194c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 6204c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 6214c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 6224c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_fp_state_bind(struct pipe_context *pipe, void *hwcso) 6234c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 6244c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 6254c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 6264c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->fragprog = hwcso; 6274c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->dirty |= NVC0_NEW_FRAGPROG; 6284c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 6294c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 6304c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void * 6314c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_gp_state_create(struct pipe_context *pipe, 6324c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller const struct pipe_shader_state *cso) 6334c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 6344c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller return nvc0_sp_state_create(pipe, cso, PIPE_SHADER_GEOMETRY); 6354c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 6364c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 6374c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 6384c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_gp_state_bind(struct pipe_context *pipe, void *hwcso) 6394c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 6404c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 6414c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 6424c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->gmtyprog = hwcso; 6434c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->dirty |= NVC0_NEW_GMTYPROG; 6444c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 6454c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 6464c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 6474c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, 648507337864fa80caf9f26602324d2c28dd0a75d61Marek Olšák struct pipe_constant_buffer *cb) 6494c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 6504c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 651507337864fa80caf9f26602324d2c28dd0a75d61Marek Olšák struct pipe_resource *res = cb ? cb->buffer : NULL; 652fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller const unsigned s = nvc0_shader_stage(shader); 653fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller const unsigned i = index; 6544c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 655fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller if (shader == PIPE_SHADER_COMPUTE) 656fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller return; 6570b7d48cbad86eaac21fce3793da41b46db8be3b4Marek Olšák 658fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller if (nvc0->constbuf[s][i].user) 659fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller nvc0->constbuf[s][i].u.buf = NULL; 660fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller else 661fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller if (nvc0->constbuf[s][i].u.buf) 662fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_CB(s, i)); 6634c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 664fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller pipe_resource_reference(&nvc0->constbuf[s][i].u.buf, res); 6654c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 666fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller nvc0->constbuf[s][i].user = (cb && cb->user_buffer) ? TRUE : FALSE; 667fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller if (nvc0->constbuf[s][i].user) { 668fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller nvc0->constbuf[s][i].u.data = cb->user_buffer; 669fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller nvc0->constbuf[s][i].size = cb->buffer_size; 670fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller } else 671fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller if (cb) { 672fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller nvc0->constbuf[s][i].offset = cb->buffer_offset; 673fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller nvc0->constbuf[s][i].size = align(cb->buffer_size, 0x100); 674fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller } 6754c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 676fcb28682101dfa127486373411043d5d97a0ff8fChristoph Bumiller nvc0->constbuf_dirty[s] |= 1 << i; 6774c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 6784c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->dirty |= NVC0_NEW_CONSTBUF; 6794c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 6804c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 6814c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller/* ============================================================================= 6824c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller */ 6834c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 6844c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 6854c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_blend_color(struct pipe_context *pipe, 6864c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller const struct pipe_blend_color *bcol) 6874c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 6884c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 6894c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 6904c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->blend_colour = *bcol; 6914c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->dirty |= NVC0_NEW_BLEND_COLOUR; 6924c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 6934c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 6944c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 6954c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_stencil_ref(struct pipe_context *pipe, 6964c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller const struct pipe_stencil_ref *sr) 6974c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 6984c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 6994c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 7004c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->stencil_ref = *sr; 7014c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->dirty |= NVC0_NEW_STENCIL_REF; 7024c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 7034c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 7044c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 7054c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_clip_state(struct pipe_context *pipe, 7064c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller const struct pipe_clip_state *clip) 7074c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 7084c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 7094c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 710dc4c821f0817a3db716f965692fb701079f66340Marek Olšák memcpy(nvc0->clip.ucp, clip->ucp, sizeof(clip->ucp)); 7115138ac033ad3708e2b82f2beebc887f65a77309eChristoph Bumiller 7124c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->dirty |= NVC0_NEW_CLIP; 7134c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 7144c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 7154c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 7164c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_sample_mask(struct pipe_context *pipe, unsigned sample_mask) 7174c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 7184c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 7194c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 7204c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->sample_mask = sample_mask; 7214c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->dirty |= NVC0_NEW_SAMPLE_MASK; 7224c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 7234c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 7244c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 7254c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 7264c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_framebuffer_state(struct pipe_context *pipe, 7274c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller const struct pipe_framebuffer_state *fb) 7284c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 7294c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 7302d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller unsigned i; 7314c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 7326d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_FB); 7336d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller 7342d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller for (i = 0; i < fb->nr_cbufs; ++i) 7352d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller pipe_surface_reference(&nvc0->framebuffer.cbufs[i], fb->cbufs[i]); 7362d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller for (; i < nvc0->framebuffer.nr_cbufs; ++i) 7372d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller pipe_surface_reference(&nvc0->framebuffer.cbufs[i], NULL); 7382d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller 7392d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller nvc0->framebuffer.nr_cbufs = fb->nr_cbufs; 7402d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller 7412d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller nvc0->framebuffer.width = fb->width; 7422d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller nvc0->framebuffer.height = fb->height; 7432d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller 7442d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller pipe_surface_reference(&nvc0->framebuffer.zsbuf, fb->zsbuf); 7452d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller 7464c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->dirty |= NVC0_NEW_FRAMEBUFFER; 7474c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 7484c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 7494c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 7504c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_polygon_stipple(struct pipe_context *pipe, 7514c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller const struct pipe_poly_stipple *stipple) 7524c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 7534c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 7544c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 7554c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->stipple = *stipple; 7564c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->dirty |= NVC0_NEW_STIPPLE; 7574c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 7584c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 7594c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 7604c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_scissor_state(struct pipe_context *pipe, 7614c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller const struct pipe_scissor_state *scissor) 7624c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 7634c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 7644c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 7654c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->scissor = *scissor; 7664c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->dirty |= NVC0_NEW_SCISSOR; 7674c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 7684c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 7694c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 7704c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_viewport_state(struct pipe_context *pipe, 7714c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller const struct pipe_viewport_state *vpt) 7724c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 7734c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 7744c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 7754c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->viewport = *vpt; 7764c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->dirty |= NVC0_NEW_VIEWPORT; 7774c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 7784c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 7794c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 7804c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_vertex_buffers(struct pipe_context *pipe, 7814c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller unsigned count, 7824c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller const struct pipe_vertex_buffer *vb) 7834c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 7844c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 785edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller uint32_t constant_vbos = 0; 7860cb6d1a4eb2dd682b499f54a82505bc3bd318bbcChristoph Bumiller unsigned i; 7870cb6d1a4eb2dd682b499f54a82505bc3bd318bbcChristoph Bumiller 788e6caafd9d7fbfcb5906d22be9d6a3c1714e078acChristoph Bumiller nvc0->vbo_user = 0; 789e6caafd9d7fbfcb5906d22be9d6a3c1714e078acChristoph Bumiller 790edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller if (count != nvc0->num_vtxbufs) { 791edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller for (i = 0; i < count; ++i) { 792edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller pipe_resource_reference(&nvc0->vtxbuf[i].buffer, vb[i].buffer); 793e6caafd9d7fbfcb5906d22be9d6a3c1714e078acChristoph Bumiller if (vb[i].user_buffer) { 794e6caafd9d7fbfcb5906d22be9d6a3c1714e078acChristoph Bumiller nvc0->vbo_user |= 1 << i; 795e6caafd9d7fbfcb5906d22be9d6a3c1714e078acChristoph Bumiller nvc0->vtxbuf[i].user_buffer = vb[i].user_buffer; 796e6caafd9d7fbfcb5906d22be9d6a3c1714e078acChristoph Bumiller if (!vb[i].stride) 797e6caafd9d7fbfcb5906d22be9d6a3c1714e078acChristoph Bumiller constant_vbos |= 1 << i; 798e6caafd9d7fbfcb5906d22be9d6a3c1714e078acChristoph Bumiller } else { 799e6caafd9d7fbfcb5906d22be9d6a3c1714e078acChristoph Bumiller nvc0->vtxbuf[i].buffer_offset = vb[i].buffer_offset; 800e6caafd9d7fbfcb5906d22be9d6a3c1714e078acChristoph Bumiller } 801edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller nvc0->vtxbuf[i].stride = vb[i].stride; 802edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller } 803edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller for (; i < nvc0->num_vtxbufs; ++i) 804edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller pipe_resource_reference(&nvc0->vtxbuf[i].buffer, NULL); 805edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller 806edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller nvc0->num_vtxbufs = count; 807edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller nvc0->dirty |= NVC0_NEW_ARRAYS; 808edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller } else { 809edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller for (i = 0; i < count; ++i) { 810e6caafd9d7fbfcb5906d22be9d6a3c1714e078acChristoph Bumiller if (vb[i].user_buffer) { 811e6caafd9d7fbfcb5906d22be9d6a3c1714e078acChristoph Bumiller nvc0->vtxbuf[i].user_buffer = vb[i].user_buffer; 812e6caafd9d7fbfcb5906d22be9d6a3c1714e078acChristoph Bumiller nvc0->vbo_user |= 1 << i; 813e6caafd9d7fbfcb5906d22be9d6a3c1714e078acChristoph Bumiller if (!vb[i].stride) 814e6caafd9d7fbfcb5906d22be9d6a3c1714e078acChristoph Bumiller constant_vbos |= 1 << i; 815e6caafd9d7fbfcb5906d22be9d6a3c1714e078acChristoph Bumiller assert(!vb[i].buffer); 816e6caafd9d7fbfcb5906d22be9d6a3c1714e078acChristoph Bumiller } 817edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller if (nvc0->vtxbuf[i].buffer == vb[i].buffer && 818edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller nvc0->vtxbuf[i].buffer_offset == vb[i].buffer_offset && 819edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller nvc0->vtxbuf[i].stride == vb[i].stride) 820edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller continue; 821edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller pipe_resource_reference(&nvc0->vtxbuf[i].buffer, vb[i].buffer); 822edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller nvc0->vtxbuf[i].buffer_offset = vb[i].buffer_offset; 823edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller nvc0->vtxbuf[i].stride = vb[i].stride; 824e6caafd9d7fbfcb5906d22be9d6a3c1714e078acChristoph Bumiller nvc0->dirty |= NVC0_NEW_ARRAYS; 825edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller } 826edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller } 827edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller if (constant_vbos != nvc0->constant_vbos) { 828edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller nvc0->constant_vbos = constant_vbos; 829edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller nvc0->dirty |= NVC0_NEW_ARRAYS; 830edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller } 831e4349027f6842563555992a39add4d0b2283fbbbChristoph Bumiller 832edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller if (nvc0->dirty & NVC0_NEW_ARRAYS) 833edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_VTX); 8344c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 8354c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 8364c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 8374c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_index_buffer(struct pipe_context *pipe, 8384c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller const struct pipe_index_buffer *ib) 8394c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 8404c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 8414c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 8426d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller if (nvc0->idxbuf.buffer) 8436d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_IDX); 84426a199efac43cc0509f174ca47ad0d2b0044eee0Christoph Bumiller 845ef7bb281292c17b762b57779306e874704c87328Christoph Bumiller if (ib) { 8466d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller pipe_resource_reference(&nvc0->idxbuf.buffer, ib->buffer); 8476d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller nvc0->idxbuf.index_size = ib->index_size; 848ef7bb281292c17b762b57779306e874704c87328Christoph Bumiller if (ib->buffer) { 849ef7bb281292c17b762b57779306e874704c87328Christoph Bumiller nvc0->idxbuf.offset = ib->offset; 850ef7bb281292c17b762b57779306e874704c87328Christoph Bumiller nvc0->dirty |= NVC0_NEW_IDXBUF; 851ef7bb281292c17b762b57779306e874704c87328Christoph Bumiller } else { 852ef7bb281292c17b762b57779306e874704c87328Christoph Bumiller nvc0->idxbuf.user_buffer = ib->user_buffer; 853ef7bb281292c17b762b57779306e874704c87328Christoph Bumiller nvc0->dirty &= ~NVC0_NEW_IDXBUF; 854ef7bb281292c17b762b57779306e874704c87328Christoph Bumiller } 85526a199efac43cc0509f174ca47ad0d2b0044eee0Christoph Bumiller } else { 8566d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller nvc0->dirty &= ~NVC0_NEW_IDXBUF; 85726a199efac43cc0509f174ca47ad0d2b0044eee0Christoph Bumiller pipe_resource_reference(&nvc0->idxbuf.buffer, NULL); 85826a199efac43cc0509f174ca47ad0d2b0044eee0Christoph Bumiller } 8594c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 8604c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 8614c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void 8624c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_vertex_state_bind(struct pipe_context *pipe, void *hwcso) 8634c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 8644c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 8654c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 8664c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->vertex = hwcso; 8674c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller nvc0->dirty |= NVC0_NEW_VERTEX; 8684c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 8694c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 87014bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumillerstatic struct pipe_stream_output_target * 87114bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumillernvc0_so_target_create(struct pipe_context *pipe, 87214bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller struct pipe_resource *res, 87314bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller unsigned offset, unsigned size) 874f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller{ 87514bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller struct nvc0_so_target *targ = MALLOC_STRUCT(nvc0_so_target); 87614bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller if (!targ) 877f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller return NULL; 878f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller 87914bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller targ->pq = pipe->create_query(pipe, NVC0_QUERY_TFB_BUFFER_OFFSET); 88014bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller if (!targ->pq) { 88114bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller FREE(targ); 88214bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller return NULL; 883f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller } 88414bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller targ->clean = TRUE; 885f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller 88614bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller targ->pipe.buffer_size = size; 88714bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller targ->pipe.buffer_offset = offset; 88814bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller targ->pipe.context = pipe; 88914bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller targ->pipe.buffer = NULL; 89014bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller pipe_resource_reference(&targ->pipe.buffer, res); 89114bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller pipe_reference_init(&targ->pipe.reference, 1); 892f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller 89314bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller return &targ->pipe; 894f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller} 895f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller 896f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumillerstatic void 89714bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumillernvc0_so_target_destroy(struct pipe_context *pipe, 89814bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller struct pipe_stream_output_target *ptarg) 899f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller{ 90014bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller struct nvc0_so_target *targ = nvc0_so_target(ptarg); 90114bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller pipe->destroy_query(pipe, targ->pq); 902fc782bcbf04f036990f69b14e01304e1e6dc8fd1Marcin Slusarz pipe_resource_reference(&targ->pipe.buffer, NULL); 90314bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller FREE(targ); 904f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller} 905f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller 906f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumillerstatic void 90714bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumillernvc0_set_transform_feedback_targets(struct pipe_context *pipe, 90814bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller unsigned num_targets, 90914bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller struct pipe_stream_output_target **targets, 91014bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller unsigned append_mask) 911f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller{ 912f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller struct nvc0_context *nvc0 = nvc0_context(pipe); 91314bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller unsigned i; 91414bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller boolean serialize = TRUE; 915f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller 91614bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller assert(num_targets <= 4); 917f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller 91814bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller for (i = 0; i < num_targets; ++i) { 91914bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller if (nvc0->tfbbuf[i] == targets[i] && (append_mask & (1 << i))) 92014bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller continue; 92114bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller nvc0->tfbbuf_dirty |= 1 << i; 922f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller 92314bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller if (nvc0->tfbbuf[i] && nvc0->tfbbuf[i] != targets[i]) 92414bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller nvc0_so_target_save_offset(pipe, nvc0->tfbbuf[i], i, &serialize); 92514bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller 92614bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller if (targets[i] && !(append_mask & (1 << i))) 92714bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller nvc0_so_target(targets[i])->clean = TRUE; 92814bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller 92914bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller pipe_so_target_reference(&nvc0->tfbbuf[i], targets[i]); 93014bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller } 93114bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller for (; i < nvc0->num_tfbbufs; ++i) { 93214bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller nvc0->tfbbuf_dirty |= 1 << i; 93314bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller nvc0_so_target_save_offset(pipe, nvc0->tfbbuf[i], i, &serialize); 93414bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller pipe_so_target_reference(&nvc0->tfbbuf[i], NULL); 93514bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller } 93614bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller nvc0->num_tfbbufs = num_targets; 937f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller 93814bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller if (nvc0->tfbbuf_dirty) 93914bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller nvc0->dirty |= NVC0_NEW_TFB_TARGETS; 940f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller} 941f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller 9424c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillervoid 9434c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_init_state_functions(struct nvc0_context *nvc0) 9444c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{ 9451ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs struct pipe_context *pipe = &nvc0->base.pipe; 9461ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs 9471ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->create_blend_state = nvc0_blend_state_create; 9481ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->bind_blend_state = nvc0_blend_state_bind; 9491ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->delete_blend_state = nvc0_blend_state_delete; 9501ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs 9511ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->create_rasterizer_state = nvc0_rasterizer_state_create; 9521ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->bind_rasterizer_state = nvc0_rasterizer_state_bind; 9531ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->delete_rasterizer_state = nvc0_rasterizer_state_delete; 9541ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs 9551ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->create_depth_stencil_alpha_state = nvc0_zsa_state_create; 9561ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->bind_depth_stencil_alpha_state = nvc0_zsa_state_bind; 9571ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->delete_depth_stencil_alpha_state = nvc0_zsa_state_delete; 9581ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs 9591f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller pipe->create_sampler_state = nv50_sampler_state_create; 9601ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->delete_sampler_state = nvc0_sampler_state_delete; 9611ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->bind_vertex_sampler_states = nvc0_vp_sampler_states_bind; 9621ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->bind_fragment_sampler_states = nvc0_fp_sampler_states_bind; 9631ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->bind_geometry_sampler_states = nvc0_gp_sampler_states_bind; 9641ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs 9651ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->create_sampler_view = nvc0_create_sampler_view; 9661ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->sampler_view_destroy = nvc0_sampler_view_destroy; 9671ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->set_vertex_sampler_views = nvc0_vp_set_sampler_views; 9681ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->set_fragment_sampler_views = nvc0_fp_set_sampler_views; 9691ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->set_geometry_sampler_views = nvc0_gp_set_sampler_views; 9701ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs 9711ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->create_vs_state = nvc0_vp_state_create; 9721ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->create_fs_state = nvc0_fp_state_create; 9731ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->create_gs_state = nvc0_gp_state_create; 9741ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->bind_vs_state = nvc0_vp_state_bind; 9751ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->bind_fs_state = nvc0_fp_state_bind; 9761ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->bind_gs_state = nvc0_gp_state_bind; 9771ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->delete_vs_state = nvc0_sp_state_delete; 9781ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->delete_fs_state = nvc0_sp_state_delete; 9791ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->delete_gs_state = nvc0_sp_state_delete; 9801ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs 9811ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->set_blend_color = nvc0_set_blend_color; 9821ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->set_stencil_ref = nvc0_set_stencil_ref; 9831ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->set_clip_state = nvc0_set_clip_state; 9841ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->set_sample_mask = nvc0_set_sample_mask; 9851ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->set_constant_buffer = nvc0_set_constant_buffer; 9861ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->set_framebuffer_state = nvc0_set_framebuffer_state; 9871ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->set_polygon_stipple = nvc0_set_polygon_stipple; 9881ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->set_scissor_state = nvc0_set_scissor_state; 9891ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->set_viewport_state = nvc0_set_viewport_state; 9901ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs 9911ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->create_vertex_elements_state = nvc0_vertex_state_create; 9921ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->delete_vertex_elements_state = nvc0_vertex_state_delete; 9931ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->bind_vertex_elements_state = nvc0_vertex_state_bind; 9941ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs 9951ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->set_vertex_buffers = nvc0_set_vertex_buffers; 9961ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->set_index_buffer = nvc0_set_index_buffer; 9971ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs 99814bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller pipe->create_stream_output_target = nvc0_so_target_create; 99914bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller pipe->stream_output_target_destroy = nvc0_so_target_destroy; 100014bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller pipe->set_stream_output_targets = nvc0_set_transform_feedback_targets; 10014c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller} 10024c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller 1003