void GLDriver::decafClearColor(const pm4::DecafClearColor &data) { float colors[] = { data.red, data.green, data.blue, data.alpha }; // Find our colorbuffer to clear auto cb_color_base = bit_cast<latte::CB_COLORN_BASE>(data.bufferAddr); auto buffer = getColorBuffer(cb_color_base, data.cb_color_size, data.cb_color_info); // Bind color buffer gl::glNamedFramebufferTexture(mColorClearFrameBuffer, gl::GL_COLOR_ATTACHMENT0, buffer->object, 0); // Check color frame buffer is complete auto status = gl::glCheckNamedFramebufferStatus(mColorClearFrameBuffer, gl::GL_DRAW_FRAMEBUFFER); if (status != gl::GL_FRAMEBUFFER_COMPLETE) { gLog->warn("Skipping clear with invalid color buffer, status {}.", status); return; } // Clear color buffer gl::glDisable(gl::GL_SCISSOR_TEST); gl::glClearNamedFramebufferfv(mColorClearFrameBuffer, gl::GL_COLOR, 0, colors); gl::glEnable(gl::GL_SCISSOR_TEST); }
void FrameBuffer :: buildMipmaps ( int no ) const { // be sure we're unbound Texture * tex = getColorBuffer ( no ); tex -> bind (); tex -> buildMipmaps (); tex -> unbind (); }
void Driver::decafCopyColorToScan(const latte::pm4::DecafCopyColorToScan &data) { flushPendingDraws(); ColorBufferDesc colorBuffer; colorBuffer.base256b = data.cb_color_base.BASE_256B(); colorBuffer.pitchTileMax = data.cb_color_size.PITCH_TILE_MAX(); colorBuffer.sliceTileMax = data.cb_color_size.SLICE_TILE_MAX(); colorBuffer.format = data.cb_color_info.FORMAT(); colorBuffer.numberType = data.cb_color_info.NUMBER_TYPE(); colorBuffer.arrayMode = data.cb_color_info.ARRAY_MODE(); colorBuffer.sliceStart = 0; colorBuffer.sliceEnd = 1; auto surfaceView = getColorBuffer(colorBuffer); auto surface = surfaceView->surface; SwapChainObject *target = nullptr; if (data.scanTarget == latte::pm4::ScanTarget::TV) { target = mTvSwapChain; } else if (data.scanTarget == latte::pm4::ScanTarget::DRC) { target = mDrcSwapChain; } else { decaf_abort("decafCopyColorToScan called for unknown scanTarget"); } transitionSurface(surface, ResourceUsage::TransferSrc, vk::ImageLayout::eTransferSrcOptimal, { 0, 1 }); // TODO: We actually need to call AVMSetTVScale inside of the SetBuffer functions // and then pass that data all the way down to here so we can scale correctly. auto copyWidth = target->desc.width; auto copyHeight = target->desc.height; if (surface->desc.width < target->desc.width) { copyWidth = surface->desc.width; } if (surface->desc.height < target->desc.height) { copyHeight = surface->desc.height; } vk::ImageBlit blitRegion( vk::ImageSubresourceLayers(vk::ImageAspectFlagBits::eColor, 0, 0, 1), { vk::Offset3D(0, 0, 0), vk::Offset3D(copyWidth, copyHeight, 1) }, vk::ImageSubresourceLayers(vk::ImageAspectFlagBits::eColor, 0, 0, 1), { vk::Offset3D(0, 0, 0), vk::Offset3D(target->desc.width, target->desc.height, 1) }); mActiveCommandBuffer.blitImage( surface->image, vk::ImageLayout::eTransferSrcOptimal, target->image, vk::ImageLayout::eTransferDstOptimal, { blitRegion }, vk::Filter::eNearest); }
void Driver::decafClearColor(const latte::pm4::DecafClearColor &data) { flushPendingDraws(); // Find our colorbuffer to clear ColorBufferDesc colorBuffer; colorBuffer.base256b = data.cb_color_base.BASE_256B(); colorBuffer.pitchTileMax = data.cb_color_size.PITCH_TILE_MAX(); colorBuffer.sliceTileMax = data.cb_color_size.SLICE_TILE_MAX(); colorBuffer.format = data.cb_color_info.FORMAT(); colorBuffer.numberType = data.cb_color_info.NUMBER_TYPE(); colorBuffer.arrayMode = data.cb_color_info.ARRAY_MODE(); colorBuffer.sliceStart = data.cb_color_view.SLICE_START(); colorBuffer.sliceEnd = data.cb_color_view.SLICE_MAX() + 1; auto surfaceView = getColorBuffer(colorBuffer); transitionSurfaceView(surfaceView, ResourceUsage::TransferDst, vk::ImageLayout::eTransferDstOptimal); std::array<float, 4> clearColor = { data.red, data.green, data.blue, data.alpha }; mActiveCommandBuffer.clearColorImage(surfaceView->surface->image, vk::ImageLayout::eTransferDstOptimal, clearColor, { surfaceView->subresRange }); }
freeimage::ImagePtr FrameBuffer::getImage() { #ifdef BRAYNS_USE_FREEIMAGE map(); const auto colorBuffer = getColorBuffer(); const auto& size = getSize(); freeimage::ImagePtr image( FreeImage_ConvertFromRawBits(const_cast<uint8_t*>(colorBuffer), size.x, size.y, getColorDepth() * size.x, 8 * getColorDepth(), 0xFF0000, 0x00FF00, 0x0000FF, false)); unmap(); #if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR freeimage::SwapRedBlue32(image.get()); #endif return image; #else return nullptr; #endif }
/** * Method is used to build texture mipmapis for mipmapping technique. * @param target is texture type. */ void FrameBufferObject::buildMipmaps(GLenum target) const { glBindTexture(target, getColorBuffer()); glGenerateMipmap(target); }