Skip to content

Commit

Permalink
Rectify float FB (clamp alpha)
Browse files Browse the repository at this point in the history
  • Loading branch information
johguenther committed Oct 10, 2024
1 parent f982427 commit 675c216
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 3 additions & 7 deletions modules/cpu/fb/LocalFB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<LiveColorConversionFrameOp>(
device.getDRTDevice(), fbv, getColorBufferFormat());
Expand Down Expand Up @@ -221,12 +221,8 @@ void LocalFrameBuffer::commit()
}
}

// Create color conversion FrameOp if needed
colorConversionFrameOp.reset();
if (getColorBufferFormat() != OSP_FB_RGBA32F) {
colorConversionFrameOp = rkcommon::make_unique<LiveColorConversionFrameOp>(
device.getDRTDevice(), fbv, getColorBufferFormat());
}
colorConversionFrameOp = rkcommon::make_unique<LiveColorConversionFrameOp>(
device.getDRTDevice(), fbv, getColorBufferFormat());
}

vec2i LocalFrameBuffer::getNumRenderTasks() const
Expand Down
6 changes: 4 additions & 2 deletions modules/cpu/fb/frame_ops/ColorConversion.ispc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 675c216

Please sign in to comment.