14a49301eSmrg/************************************************************************** 24a49301eSmrg * 3af69d88dSmrg * Copyright 2003 VMware, Inc. 44a49301eSmrg * All Rights Reserved. 54a49301eSmrg * 64a49301eSmrg * Permission is hereby granted, free of charge, to any person obtaining a 74a49301eSmrg * copy of this software and associated documentation files (the 84a49301eSmrg * "Software"), to deal in the Software without restriction, including 94a49301eSmrg * without limitation the rights to use, copy, modify, merge, publish, 104a49301eSmrg * distribute, sub license, and/or sell copies of the Software, and to 114a49301eSmrg * permit persons to whom the Software is furnished to do so, subject to 124a49301eSmrg * the following conditions: 134a49301eSmrg * 144a49301eSmrg * The above copyright notice and this permission notice (including the 154a49301eSmrg * next paragraph) shall be included in all copies or substantial portions 164a49301eSmrg * of the Software. 174a49301eSmrg * 184a49301eSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 194a49301eSmrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 204a49301eSmrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21af69d88dSmrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 224a49301eSmrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 234a49301eSmrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 244a49301eSmrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 254a49301eSmrg * 264a49301eSmrg **************************************************************************/ 274a49301eSmrg 284a49301eSmrg /* 294a49301eSmrg * Authors: 30af69d88dSmrg * Keith Whitwell <keithw@vmware.com> 314a49301eSmrg */ 324a49301eSmrg 334a49301eSmrg 344a49301eSmrg#ifndef ST_ATOM_H 354a49301eSmrg#define ST_ATOM_H 364a49301eSmrg 373464ebd5Sriastradh#include "main/glheader.h" 383464ebd5Sriastradh 394a49301eSmrgstruct st_context; 40b9abf16eSmayastruct st_vertex_program; 417ec681f3Smrgstruct st_common_variant; 42b9abf16eSmayastruct pipe_vertex_buffer; 43b9abf16eSmayastruct pipe_vertex_element; 447ec681f3Smrgstruct cso_velems_state; 4501e04c3fSmrg 4601e04c3fSmrg/** 4701e04c3fSmrg * Enumeration of state tracker pipelines. 4801e04c3fSmrg */ 4901e04c3fSmrgenum st_pipeline { 5001e04c3fSmrg ST_PIPELINE_RENDER, 517ec681f3Smrg ST_PIPELINE_RENDER_NO_VARRAYS, 5201e04c3fSmrg ST_PIPELINE_CLEAR, 5301e04c3fSmrg ST_PIPELINE_META, 5401e04c3fSmrg ST_PIPELINE_UPDATE_FRAMEBUFFER, 5501e04c3fSmrg ST_PIPELINE_COMPUTE, 5601e04c3fSmrg}; 574a49301eSmrg 584a49301eSmrgvoid st_init_atoms( struct st_context *st ); 594a49301eSmrgvoid st_destroy_atoms( struct st_context *st ); 6001e04c3fSmrgvoid st_validate_state( struct st_context *st, enum st_pipeline pipeline ); 617ec681f3Smrgvoid st_update_edgeflags(struct st_context *st, bool per_vertex_edgeflags); 624a49301eSmrg 63b9abf16eSmayavoid 64b9abf16eSmayast_setup_arrays(struct st_context *st, 65b9abf16eSmaya const struct st_vertex_program *vp, 667ec681f3Smrg const struct st_common_variant *vp_variant, 677ec681f3Smrg struct cso_velems_state *velements, 687ec681f3Smrg struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers, 697ec681f3Smrg bool *has_user_vertex_buffers); 70b9abf16eSmaya 71b9abf16eSmayavoid 72b9abf16eSmayast_setup_current_user(struct st_context *st, 73b9abf16eSmaya const struct st_vertex_program *vp, 747ec681f3Smrg const struct st_common_variant *vp_variant, 757ec681f3Smrg struct cso_velems_state *velements, 76b9abf16eSmaya struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers); 774a49301eSmrg 787ec681f3Smrgstruct pipe_vertex_state * 797ec681f3Smrgst_create_gallium_vertex_state(struct gl_context *ctx, 807ec681f3Smrg const struct gl_vertex_array_object *vao, 817ec681f3Smrg struct gl_buffer_object *indexbuf, 827ec681f3Smrg uint32_t enabled_attribs); 837ec681f3Smrg 8401e04c3fSmrg/* Define ST_NEW_xxx_INDEX */ 8501e04c3fSmrgenum { 8601e04c3fSmrg#define ST_STATE(FLAG, st_update) FLAG##_INDEX, 8701e04c3fSmrg#include "st_atom_list.h" 8801e04c3fSmrg#undef ST_STATE 8901e04c3fSmrg}; 904a49301eSmrg 9101e04c3fSmrg/* Define ST_NEW_xxx values as static const uint64_t values. 9201e04c3fSmrg * We can't use an enum type because MSVC doesn't allow 64-bit enum values. 9301e04c3fSmrg */ 9401e04c3fSmrg#define ST_STATE(FLAG, st_update) static const uint64_t FLAG = 1ull << FLAG##_INDEX; 9501e04c3fSmrg#include "st_atom_list.h" 9601e04c3fSmrg#undef ST_STATE 974a49301eSmrg 9801e04c3fSmrg/* Declare function prototypes. */ 9901e04c3fSmrg#define ST_STATE(FLAG, st_update) void st_update(struct st_context *st); 10001e04c3fSmrg#include "st_atom_list.h" 10101e04c3fSmrg#undef ST_STATE 10201e04c3fSmrg 10301e04c3fSmrg/* Combined state flags. */ 10401e04c3fSmrg#define ST_NEW_SAMPLERS (ST_NEW_VS_SAMPLERS | \ 10501e04c3fSmrg ST_NEW_TCS_SAMPLERS | \ 10601e04c3fSmrg ST_NEW_TES_SAMPLERS | \ 10701e04c3fSmrg ST_NEW_GS_SAMPLERS | \ 10801e04c3fSmrg ST_NEW_FS_SAMPLERS | \ 10901e04c3fSmrg ST_NEW_CS_SAMPLERS) 11001e04c3fSmrg 11101e04c3fSmrg#define ST_NEW_FRAMEBUFFER (ST_NEW_FB_STATE | \ 11201e04c3fSmrg ST_NEW_SAMPLE_STATE | \ 11301e04c3fSmrg ST_NEW_SAMPLE_SHADING) 11401e04c3fSmrg 1157ec681f3Smrg#define ST_NEW_VERTEX_PROGRAM(st, p) ((p)->affected_states | \ 11601e04c3fSmrg (st_user_clip_planes_enabled(st->ctx) ? \ 11701e04c3fSmrg ST_NEW_CLIP_STATE : 0)) 11801e04c3fSmrg 11901e04c3fSmrg#define ST_NEW_CONSTANTS (ST_NEW_VS_CONSTANTS | \ 12001e04c3fSmrg ST_NEW_TCS_CONSTANTS | \ 12101e04c3fSmrg ST_NEW_TES_CONSTANTS | \ 12201e04c3fSmrg ST_NEW_FS_CONSTANTS | \ 12301e04c3fSmrg ST_NEW_GS_CONSTANTS | \ 12401e04c3fSmrg ST_NEW_CS_CONSTANTS) 12501e04c3fSmrg 12601e04c3fSmrg#define ST_NEW_UNIFORM_BUFFER (ST_NEW_VS_UBOS | \ 12701e04c3fSmrg ST_NEW_TCS_UBOS | \ 12801e04c3fSmrg ST_NEW_TES_UBOS | \ 12901e04c3fSmrg ST_NEW_FS_UBOS | \ 13001e04c3fSmrg ST_NEW_GS_UBOS | \ 13101e04c3fSmrg ST_NEW_CS_UBOS) 13201e04c3fSmrg 13301e04c3fSmrg#define ST_NEW_SAMPLER_VIEWS (ST_NEW_VS_SAMPLER_VIEWS | \ 13401e04c3fSmrg ST_NEW_FS_SAMPLER_VIEWS | \ 13501e04c3fSmrg ST_NEW_GS_SAMPLER_VIEWS | \ 13601e04c3fSmrg ST_NEW_TCS_SAMPLER_VIEWS | \ 13701e04c3fSmrg ST_NEW_TES_SAMPLER_VIEWS | \ 13801e04c3fSmrg ST_NEW_CS_SAMPLER_VIEWS) 13901e04c3fSmrg 14001e04c3fSmrg#define ST_NEW_ATOMIC_BUFFER (ST_NEW_VS_ATOMICS | \ 14101e04c3fSmrg ST_NEW_TCS_ATOMICS | \ 14201e04c3fSmrg ST_NEW_TES_ATOMICS | \ 14301e04c3fSmrg ST_NEW_FS_ATOMICS | \ 14401e04c3fSmrg ST_NEW_GS_ATOMICS | \ 14501e04c3fSmrg ST_NEW_CS_ATOMICS) 14601e04c3fSmrg 14701e04c3fSmrg#define ST_NEW_STORAGE_BUFFER (ST_NEW_VS_SSBOS | \ 14801e04c3fSmrg ST_NEW_TCS_SSBOS | \ 14901e04c3fSmrg ST_NEW_TES_SSBOS | \ 15001e04c3fSmrg ST_NEW_FS_SSBOS | \ 15101e04c3fSmrg ST_NEW_GS_SSBOS | \ 15201e04c3fSmrg ST_NEW_CS_SSBOS) 15301e04c3fSmrg 15401e04c3fSmrg#define ST_NEW_IMAGE_UNITS (ST_NEW_VS_IMAGES | \ 15501e04c3fSmrg ST_NEW_TCS_IMAGES | \ 15601e04c3fSmrg ST_NEW_TES_IMAGES | \ 15701e04c3fSmrg ST_NEW_GS_IMAGES | \ 15801e04c3fSmrg ST_NEW_FS_IMAGES | \ 15901e04c3fSmrg ST_NEW_CS_IMAGES) 16001e04c3fSmrg 16101e04c3fSmrg#define ST_ALL_SHADER_RESOURCES (ST_NEW_SAMPLER_VIEWS | \ 16201e04c3fSmrg ST_NEW_SAMPLERS | \ 16301e04c3fSmrg ST_NEW_CONSTANTS | \ 16401e04c3fSmrg ST_NEW_UNIFORM_BUFFER | \ 16501e04c3fSmrg ST_NEW_ATOMIC_BUFFER | \ 16601e04c3fSmrg ST_NEW_STORAGE_BUFFER | \ 16701e04c3fSmrg ST_NEW_IMAGE_UNITS) 16801e04c3fSmrg 16901e04c3fSmrg/* All state flags within each group: */ 17001e04c3fSmrg#define ST_PIPELINE_RENDER_STATE_MASK (ST_NEW_CS_STATE - 1) 1717ec681f3Smrg#define ST_PIPELINE_RENDER_STATE_MASK_NO_VARRAYS \ 1727ec681f3Smrg (ST_PIPELINE_RENDER_STATE_MASK & ~ST_NEW_VERTEX_ARRAYS) 17301e04c3fSmrg#define ST_PIPELINE_COMPUTE_STATE_MASK (0xffull << ST_NEW_CS_STATE_INDEX) 17401e04c3fSmrg#define ST_PIPELINE_CLEAR_STATE_MASK (ST_NEW_FB_STATE | \ 17501e04c3fSmrg ST_NEW_SCISSOR | \ 17601e04c3fSmrg ST_NEW_WINDOW_RECTANGLES) 1777ec681f3Smrg#define ST_PIPELINE_META_STATE_MASK ST_PIPELINE_RENDER_STATE_MASK_NO_VARRAYS 17801e04c3fSmrg/* For ReadPixels, ReadBuffer, GetSamplePosition: */ 17901e04c3fSmrg#define ST_PIPELINE_UPDATE_FB_STATE_MASK (ST_NEW_FB_STATE) 18001e04c3fSmrg 18101e04c3fSmrg#define ST_ALL_STATES_MASK (ST_PIPELINE_RENDER_STATE_MASK | \ 18201e04c3fSmrg ST_PIPELINE_COMPUTE_STATE_MASK) 183af69d88dSmrg 1844a49301eSmrg#endif 185