mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-04-14 13:21:43 +00:00
[qfcc] Use a tagged pointer for __imageTexel()
It seems it should return an Image storage class pointer. Validation still fails because of the ptr local var (not allowed by default) and so needs to be an SSA temp, but I'm having a little trouble with *that*.
This commit is contained in:
parent
cdfc6bc704
commit
f08faee2ed
4 changed files with 21 additions and 6 deletions
|
@ -119,7 +119,7 @@ tf_field_func (progs_t *pr, void *data)
|
|||
auto ctx = *(typectx_t **) data;
|
||||
unsigned id = P_UINT (pr, 0);
|
||||
auto type = fetch_type (id, ctx);
|
||||
type = pointer_type (type);
|
||||
type = field_type (type);
|
||||
type = find_type (type);
|
||||
R_UINT (pr) = type->id;
|
||||
}
|
||||
|
@ -129,8 +129,9 @@ tf_pointer_func (progs_t *pr, void *data)
|
|||
{
|
||||
auto ctx = *(typectx_t **) data;
|
||||
unsigned id = P_UINT (pr, 0);
|
||||
unsigned tag = P_UINT (pr, 1);
|
||||
auto type = fetch_type (id, ctx);
|
||||
type = pointer_type (type);
|
||||
type = tagged_pointer_type (tag, type);
|
||||
type = find_type (type);
|
||||
R_UINT (pr) = type->id;
|
||||
}
|
||||
|
|
|
@ -320,7 +320,12 @@ static const type_t *
|
|||
resolve_pointer (int arg_count, const expr_t **args, rua_ctx_t *ctx)
|
||||
{
|
||||
auto type = resolve_type (args[0], ctx);
|
||||
type = pointer_type (type);
|
||||
if (arg_count > 1) {
|
||||
unsigned tag = expr_integral (args[1]);
|
||||
type = tagged_pointer_type (tag, type);
|
||||
} else {
|
||||
type = pointer_type (type);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
|
@ -585,7 +590,12 @@ compute_pointer (int arg_count, const expr_t **args, comp_ctx_t *ctx)
|
|||
{
|
||||
auto type = compute_type (args[0], ctx);
|
||||
auto res = compute_tmp (ctx);
|
||||
def_t *tag = nullptr;
|
||||
if (arg_count > 1) {
|
||||
tag = compute_val (args[1], ctx);
|
||||
}
|
||||
C (OP_STORE_A_1, ctx->args[0], nullptr, type);
|
||||
C (OP_STORE_A_1, ctx->args[1], nullptr, tag);
|
||||
C (OP_CALL_B, ctx->funcs[tf_pointer], nullptr, res);
|
||||
return res;
|
||||
}
|
||||
|
@ -730,7 +740,7 @@ static type_func_t type_funcs[] = {
|
|||
},
|
||||
[QC_AT_POINTER] = {
|
||||
.name = "@pointer",
|
||||
.check_params = single_type,
|
||||
.check_params = single_type_opt_int,
|
||||
.resolve = resolve_pointer,
|
||||
.compute = compute_pointer,
|
||||
},
|
||||
|
|
|
@ -1222,8 +1222,8 @@ SRC_LINE
|
|||
"gvec4MS imageLoad(readonly IMAGE_PARAMS_MS) = " SPV(OpImageRead) ";" "\n"
|
||||
"void imageStore(writeonly IMAGE_PARAMS, gvec4 data) = " SPV(OpImageWrite) ";" "\n"
|
||||
"void imageStore(writeonly IMAGE_PARAMS_MS, gvec4MS data) = " SPV(OpImageWrite) ";" "\n"
|
||||
"@pointer(gimage.sample_type) __imageTexel(IMAGE_PARAMS, int sample) = " SPV(OpImageTexelPointer) ";" "\n"
|
||||
"@pointer(gimageMS.sample_type) __imageTexel(IMAGE_PARAMS_MS) = " SPV(OpImageTexelPointer) ";" "\n"
|
||||
"@pointer(gimage.sample_type, StorageClass.Image) __imageTexel(IMAGE_PARAMS, int sample) = " SPV(OpImageTexelPointer) ";" "\n"
|
||||
"@pointer(gimageMS.sample_type, StorageClass.Image) __imageTexel(IMAGE_PARAMS_MS) = " SPV(OpImageTexelPointer) ";" "\n"
|
||||
"#define __imageAtomic(op,type) \\" "\n"
|
||||
"type imageAtomic##op(IMAGE_PARAMS, type data) \\" "\n"
|
||||
"{ \\" "\n"
|
||||
|
|
|
@ -78,6 +78,7 @@
|
|||
#include "tools/qfcc/include/struct.h"
|
||||
#include "tools/qfcc/include/switch.h"
|
||||
#include "tools/qfcc/include/symtab.h"
|
||||
#include "tools/qfcc/include/target.h"
|
||||
#include "tools/qfcc/include/type.h"
|
||||
#include "tools/qfcc/include/value.h"
|
||||
|
||||
|
@ -336,6 +337,9 @@ generic_spec (rua_ctx_t *ctx)
|
|||
.is_generic = true,
|
||||
};
|
||||
generic_symtab = spec.symtab;
|
||||
if (current_target.setup_intrinsic_symtab) {
|
||||
current_target.setup_intrinsic_symtab (generic_symtab);
|
||||
}
|
||||
return spec;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue