1c73e919a4b4dd79166d0633075990056f27fd28 made it possible to not allocate
the tgsi machine if llvm was used. However, draw_get_option_use_llvm() is
not reliable after draw context creation, since drivers can explicitly
request a non-llvm draw context even if draw_get_option_use_llvm() would
return true (and softpipe does just that) which leads to crashes.
Thus use draw->llvm to determine if we're using llvm or not instead (and
make draw->llvm available even if HAVE_LLVM is false so we don't have to put
even more ifdefs).
Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
/**
* XXX: Results for PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS because there are two
* different ways of setting textures, and drivers typically only support one.
+ * Drivers requesting a draw context explicitly without llvm must call
+ * draw_get_shader_param_no_llvm instead.
*/
int
draw_get_shader_param(unsigned shader, enum pipe_shader_cap param)
#ifdef HAVE_LLVM
- if (draw_get_option_use_llvm()) {
+ if (shader->draw->llvm) {
shader->gs_output = output_verts->verts;
if (max_out_prims > shader->max_out_prims) {
unsigned i;
void draw_geometry_shader_prepare(struct draw_geometry_shader *shader,
struct draw_context *draw)
{
- boolean use_llvm = draw_get_option_use_llvm();
+ boolean use_llvm = draw->llvm != NULL;
if (!use_llvm && shader && shader->machine->Tokens != shader->state.tokens) {
tgsi_exec_machine_bind_shader(shader->machine,
shader->state.tokens,
boolean
draw_gs_init( struct draw_context *draw )
{
- if (!draw_get_option_use_llvm()) {
+ if (!draw->llvm) {
draw->gs.tgsi.machine = tgsi_exec_machine_create();
if (!draw->gs.tgsi.machine)
return FALSE;
const struct pipe_shader_state *state)
{
#ifdef HAVE_LLVM
- boolean use_llvm = draw_get_option_use_llvm();
+ boolean use_llvm = draw->llvm != NULL;
struct llvm_geometry_shader *llvm_gs;
#endif
struct draw_geometry_shader *gs;
return;
}
#ifdef HAVE_LLVM
- if (draw_get_option_use_llvm()) {
+ if (draw->llvm) {
struct llvm_geometry_shader *shader = llvm_geometry_shader(dgs);
struct draw_gs_llvm_variant_list_item *li;
#include "tgsi/tgsi_scan.h"
#ifdef HAVE_LLVM
-struct draw_llvm;
struct gallivm_state;
#endif
struct tgsi_sampler;
struct draw_pt_front_end;
struct draw_assembler;
+struct draw_llvm;
/**
unsigned start_instance;
unsigned start_index;
-#ifdef HAVE_LLVM
struct draw_llvm *llvm;
-#endif
/** Texture sampler and sampler view state.
* Note that we have arrays indexed by shader type. At this time
{
draw->dump_vs = debug_get_option_gallium_dump_vs();
- if (!draw_get_option_use_llvm()) {
+ if (!draw->llvm) {
draw->vs.tgsi.machine = tgsi_exec_machine_create();
if (!draw->vs.tgsi.machine)
return FALSE;
if (draw->vs.emit_cache)
translate_cache_destroy(draw->vs.emit_cache);
- if (!draw_get_option_use_llvm())
+ if (!draw->llvm)
tgsi_exec_machine_destroy(draw->vs.tgsi.machine);
}
{
struct exec_vertex_shader *evs = exec_vertex_shader(shader);
- debug_assert(!draw_get_option_use_llvm());
+ debug_assert(!draw->llvm);
/* Specify the vertex program to interpret/execute.
* Avoid rebinding when possible.
*/
unsigned slot;
boolean clamp_vertex_color = shader->draw->rasterizer->clamp_vertex_color;
- debug_assert(!draw_get_option_use_llvm());
+ debug_assert(!shader->draw->llvm);
tgsi_exec_set_constant_buffers(machine, PIPE_MAX_CONSTANT_BUFFERS,
constants, const_size);