#include "state.h"
#include "JitManager.h"
-#include "state_llvm.h"
+#include "gen_state_llvm.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
#include "util/u_memory.h"
#include "swr_tex_sample.h"
-#include "swr_context_llvm.h"
+#include "gen_swr_context_llvm.h"
+using namespace SwrJit;
/**
* This provides the bridge between the sampler state store in
struct lp_sampler_dynamic_state base;
const struct swr_sampler_static_state *static_state;
+
+ enum pipe_shader_type shader_type;
};
/* context[0] */
indices[0] = lp_build_const_int32(gallivm, 0);
/* context[0].textures */
- indices[1] = lp_build_const_int32(gallivm, swr_draw_context_texturesFS);
+ auto dynamic = (const struct swr_sampler_dynamic_state *)base;
+ switch (dynamic->shader_type) {
+ case PIPE_SHADER_FRAGMENT:
+ indices[1] = lp_build_const_int32(gallivm, swr_draw_context_texturesFS);
+ break;
+ case PIPE_SHADER_VERTEX:
+ indices[1] = lp_build_const_int32(gallivm, swr_draw_context_texturesVS);
+ break;
+ case PIPE_SHADER_GEOMETRY:
+ indices[1] = lp_build_const_int32(gallivm, swr_draw_context_texturesGS);
+ break;
+ default:
+ assert(0 && "unsupported shader type");
+ break;
+ }
/* context[0].textures[unit] */
indices[2] = lp_build_const_int32(gallivm, texture_unit);
/* context[0].textures[unit].member */
indices[3] = lp_build_const_int32(gallivm, member_index);
- ptr = LLVMBuildGEP(builder, context_ptr, indices, Elements(indices), "");
+ ptr = LLVMBuildGEP(builder, context_ptr, indices, ARRAY_SIZE(indices), "");
if (emit_load)
res = LLVMBuildLoad(builder, ptr, "");
/* context[0] */
indices[0] = lp_build_const_int32(gallivm, 0);
/* context[0].samplers */
- indices[1] = lp_build_const_int32(gallivm, swr_draw_context_samplersFS);
+ auto dynamic = (const struct swr_sampler_dynamic_state *)base;
+ switch (dynamic->shader_type) {
+ case PIPE_SHADER_FRAGMENT:
+ indices[1] = lp_build_const_int32(gallivm, swr_draw_context_samplersFS);
+ break;
+ case PIPE_SHADER_VERTEX:
+ indices[1] = lp_build_const_int32(gallivm, swr_draw_context_samplersVS);
+ break;
+ case PIPE_SHADER_GEOMETRY:
+ indices[1] = lp_build_const_int32(gallivm, swr_draw_context_samplersGS);
+ break;
+ default:
+ assert(0 && "unsupported shader type");
+ break;
+ }
/* context[0].samplers[unit] */
indices[2] = lp_build_const_int32(gallivm, sampler_unit);
/* context[0].samplers[unit].member */
indices[3] = lp_build_const_int32(gallivm, member_index);
- ptr = LLVMBuildGEP(builder, context_ptr, indices, Elements(indices), "");
+ ptr = LLVMBuildGEP(builder, context_ptr, indices, ARRAY_SIZE(indices), "");
if (emit_load)
res = LLVMBuildLoad(builder, ptr, "");
static void
swr_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base,
struct gallivm_state *gallivm,
- struct lp_type type,
- unsigned texture_unit,
- unsigned target,
- LLVMValueRef context_ptr,
- boolean is_sviewinfo,
- enum lp_sampler_lod_property lod_property,
- LLVMValueRef explicit_lod, /* optional */
- LLVMValueRef *sizes_out)
+ const struct lp_sampler_size_query_params *params)
{
struct swr_sampler_soa *sampler = (struct swr_sampler_soa *)base;
- assert(texture_unit < PIPE_MAX_SHADER_SAMPLER_VIEWS);
+ assert(params->texture_unit < PIPE_MAX_SHADER_SAMPLER_VIEWS);
lp_build_size_query_soa(
gallivm,
- &sampler->dynamic_state.static_state[texture_unit].texture_state,
+ &sampler->dynamic_state.static_state[params->texture_unit].texture_state,
&sampler->dynamic_state.base,
- type,
- texture_unit,
- target,
- context_ptr,
- is_sviewinfo,
- lod_property,
- explicit_lod,
- sizes_out);
+ params);
}
struct lp_build_sampler_soa *
-swr_sampler_soa_create(const struct swr_sampler_static_state *static_state)
+swr_sampler_soa_create(const struct swr_sampler_static_state *static_state,
+ enum pipe_shader_type shader_type)
{
struct swr_sampler_soa *sampler;
sampler->dynamic_state.static_state = static_state;
+ sampler->dynamic_state.shader_type = shader_type;
+
return &sampler->base;
}