У меня есть 2 экземпляра этого класса, и они оба рисуют на своей отдельной поверхности. Мне нужно иметь возможность обнаружить перекрытие двух чертежей - и когда обнаружено перекрытие, перекрываемая область будет белой.
Код: Выделить всё
void A::share_texture_resource()
{
// Creating the OpenGL texture object
err = cudaGraphicsGLRegisterImage(&texture_mem,
m_nSharedTextureID,
GL_TEXTURE_2D,
cudaGraphicsRegisterFlagsNone);
CHECK_CUDA_ERROR(err);
struct cudaResourceDesc desc;
std::memset(&desc, 0, sizeof(desc));
desc.resType = cudaResourceTypeArray;
// Map graphics resources for access by CUDA.
err = cudaGraphicsMapResources(1, &texture_mem, 0);
CHECK_CUDA_ERROR(err);
// Get an array through which to access a subresource of a mapped graphics resource
err = cudaGraphicsSubResourceGetMappedArray(&desc.res.array.array, texture_mem, 0, 0);
CHECK_CUDA_ERROR(err);
// Creating the CUDA surface object to which we will be drawing in the .cu kernel
err = cudaCreateSurfaceObject(&m_tex_surface, &desc);
CHECK_CUDA_ERROR(err);
// Unmapping of the graphics resources
err = cudaGraphicsUnmapResources(1, &texture_mem, 0);
CHECK_CUDA_ERROR(err);
// Creating the CUDA stream
err = cudaStreamCreateWithFlags(&m_stream, cudaStreamNonBlocking);
CHECK_CUDA_ERROR(err);
}
< /code>
texture_mem is a cudaGraphicsResource_tКод: Выделить всё
surf2DwriteКод: Выделить всё
uchar4 currentIndexColor;
cudaSurfaceObject_t surfaceValue = other_object_surface;
surf2Dread(¤tIndexColor, other_object_surface, index * sizeof(uchar4), i);
if(currentIndexColor.w > 0)
{
colorToDraw = make_uchar4(255, 255, 255, 255);
}
< /code>
other_object_surfaceПо сути, я не могу выяснить, как получить доступ ранее на поверхности из одного ядра к другому, и я ищу решение.
будет оценена.>
Подробнее здесь: https://stackoverflow.com/questions/795 ... f-surf2dre
Мобильная версия