Unexpected results from calling Texture.get_ram_image()

I’m creating a texture like:

self.tex = Texture()
self.tex.setup_1d_texture(1000000, Texture.T_unsigned_int, Texture.F_r32i)


1-d, 1000000 pixels, each 1 ints, r32i
sampler wrap(u=repeat, v=repeat, w=repeat, border=0 0 0 1) filter(min=default, mag=default, aniso=0) lod(min=-1000, max=1000, bias=0) no ram image

However, when I try to read the texture (after rendering to it) with this code:

if self.graphics_engine.extract_texture_data(self.tex, gsg):
       texels = np.asarray(memoryview(self.tex.get_ram_image()).cast("I"))
       print('texels: ', texels.shape)

I get the following output:

texels: (31250,)

Why am I getting 31250 texels, and not 1000000?

Thanks for any clarification.

How exactly are you rendering to it? If the GPU has a certain limit on texture size, and Panda adjusts it based on that, then that could explain this. What’s the value of base.win.gsg.max_texture_dimension?

I am not sure about 31250, but 32768 is a common value for GL_MAX_TEXTURE_SIZE:

Buffer textures have a much greater size limit, but can’t be used with render-to-texture directly; though you can write to them from a shader using imageStore().


Perfect! I am new to shader programming, etc, so I wasn’t aware of the difference between a ‘regular’ texture and a buffer texture. I am writing to it using imageAtomicOr so a buffer texture works perfectly.

Could you recommend any good resources (besides the GLSL docs) that discuss programmable shaders and the difference(s) between ‘regular’ textures and buffer textures, etc?