Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Updating a texture used in a post-process with data directly from the GPU without a CPU copy.

Hello everyone, I hope this is the right place to ask this question,

I am currently trying to include the Nvidia OptiX framework via a Plugin into Unreal, but I'm a little stuck on executing a performant texture update each frame.

What I am currently (successfully) doing is this:

1) OptiX uses the Unreal camera matrices, traces and renders its output each frame into an full-screen sized (OptiX) buffer on the GPU. 2) Then, I map this output buffer, which consists of FColor values (or float depth values for an additional depth buffer) and update the Unreal Texture2D (in the render thread) via:

 RHICmdList.UpdateTexture2D(OutputTextureColorRef, 0, TextureRegion, Width * 4, (uint8*)OptiXData);

3) The respective textures are used in a post process material and blended over the standard scene each frame. 

All of this works as expected. What surprised me now is that the OptiX full screen trace takes almost less time than the mapping and updating part, especially when using a VR headset.  I am assuming that this is because the data gets copied to the CPU and then straight back into the texture buffer on the GPU again when updating the texture. 

Now, my question is: Can this copy somehow be avoided? I see two possibilities but am completely lost on how viable they actually are:

1) Use the Unreal Texture2D and somehow get a native pointer to the memory on the GPU, and tell OptiX to write its output into this memory. Is the former part even possible here?  2) Copy the data in the OptiX buffer directly into the memory of the Texture2D without going through a CPU copy. OptiX has no direct interoperability with DirectX textures, but CUDA can be used as a bridge here. Is it possible to directly update the underlying resource of an Unreal Texture2D here? 

My knowledge about GPU Memory Management and how Unreal does it is sadly very limited - I would be really glad if someone here could help me out.  Alternatively I thought about just using the new DXR functionality directly, but the current implementation in Unreal seems to be limited still, especially considering VR devices. 

Thanks in advance,  David

Product Version: UE 4.22
more ▼

asked Apr 23 '19 at 03:36 PM in Rendering

avatar image


(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question