diff --git a/modules/cpu/fb/LocalFB.cpp b/modules/cpu/fb/LocalFB.cpp index 888f99e4b..2dfd017e9 100644 --- a/modules/cpu/fb/LocalFB.cpp +++ b/modules/cpu/fb/LocalFB.cpp @@ -114,7 +114,7 @@ LocalFrameBuffer::LocalFrameBuffer(api::ISPCDevice &device, device.getDRTDevice(), numPixels); // Create color conversion FrameOp if needed - if ((hasColorBuffer) && (getColorBufferFormat() != OSP_FB_RGBA32F)) { + if (hasColorBuffer) { FrameBufferView fbv(getNumPixels(), colorBuffer->devicePtr()); colorConversionFrameOp = rkcommon::make_unique( device.getDRTDevice(), fbv, getColorBufferFormat()); @@ -221,12 +221,8 @@ void LocalFrameBuffer::commit() } } - // Create color conversion FrameOp if needed - colorConversionFrameOp.reset(); - if (getColorBufferFormat() != OSP_FB_RGBA32F) { - colorConversionFrameOp = rkcommon::make_unique( - device.getDRTDevice(), fbv, getColorBufferFormat()); - } + colorConversionFrameOp = rkcommon::make_unique( + device.getDRTDevice(), fbv, getColorBufferFormat()); } vec2i LocalFrameBuffer::getNumRenderTasks() const diff --git a/modules/cpu/fb/frame_ops/ColorConversion.ispc b/modules/cpu/fb/frame_ops/ColorConversion.ispc index 4a13b0fd2..a0818ba77 100644 --- a/modules/cpu/fb/frame_ops/ColorConversion.ispc +++ b/modules/cpu/fb/frame_ops/ColorConversion.ispc @@ -14,7 +14,7 @@ inline void ColorConversion_kernel( const LiveColorConversion *uniform self = (const LiveColorConversion *uniform)fbvSelf; const uint32 i = itemIndex.y * fbvSelf->viewDims.x + itemIndex.x; - vec4f v = fbvSelf->colorBufferInput[i]; + const vec4f v = fbvSelf->colorBufferInput[i]; switch (self->targetColorFormat) { case OSP_FB_RGBA8: { uint32 *uniform typedCB = (uint32 * uniform) self->convBuffer; @@ -25,7 +25,9 @@ inline void ColorConversion_kernel( typedCB[i] = linear_to_srgba8(v); } break; case OSP_FB_RGBA32F: { - // Should never get here + vec4f *uniform typedCB = (vec4f * uniform) self->convBuffer; + const vec4f vc = max(v, make_vec4f(0.f)); + typedCB[i] = make_vec4f(vc.x, vc.y, vc.z, min(vc.w, 1.f)); } break; default: // Should never get here