switch (deref->mode) {
case nir_var_shader_out:
+ if (ctx->stage == MESA_SHADER_VERTEX && var->data.location == VARYING_SLOT_POS) {
+
+ LLVMValueRef vertexCache = LLVMGetParam(ctx->main_function, 2);
+ LLVMValueRef idx[3];
+
+ idx[0] = LLVMConstInt(ctx->lc.i32, 0, false);
+ idx[1] = LLVMConstInt(ctx->lc.i32, 0, false);
+ LLVMValueRef outPos = LLVMConstInBoundsGEP(vertexCache,
+ idx,
+ 2);
+ LLVMBuildStore(ctx->lc.builder, src, outPos);
+ break;
+ }
+ if (ctx->stage == MESA_SHADER_FRAGMENT && var->data.location == FRAG_RESULT_DATA0) {
+
+ LLVMValueRef outColor = LLVMGetParam(ctx->main_function, 4);
+ // LLVMValueRef idx[3];
+
+ // idx[0] = LLVMConstInt(ctx->lc.i32, 0, false);
+ // idx[1] = LLVMConstInt(ctx->lc.i32, 0, false);
+ // LLVMValueRef outPos = LLVMConstInBoundsGEP(vertexCache,
+ // idx,
+ // 2);
+ LLVMBuildStore(ctx->lc.builder, src, outColor);
+ break;
+ }
/* TODO: remove this after RADV switches to lowered IO */
// if (ctx->stage == MESA_SHADER_TESS_CTRL) {
// LLVMValueRef vertex_index = NULL;
// result = ctx->abi->load_local_group_size(ctx->abi);
break;
case nir_intrinsic_load_vertex_id:
- result = LLVMBuildAdd(ctx->lc.builder, LLVMGetParam(ctx->main_function, ctx->args.vertex_id.arg_index),
- LLVMGetParam(ctx->main_function, ctx->args.base_vertex.arg_index), "");
+ result = LLVMGetParam(ctx->main_function, 1);
+ // result = LLVMBuildAdd(ctx->lc.builder, LLVMGetParam(ctx->main_function, ctx->args.vertex_id.arg_index),
+ // LLVMGetParam(ctx->main_function, ctx->args.base_vertex.arg_index), "");
break;
case nir_intrinsic_load_vertex_id_zero_base: {
// result = ctx->abi->vertex_id;
arg_types[i] = arg_llvm_type(ctx.args.args[i].type, ctx.args.args[i].size, &ctx.lc);
}
- //TODO: this is zero argument function and returns void
- LLVMTypeRef main_function_type = LLVMFunctionType(ret_type, arg_types, ctx.args.arg_count, 0);
-
+ LLVMTypeRef main_function_type;
+ if(nir->info.stage == MESA_SHADER_VERTEX) {
+ LLVMTypeRef arg_types[32];
+ LLVMTypeRef floatType = LLVMFloatTypeInContext(llvm_ref->lc.context);
+ LLVMTypeRef float4 = LLVMVectorType(floatType, 4);
+ LLVMTypeRef f4arrayType = LLVMArrayType(float4, 10);
+ arg_types[0] = float4;
+ arg_types[1] = f4arrayType;
+ LLVMTypeRef vertexCacheType = LLVMStructTypeInContext(llvm_ref->lc.context, arg_types, 2, false);
+ LLVMTypeRef gpuStatePtrType = LLVMPointerType(LLVMStructCreateNamed(llvm_ref->lc.context, "GPUState"), 0);
+ arg_types[0] = gpuStatePtrType;
+ arg_types[1] = LLVMIntTypeInContext(llvm_ref->lc.context, 32);
+ arg_types[2] = LLVMPointerType(vertexCacheType, 0);
+ main_function_type = LLVMFunctionType(ret_type, arg_types, 3, 0);
+ } else {
+
+ LLVMTypeRef floatType = LLVMFloatTypeInContext(llvm_ref->lc.context);
+ LLVMTypeRef float4 = LLVMVectorType(floatType, 4);
+ LLVMTypeRef f4arrayType = LLVMArrayType(float4, 10);
+ arg_types[0] = float4;
+ arg_types[1] = f4arrayType;
+ LLVMTypeRef vertexCacheType = LLVMStructTypeInContext(llvm_ref->lc.context, arg_types, 2, false);
+ arg_types[3] = LLVMPointerType(vertexCacheType, 0);
+ LLVMTypeRef gpuStatePtrType = LLVMPointerType(LLVMStructCreateNamed(llvm_ref->lc.context, "GPUState"), 0);
+ arg_types[0] = gpuStatePtrType;
+ arg_types[1] = LLVMFloatTypeInContext(llvm_ref->lc.context);
+ arg_types[2] = LLVMPointerType(float4, 0);
+ arg_types[4] = LLVMPointerType(float4, 0);
+ main_function_type = LLVMFunctionType(ret_type, arg_types, 3, 0);
+ //TODO: this is zero argument function and returns void
+ main_function_type = LLVMFunctionType(ret_type, arg_types, 5, 0);
+ }
LLVMValueRef main_function = LLVMAddFunction(mod, gl_shader_stage_name(nir->info.stage), main_function_type);
LLVMBasicBlockRef main_function_body =
LLVMAppendBasicBlockInContext(ctx.lc.context, main_function, "main_body");