nvc0_state.c revision 7a40ae4a31f3ab526706fdfda7631d54f094512a
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{
894c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    struct nvc0_blend_stateobj *so = CALLOC_STRUCT(nvc0_blend_stateobj);
904c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    int i;
91b2dcf880e8bcd61be59602f5a2d18c77a5fc60c1Christoph Bumiller    uint32_t ms;
924c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
934c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    so->pipe = *cso;
944c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
952c20aae23393a3f6899f1775df47697ce65fc6caChristoph Bumiller    SB_IMMED_3D(so, BLEND_INDEPENDENT, cso->independent_blend_enable);
964c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
97d9ef97696770c8a6b04e4adf9a813614f9b3c741Christoph Bumiller    if (!cso->logicop_enable)
98d9ef97696770c8a6b04e4adf9a813614f9b3c741Christoph Bumiller       SB_IMMED_3D(so, LOGIC_OP_ENABLE, 0);
99d9ef97696770c8a6b04e4adf9a813614f9b3c741Christoph Bumiller
100d9ef97696770c8a6b04e4adf9a813614f9b3c741Christoph Bumiller    if (cso->logicop_enable) {
101d9ef97696770c8a6b04e4adf9a813614f9b3c741Christoph Bumiller       SB_BEGIN_3D(so, LOGIC_OP_ENABLE, 2);
102d9ef97696770c8a6b04e4adf9a813614f9b3c741Christoph Bumiller       SB_DATA    (so, 1);
103d9ef97696770c8a6b04e4adf9a813614f9b3c741Christoph Bumiller       SB_DATA    (so, nvgl_logicop_func(cso->logicop_func));
104d9ef97696770c8a6b04e4adf9a813614f9b3c741Christoph Bumiller
1057a40ae4a31f3ab526706fdfda7631d54f094512aChristoph Bumiller       SB_IMMED_3D(so, MACRO_BLEND_ENABLES, 0);
106d9ef97696770c8a6b04e4adf9a813614f9b3c741Christoph Bumiller    } else
1074c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    if (!cso->independent_blend_enable) {
1087a40ae4a31f3ab526706fdfda7631d54f094512aChristoph Bumiller        SB_IMMED_3D(so,
1097a40ae4a31f3ab526706fdfda7631d54f094512aChristoph Bumiller                    MACRO_BLEND_ENABLES, cso->rt[0].blend_enable ? 0xff : 0);
1104c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
1114c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller        if (cso->rt[0].blend_enable) {
1124c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            SB_BEGIN_3D(so, BLEND_EQUATION_RGB, 5);
1134c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            SB_DATA    (so, nvgl_blend_eqn(cso->rt[0].rgb_func));
1144c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            SB_DATA    (so, nvc0_blend_fac(cso->rt[0].rgb_src_factor));
1154c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            SB_DATA    (so, nvc0_blend_fac(cso->rt[0].rgb_dst_factor));
1164c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            SB_DATA    (so, nvgl_blend_eqn(cso->rt[0].alpha_func));
1174c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            SB_DATA    (so, nvc0_blend_fac(cso->rt[0].alpha_src_factor));
1184c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            SB_BEGIN_3D(so, BLEND_FUNC_DST_ALPHA, 1);
1194c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            SB_DATA    (so, nvc0_blend_fac(cso->rt[0].alpha_dst_factor));
1204c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller        }
1214c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
1227b4e478496cf45f527f72c39d72efe2e94fe2386Christoph Bumiller        SB_IMMED_3D(so, COLOR_MASK_COMMON, 1);
1237b4e478496cf45f527f72c39d72efe2e94fe2386Christoph Bumiller        SB_BEGIN_3D(so, COLOR_MASK(0), 1);
1244c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller        SB_DATA    (so, nvc0_colormask(cso->rt[0].colormask));
1254c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    } else {
1264c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller        uint8_t en = 0;
1274c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
1284c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller        for (i = 0; i < 8; ++i) {
1294c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            if (!cso->rt[i].blend_enable)
1304c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                continue;
1314c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            en |= 1 << i;
1324c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
1334c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            SB_BEGIN_3D(so, IBLEND_EQUATION_RGB(i), 6);
1344c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            SB_DATA    (so, nvgl_blend_eqn(cso->rt[i].rgb_func));
1354c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            SB_DATA    (so, nvc0_blend_fac(cso->rt[i].rgb_src_factor));
1364c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            SB_DATA    (so, nvc0_blend_fac(cso->rt[i].rgb_dst_factor));
1374c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            SB_DATA    (so, nvgl_blend_eqn(cso->rt[i].alpha_func));
1384c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            SB_DATA    (so, nvc0_blend_fac(cso->rt[i].alpha_src_factor));
1394c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            SB_DATA    (so, nvc0_blend_fac(cso->rt[i].alpha_dst_factor));
1404c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller        }
1417a40ae4a31f3ab526706fdfda7631d54f094512aChristoph Bumiller        SB_IMMED_3D(so, MACRO_BLEND_ENABLES, en);
1424c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
1437b4e478496cf45f527f72c39d72efe2e94fe2386Christoph Bumiller        SB_IMMED_3D(so, COLOR_MASK_COMMON, 0);
1444c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller        SB_BEGIN_3D(so, COLOR_MASK(0), 8);
1454c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller        for (i = 0; i < 8; ++i)
1464c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            SB_DATA(so, nvc0_colormask(cso->rt[i].colormask));
1474c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    }
1484c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
149b2dcf880e8bcd61be59602f5a2d18c77a5fc60c1Christoph Bumiller    ms = 0;
150b2dcf880e8bcd61be59602f5a2d18c77a5fc60c1Christoph Bumiller    if (cso->alpha_to_coverage)
151b2dcf880e8bcd61be59602f5a2d18c77a5fc60c1Christoph Bumiller       ms |= NVC0_3D_MULTISAMPLE_CTRL_ALPHA_TO_COVERAGE;
152b2dcf880e8bcd61be59602f5a2d18c77a5fc60c1Christoph Bumiller    if (cso->alpha_to_one)
153b2dcf880e8bcd61be59602f5a2d18c77a5fc60c1Christoph Bumiller       ms |= NVC0_3D_MULTISAMPLE_CTRL_ALPHA_TO_ONE;
154b2dcf880e8bcd61be59602f5a2d18c77a5fc60c1Christoph Bumiller
155b2dcf880e8bcd61be59602f5a2d18c77a5fc60c1Christoph Bumiller    SB_BEGIN_3D(so, MULTISAMPLE_CTRL, 1);
156b2dcf880e8bcd61be59602f5a2d18c77a5fc60c1Christoph Bumiller    SB_DATA    (so, ms);
157b2dcf880e8bcd61be59602f5a2d18c77a5fc60c1Christoph Bumiller
158d9ef97696770c8a6b04e4adf9a813614f9b3c741Christoph Bumiller    assert(so->size <= (sizeof(so->state) / sizeof(so->state[0])));
1594c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    return so;
1604c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
1614c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
1624c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
1634c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_blend_state_bind(struct pipe_context *pipe, void *hwcso)
1644c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
1654c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    struct nvc0_context *nvc0 = nvc0_context(pipe);
1664c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
1674c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->blend = hwcso;
1684c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->dirty |= NVC0_NEW_BLEND;
1694c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
1704c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
1714c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
1724c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_blend_state_delete(struct pipe_context *pipe, void *hwcso)
1734c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
1744c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    FREE(hwcso);
1754c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
1764c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
177843d5391c3b7b80ff2087ce7e6440417aab623ccChristoph Bumiller/* NOTE: ignoring line_last_pixel, using FALSE (set on screen init) */
1784c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void *
1794c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_rasterizer_state_create(struct pipe_context *pipe,
1804c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                             const struct pipe_rasterizer_state *cso)
1814c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
1824c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    struct nvc0_rasterizer_stateobj *so;
183d9f1310e519ac8182329fcd3e6c357d44d110955Christoph Bumiller    uint32_t reg;
1844c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
1854c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    so = CALLOC_STRUCT(nvc0_rasterizer_stateobj);
1864c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    if (!so)
1874c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller        return NULL;
1884c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    so->pipe = *cso;
189d047168d81cfeb39a98f3ae16416872facc6237cChristoph Bumiller
190e7845e319679e3539274c37e9c16692a2dfe59feChristoph Bumiller    /* Scissor enables are handled in scissor state, we will not want to
191e7845e319679e3539274c37e9c16692a2dfe59feChristoph Bumiller     * always emit 16 commands, one for each scissor rectangle, here.
192e7845e319679e3539274c37e9c16692a2dfe59feChristoph Bumiller     */
1934c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
1944c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    SB_BEGIN_3D(so, SHADE_MODEL, 1);
1954c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    SB_DATA    (so, cso->flatshade ? NVC0_3D_SHADE_MODEL_FLAT :
1964c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                                     NVC0_3D_SHADE_MODEL_SMOOTH);
1972c20aae23393a3f6899f1775df47697ce65fc6caChristoph Bumiller    SB_IMMED_3D(so, PROVOKING_VERTEX_LAST, !cso->flatshade_first);
1982c20aae23393a3f6899f1775df47697ce65fc6caChristoph Bumiller    SB_IMMED_3D(so, VERTEX_TWO_SIDE_ENABLE, cso->light_twoside);
1994c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2008f060df60d1f5ad63a341e39f2ec5a0c3c452cf5Christoph Bumiller    SB_IMMED_3D(so, VERT_COLOR_CLAMP_EN, cso->clamp_vertex_color);
2018f060df60d1f5ad63a341e39f2ec5a0c3c452cf5Christoph Bumiller    SB_BEGIN_3D(so, FRAG_COLOR_CLAMP_EN, 1);
2028f060df60d1f5ad63a341e39f2ec5a0c3c452cf5Christoph Bumiller    SB_DATA    (so, cso->clamp_fragment_color ? 0x11111111 : 0x00000000);
2038f060df60d1f5ad63a341e39f2ec5a0c3c452cf5Christoph Bumiller
204b2dcf880e8bcd61be59602f5a2d18c77a5fc60c1Christoph Bumiller    SB_IMMED_3D(so, MULTISAMPLE_ENABLE, cso->multisample);
205b2dcf880e8bcd61be59602f5a2d18c77a5fc60c1Christoph Bumiller
2062c20aae23393a3f6899f1775df47697ce65fc6caChristoph Bumiller    SB_IMMED_3D(so, LINE_SMOOTH_ENABLE, cso->line_smooth);
207843d5391c3b7b80ff2087ce7e6440417aab623ccChristoph Bumiller    if (cso->line_smooth)
208843d5391c3b7b80ff2087ce7e6440417aab623ccChristoph Bumiller       SB_BEGIN_3D(so, LINE_WIDTH_SMOOTH, 1);
209843d5391c3b7b80ff2087ce7e6440417aab623ccChristoph Bumiller    else
210843d5391c3b7b80ff2087ce7e6440417aab623ccChristoph Bumiller       SB_BEGIN_3D(so, LINE_WIDTH_ALIASED, 1);
211843d5391c3b7b80ff2087ce7e6440417aab623ccChristoph Bumiller    SB_DATA    (so, fui(cso->line_width));
2124c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
213d9ef97696770c8a6b04e4adf9a813614f9b3c741Christoph Bumiller    SB_IMMED_3D(so, LINE_STIPPLE_ENABLE, cso->line_stipple_enable);
2144c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    if (cso->line_stipple_enable) {
2154c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller        SB_BEGIN_3D(so, LINE_STIPPLE_PATTERN, 1);
2164c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller        SB_DATA    (so, (cso->line_stipple_pattern << 8) |
2174c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                         cso->line_stipple_factor);
2184c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2194c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    }
2204c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2212c20aae23393a3f6899f1775df47697ce65fc6caChristoph Bumiller    SB_IMMED_3D(so, VP_POINT_SIZE_EN, cso->point_size_per_vertex);
2224c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    if (!cso->point_size_per_vertex) {
2234c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller       SB_BEGIN_3D(so, POINT_SIZE, 1);
2244c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller       SB_DATA    (so, fui(cso->point_size));
2254c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    }
226d9f1310e519ac8182329fcd3e6c357d44d110955Christoph Bumiller
227d9f1310e519ac8182329fcd3e6c357d44d110955Christoph Bumiller    reg = (cso->sprite_coord_mode == PIPE_SPRITE_COORD_UPPER_LEFT) ?
228d9f1310e519ac8182329fcd3e6c357d44d110955Christoph Bumiller       NVC0_3D_POINT_COORD_REPLACE_COORD_ORIGIN_UPPER_LEFT :
229d9f1310e519ac8182329fcd3e6c357d44d110955Christoph Bumiller       NVC0_3D_POINT_COORD_REPLACE_COORD_ORIGIN_LOWER_LEFT;
230d9f1310e519ac8182329fcd3e6c357d44d110955Christoph Bumiller
231d9f1310e519ac8182329fcd3e6c357d44d110955Christoph Bumiller    SB_BEGIN_3D(so, POINT_COORD_REPLACE, 1);
232d9f1310e519ac8182329fcd3e6c357d44d110955Christoph Bumiller    SB_DATA    (so, ((cso->sprite_coord_enable & 0xff) << 3) | reg);
2332c20aae23393a3f6899f1775df47697ce65fc6caChristoph Bumiller    SB_IMMED_3D(so, POINT_SPRITE_ENABLE, cso->point_quad_rasterization);
234370ae0bd614fcbf9c4c0424fb5c41f2cfbc17b3eChristoph Bumiller    SB_IMMED_3D(so, POINT_SMOOTH_ENABLE, cso->point_smooth);
2354c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2367a40ae4a31f3ab526706fdfda7631d54f094512aChristoph Bumiller    SB_BEGIN_3D(so, MACRO_POLYGON_MODE_FRONT, 1);
2374c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    SB_DATA    (so, nvgl_polygon_mode(cso->fill_front));
2387a40ae4a31f3ab526706fdfda7631d54f094512aChristoph Bumiller    SB_BEGIN_3D(so, MACRO_POLYGON_MODE_BACK, 1);
2394c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    SB_DATA    (so, nvgl_polygon_mode(cso->fill_back));
2402c20aae23393a3f6899f1775df47697ce65fc6caChristoph Bumiller    SB_IMMED_3D(so, POLYGON_SMOOTH_ENABLE, cso->poly_smooth);
2414c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
242dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller    SB_BEGIN_3D(so, CULL_FACE_ENABLE, 3);
243dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller    SB_DATA    (so, cso->cull_face != PIPE_FACE_NONE);
244dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller    SB_DATA    (so, cso->front_ccw ? NVC0_3D_FRONT_FACE_CCW :
245dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller                                     NVC0_3D_FRONT_FACE_CW);
246dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller    switch (cso->cull_face) {
247dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller    case PIPE_FACE_FRONT_AND_BACK:
248dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller       SB_DATA(so, NVC0_3D_CULL_FACE_FRONT_AND_BACK);
249dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller       break;
250dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller    case PIPE_FACE_FRONT:
251dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller       SB_DATA(so, NVC0_3D_CULL_FACE_FRONT);
252dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller       break;
253dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller    case PIPE_FACE_BACK:
254dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller    default:
255dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller       SB_DATA(so, NVC0_3D_CULL_FACE_BACK);
256dea9d604005e9aaed2bd6807f1913ac668479443Christoph Bumiller       break;
2574c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    }
2584c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2592c20aae23393a3f6899f1775df47697ce65fc6caChristoph Bumiller    SB_IMMED_3D(so, POLYGON_STIPPLE_ENABLE, cso->poly_stipple_enable);
2604c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    SB_BEGIN_3D(so, POLYGON_OFFSET_POINT_ENABLE, 3);
2614c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    SB_DATA    (so, cso->offset_point);
2624c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    SB_DATA    (so, cso->offset_line);
2634c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    SB_DATA    (so, cso->offset_tri);
2644c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2654c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    if (cso->offset_point || cso->offset_line || cso->offset_tri) {
2664c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller        SB_BEGIN_3D(so, POLYGON_OFFSET_FACTOR, 1);
2674c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller        SB_DATA    (so, fui(cso->offset_scale));
2684c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller        SB_BEGIN_3D(so, POLYGON_OFFSET_UNITS, 1);
2691579017b08f28d460e17de65bcc8ba17ba695c37Christoph Bumiller        SB_DATA    (so, fui(cso->offset_units * 2.0f));
270b3fa0d311e553ec815d58e58a30aa8b3927e4afdChristoph Bumiller        SB_BEGIN_3D(so, POLYGON_OFFSET_CLAMP, 1);
271b3fa0d311e553ec815d58e58a30aa8b3927e4afdChristoph Bumiller        SB_DATA    (so, fui(cso->offset_clamp));
2724c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    }
2734c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
274dc4c821f0817a3db716f965692fb701079f66340Marek Olšák    if (cso->depth_clip)
275dc4c821f0817a3db716f965692fb701079f66340Marek Olšák       reg = NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK1_UNK1;
276dc4c821f0817a3db716f965692fb701079f66340Marek Olšák    else
277dc4c821f0817a3db716f965692fb701079f66340Marek Olšák       reg =
278dc4c821f0817a3db716f965692fb701079f66340Marek Olšák          NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK1_UNK1 |
279dc4c821f0817a3db716f965692fb701079f66340Marek Olšák          NVC0_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_NEAR |
280dc4c821f0817a3db716f965692fb701079f66340Marek Olšák          NVC0_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_FAR |
281dc4c821f0817a3db716f965692fb701079f66340Marek Olšák          NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK12_UNK2;
282dc4c821f0817a3db716f965692fb701079f66340Marek Olšák
283dc4c821f0817a3db716f965692fb701079f66340Marek Olšák    SB_BEGIN_3D(so, VIEW_VOLUME_CLIP_CTRL, 1);
284dc4c821f0817a3db716f965692fb701079f66340Marek Olšák    SB_DATA    (so, reg);
285dc4c821f0817a3db716f965692fb701079f66340Marek Olšák
286d9ef97696770c8a6b04e4adf9a813614f9b3c741Christoph Bumiller    assert(so->size <= (sizeof(so->state) / sizeof(so->state[0])));
2874c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    return (void *)so;
2884c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
2894c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2904c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
2914c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_rasterizer_state_bind(struct pipe_context *pipe, void *hwcso)
2924c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
2934c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   struct nvc0_context *nvc0 = nvc0_context(pipe);
2944c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2954c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0->rast = hwcso;
2964c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0->dirty |= NVC0_NEW_RASTERIZER;
2974c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
2984c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2994c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
3004c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso)
3014c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
3024c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   FREE(hwcso);
3034c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
3044c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
3054c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void *
3064c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_zsa_state_create(struct pipe_context *pipe,
3074c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                      const struct pipe_depth_stencil_alpha_state *cso)
3084c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
3094c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   struct nvc0_zsa_stateobj *so = CALLOC_STRUCT(nvc0_zsa_stateobj);
3104c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
3114c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   so->pipe = *cso;
3124c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
313f0ee7d8bb46ac7694693f3fb8cd0f15c422f1befChristoph Bumiller   SB_IMMED_3D(so, DEPTH_TEST_ENABLE, cso->depth.enabled);
3144c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   if (cso->depth.enabled) {
315f0ee7d8bb46ac7694693f3fb8cd0f15c422f1befChristoph Bumiller      SB_IMMED_3D(so, DEPTH_WRITE_ENABLE, cso->depth.writemask);
3164c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_BEGIN_3D(so, DEPTH_TEST_FUNC, 1);
3174c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_DATA    (so, nvgl_comparison_op(cso->depth.func));
3184c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   }
3194c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
3204c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   if (cso->stencil[0].enabled) {
321293a8d1b600cd5bd89b3c4c0b6c2bb245d9bd80fChristoph Bumiller      SB_BEGIN_3D(so, STENCIL_ENABLE, 5);
3224c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_DATA    (so, 1);
3234c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_DATA    (so, nvgl_stencil_op(cso->stencil[0].fail_op));
3244c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_DATA    (so, nvgl_stencil_op(cso->stencil[0].zfail_op));
3254c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_DATA    (so, nvgl_stencil_op(cso->stencil[0].zpass_op));
3264c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_DATA    (so, nvgl_comparison_op(cso->stencil[0].func));
327293a8d1b600cd5bd89b3c4c0b6c2bb245d9bd80fChristoph Bumiller      SB_BEGIN_3D(so, STENCIL_FRONT_FUNC_MASK, 2);
3284c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_DATA    (so, cso->stencil[0].valuemask);
329293a8d1b600cd5bd89b3c4c0b6c2bb245d9bd80fChristoph Bumiller      SB_DATA    (so, cso->stencil[0].writemask);
3304c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   } else {
331293a8d1b600cd5bd89b3c4c0b6c2bb245d9bd80fChristoph Bumiller      SB_IMMED_3D(so, STENCIL_ENABLE, 0);
3324c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   }
3334c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
3344c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   if (cso->stencil[1].enabled) {
335293a8d1b600cd5bd89b3c4c0b6c2bb245d9bd80fChristoph Bumiller      assert(cso->stencil[0].enabled);
3364c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_BEGIN_3D(so, STENCIL_TWO_SIDE_ENABLE, 5);
3374c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_DATA    (so, 1);
3384c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_DATA    (so, nvgl_stencil_op(cso->stencil[1].fail_op));
3394c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_DATA    (so, nvgl_stencil_op(cso->stencil[1].zfail_op));
3404c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_DATA    (so, nvgl_stencil_op(cso->stencil[1].zpass_op));
3414c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_DATA    (so, nvgl_comparison_op(cso->stencil[1].func));
3424c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_BEGIN_3D(so, STENCIL_BACK_MASK, 2);
3434c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_DATA    (so, cso->stencil[1].writemask);
3444c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_DATA    (so, cso->stencil[1].valuemask);
345293a8d1b600cd5bd89b3c4c0b6c2bb245d9bd80fChristoph Bumiller   } else
346293a8d1b600cd5bd89b3c4c0b6c2bb245d9bd80fChristoph Bumiller   if (cso->stencil[0].enabled) {
3472c20aae23393a3f6899f1775df47697ce65fc6caChristoph Bumiller      SB_IMMED_3D(so, STENCIL_TWO_SIDE_ENABLE, 0);
3484c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   }
349f0ee7d8bb46ac7694693f3fb8cd0f15c422f1befChristoph Bumiller
350f0ee7d8bb46ac7694693f3fb8cd0f15c422f1befChristoph Bumiller   SB_IMMED_3D(so, ALPHA_TEST_ENABLE, cso->alpha.enabled);
3514c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   if (cso->alpha.enabled) {
3524c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_BEGIN_3D(so, ALPHA_TEST_REF, 2);
3534c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_DATA    (so, fui(cso->alpha.ref_value));
3544c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      SB_DATA    (so, nvgl_comparison_op(cso->alpha.func));
3554c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   }
3564c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
357d9ef97696770c8a6b04e4adf9a813614f9b3c741Christoph Bumiller   assert(so->size <= (sizeof(so->state) / sizeof(so->state[0])));
3584c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   return (void *)so;
3594c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
3604c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
3614c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
3624c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_zsa_state_bind(struct pipe_context *pipe, void *hwcso)
3634c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
3644c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   struct nvc0_context *nvc0 = nvc0_context(pipe);
3654c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
3664c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0->zsa = hwcso;
3674c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0->dirty |= NVC0_NEW_ZSA;
3684c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
3694c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
3704c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
3714c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_zsa_state_delete(struct pipe_context *pipe, void *hwcso)
3724c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
3734c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   FREE(hwcso);
3744c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
3754c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
3764c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller/* ====================== SAMPLERS AND TEXTURES ================================
3774c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller */
3784c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
3794c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller#define NV50_TSC_WRAP_CASE(n) \
3804c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    case PIPE_TEX_WRAP_##n: return NV50_TSC_WRAP_##n
3814c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
3824c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic INLINE unsigned
3834c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernv50_tsc_wrap_mode(unsigned wrap)
3844c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
3854c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   switch (wrap) {
3864c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   NV50_TSC_WRAP_CASE(REPEAT);
3874c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   NV50_TSC_WRAP_CASE(MIRROR_REPEAT);
3884c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   NV50_TSC_WRAP_CASE(CLAMP_TO_EDGE);
3894c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   NV50_TSC_WRAP_CASE(CLAMP_TO_BORDER);
3904c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   NV50_TSC_WRAP_CASE(CLAMP);
3914c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   NV50_TSC_WRAP_CASE(MIRROR_CLAMP_TO_EDGE);
3924c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   NV50_TSC_WRAP_CASE(MIRROR_CLAMP_TO_BORDER);
3934c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   NV50_TSC_WRAP_CASE(MIRROR_CLAMP);
3944c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   default:
3954c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller       NOUVEAU_ERR("unknown wrap mode: %d\n", wrap);
3964c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller       return NV50_TSC_WRAP_REPEAT;
3974c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   }
3984c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
3994c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4004c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
4014c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
4024c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
4034c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   unsigned s, i;
4044c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4054c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   for (s = 0; s < 5; ++s)
4064c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      for (i = 0; i < nvc0_context(pipe)->num_samplers[s]; ++i)
4074c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller         if (nvc0_context(pipe)->samplers[s][i] == hwcso)
4084c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller            nvc0_context(pipe)->samplers[s][i] = NULL;
4094c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4101f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller   nvc0_screen_tsc_free(nvc0_context(pipe)->screen, nv50_tsc_entry(hwcso));
4114c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4124c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   FREE(hwcso);
4134c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
4144c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4154c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic INLINE void
4164c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_stage_sampler_states_bind(struct nvc0_context *nvc0, int s,
4174c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                               unsigned nr, void **hwcso)
4184c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
4194c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   unsigned i;
4204c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4214c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   for (i = 0; i < nr; ++i) {
4221f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller      struct nv50_tsc_entry *old = nvc0->samplers[s][i];
4234c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
424784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      if (hwcso[i] == old)
425784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller         continue;
426784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      nvc0->samplers_dirty[s] |= 1 << i;
427784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller
4281f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller      nvc0->samplers[s][i] = nv50_tsc_entry(hwcso[i]);
4294c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      if (old)
4304c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller         nvc0_screen_tsc_unlock(nvc0->screen, old);
4314c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   }
432784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller   for (; i < nvc0->num_samplers[s]; ++i) {
433784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      if (nvc0->samplers[s][i]) {
4344c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller         nvc0_screen_tsc_unlock(nvc0->screen, nvc0->samplers[s][i]);
435784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller         nvc0->samplers[s][i] = NULL;
436784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      }
437784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller   }
4384c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4394c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0->num_samplers[s] = nr;
4404c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4414c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0->dirty |= NVC0_NEW_SAMPLERS;
4424c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
4434c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4444c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
4454c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_vp_sampler_states_bind(struct pipe_context *pipe, unsigned nr, void **s)
4464c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
4474c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0_stage_sampler_states_bind(nvc0_context(pipe), 0, nr, s);
4484c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
4494c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4504c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
4514c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_fp_sampler_states_bind(struct pipe_context *pipe, unsigned nr, void **s)
4524c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
4534c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0_stage_sampler_states_bind(nvc0_context(pipe), 4, nr, s);
4544c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
4554c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4564c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
4574c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_gp_sampler_states_bind(struct pipe_context *pipe, unsigned nr, void **s)
4584c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
4594c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0_stage_sampler_states_bind(nvc0_context(pipe), 3, nr, s);
4604c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
4614c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4624c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller/* NOTE: only called when not referenced anywhere, won't be bound */
4634c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
4644c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_sampler_view_destroy(struct pipe_context *pipe,
4654c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                          struct pipe_sampler_view *view)
4664c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
4674c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   pipe_resource_reference(&view->texture, NULL);
4684c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4691f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller   nvc0_screen_tic_free(nvc0_context(pipe)->screen, nv50_tic_entry(view));
4704c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4711f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller   FREE(nv50_tic_entry(view));
4724c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
4734c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4744c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic INLINE void
4754c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_stage_set_sampler_views(struct nvc0_context *nvc0, int s,
4764c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                             unsigned nr,
4774c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                             struct pipe_sampler_view **views)
4784c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
4794c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   unsigned i;
4804c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4814c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   for (i = 0; i < nr; ++i) {
4821f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller      struct nv50_tic_entry *old = nv50_tic_entry(nvc0->textures[s][i]);
483784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller
484784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      if (views[i] == nvc0->textures[s][i])
485784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller         continue;
486784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      nvc0->textures_dirty[s] |= 1 << i;
487784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller
488784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      if (old) {
489784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller         nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_TEX(s, i));
4904c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller         nvc0_screen_tic_unlock(nvc0->screen, old);
491784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      }
4924c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4934c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      pipe_sampler_view_reference(&nvc0->textures[s][i], views[i]);
4944c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   }
4954c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4964c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   for (i = nr; i < nvc0->num_textures[s]; ++i) {
4971f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller      struct nv50_tic_entry *old = nv50_tic_entry(nvc0->textures[s][i]);
498784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      if (old) {
499784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller         nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_TEX(s, i));
500784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller         nvc0_screen_tic_unlock(nvc0->screen, old);
501784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller         pipe_sampler_view_reference(&nvc0->textures[s][i], NULL);
502784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      }
5034c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   }
5044c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5054c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0->num_textures[s] = nr;
5064c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5074c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0->dirty |= NVC0_NEW_TEXTURES;
5084c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
5094c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5104c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
5114c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_vp_set_sampler_views(struct pipe_context *pipe,
5124c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                          unsigned nr,
5134c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                          struct pipe_sampler_view **views)
5144c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
5154c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0_stage_set_sampler_views(nvc0_context(pipe), 0, nr, views);
5164c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
5174c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5184c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
5194c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_fp_set_sampler_views(struct pipe_context *pipe,
5204c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                          unsigned nr,
5214c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                          struct pipe_sampler_view **views)
5224c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
5234c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0_stage_set_sampler_views(nvc0_context(pipe), 4, nr, views);
5244c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
5254c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5264c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
5274c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_gp_set_sampler_views(struct pipe_context *pipe,
5284c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                          unsigned nr,
5294c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                          struct pipe_sampler_view **views)
5304c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
5314c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0_stage_set_sampler_views(nvc0_context(pipe), 3, nr, views);
5324c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
5334c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5344c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller/* ============================= SHADERS =======================================
5354c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller */
5364c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5374c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void *
5384c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_sp_state_create(struct pipe_context *pipe,
5394c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                     const struct pipe_shader_state *cso, unsigned type)
5404c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
5414c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   struct nvc0_program *prog;
5424c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5434c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   prog = CALLOC_STRUCT(nvc0_program);
5444c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   if (!prog)
5454c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      return NULL;
5464c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5474c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   prog->type = type;
54814bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller
54914bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   if (cso->tokens)
55014bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller      prog->pipe.tokens = tgsi_dup_tokens(cso->tokens);
55114bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller
55214bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   if (cso->stream_output.num_outputs)
55314bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller      prog->pipe.stream_output = cso->stream_output;
5544c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5554c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   return (void *)prog;
5564c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
5574c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5584c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
5594c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_sp_state_delete(struct pipe_context *pipe, void *hwcso)
5604c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
5614c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   struct nvc0_program *prog = (struct nvc0_program *)hwcso;
5624c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5634c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0_program_destroy(nvc0_context(pipe), prog);
5644c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5654c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   FREE((void *)prog->pipe.tokens);
5664c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   FREE(prog);
5674c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
5684c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5694c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void *
5704c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_vp_state_create(struct pipe_context *pipe,
5714c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                     const struct pipe_shader_state *cso)
5724c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
5734c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   return nvc0_sp_state_create(pipe, cso, PIPE_SHADER_VERTEX);
5744c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
5754c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5764c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
5774c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_vp_state_bind(struct pipe_context *pipe, void *hwcso)
5784c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
5794c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    struct nvc0_context *nvc0 = nvc0_context(pipe);
5804c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5814c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->vertprog = hwcso;
5824c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->dirty |= NVC0_NEW_VERTPROG;
5834c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
5844c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5854c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void *
5864c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_fp_state_create(struct pipe_context *pipe,
5874c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                     const struct pipe_shader_state *cso)
5884c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
5894c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   return nvc0_sp_state_create(pipe, cso, PIPE_SHADER_FRAGMENT);
5904c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
5914c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5924c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
5934c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_fp_state_bind(struct pipe_context *pipe, void *hwcso)
5944c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
5954c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    struct nvc0_context *nvc0 = nvc0_context(pipe);
5964c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
5974c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->fragprog = hwcso;
5984c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->dirty |= NVC0_NEW_FRAGPROG;
5994c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
6004c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6014c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void *
6024c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_gp_state_create(struct pipe_context *pipe,
6034c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                     const struct pipe_shader_state *cso)
6044c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
6054c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   return nvc0_sp_state_create(pipe, cso, PIPE_SHADER_GEOMETRY);
6064c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
6074c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6084c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
6094c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_gp_state_bind(struct pipe_context *pipe, void *hwcso)
6104c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
6114c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    struct nvc0_context *nvc0 = nvc0_context(pipe);
6124c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6134c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->gmtyprog = hwcso;
6144c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->dirty |= NVC0_NEW_GMTYPROG;
6154c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
6164c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6174c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
6184c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
6194c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                         struct pipe_resource *res)
6204c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
6214c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   struct nvc0_context *nvc0 = nvc0_context(pipe);
6224c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6234c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   switch (shader) {
6244c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   case PIPE_SHADER_VERTEX: shader = 0; break;
6254c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      /*
6264c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   case PIPE_SHADER_TESSELLATION_CONTROL: shader = 1; break;
6274c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   case PIPE_SHADER_TESSELLATION_EVALUATION: shader = 2; break;
6284c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      */
6294c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   case PIPE_SHADER_GEOMETRY: shader = 3; break;
6304c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   case PIPE_SHADER_FRAGMENT: shader = 4; break;
6314c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   default:
6324c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      assert(0);
6334c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      break;
6344c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   }
6354c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6364c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   if (nvc0->constbuf[shader][index])
6376d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller      nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_CB(shader, index));
6384c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6394c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   pipe_resource_reference(&nvc0->constbuf[shader][index], res);
6404c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6414c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0->constbuf_dirty[shader] |= 1 << index;
6424c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6434c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0->dirty |= NVC0_NEW_CONSTBUF;
6444c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
6454c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6464c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller/* =============================================================================
6474c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller */
6484c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6494c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
6504c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_blend_color(struct pipe_context *pipe,
6514c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                     const struct pipe_blend_color *bcol)
6524c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
6534c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    struct nvc0_context *nvc0 = nvc0_context(pipe);
6544c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6554c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->blend_colour = *bcol;
6564c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->dirty |= NVC0_NEW_BLEND_COLOUR;
6574c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
6584c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6594c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
6604c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_stencil_ref(struct pipe_context *pipe,
6614c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                     const struct pipe_stencil_ref *sr)
6624c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
6634c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    struct nvc0_context *nvc0 = nvc0_context(pipe);
6644c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6654c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->stencil_ref = *sr;
6664c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->dirty |= NVC0_NEW_STENCIL_REF;
6674c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
6684c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6694c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
6704c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_clip_state(struct pipe_context *pipe,
6714c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                    const struct pipe_clip_state *clip)
6724c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
6734c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    struct nvc0_context *nvc0 = nvc0_context(pipe);
6744c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
675dc4c821f0817a3db716f965692fb701079f66340Marek Olšák    memcpy(nvc0->clip.ucp, clip->ucp, sizeof(clip->ucp));
6765138ac033ad3708e2b82f2beebc887f65a77309eChristoph Bumiller
6774c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->dirty |= NVC0_NEW_CLIP;
6784c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
6794c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6804c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
6814c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_sample_mask(struct pipe_context *pipe, unsigned sample_mask)
6824c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
6834c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    struct nvc0_context *nvc0 = nvc0_context(pipe);
6844c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6854c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->sample_mask = sample_mask;
6864c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->dirty |= NVC0_NEW_SAMPLE_MASK;
6874c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
6884c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6894c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6904c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
6914c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_framebuffer_state(struct pipe_context *pipe,
6924c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                           const struct pipe_framebuffer_state *fb)
6934c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
6944c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    struct nvc0_context *nvc0 = nvc0_context(pipe);
6952d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller    unsigned i;
6964c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
6976d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller    nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_FB);
6986d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller
6992d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller    for (i = 0; i < fb->nr_cbufs; ++i)
7002d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller       pipe_surface_reference(&nvc0->framebuffer.cbufs[i], fb->cbufs[i]);
7012d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller    for (; i < nvc0->framebuffer.nr_cbufs; ++i)
7022d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller       pipe_surface_reference(&nvc0->framebuffer.cbufs[i], NULL);
7032d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller
7042d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller    nvc0->framebuffer.nr_cbufs = fb->nr_cbufs;
7052d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller
7062d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller    nvc0->framebuffer.width = fb->width;
7072d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller    nvc0->framebuffer.height = fb->height;
7082d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller
7092d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller    pipe_surface_reference(&nvc0->framebuffer.zsbuf, fb->zsbuf);
7102d06ee8bf784d98a822617db5366f56b9bb5d3a2Christoph Bumiller
7114c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->dirty |= NVC0_NEW_FRAMEBUFFER;
7124c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
7134c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
7144c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
7154c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_polygon_stipple(struct pipe_context *pipe,
7164c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                         const struct pipe_poly_stipple *stipple)
7174c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
7184c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    struct nvc0_context *nvc0 = nvc0_context(pipe);
7194c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
7204c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->stipple = *stipple;
7214c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->dirty |= NVC0_NEW_STIPPLE;
7224c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
7234c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
7244c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
7254c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_scissor_state(struct pipe_context *pipe,
7264c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                       const struct pipe_scissor_state *scissor)
7274c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
7284c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    struct nvc0_context *nvc0 = nvc0_context(pipe);
7294c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
7304c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->scissor = *scissor;
7314c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->dirty |= NVC0_NEW_SCISSOR;
7324c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
7334c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
7344c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
7354c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_viewport_state(struct pipe_context *pipe,
7364c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                        const struct pipe_viewport_state *vpt)
7374c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
7384c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    struct nvc0_context *nvc0 = nvc0_context(pipe);
7394c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
7404c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->viewport = *vpt;
7414c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->dirty |= NVC0_NEW_VIEWPORT;
7424c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
7434c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
7444c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
7454c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_vertex_buffers(struct pipe_context *pipe,
7464c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                        unsigned count,
7474c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                        const struct pipe_vertex_buffer *vb)
7484c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
7494c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    struct nvc0_context *nvc0 = nvc0_context(pipe);
750edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller    uint32_t constant_vbos = 0;
7510cb6d1a4eb2dd682b499f54a82505bc3bd318bbcChristoph Bumiller    unsigned i;
7520cb6d1a4eb2dd682b499f54a82505bc3bd318bbcChristoph Bumiller
753edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller    if (count != nvc0->num_vtxbufs) {
754edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller       for (i = 0; i < count; ++i) {
755edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller          pipe_resource_reference(&nvc0->vtxbuf[i].buffer, vb[i].buffer);
756edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller          nvc0->vtxbuf[i].buffer_offset = vb[i].buffer_offset;
757edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller          nvc0->vtxbuf[i].stride = vb[i].stride;
758edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller          if (!vb[i].stride)
759edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller             constant_vbos |= 1 << i;
760edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller       }
761edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller       for (; i < nvc0->num_vtxbufs; ++i)
762edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller          pipe_resource_reference(&nvc0->vtxbuf[i].buffer, NULL);
763edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller
764edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller       nvc0->num_vtxbufs = count;
765edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller       nvc0->dirty |= NVC0_NEW_ARRAYS;
766edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller    } else {
767edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller       for (i = 0; i < count; ++i) {
768edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller          if (nvc0->vtxbuf[i].buffer == vb[i].buffer &&
769edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller              nvc0->vtxbuf[i].buffer_offset == vb[i].buffer_offset &&
770edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller              nvc0->vtxbuf[i].stride == vb[i].stride)
771edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller             continue;
772edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller          pipe_resource_reference(&nvc0->vtxbuf[i].buffer, vb[i].buffer);
773edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller          nvc0->vtxbuf[i].buffer_offset = vb[i].buffer_offset;
774edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller          nvc0->vtxbuf[i].stride = vb[i].stride;
775edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller          if (likely(vb[i].stride))
776edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller             nvc0->dirty |= NVC0_NEW_ARRAYS;
777edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller          else
778edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller             constant_vbos |= 1 << i;
779edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller       }
780edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller    }
781edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller    if (constant_vbos != nvc0->constant_vbos) {
782edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller       nvc0->constant_vbos = constant_vbos;
783edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller       nvc0->dirty |= NVC0_NEW_ARRAYS;
784edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller    }
785e4349027f6842563555992a39add4d0b2283fbbbChristoph Bumiller
786edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller    if (nvc0->dirty & NVC0_NEW_ARRAYS)
787edbfeed56f1ebd8517840ef48f8c87e24bb98157Christoph Bumiller       nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_VTX);
7884c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
7894c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
7904c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
7914c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_set_index_buffer(struct pipe_context *pipe,
7924c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                      const struct pipe_index_buffer *ib)
7934c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
7944c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    struct nvc0_context *nvc0 = nvc0_context(pipe);
7954c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
7966d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller    if (nvc0->idxbuf.buffer)
7976d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller       nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_IDX);
79826a199efac43cc0509f174ca47ad0d2b0044eee0Christoph Bumiller
7996d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller    if (ib && ib->buffer) {
8006d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller       nvc0->dirty |= NVC0_NEW_IDXBUF;
8016d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller       pipe_resource_reference(&nvc0->idxbuf.buffer, ib->buffer);
8026d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller       nvc0->idxbuf.offset = ib->offset;
8036d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller       nvc0->idxbuf.index_size = ib->index_size;
80426a199efac43cc0509f174ca47ad0d2b0044eee0Christoph Bumiller    } else {
8056d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller       nvc0->dirty &= ~NVC0_NEW_IDXBUF;
80626a199efac43cc0509f174ca47ad0d2b0044eee0Christoph Bumiller       pipe_resource_reference(&nvc0->idxbuf.buffer, NULL);
80726a199efac43cc0509f174ca47ad0d2b0044eee0Christoph Bumiller    }
8084c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
8094c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
8104c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic void
8114c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_vertex_state_bind(struct pipe_context *pipe, void *hwcso)
8124c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
8134c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    struct nvc0_context *nvc0 = nvc0_context(pipe);
8144c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
8154c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->vertex = hwcso;
8164c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller    nvc0->dirty |= NVC0_NEW_VERTEX;
8174c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
8184c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
81914bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumillerstatic struct pipe_stream_output_target *
82014bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumillernvc0_so_target_create(struct pipe_context *pipe,
82114bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller                      struct pipe_resource *res,
82214bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller                      unsigned offset, unsigned size)
823f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller{
82414bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   struct nvc0_so_target *targ = MALLOC_STRUCT(nvc0_so_target);
82514bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   if (!targ)
826f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller      return NULL;
827f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller
82814bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   targ->pq = pipe->create_query(pipe, NVC0_QUERY_TFB_BUFFER_OFFSET);
82914bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   if (!targ->pq) {
83014bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller      FREE(targ);
83114bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller      return NULL;
832f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller   }
83314bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   targ->clean = TRUE;
834f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller
83514bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   targ->pipe.buffer_size = size;
83614bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   targ->pipe.buffer_offset = offset;
83714bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   targ->pipe.context = pipe;
83814bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   targ->pipe.buffer = NULL;
83914bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   pipe_resource_reference(&targ->pipe.buffer, res);
84014bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   pipe_reference_init(&targ->pipe.reference, 1);
841f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller
84214bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   return &targ->pipe;
843f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller}
844f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller
845f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumillerstatic void
84614bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumillernvc0_so_target_destroy(struct pipe_context *pipe,
84714bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller                       struct pipe_stream_output_target *ptarg)
848f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller{
84914bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   struct nvc0_so_target *targ = nvc0_so_target(ptarg);
85014bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   pipe->destroy_query(pipe, targ->pq);
85114bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   FREE(targ);
852f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller}
853f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller
854f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumillerstatic void
85514bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumillernvc0_set_transform_feedback_targets(struct pipe_context *pipe,
85614bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller                                    unsigned num_targets,
85714bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller                                    struct pipe_stream_output_target **targets,
85814bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller                                    unsigned append_mask)
859f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller{
860f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller   struct nvc0_context *nvc0 = nvc0_context(pipe);
86114bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   unsigned i;
86214bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   boolean serialize = TRUE;
863f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller
86414bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   assert(num_targets <= 4);
865f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller
86614bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   for (i = 0; i < num_targets; ++i) {
86714bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller      if (nvc0->tfbbuf[i] == targets[i] && (append_mask & (1 << i)))
86814bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller         continue;
86914bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller      nvc0->tfbbuf_dirty |= 1 << i;
870f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller
87114bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller      if (nvc0->tfbbuf[i] && nvc0->tfbbuf[i] != targets[i])
87214bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller         nvc0_so_target_save_offset(pipe, nvc0->tfbbuf[i], i, &serialize);
87314bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller
87414bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller      if (targets[i] && !(append_mask & (1 << i)))
87514bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller         nvc0_so_target(targets[i])->clean = TRUE;
87614bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller
87714bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller      pipe_so_target_reference(&nvc0->tfbbuf[i], targets[i]);
87814bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   }
87914bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   for (; i < nvc0->num_tfbbufs; ++i) {
88014bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller      nvc0->tfbbuf_dirty |= 1 << i;
88114bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller      nvc0_so_target_save_offset(pipe, nvc0->tfbbuf[i], i, &serialize);
88214bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller      pipe_so_target_reference(&nvc0->tfbbuf[i], NULL);
88314bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   }
88414bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   nvc0->num_tfbbufs = num_targets;
885f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller
88614bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   if (nvc0->tfbbuf_dirty)
88714bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller      nvc0->dirty |= NVC0_NEW_TFB_TARGETS;
888f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller}
889f8a7a0b6f30ff38b2743860cbc4caeab102c2c29Christoph Bumiller
8904c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillervoid
8914c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_init_state_functions(struct nvc0_context *nvc0)
8924c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
8931ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   struct pipe_context *pipe = &nvc0->base.pipe;
8941ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs
8951ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->create_blend_state = nvc0_blend_state_create;
8961ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->bind_blend_state = nvc0_blend_state_bind;
8971ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->delete_blend_state = nvc0_blend_state_delete;
8981ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs
8991ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->create_rasterizer_state = nvc0_rasterizer_state_create;
9001ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->bind_rasterizer_state = nvc0_rasterizer_state_bind;
9011ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->delete_rasterizer_state = nvc0_rasterizer_state_delete;
9021ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs
9031ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->create_depth_stencil_alpha_state = nvc0_zsa_state_create;
9041ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->bind_depth_stencil_alpha_state = nvc0_zsa_state_bind;
9051ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->delete_depth_stencil_alpha_state = nvc0_zsa_state_delete;
9061ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs
9071f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller   pipe->create_sampler_state = nv50_sampler_state_create;
9081ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->delete_sampler_state = nvc0_sampler_state_delete;
9091ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->bind_vertex_sampler_states   = nvc0_vp_sampler_states_bind;
9101ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->bind_fragment_sampler_states = nvc0_fp_sampler_states_bind;
9111ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->bind_geometry_sampler_states = nvc0_gp_sampler_states_bind;
9121ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs
9131ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->create_sampler_view = nvc0_create_sampler_view;
9141ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->sampler_view_destroy = nvc0_sampler_view_destroy;
9151ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->set_vertex_sampler_views   = nvc0_vp_set_sampler_views;
9161ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->set_fragment_sampler_views = nvc0_fp_set_sampler_views;
9171ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->set_geometry_sampler_views = nvc0_gp_set_sampler_views;
9181ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs
9191ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->create_vs_state = nvc0_vp_state_create;
9201ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->create_fs_state = nvc0_fp_state_create;
9211ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->create_gs_state = nvc0_gp_state_create;
9221ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->bind_vs_state = nvc0_vp_state_bind;
9231ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->bind_fs_state = nvc0_fp_state_bind;
9241ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->bind_gs_state = nvc0_gp_state_bind;
9251ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->delete_vs_state = nvc0_sp_state_delete;
9261ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->delete_fs_state = nvc0_sp_state_delete;
9271ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->delete_gs_state = nvc0_sp_state_delete;
9281ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs
9291ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->set_blend_color = nvc0_set_blend_color;
9301ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->set_stencil_ref = nvc0_set_stencil_ref;
9311ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->set_clip_state = nvc0_set_clip_state;
9321ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->set_sample_mask = nvc0_set_sample_mask;
9331ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->set_constant_buffer = nvc0_set_constant_buffer;
9341ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->set_framebuffer_state = nvc0_set_framebuffer_state;
9351ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->set_polygon_stipple = nvc0_set_polygon_stipple;
9361ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->set_scissor_state = nvc0_set_scissor_state;
9371ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->set_viewport_state = nvc0_set_viewport_state;
9381ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs
9391ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->create_vertex_elements_state = nvc0_vertex_state_create;
9401ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->delete_vertex_elements_state = nvc0_vertex_state_delete;
9411ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->bind_vertex_elements_state = nvc0_vertex_state_bind;
9421ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs
9431ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->set_vertex_buffers = nvc0_set_vertex_buffers;
9441ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->set_index_buffer = nvc0_set_index_buffer;
9451ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs
94614bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   pipe->create_stream_output_target = nvc0_so_target_create;
94714bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   pipe->stream_output_target_destroy = nvc0_so_target_destroy;
94814bd9d764802b5fedb652c791faafe4d13b65262Christoph Bumiller   pipe->set_stream_output_targets = nvc0_set_transform_feedback_targets;
9491ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs
9501ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs   pipe->redefine_user_buffer = u_default_redefine_user_buffer;
9514c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
9524c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
953