Ok, thanks for the link, I’ll jhave a look at it.
Let me clarify the problem i have / what I’m trying to do:
I want to access the buffer which contains the color pixels in a format [R][G][B][A] arranged as 8bits each or so, for further use with NDI.
I got the NDI part working, this is out of the scope of this question, but retrieving the data from the GPU in NAP is causing me problems.
I’m not very familiar with Vulkan, and the issue might be coming from that, 
I’ve got a video player working-project called VideoPlayer
-, of which i want to access the texture as a uint8_t* buffer.
The RenderTexture2D
I’m using (called VideoColorTexture
) is as follow :
The OutputTexture
of my RenderVideoComponent
is what I am trying to process to get the buffer on the CPU.
I have made a mini class to explain where I’m at:
class NapSender {
public:
NapSender()
{
}
void SendImage(Texture2D& tex) {
VkFormat fmt = tex.getFormat();
if (fmt != 0) {
const SurfaceDescriptor desc = tex.getDescriptor();
int w = tex.getWidth();
int h = tex.getHeight();
tex.asyncGetData(std::bind(&NapSender::onTextureCallback, this, _1, _2, w, h, desc));
}
}
void onTextureCallback(const void* data, size_t sizeByte, int w, int h, const SurfaceDescriptor desc) {
// empty buffer here
uint8_t* tmp = (uint8_t*)data;
}
};
I’m calling SendImage
inside the update method of VideoPlayer
by doing :
void VideoPlayerApp::update(double deltaTime)
{
// Use a default input router to forward input events (recursively) to all input components in the default scene
nap::DefaultInputRouter input_router(true);
mInputService->processWindowEvents(*mRenderWindow, input_router, { &mScene->getRootEntity() });
napSender->SendImage(mVideoEntity->getComponent<RenderToTextureComponentInstance>().getOutputTexture());
}
After waiting for the video player to start playing (1 or 2 seconds), I set a point break inside my method called back by `asyncGetData`, and this is what I'm getting:
When setting my breakpoint after the callback, and inspecting the
uint8_t*
tmp
, it is empty…
As you can see the texture descriptor is filled up with stuff, so seems right.
Hope this explains the problem better.
I’m not sure what I’m doing wrong to get the uint8_t* to fill up with content.
I have looked at the snapshot method pointed above : void Snapshot::snap(PerspCameraComponentInstance& camera, std::function<void(nap::SnapshotRenderTarget&)> renderCallback)
The callback transforms the const void*
straight into (uint8*)
no problem it seems here, this is why I was asking for clarifications as it seems straight forward, :).
Will study it more ( recompile snapshot in debugf maybe so i can see the steps in detail) as I must have missed something.
Thanks for your help so far,
Best,
P