Skip to content

Commit 25ba91a

Browse files
committed
fix textures on LLVM14
1 parent 19b16ff commit 25ba91a

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

src/frontends/llvm/l2s_type.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,6 @@ const Type* convert_type(Parser* p, LLVMTypeRef t) {
4949
Node* decl = NULL;
5050
const Node* result = NULL;
5151
if (name) {
52-
if (strcmp(name, "struct.__shady_builtin_sampler2D") == 0)
53-
return sampled_image_type(a, (SampledImageType) { .image_type = image_type(a, (ImageType) {
54-
//.sampled_type = pack_type(a, (PackType) { .element_type = float_type(a, (Float) { .width = FloatTy32 }), .width = 4 }),
55-
.sampled_type = float_type(a, (Float) { .width = FloatTy32 }),
56-
.dim = 1,
57-
.depth = 0,
58-
.arrayed = 0,
59-
.ms = 0,
60-
.sampled = 1,
61-
.imageformat = 0
62-
} ) });
63-
6452
decl = nominal_type(p->dst, empty(a), name);
6553
result = type_decl_ref_helper(a, decl);
6654
insert_dict(LLVMTypeRef, const Type*, p->map, t, result);
@@ -89,7 +77,21 @@ const Type* convert_type(Parser* p, LLVMTypeRef t) {
8977
return arr_type(a, (ArrType) { .element_type = elem_t, .size = uint32_literal(a, length)});
9078
}
9179
case LLVMPointerTypeKind: {
92-
AddressSpace as = convert_llvm_address_space(LLVMGetPointerAddressSpace(t));
80+
unsigned int llvm_as = LLVMGetPointerAddressSpace(t);
81+
switch (llvm_as) {
82+
case 0x1000: return sampled_image_type(a, (SampledImageType) { .image_type = image_type(a, (ImageType) {
83+
//.sampled_type = pack_type(a, (PackType) { .element_type = float_type(a, (Float) { .width = FloatTy32 }), .width = 4 }),
84+
.sampled_type = float_type(a, (Float) { .width = FloatTy32 }),
85+
.dim = 1,
86+
.depth = 0,
87+
.arrayed = 0,
88+
.ms = 0,
89+
.sampled = 1,
90+
.imageformat = 0
91+
} ) });
92+
default: break;
93+
}
94+
AddressSpace as = convert_llvm_address_space(llvm_as);
9395
const Type* pointee = NULL;
9496
#if !UNTYPED_POINTERS
9597
LLVMTypeRef element_type = LLVMGetElementType(t);

src/frontends/llvm/l2s_value.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ const Node* convert_value(Parser* p, LLVMValueRef v) {
130130
return get_default_zero_value(a, convert_type(p, LLVMTypeOf(v)));
131131
case LLVMConstantArrayValueKind: {
132132
assert(t->tag == ArrType_TAG);
133+
assert(LLVMIsConstant(v));
133134
if (LLVMIsConstantString(v)) {
134135
size_t idc;
135136
r = string_lit_helper(a, LLVMGetAsString(v, &idc));

src/shady/internal/scheduler.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@Internal var logical subgroup TreeNode active_branch;
2020

2121
@Internal @Builtin("SubgroupLocalInvocationId")
22-
var logical input u32 subgroup_local_id;
22+
var input u32 subgroup_local_id;
2323

2424
@Internal @Leaf
2525
fn builtin_init_scheduler() {

test/vcc/textured.frag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <stdint.h>
22
#include <shady.h>
33

4-
descriptor_set(0) descriptor_binding(1) uniform sampler2D texSampler;
4+
descriptor_set(0) descriptor_binding(1) uniform_constant sampler2D texSampler;
55

66
location(0) input vec3 fragColor;
77
location(1) input vec2 fragTexCoord;

vcc-std/include/shady.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,16 @@ namespace vcc {
2121
#define input __attribute__((address_space(389)))
2222
#define output __attribute__((address_space(390)))
2323
// maybe deprecate it ?
24-
#define uniform __attribute__((annotate("shady::uniform")))
2524
#define uniform_constant __attribute__((address_space(398)))
2625
#define uniform_block __attribute__((address_space(395)))
2726
#define push_constant __attribute__((address_space(392)))
2827
#define global __attribute__((address_space(1)))
2928
#define shared __attribute__((address_space(3)))
3029
#define private __attribute__((address_space(5)))
31-
#define private_logical __attribute__((address_space(385)))
3230

3331
#include "shady_vec.h"
3432

35-
typedef struct __shady_builtin_sampler2D {} sampler2D;
33+
typedef __attribute__((address_space(0x1000))) struct __shady_builtin_sampler2D* sampler2D;
3634

3735
vec4 texture2D(const sampler2D, native_vec2) __asm__("shady::prim_op::sample_texture");
3836

0 commit comments

Comments
 (0)