blob: 37e382c445679ce8d5075b40aad49337bfce5d45 [file] [log] [blame]
Keith Whitwell8e4a95a2007-05-24 10:41:34 +01001/**************************************************************************
2 *
José Fonseca87712852014-01-17 16:27:50 +00003 * Copyright 2003 VMware, Inc.
Keith Whitwell8e4a95a2007-05-24 10:41:34 +01004 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
José Fonseca87712852014-01-17 16:27:50 +000021 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010022 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 /*
29 * Authors:
José Fonseca87712852014-01-17 16:27:50 +000030 * Keith Whitwell <keithw@vmware.com>
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010031 */
32
33
34#ifndef ST_ATOM_H
35#define ST_ATOM_H
36
Vinson Leedf66c642010-08-03 01:14:37 -070037#include "main/glheader.h"
38
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010039struct st_context;
Marek Olšákc8fe3b92016-07-17 18:38:38 +020040
41/**
42 * Enumeration of state tracker pipelines.
43 */
44enum st_pipeline {
45 ST_PIPELINE_RENDER,
46 ST_PIPELINE_COMPUTE,
47};
48
49struct st_tracked_state {
50 void (*update)( struct st_context *st );
51};
52
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010053
54void st_init_atoms( struct st_context *st );
55void st_destroy_atoms( struct st_context *st );
Samuel Pitoiset08c46022016-01-05 21:20:06 +010056void st_validate_state( struct st_context *st, enum st_pipeline pipeline );
Brian Paulfa5309f2010-10-15 17:18:39 -060057GLuint st_compare_func_to_pipe(GLenum func);
Brianb1876312007-11-08 09:31:57 -070058
Marek Olšákb4753da2012-05-12 15:52:40 +020059enum pipe_format
60st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
61 GLboolean normalized, GLboolean integer);
62
Marek Olšákc8fe3b92016-07-17 18:38:38 +020063
64/* Define ST_NEW_xxx_INDEX */
65enum {
66#define ST_STATE(FLAG, st_update) FLAG##_INDEX,
67#include "st_atom_list.h"
68#undef ST_STATE
69};
70
Brian Paul60dc36a2016-08-08 16:37:00 -060071/* Define ST_NEW_xxx values as static const uint64_t values.
72 * We can't use an enum type because MSVC doesn't allow 64-bit enum values.
73 */
74#define ST_STATE(FLAG, st_update) static const uint64_t FLAG = 1llu << FLAG##_INDEX;
Marek Olšákc8fe3b92016-07-17 18:38:38 +020075#include "st_atom_list.h"
76#undef ST_STATE
Marek Olšákc8fe3b92016-07-17 18:38:38 +020077
78/* Add extern struct declarations. */
79#define ST_STATE(FLAG, st_update) extern const struct st_tracked_state st_update;
80#include "st_atom_list.h"
81#undef ST_STATE
82
83/* Combined state flags. */
84#define ST_NEW_SAMPLERS (ST_NEW_RENDER_SAMPLERS | \
85 ST_NEW_CS_SAMPLERS)
86
87#define ST_NEW_FRAMEBUFFER (ST_NEW_FB_STATE | \
88 ST_NEW_SAMPLE_MASK | \
89 ST_NEW_SAMPLE_SHADING)
90
Marek Olšákc323d5b2016-08-02 16:40:50 +020091#define ST_NEW_VERTEX_PROGRAM(st, p) (p->affected_states | \
92 (st_user_clip_planes_enabled(st->ctx) ? \
93 ST_NEW_CLIP_STATE : 0))
Marek Olšákc8fe3b92016-07-17 18:38:38 +020094
95#define ST_NEW_CONSTANTS (ST_NEW_VS_CONSTANTS | \
96 ST_NEW_TCS_CONSTANTS | \
97 ST_NEW_TES_CONSTANTS | \
98 ST_NEW_FS_CONSTANTS | \
99 ST_NEW_GS_CONSTANTS | \
100 ST_NEW_CS_CONSTANTS)
101
102#define ST_NEW_UNIFORM_BUFFER (ST_NEW_VS_UBOS | \
103 ST_NEW_TCS_UBOS | \
104 ST_NEW_TES_UBOS | \
105 ST_NEW_FS_UBOS | \
106 ST_NEW_GS_UBOS | \
107 ST_NEW_CS_UBOS)
108
109#define ST_NEW_SAMPLER_VIEWS (ST_NEW_VS_SAMPLER_VIEWS | \
110 ST_NEW_FS_SAMPLER_VIEWS | \
111 ST_NEW_GS_SAMPLER_VIEWS | \
112 ST_NEW_TCS_SAMPLER_VIEWS | \
113 ST_NEW_TES_SAMPLER_VIEWS | \
114 ST_NEW_CS_SAMPLER_VIEWS)
115
116#define ST_NEW_ATOMIC_BUFFER (ST_NEW_VS_ATOMICS | \
117 ST_NEW_TCS_ATOMICS | \
118 ST_NEW_TES_ATOMICS | \
119 ST_NEW_FS_ATOMICS | \
120 ST_NEW_GS_ATOMICS | \
121 ST_NEW_CS_ATOMICS)
122
123#define ST_NEW_STORAGE_BUFFER (ST_NEW_VS_SSBOS | \
124 ST_NEW_TCS_SSBOS | \
125 ST_NEW_TES_SSBOS | \
126 ST_NEW_FS_SSBOS | \
127 ST_NEW_GS_SSBOS | \
128 ST_NEW_CS_SSBOS)
129
130#define ST_NEW_IMAGE_UNITS (ST_NEW_VS_IMAGES | \
131 ST_NEW_TCS_IMAGES | \
132 ST_NEW_TES_IMAGES | \
133 ST_NEW_GS_IMAGES | \
134 ST_NEW_FS_IMAGES | \
135 ST_NEW_CS_IMAGES)
136
Marek Olšákac032d82016-08-02 16:59:41 +0200137#define ST_ALL_SHADER_RESOURCES (ST_NEW_SAMPLER_VIEWS | \
138 ST_NEW_SAMPLERS | \
139 ST_NEW_CONSTANTS | \
140 ST_NEW_UNIFORM_BUFFER | \
141 ST_NEW_ATOMIC_BUFFER | \
142 ST_NEW_STORAGE_BUFFER | \
143 ST_NEW_IMAGE_UNITS)
144
Marek Olšákc8fe3b92016-07-17 18:38:38 +0200145/* All state flags within each group: */
146#define ST_PIPELINE_RENDER_STATE_MASK (ST_NEW_CS_STATE - 1)
Marek Olšákc323d5b2016-08-02 16:40:50 +0200147#define ST_PIPELINE_COMPUTE_STATE_MASK (0xffllu << ST_NEW_CS_STATE_INDEX)
Marek Olšákc8fe3b92016-07-17 18:38:38 +0200148
149#define ST_ALL_STATES_MASK (ST_PIPELINE_RENDER_STATE_MASK | \
150 ST_PIPELINE_COMPUTE_STATE_MASK)
151
Keith Whitwell8e4a95a2007-05-24 10:41:34 +0100152#endif