interactive drawing with binary brush into 3d texture, best approach advice wanted

Hi,
I have a 3d texture of a dataset that the user can explore with arbitrarily positioned slice cuts in several viewports. I want to enable user drawing of regions of interest using a binary brush navigated by the mouse cursor (“freehand painting”). I would like the brush to have 3 dimensions
In terms of data structures there will be two textures: the image itself and the mask drawn by the user. Both are 3d textures.
I have the texture coordinates where I want to draw into, that part is sorted. What is the best way to interactively “edit” a 3d texture?
The way is see it I need to read the area affected by the brush back to the CPU and OR it with the brush and then send it back with texturesubbuffer.
Naturally there will be some overhead in this back and forth, but is there an alternative? Is there a way to manually update the texture (we are talking a 3d section of it, so drawing to it seems tedious).
Ideally I would OR a GPU based brush with the mask texture and then draw to screen. Do I need to look at compute shaders?

Thanks

I don;t quite understand what you are trying to do but if you think it can be solved with OR/XOR type function you can do these with the glBlend/glBlendequation/glBlendFunc functions

Thanks for the suggestion. My understanding is that these function determine the blending applied upon rendering. I would like to change the texture without rendering - because I am just changing a small number of pixels in 3D each time - I would have to render multiple times to just update the texture. I think it would have to be something like extracting the paint brush area to the GPU, then OR with the brush, then back to the GPU. Then finally render the planes of the texture that are currently visible.
At the moment I think I am looking for a functional GlGetTexSubImage - which does not exist unfortunately. I am still hoping there is a way to do this entirely on the GPU.

you can create glGetTextureImage from glBufferSubData

extracting the paint brush area to the GPU, then OR with the brush, then back to the GPU.

This can be done by using 2 frame buffers. Render to one, toggle to other, blit old buffer to new, use glBufferSubData to get the data from the brush area, modify, blit to new buffer

This is not 3D of course it just look likeit.

Thanks again.
After some thought I figured maybe doing it on the GPU wasn’t worth it - at least not without compute shaders. As you suggest you can do this calculation by rendering, but this is really a rather indirect solution to something that is that is a simple AND of two arrays. I also thought of using GImage which apparently also can modify a texture, but I ended up concluding that performing a basic operation on a 3D section of a 3D texture does not lend itself easily to shader programs triggered by rendering (compute shader different story I guess). So in stead I now keep my paint mask on the CPU, modify it here and transfer just the small section that changed to the GPU - this seems to work well.
.