Lines Matching refs:emit

55 svga_shader_expand(struct svga_shader_emitter *emit)
58 unsigned newsize = emit->size * 2;
60 if (emit->buf != err_buf)
61 new_buf = REALLOC(emit->buf, emit->size, newsize);
66 emit->ptr = err_buf;
67 emit->buf = err_buf;
68 emit->size = sizeof(err_buf);
72 emit->size = newsize;
73 emit->ptr = new_buf + (emit->ptr - emit->buf);
74 emit->buf = new_buf;
80 reserve(struct svga_shader_emitter *emit, unsigned nr_dwords)
82 if (emit->ptr - emit->buf + nr_dwords * sizeof(unsigned) >= emit->size) {
83 if (!svga_shader_expand(emit)) {
93 svga_shader_emit_dword(struct svga_shader_emitter * emit, unsigned dword)
95 if (!reserve(emit, 1))
98 *(unsigned *) emit->ptr = dword;
99 emit->ptr += sizeof dword;
105 svga_shader_emit_dwords(struct svga_shader_emitter * emit,
108 if (!reserve(emit, nr))
111 memcpy(emit->ptr, dwords, nr * sizeof *dwords);
112 emit->ptr += nr * sizeof *dwords;
118 svga_shader_emit_opcode(struct svga_shader_emitter * emit, unsigned opcode)
122 if (!reserve(emit, 1))
125 here = (SVGA3dShaderInstToken *) emit->ptr;
128 if (emit->insn_offset) {
130 (SVGA3dShaderInstToken *) (emit->buf + emit->insn_offset);
134 emit->insn_offset = emit->ptr - emit->buf;
135 emit->ptr += sizeof(unsigned);
141 svga_shader_emit_header(struct svga_shader_emitter *emit)
147 switch (emit->unit) {
156 return svga_shader_emit_dword(emit, header.value);
175 struct svga_shader_emitter emit;
179 memset(&emit, 0, sizeof(emit));
181 emit.size = 1024;
182 emit.buf = MALLOC(emit.size);
183 if (emit.buf == NULL) {
187 emit.ptr = emit.buf;
188 emit.unit = unit;
189 emit.key = *key;
191 tgsi_scan_shader(shader->tokens, &emit.info);
193 emit.imm_start = emit.info.file_max[TGSI_FILE_CONSTANT] + 1;
196 emit.imm_start += key->num_unnormalized_coords;
199 emit.imm_start += key->vs.need_prescale ? 2 : 0;
202 emit.nr_hw_float_const =
203 (emit.imm_start + emit.info.file_max[TGSI_FILE_IMMEDIATE] + 1);
205 emit.nr_hw_temp = emit.info.file_max[TGSI_FILE_TEMPORARY] + 1;
207 if (emit.nr_hw_temp >= SVGA3D_TEMPREG_MAX) {
209 emit.nr_hw_temp);
213 if (emit.info.indirect_files & (1 << TGSI_FILE_TEMPORARY)) {
219 emit.in_main_func = TRUE;
221 if (!svga_shader_emit_header(&emit)) {
222 debug_printf("svga: emit header failed\n");
226 if (!svga_shader_emit_instructions(&emit, shader->tokens)) {
227 debug_printf("svga: emit instructions failed\n");
236 variant->tokens = (const unsigned *) emit.buf;
237 variant->nr_tokens = (emit.ptr - emit.buf) / sizeof(unsigned);
244 fs_variant->pstipple_sampler_unit = emit.pstipple_sampler_unit;
251 emit.constant_color_output && emit.num_output_writes == 1;
272 if (emit.buf != err_buf)
273 FREE(emit.buf);