cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

kos
Journeyman III

Memory model problem

I have a kernel :

"il_ps_2_0\n"
"dcl_cb cb0[1]\n"
"dcl_input_interp(linear) v0.xy\n"
"dcl_output_generic o0.x___\n"
"dcl_resource_id(0)_type(2d)_fmtx(float)_fmty(float)_fmtz(float)_fmtw(float)\n"
"dcl_resource_id(1)_type(2d)_fmtx(float)_fmty(float)_fmtz(float)_fmtw(float)\n"
"dcl_literal l0, 0x00000000, 0x00000000, 0x00000000, 0x00000000\n"
"dcl_literal l1, 0x3F800000, 0x3F800000, 0x3F800000, 0x3F800000\n"

//l2==128
"dcl_literal l2, 0x43000000, 0x43000000, 0x00000000, 0x00000000\n"
"dcl_literal l3, 0x3F000000, 0x3F000000, 0x00000000, 0x00000000\n"
"mov r0.__zw, l0\n"
"sub r2.x, v0.x, l3\n"//making normal thread number
"mad r2.z, r2.x , l2.x, r0.w"//making normal memory pointer
"sample_resource(0)_sampler(0) r0.xy__, r2.z\n"
"sample_resource(1)_sampler(0) r2.y, r0.y\n"
"mad_ieee r0.__z_, r0.x, r2.y, r0.z\n"
"mov o0.x___, r0.z\n"
"ret_dyn\n"
"end\n";

Memory pointers are ok, and data on resource  0 looks like this

for each thread(128 at all):

N0(12, 1 ) ... N63(12,1)  N64(32,1).... N127(32,1)

but result  looks like in is for first thread N0(12,1) and all another (32,1)

So I don't know why it samples another values

0 Likes
6 Replies
gaurav_garg
Adept I

When you declare resources like this-
dcl_resource_id(0)_type(2d)_fmtx(float)_fmty(float)_fmtz(float)_fmtw(float)

Sampling is expected to be done using a normalized co-ordinate(x/width, y/height). If you want to use un-normalized co-ordinates, declare resources with unnorm keyword.
dcl_resource_id(0)_type(2d, unnorm)_fmtx(float)_fmty(float)_fmtz(float)_fmtw(float)

0 Likes

Thank you.

I don't know why but that doesn't helps.

0 Likes
kos
Journeyman III

This kernel returns only 0 - which isn't right.

"il_ps_2_0\n"
"dcl_input_interp(linear) v0.xy\n"
"dcl_output_generic o0.x___\n"
"dcl_resource_id(0)_type(2d,unnorm)_fmtx(float)_fmty(float)_fmtz(float)_fmtw(float)\n"
"dcl_literal l0, 0x00000000, 0x00000000, 0x00000000, 0x00000000\n"
"dcl_literal l2, 0x43000000, 0x41000000, 0x41000000, 0x41000000\n"
"mov r2.zw, l2\n"//just a joke
"sample_resource(0)_sampler(0) r0.xy__, r2.zw\n"
"mov o0.x___, r0.x\n"
"ret_dyn\n"
"end\n";

0 Likes

Hint: you are sampling at location r2.zw.

Originally posted by: kos

"sample_resource(0)_sampler(0) r0.xy__, r2.zw\n"

0 Likes

I know.

 

0 Likes
kos
Journeyman III

O, I'm sorry I've found and solved problem. That was the domain size.

0 Likes