2 * Copyright © 2013 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 #include "main/mtypes.h"
25 #include "program/prog_parameter.h"
26 #include "main/shaderapi.h"
28 #include "brw_context.h"
29 #include "brw_state.h"
32 /* Creates a new GS constant buffer reflecting the current GS program's
33 * constants, if needed by the GS program.
35 * Otherwise, constants go through the CURBEs using the brw_constant_buffer
39 brw_upload_gs_pull_constants(struct brw_context
*brw
)
41 struct brw_stage_state
*stage_state
= &brw
->gs
.base
;
43 /* BRW_NEW_GEOMETRY_PROGRAM */
44 struct brw_program
*gp
= (struct brw_program
*) brw
->geometry_program
;
49 /* BRW_NEW_GS_PROG_DATA */
50 const struct brw_stage_prog_data
*prog_data
= brw
->gs
.base
.prog_data
;
52 _mesa_shader_write_subroutine_indices(&brw
->ctx
, MESA_SHADER_GEOMETRY
);
53 /* _NEW_PROGRAM_CONSTANTS */
54 brw_upload_pull_constants(brw
, BRW_NEW_GS_CONSTBUF
, &gp
->program
,
55 stage_state
, prog_data
);
58 const struct brw_tracked_state brw_gs_pull_constants
= {
60 .mesa
= _NEW_PROGRAM_CONSTANTS
,
61 .brw
= BRW_NEW_BATCH
|
62 BRW_NEW_GEOMETRY_PROGRAM
|
65 .emit
= brw_upload_gs_pull_constants
,
69 brw_upload_gs_ubo_surfaces(struct brw_context
*brw
)
71 struct gl_context
*ctx
= &brw
->ctx
;
74 struct gl_program
*prog
=
75 ctx
->_Shader
->CurrentProgram
[MESA_SHADER_GEOMETRY
];
77 /* BRW_NEW_GS_PROG_DATA */
78 struct brw_stage_prog_data
*prog_data
= brw
->gs
.base
.prog_data
;
80 brw_upload_ubo_surfaces(brw
, prog
, &brw
->gs
.base
, prog_data
);
83 const struct brw_tracked_state brw_gs_ubo_surfaces
= {
86 .brw
= BRW_NEW_BATCH
|
87 BRW_NEW_GS_PROG_DATA
|
88 BRW_NEW_UNIFORM_BUFFER
,
90 .emit
= brw_upload_gs_ubo_surfaces
,
94 brw_upload_gs_abo_surfaces(struct brw_context
*brw
)
97 const struct gl_program
*gp
= brw
->geometry_program
;
100 /* BRW_NEW_GS_PROG_DATA */
101 brw_upload_abo_surfaces(brw
, gp
, &brw
->gs
.base
, brw
->gs
.base
.prog_data
);
105 const struct brw_tracked_state brw_gs_abo_surfaces
= {
107 .mesa
= _NEW_PROGRAM
,
108 .brw
= BRW_NEW_ATOMIC_BUFFER
|
110 BRW_NEW_GS_PROG_DATA
,
112 .emit
= brw_upload_gs_abo_surfaces
,
116 brw_upload_gs_image_surfaces(struct brw_context
*brw
)
118 /* BRW_NEW_GEOMETRY_PROGRAM */
119 const struct gl_program
*gp
= brw
->geometry_program
;
122 /* BRW_NEW_GS_PROG_DATA, BRW_NEW_IMAGE_UNITS, _NEW_TEXTURE */
123 brw_upload_image_surfaces(brw
, gp
, &brw
->gs
.base
,
124 brw
->gs
.base
.prog_data
);
128 const struct brw_tracked_state brw_gs_image_surfaces
= {
130 .mesa
= _NEW_TEXTURE
,
131 .brw
= BRW_NEW_BATCH
|
133 BRW_NEW_GEOMETRY_PROGRAM
|
134 BRW_NEW_GS_PROG_DATA
|
137 .emit
= brw_upload_gs_image_surfaces
,