Fix T53289: CUDA missing textures not showing pink, after recent changes.

This commit is contained in:
Brecht Van Lommel 2017-11-12 20:43:40 +01:00
parent ebcb880375
commit e568c1a975
Notes: blender-bot 2023-02-14 06:24:18 +01:00
Referenced by issue #53289, Missing textures renders as black color (cycles)
2 changed files with 9 additions and 3 deletions

View File

@ -908,7 +908,7 @@ public:
cmem->texobject = 0;
cmem->array = array_3d;
}
else if(mem.data_height > 1) {
else if(mem.data_height > 0) {
/* 2D texture, using pitch aligned linear memory. */
int alignment = 0;
cuda_assert(cuDeviceGetAttribute(&alignment, CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT, cuDevice));
@ -962,7 +962,7 @@ public:
resDesc.res.array.hArray = array_3d;
resDesc.flags = 0;
}
else if(mem.data_height > 1) {
else if(mem.data_height > 0) {
resDesc.resType = CU_RESOURCE_TYPE_PITCH2D;
resDesc.res.pitch2D.devPtr = mem.device_pointer;
resDesc.res.pitch2D.format = format;
@ -1012,7 +1012,7 @@ public:
if(array_3d) {
cuda_assert(cuTexRefSetArray(texref, array_3d, CU_TRSA_OVERRIDE_FORMAT));
}
else if(mem.data_height > 1) {
else if(mem.data_height > 0) {
CUDA_ARRAY_DESCRIPTOR array_desc;
array_desc.Format = format;
array_desc.Height = mem.data_height;

View File

@ -723,6 +723,7 @@ void ImageManager::device_load_image(Device *device,
*tex_img))
{
/* on failure to load, we set a 1x1 pixels pink image */
thread_scoped_lock device_lock(device_mutex);
float *pixels = (float*)tex_img->alloc(1, 1);
pixels[0] = TEX_IMAGE_MISSING_R;
@ -748,6 +749,7 @@ void ImageManager::device_load_image(Device *device,
*tex_img))
{
/* on failure to load, we set a 1x1 pixels pink image */
thread_scoped_lock device_lock(device_mutex);
float *pixels = (float*)tex_img->alloc(1, 1);
pixels[0] = TEX_IMAGE_MISSING_R;
@ -770,6 +772,7 @@ void ImageManager::device_load_image(Device *device,
*tex_img))
{
/* on failure to load, we set a 1x1 pixels pink image */
thread_scoped_lock device_lock(device_mutex);
uchar *pixels = (uchar*)tex_img->alloc(1, 1);
pixels[0] = (TEX_IMAGE_MISSING_R * 255);
@ -794,6 +797,7 @@ void ImageManager::device_load_image(Device *device,
texture_limit,
*tex_img)) {
/* on failure to load, we set a 1x1 pixels pink image */
thread_scoped_lock device_lock(device_mutex);
uchar *pixels = (uchar*)tex_img->alloc(1, 1);
pixels[0] = (TEX_IMAGE_MISSING_R * 255);
@ -815,6 +819,7 @@ void ImageManager::device_load_image(Device *device,
texture_limit,
*tex_img)) {
/* on failure to load, we set a 1x1 pixels pink image */
thread_scoped_lock device_lock(device_mutex);
half *pixels = (half*)tex_img->alloc(1, 1);
pixels[0] = TEX_IMAGE_MISSING_R;
@ -839,6 +844,7 @@ void ImageManager::device_load_image(Device *device,
texture_limit,
*tex_img)) {
/* on failure to load, we set a 1x1 pixels pink image */
thread_scoped_lock device_lock(device_mutex);
half *pixels = (half*)tex_img->alloc(1, 1);
pixels[0] = TEX_IMAGE_MISSING_R;