#include "brw_context.h"
#include "brw_screen.h"
-#include "brw_util.h"
#include "brw_wm.h"
#include "brw_state.h"
#include "brw_debug.h"
case WM_FB_WRITE:
case WM_PINTERP:
return 3;
+ case TGSI_OPCODE_TEX:
+ case TGSI_OPCODE_TXP:
+ case TGSI_OPCODE_TXB:
+ case TGSI_OPCODE_TXD:
+ /* sampler arg is held as a field in the instruction, not in an
+ * actual register:
+ */
+ return tgsi_get_opcode_info(opcode)->num_src - 1;
+
default:
assert(opcode < MAX_OPCODE);
return tgsi_get_opcode_info(opcode)->num_src;
* Depending on the instructions used (i.e. flow control instructions)
* we'll use one of two code generators.
*/
-static int do_wm_prog( struct brw_context *brw,
- struct brw_fragment_shader *fp,
- struct brw_wm_prog_key *key)
+static enum pipe_error do_wm_prog( struct brw_context *brw,
+ struct brw_fragment_shader *fp,
+ struct brw_wm_prog_key *key,
+ struct brw_winsys_buffer **bo_out)
{
+ enum pipe_error ret;
struct brw_wm_compile *c;
const GLuint *program;
GLuint program_size;
- c = brw->wm.compile_data;
- if (c == NULL) {
- brw->wm.compile_data = calloc(1, sizeof(*brw->wm.compile_data));
- c = brw->wm.compile_data;
- if (c == NULL) {
- /* Ouch - big out of memory problem. Can't continue
- * without triggering a segfault, no way to signal,
- * so just return.
- */
+ if (brw->wm.compile_data == NULL) {
+ brw->wm.compile_data = MALLOC(sizeof(*brw->wm.compile_data));
+ if (!brw->wm.compile_data)
return PIPE_ERROR_OUT_OF_MEMORY;
- }
- } else {
- memset(c, 0, sizeof(*brw->wm.compile_data));
}
- memcpy(&c->key, key, sizeof(*key));
+ c = brw->wm.compile_data;
+ memset(c, 0, sizeof *c);
+
+ c->key = *key;
c->fp = fp;
c->env_param = NULL; /*brw->intel.ctx.FragmentProgram.Parameters;*/
brw_init_compile(brw, &c->func);
- /* temporary sanity check assertion */
- assert(fp->has_flow_control == brw_wm_has_flow_control(c->fp));
-
/*
* Shader which use GLSL features such as flow control are handled
* differently from "simple" shaders.
/* XXX: GLSL support
*/
exit(1);
- //brw_wm_branching_shader_emit(brw, c);
+ /* brw_wm_branching_shader_emit(brw, c); */
}
else {
c->dispatch_width = 16;
/* get the program
*/
- program = brw_get_program(&c->func, &program_size);
-
- brw->sws->bo_unreference(brw->wm.prog_bo);
- brw->wm.prog_bo = brw_upload_cache( &brw->cache, BRW_WM_PROG,
- &c->key, sizeof(c->key),
- NULL, 0,
- program, program_size,
- &c->prog_data,
- &brw->wm.prog_data );
-
- return 0;
+ ret = brw_get_program(&c->func, &program, &program_size);
+ if (ret)
+ return ret;
+
+ ret = brw_upload_cache( &brw->cache, BRW_WM_PROG,
+ &c->key, sizeof(c->key),
+ NULL, 0,
+ program, program_size,
+ &c->prog_data,
+ &brw->wm.prog_data,
+ bo_out );
+ if (ret)
+ return ret;
+
+ return PIPE_OK;
}
line_aa = AA_NEVER;
break;
case PIPE_PRIM_LINES:
- line_aa = AA_ALWAYS;
+ line_aa = (brw->curr.rast->templ.line_smooth ?
+ AA_ALWAYS : AA_NEVER);
break;
default:
line_aa = brw->curr.rast->unfilled_aa_line;
/* CACHE_NEW_VS_PROG */
key->vp_nr_outputs = brw->vs.prog_data->nr_outputs;
+ key->nr_cbufs = brw->curr.fb.nr_cbufs;
+
+ key->nr_inputs = brw->curr.fragment_shader->info.num_inputs;
+
/* The unique fragment program ID */
key->program_string_id = brw->curr.fragment_shader->id;
}
-static int brw_prepare_wm_prog(struct brw_context *brw)
+static enum pipe_error brw_prepare_wm_prog(struct brw_context *brw)
{
struct brw_wm_prog_key key;
struct brw_fragment_shader *fs = brw->curr.fragment_shader;
+ enum pipe_error ret;
brw_wm_populate_key(brw, &key);
/* Make an early check for the key.
*/
- brw->sws->bo_unreference(brw->wm.prog_bo);
- brw->wm.prog_bo = brw_search_cache(&brw->cache, BRW_WM_PROG,
- &key, sizeof(key),
- NULL, 0,
- &brw->wm.prog_data);
- if (brw->wm.prog_bo == NULL)
- return do_wm_prog(brw, fs, &key);
-
- return 0;
+ if (brw_search_cache(&brw->cache, BRW_WM_PROG,
+ &key, sizeof(key),
+ NULL, 0,
+ &brw->wm.prog_data,
+ &brw->wm.prog_bo))
+ return PIPE_OK;
+
+ ret = do_wm_prog(brw, fs, &key, &brw->wm.prog_bo);
+ if (ret)
+ return ret;
+
+ return PIPE_OK;
}
.mesa = (PIPE_NEW_FRAGMENT_SHADER |
PIPE_NEW_DEPTH_STENCIL_ALPHA |
PIPE_NEW_RAST |
+ PIPE_NEW_NR_CBUFS |
PIPE_NEW_BOUND_TEXTURES),
.brw = (BRW_NEW_WM_INPUT_DIMENSIONS |
BRW_NEW_REDUCED_PRIMITIVE),