Skip to content

Commit 73210e1

Browse files
committed
fix ao.cu
1 parent 767ad98 commit 73210e1

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

samples/aobench/ao.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#define FUNCTION
77
#endif
88

9-
FUNCTION static unsigned int FNVHash(char* str, unsigned int length) {
9+
FUNCTION unsigned int FNVHash(char* str, unsigned int length) {
1010
const unsigned int fnv_prime = 0x811C9DC5;
1111
unsigned int hash = 0;
1212
unsigned int i = 0;
@@ -20,31 +20,31 @@ FUNCTION static unsigned int FNVHash(char* str, unsigned int length) {
2020
return hash;
2121
}
2222

23-
FUNCTION static unsigned int nrand(unsigned int* rng) {
23+
FUNCTION unsigned int nrand(unsigned int* rng) {
2424
unsigned int orand = *rng;
2525
*rng = FNVHash((char*) &orand, 4);
2626
return *rng;
2727
}
2828

29-
FUNCTION static Scalar drand48(Ctx* ctx) {
29+
FUNCTION Scalar drand48(Ctx* ctx) {
3030
Scalar n = (nrand(&ctx->rng) / 65536.0f);
3131
n = n - floorf(n);
3232
return n;
3333
}
3434

35-
FUNCTION static Scalar vdot(vec v0, vec v1)
35+
FUNCTION Scalar vdot(vec v0, vec v1)
3636
{
3737
return v0.x * v1.x + v0.y * v1.y + v0.z * v1.z;
3838
}
3939

40-
FUNCTION static void vcross(vec *c, vec v0, vec v1)
40+
FUNCTION void vcross(vec *c, vec v0, vec v1)
4141
{
4242
c->x = v0.y * v1.z - v0.z * v1.y;
4343
c->y = v0.z * v1.x - v0.x * v1.z;
4444
c->z = v0.x * v1.y - v0.y * v1.x;
4545
}
4646

47-
FUNCTION static void vnormalize(vec *c)
47+
FUNCTION void vnormalize(vec *c)
4848
{
4949
Scalar length = sqrtf(vdot((*c), (*c)));
5050

@@ -55,7 +55,7 @@ FUNCTION static void vnormalize(vec *c)
5555
}
5656
}
5757

58-
FUNCTION static void
58+
FUNCTION void
5959
ray_sphere_intersect(Isect *isect, const Ray *ray, const Sphere *sphere)
6060
{
6161
vec rs = { 0 };
@@ -88,7 +88,7 @@ ray_sphere_intersect(Isect *isect, const Ray *ray, const Sphere *sphere)
8888
}
8989
}
9090

91-
FUNCTION static void
91+
FUNCTION void
9292
ray_plane_intersect(Isect *isect, const Ray *ray, const Plane *plane)
9393
{
9494
Scalar d = -vdot(plane->p, plane->n);
@@ -110,7 +110,7 @@ ray_plane_intersect(Isect *isect, const Ray *ray, const Plane *plane)
110110
}
111111
}
112112

113-
FUNCTION static void
113+
FUNCTION void
114114
orthoBasis(vec *basis, vec n)
115115
{
116116
basis[2] = n;
@@ -133,7 +133,7 @@ orthoBasis(vec *basis, vec n)
133133
vnormalize(&basis[1]);
134134
}
135135

136-
FUNCTION static void ambient_occlusion(Ctx* ctx, vec *col, const Isect *isect)
136+
FUNCTION void ambient_occlusion(Ctx* ctx, vec *col, const Isect *isect)
137137
{
138138
int i, j;
139139
int ntheta = NAO_SAMPLES;
@@ -193,7 +193,7 @@ FUNCTION static void ambient_occlusion(Ctx* ctx, vec *col, const Isect *isect)
193193
col->z = occlusion;
194194
}
195195

196-
FUNCTION static unsigned char aobench_clamp(Scalar f)
196+
FUNCTION unsigned char aobench_clamp(Scalar f)
197197
{
198198
Scalar s = (f * 255.5f);
199199

samples/aobench/ao.cu

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
#define EXTERNAL_FN static inline __device__ __attribute__((always_inline))
2-
#define FUNCTION static inline __device__ __attribute__((always_inline))
1+
// #define EXTERNAL_FN static inline __device__ __attribute__((always_inline))
2+
// #define FUNCTION static inline __device__ __attribute__((always_inline))
3+
4+
#define EXTERNAL_FN static __device__
5+
#define FUNCTION static __device__
36

47
#include "ao.c"
58

69
extern "C" {
710

8-
__global__ void aobench_kernel(unsigned TEXEL_T* out) {
11+
__global__ void aobench_kernel(TEXEL_T* out) {
912
int x = threadIdx.x + blockDim.x * blockIdx.x;
1013
int y = threadIdx.y + blockDim.y * blockIdx.y;
1114

src/shady/emit/spirv/emit_spv_instructions.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,10 @@ static void emit_primop(Emitter* emitter, FnBuilder fn_builder, BBBuilder bb_bui
385385
assert(results_count == 1);
386386
results[0] = result;
387387
} else {
388-
error("TODO: OpPtrAccessChain")
388+
const Type* target_type = instr->type;
389+
SpvId result = spvb_ptr_access_chain(bb_builder, emit_type(emitter, target_type), base, emit_value(emitter, bb_builder, args.nodes[1]), args.count - 2, indices);
390+
assert(results_count == 1);
391+
results[0] = result;
389392
}
390393
return;
391394
}

0 commit comments

Comments
 (0)