3D Textures support on all backends?
-
Hello,
I'm developing a 3D image volume renderer using the RHI framework. I'm using Qt 6.9.3. Using the OpenGL backend, everything is fine: the 3D image is visible and the shader performs as expected.
Unfortunately, on any of the other backends (Vulkan, D3D, Metal), the image is not visible. The shader seems to work, except that it samples always returns vec4(0,0,0,0) (so nothing is shown on the screen). This makes me think that the image is not uploaded correctly, but I don't know what the problem could be. This is my upload code:const uint8_t* base = data.data(); QRhiTextureUploadDescription desc; std::vector<QRhiTextureUploadEntry> entries(slices); for (int z = 0; z < slices; ++z) { const uint8_t* slicePtr = base + qint64(z) * (sliceSize); QRhiTextureSubresourceUploadDescription subRes = { slicePtr, (quint32) sliceSize }; entries[z] = { z, 0, subRes }; } desc.setEntries(entries.begin(), entries.end()); u->uploadTexture(texture.get(), desc);The data is an std::vector<uint8_t> that holds the image data. My main test image is a 100x100x100 8-bit grayscale image. I'm using the QRhiTexture::Format::R8 format. I've verified that all the relevant features (R8, ThreeDimensionalTexture) are supported on the other backends, so I'm quite puzzled why it only works for OpenGL.
I would appreciate it if anyone can provide some insight.
Thanks in advance! -
First I'd suggest trying a more recent version of Qt and if that does not help then post the full code here or make a small reproducer to narrow down the issue.
-
This post is deleted!
-
Sorry took me a while to get back to this. I found the error and it turns out I did not use consistent uniform bindings between my vertex and fragment shader, you know, one of those ID-10-T errors :). Interestingly, OpenGL didn't seem to care and worked fine regardless.
Anyways, the volume rendering is now working on all backends. -
F febiodeveloper has marked this topic as solved