gen6_cc.c revision 2ee1fd2e8f023853b60c242ce7f83a595c0f65ff
17ee590424c974cb10882e9c4664a6024595fc9deEric Anholt/* 27ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * Copyright © 2009 Intel Corporation 37ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * 47ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * Permission is hereby granted, free of charge, to any person obtaining a 57ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * copy of this software and associated documentation files (the "Software"), 67ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * to deal in the Software without restriction, including without limitation 77ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * the rights to use, copy, modify, merge, publish, distribute, sublicense, 87ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * and/or sell copies of the Software, and to permit persons to whom the 97ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * Software is furnished to do so, subject to the following conditions: 107ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * 117ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * The above copyright notice and this permission notice (including the next 127ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * paragraph) shall be included in all copies or substantial portions of the 137ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * Software. 147ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * 157ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 177ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 187ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 197ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 207ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 217ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * IN THE SOFTWARE. 227ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * 237ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * Authors: 247ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * Eric Anholt <eric@anholt.net> 257ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * 267ee590424c974cb10882e9c4664a6024595fc9deEric Anholt */ 277ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 287ee590424c974cb10882e9c4664a6024595fc9deEric Anholt#include "brw_context.h" 297ee590424c974cb10882e9c4664a6024595fc9deEric Anholt#include "brw_state.h" 307ee590424c974cb10882e9c4664a6024595fc9deEric Anholt#include "brw_defines.h" 317ee590424c974cb10882e9c4664a6024595fc9deEric Anholt#include "brw_util.h" 327ee590424c974cb10882e9c4664a6024595fc9deEric Anholt#include "intel_batchbuffer.h" 33cb099c2ecfe3cf8d8ff21c3031e3c2d43efd0e69Brian Paul#include "main/macros.h" 347ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 35879ea6f27972766c792fe78971a36c5c7b9f1884Eric Anholtstruct gen6_blend_state_key { 367ee590424c974cb10882e9c4664a6024595fc9deEric Anholt GLboolean color_blend, alpha_enabled; 375d18e86971bdcf0a4dff3cb62581d7ae54c5e67aEric Anholt GLboolean dither; 384b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt GLboolean color_mask[BRW_MAX_DRAW_BUFFERS][4]; 397ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 407ee590424c974cb10882e9c4664a6024595fc9deEric Anholt GLenum logic_op; 417ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 427ee590424c974cb10882e9c4664a6024595fc9deEric Anholt GLenum blend_eq_rgb, blend_eq_a; 437ee590424c974cb10882e9c4664a6024595fc9deEric Anholt GLenum blend_src_rgb, blend_src_a; 447ee590424c974cb10882e9c4664a6024595fc9deEric Anholt GLenum blend_dst_rgb, blend_dst_a; 457ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 467ee590424c974cb10882e9c4664a6024595fc9deEric Anholt GLenum alpha_func; 477ee590424c974cb10882e9c4664a6024595fc9deEric Anholt}; 487ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 497ee590424c974cb10882e9c4664a6024595fc9deEric Anholtstatic void 507ee590424c974cb10882e9c4664a6024595fc9deEric Anholtblend_state_populate_key(struct brw_context *brw, 51879ea6f27972766c792fe78971a36c5c7b9f1884Eric Anholt struct gen6_blend_state_key *key) 527ee590424c974cb10882e9c4664a6024595fc9deEric Anholt{ 53f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg struct gl_context *ctx = &brw->intel.ctx; 547ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 557ee590424c974cb10882e9c4664a6024595fc9deEric Anholt memset(key, 0, sizeof(*key)); 567ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 577ee590424c974cb10882e9c4664a6024595fc9deEric Anholt /* _NEW_COLOR */ 584b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt memcpy(key->color_mask, ctx->Color.ColorMask, sizeof(key->color_mask)); 590d3b8a5cc2c1730af0efc69482d36a86ff18f15eEric Anholt 600d3b8a5cc2c1730af0efc69482d36a86ff18f15eEric Anholt /* _NEW_COLOR */ 617ee590424c974cb10882e9c4664a6024595fc9deEric Anholt if (ctx->Color._LogicOpEnabled) 627ee590424c974cb10882e9c4664a6024595fc9deEric Anholt key->logic_op = ctx->Color.LogicOp; 637ee590424c974cb10882e9c4664a6024595fc9deEric Anholt else 647ee590424c974cb10882e9c4664a6024595fc9deEric Anholt key->logic_op = GL_COPY; 657ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 667ee590424c974cb10882e9c4664a6024595fc9deEric Anholt /* _NEW_COLOR */ 677ee590424c974cb10882e9c4664a6024595fc9deEric Anholt key->color_blend = ctx->Color.BlendEnabled; 687ee590424c974cb10882e9c4664a6024595fc9deEric Anholt if (key->color_blend) { 6974713e2d293f9e796a4053a5a99ee5cb7df5c740Brian Paul key->blend_eq_rgb = ctx->Color.Blend[0].EquationRGB; 7074713e2d293f9e796a4053a5a99ee5cb7df5c740Brian Paul key->blend_eq_a = ctx->Color.Blend[0].EquationA; 7174713e2d293f9e796a4053a5a99ee5cb7df5c740Brian Paul key->blend_src_rgb = ctx->Color.Blend[0].SrcRGB; 7274713e2d293f9e796a4053a5a99ee5cb7df5c740Brian Paul key->blend_dst_rgb = ctx->Color.Blend[0].DstRGB; 7374713e2d293f9e796a4053a5a99ee5cb7df5c740Brian Paul key->blend_src_a = ctx->Color.Blend[0].SrcA; 7474713e2d293f9e796a4053a5a99ee5cb7df5c740Brian Paul key->blend_dst_a = ctx->Color.Blend[0].DstA; 757ee590424c974cb10882e9c4664a6024595fc9deEric Anholt } 767ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 777ee590424c974cb10882e9c4664a6024595fc9deEric Anholt /* _NEW_COLOR */ 787ee590424c974cb10882e9c4664a6024595fc9deEric Anholt key->alpha_enabled = ctx->Color.AlphaEnabled; 797ee590424c974cb10882e9c4664a6024595fc9deEric Anholt if (key->alpha_enabled) { 807ee590424c974cb10882e9c4664a6024595fc9deEric Anholt key->alpha_func = ctx->Color.AlphaFunc; 817ee590424c974cb10882e9c4664a6024595fc9deEric Anholt } 827ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 837ee590424c974cb10882e9c4664a6024595fc9deEric Anholt /* _NEW_COLOR */ 847ee590424c974cb10882e9c4664a6024595fc9deEric Anholt key->dither = ctx->Color.DitherFlag; 857ee590424c974cb10882e9c4664a6024595fc9deEric Anholt} 867ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 877ee590424c974cb10882e9c4664a6024595fc9deEric Anholt/** 887ee590424c974cb10882e9c4664a6024595fc9deEric Anholt * Creates the state cache entry for the given CC unit key. 897ee590424c974cb10882e9c4664a6024595fc9deEric Anholt */ 907ee590424c974cb10882e9c4664a6024595fc9deEric Anholtstatic drm_intel_bo * 917ee590424c974cb10882e9c4664a6024595fc9deEric Anholtblend_state_create_from_key(struct brw_context *brw, 92879ea6f27972766c792fe78971a36c5c7b9f1884Eric Anholt struct gen6_blend_state_key *key) 937ee590424c974cb10882e9c4664a6024595fc9deEric Anholt{ 944b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt struct gen6_blend_state blend[BRW_MAX_DRAW_BUFFERS]; 957ee590424c974cb10882e9c4664a6024595fc9deEric Anholt drm_intel_bo *bo; 964b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt int b; 977ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 987ee590424c974cb10882e9c4664a6024595fc9deEric Anholt memset(&blend, 0, sizeof(blend)); 997ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 1004b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt for (b = 0; b < BRW_MAX_DRAW_BUFFERS; b++) { 1014b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt if (key->logic_op != GL_COPY) { 1024b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend1.logic_op_enable = 1; 1034b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend1.logic_op_func = intel_translate_logic_op(key->logic_op); 1044b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt } else if (key->color_blend & (1 << b)) { 1054b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt GLenum eqRGB = key->blend_eq_rgb; 1064b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt GLenum eqA = key->blend_eq_a; 1074b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt GLenum srcRGB = key->blend_src_rgb; 1084b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt GLenum dstRGB = key->blend_dst_rgb; 1094b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt GLenum srcA = key->blend_src_a; 1104b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt GLenum dstA = key->blend_dst_a; 1114b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt 1124b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt if (eqRGB == GL_MIN || eqRGB == GL_MAX) { 1134b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt srcRGB = dstRGB = GL_ONE; 1144b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt } 1154b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt 1164b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt if (eqA == GL_MIN || eqA == GL_MAX) { 1174b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt srcA = dstA = GL_ONE; 1184b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt } 1194b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt 1204b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend0.dest_blend_factor = brw_translate_blend_factor(dstRGB); 1214b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend0.source_blend_factor = brw_translate_blend_factor(srcRGB); 1224b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend0.blend_func = brw_translate_blend_equation(eqRGB); 1234b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt 1244b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend0.ia_dest_blend_factor = brw_translate_blend_factor(dstA); 1254b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend0.ia_source_blend_factor = brw_translate_blend_factor(srcA); 1264b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend0.ia_blend_func = brw_translate_blend_equation(eqA); 1274b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt 1284b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend0.blend_enable = 1; 1294b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend0.ia_blend_enable = (srcA != srcRGB || 1304b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt dstA != dstRGB || 1314b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt eqA != eqRGB); 1327ee590424c974cb10882e9c4664a6024595fc9deEric Anholt } 1337ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 1344b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt if (key->alpha_enabled) { 1354b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend1.alpha_test_enable = 1; 1364b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend1.alpha_test_func = intel_translate_compare_func(key->alpha_func); 1377ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 1384b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt } 1397ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 1404b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt if (key->dither) { 1414b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend1.dither_enable = 1; 1424b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend1.y_dither_offset = 0; 1434b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend1.x_dither_offset = 0; 1444b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt } 1457ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 1464b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend1.write_disable_r = !key->color_mask[b][0]; 1474b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend1.write_disable_g = !key->color_mask[b][1]; 1484b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend1.write_disable_b = !key->color_mask[b][2]; 1494b4dc778b6289891d18ad62efdea86b060f07061Eric Anholt blend[b].blend1.write_disable_a = !key->color_mask[b][3]; 1507ee590424c974cb10882e9c4664a6024595fc9deEric Anholt } 1517ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 1527ee590424c974cb10882e9c4664a6024595fc9deEric Anholt bo = brw_upload_cache(&brw->cache, BRW_BLEND_STATE, 1537ee590424c974cb10882e9c4664a6024595fc9deEric Anholt key, sizeof(*key), 1547ee590424c974cb10882e9c4664a6024595fc9deEric Anholt NULL, 0, 1557ee590424c974cb10882e9c4664a6024595fc9deEric Anholt &blend, sizeof(blend)); 1567ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 1577ee590424c974cb10882e9c4664a6024595fc9deEric Anholt return bo; 1587ee590424c974cb10882e9c4664a6024595fc9deEric Anholt} 1597ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 1607ee590424c974cb10882e9c4664a6024595fc9deEric Anholtstatic void 1617ee590424c974cb10882e9c4664a6024595fc9deEric Anholtprepare_blend_state(struct brw_context *brw) 1627ee590424c974cb10882e9c4664a6024595fc9deEric Anholt{ 163879ea6f27972766c792fe78971a36c5c7b9f1884Eric Anholt struct gen6_blend_state_key key; 1647ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 1657ee590424c974cb10882e9c4664a6024595fc9deEric Anholt blend_state_populate_key(brw, &key); 1667ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 1677ee590424c974cb10882e9c4664a6024595fc9deEric Anholt drm_intel_bo_unreference(brw->cc.blend_state_bo); 1687ee590424c974cb10882e9c4664a6024595fc9deEric Anholt brw->cc.blend_state_bo = brw_search_cache(&brw->cache, BRW_BLEND_STATE, 1697ee590424c974cb10882e9c4664a6024595fc9deEric Anholt &key, sizeof(key), 1707ee590424c974cb10882e9c4664a6024595fc9deEric Anholt NULL, 0, 1717ee590424c974cb10882e9c4664a6024595fc9deEric Anholt NULL); 1727ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 1737ee590424c974cb10882e9c4664a6024595fc9deEric Anholt if (brw->cc.blend_state_bo == NULL) 1747ee590424c974cb10882e9c4664a6024595fc9deEric Anholt brw->cc.blend_state_bo = blend_state_create_from_key(brw, &key); 1757ee590424c974cb10882e9c4664a6024595fc9deEric Anholt} 1767ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 1777ee590424c974cb10882e9c4664a6024595fc9deEric Anholtconst struct brw_tracked_state gen6_blend_state = { 1787ee590424c974cb10882e9c4664a6024595fc9deEric Anholt .dirty = { 1797ee590424c974cb10882e9c4664a6024595fc9deEric Anholt .mesa = _NEW_COLOR, 1807ee590424c974cb10882e9c4664a6024595fc9deEric Anholt .brw = 0, 1817ee590424c974cb10882e9c4664a6024595fc9deEric Anholt .cache = 0, 1827ee590424c974cb10882e9c4664a6024595fc9deEric Anholt }, 1837ee590424c974cb10882e9c4664a6024595fc9deEric Anholt .prepare = prepare_blend_state, 1847ee590424c974cb10882e9c4664a6024595fc9deEric Anholt}; 1857ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 1867ee590424c974cb10882e9c4664a6024595fc9deEric Anholtstatic void 1872ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholtgen6_prepare_color_calc_state(struct brw_context *brw) 1887ee590424c974cb10882e9c4664a6024595fc9deEric Anholt{ 189f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg struct gl_context *ctx = &brw->intel.ctx; 1902ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholt struct gen6_color_calc_state *cc; 1917ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 1922ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholt cc = brw_state_batch(brw, sizeof(*cc), 64, &brw->cc.state_offset); 1932ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholt memset(cc, 0, sizeof(*cc)); 1947ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 1957ee590424c974cb10882e9c4664a6024595fc9deEric Anholt /* _NEW_COLOR */ 1962ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholt cc->cc0.alpha_test_format = BRW_ALPHATEST_FORMAT_UNORM8; 1972ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholt UNCLAMPED_FLOAT_TO_UBYTE(cc->cc1.alpha_ref_fi.ui, ctx->Color.AlphaRef); 1987ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 1992ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholt /* _NEW_STENCIL */ 2002ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholt cc->cc0.stencil_ref = ctx->Stencil.Ref[0]; 2012ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholt cc->cc0.bf_stencil_ref = ctx->Stencil.Ref[ctx->Stencil._BackFace]; 2027ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 2032ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholt /* _NEW_COLOR */ 2042ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholt cc->constant_r = ctx->Color.BlendColorUnclamped[0]; 2052ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholt cc->constant_g = ctx->Color.BlendColorUnclamped[1]; 2062ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholt cc->constant_b = ctx->Color.BlendColorUnclamped[2]; 2072ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholt cc->constant_a = ctx->Color.BlendColorUnclamped[3]; 2087ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 2092ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholt brw->state.dirty.cache |= CACHE_NEW_COLOR_CALC_STATE; 2107ee590424c974cb10882e9c4664a6024595fc9deEric Anholt} 2117ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 2127ee590424c974cb10882e9c4664a6024595fc9deEric Anholtconst struct brw_tracked_state gen6_color_calc_state = { 2137ee590424c974cb10882e9c4664a6024595fc9deEric Anholt .dirty = { 2149d45c7d1ce0c4ab7c981ddd15b296b2117437fa4Eric Anholt .mesa = _NEW_COLOR | _NEW_STENCIL, 2152ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholt .brw = BRW_NEW_BATCH, 2167ee590424c974cb10882e9c4664a6024595fc9deEric Anholt .cache = 0, 2177ee590424c974cb10882e9c4664a6024595fc9deEric Anholt }, 2182ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholt .prepare = gen6_prepare_color_calc_state, 2197ee590424c974cb10882e9c4664a6024595fc9deEric Anholt}; 2207ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 2217ee590424c974cb10882e9c4664a6024595fc9deEric Anholtstatic void upload_cc_state_pointers(struct brw_context *brw) 2227ee590424c974cb10882e9c4664a6024595fc9deEric Anholt{ 2237ee590424c974cb10882e9c4664a6024595fc9deEric Anholt struct intel_context *intel = &brw->intel; 2247ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 2257ee590424c974cb10882e9c4664a6024595fc9deEric Anholt BEGIN_BATCH(4); 226e31defc825ee94f1d1092e277954abad7097c552Kenneth Graunke OUT_BATCH(_3DSTATE_CC_STATE_POINTERS << 16 | (4 - 2)); 2277ee590424c974cb10882e9c4664a6024595fc9deEric Anholt OUT_RELOC(brw->cc.blend_state_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 1); 2287ee590424c974cb10882e9c4664a6024595fc9deEric Anholt OUT_RELOC(brw->cc.depth_stencil_state_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 1); 2292ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholt OUT_RELOC(intel->batch.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 2302ee1fd2e8f023853b60c242ce7f83a595c0f65ffEric Anholt brw->cc.state_offset | 1); 2317ee590424c974cb10882e9c4664a6024595fc9deEric Anholt ADVANCE_BATCH(); 2327ee590424c974cb10882e9c4664a6024595fc9deEric Anholt} 2337ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 2347ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 2357ee590424c974cb10882e9c4664a6024595fc9deEric Anholtstatic void prepare_cc_state_pointers(struct brw_context *brw) 2367ee590424c974cb10882e9c4664a6024595fc9deEric Anholt{ 2377ee590424c974cb10882e9c4664a6024595fc9deEric Anholt brw_add_validated_bo(brw, brw->cc.blend_state_bo); 2387ee590424c974cb10882e9c4664a6024595fc9deEric Anholt brw_add_validated_bo(brw, brw->cc.depth_stencil_state_bo); 2397ee590424c974cb10882e9c4664a6024595fc9deEric Anholt} 2407ee590424c974cb10882e9c4664a6024595fc9deEric Anholt 2417ee590424c974cb10882e9c4664a6024595fc9deEric Anholtconst struct brw_tracked_state gen6_cc_state_pointers = { 2427ee590424c974cb10882e9c4664a6024595fc9deEric Anholt .dirty = { 2437ee590424c974cb10882e9c4664a6024595fc9deEric Anholt .mesa = 0, 2447ee590424c974cb10882e9c4664a6024595fc9deEric Anholt .brw = BRW_NEW_BATCH, 2457ee590424c974cb10882e9c4664a6024595fc9deEric Anholt .cache = (CACHE_NEW_BLEND_STATE | 2467ee590424c974cb10882e9c4664a6024595fc9deEric Anholt CACHE_NEW_COLOR_CALC_STATE | 2477ee590424c974cb10882e9c4664a6024595fc9deEric Anholt CACHE_NEW_DEPTH_STENCIL_STATE) 2487ee590424c974cb10882e9c4664a6024595fc9deEric Anholt }, 2497ee590424c974cb10882e9c4664a6024595fc9deEric Anholt .prepare = prepare_cc_state_pointers, 2507ee590424c974cb10882e9c4664a6024595fc9deEric Anholt .emit = upload_cc_state_pointers, 2517ee590424c974cb10882e9c4664a6024595fc9deEric Anholt}; 252