diff --git a/meson.build b/meson.build index 6a7c75c..362d351 100644 --- a/meson.build +++ b/meson.build @@ -22,13 +22,15 @@ xcb = [ dependency('xcb-xfixes'), dependency('xcb-damage'), dependency('xcb-shm'), + dependency('xcb-dri3'), dependency('xcb-composite'), dependency('xcb-icccm'), dependency('xcb-ewmh') ] vk = [ - dependency('vulkan') + dependency('vulkan'), + dependency('gbm') ] python = [ diff --git a/src/CompositorResource.cpp b/src/CompositorResource.cpp index 41237bb..f06b1b8 100644 --- a/src/CompositorResource.cpp +++ b/src/CompositorResource.cpp @@ -5,47 +5,21 @@ #include "compositor.h" #include +#include +#include #include "spirv_reflect.h" namespace Compositor{ -Texture::Texture(uint _w, uint _h, VkFormat format, const CompositorInterface *_pcomp) : pcomp(_pcomp), imageLayout(VK_IMAGE_LAYOUT_UNDEFINED), w(_w), h(_h){ +TextureBase::TextureBase(uint _w, uint _h, VkFormat format, const CompositorInterface *_pcomp) : w(_w), h(_h), imageLayout(VK_IMAGE_LAYOUT_UNDEFINED), pcomp(_pcomp){ // auto m = std::find_if(formatSizeMap.begin(),formatSizeMap.end(),[&](auto &r)->bool{ return r.first == format; }); formatIndex = m-formatSizeMap.begin(); - DebugPrintf(stdout,"*** creating texture: %u, (%ux%u)\n",(*m).second,w,h); - - //staging buffer - VkBufferCreateInfo bufferCreateInfo = {}; - bufferCreateInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; - bufferCreateInfo.size = (*m).second*w*h; - bufferCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; - bufferCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; - if(vkCreateBuffer(pcomp->logicalDev,&bufferCreateInfo,0,&stagingBuffer) != VK_SUCCESS) - throw Exception("Failed to create a staging buffer."); - - VkPhysicalDeviceMemoryProperties physicalDeviceMemoryProps; - vkGetPhysicalDeviceMemoryProperties(pcomp->physicalDev,&physicalDeviceMemoryProps); - - VkMemoryRequirements memoryRequirements; - vkGetBufferMemoryRequirements(pcomp->logicalDev,stagingBuffer,&memoryRequirements); - - VkMemoryAllocateInfo memoryAllocateInfo = {}; - memoryAllocateInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; - memoryAllocateInfo.allocationSize = memoryRequirements.size; - for(memoryAllocateInfo.memoryTypeIndex = 0; memoryAllocateInfo.memoryTypeIndex < physicalDeviceMemoryProps.memoryTypeCount; memoryAllocateInfo.memoryTypeIndex++){ - if(memoryRequirements.memoryTypeBits & (1<logicalDev,&memoryAllocateInfo,0,&stagingMemory) != VK_SUCCESS) - throw Exception("Failed to allocate staging buffer memory."); - vkBindBufferMemory(pcomp->logicalDev,stagingBuffer,stagingMemory,0); - - stagingMemorySize = memoryRequirements.size; + //DebugPrintf(stdout,"*** creating texture: %u, (%ux%u)\n",(*m).second,w,h); //image VkImageCreateInfo imageCreateInfo = {}; @@ -66,8 +40,14 @@ Texture::Texture(uint _w, uint _h, VkFormat format, const CompositorInterface *_ if(vkCreateImage(pcomp->logicalDev,&imageCreateInfo,0,&image) != VK_SUCCESS) throw Exception("Failed to create an image."); + VkPhysicalDeviceMemoryProperties physicalDeviceMemoryProps; + vkGetPhysicalDeviceMemoryProperties(pcomp->physicalDev,&physicalDeviceMemoryProps); + + VkMemoryRequirements memoryRequirements; vkGetImageMemoryRequirements(pcomp->logicalDev,image,&memoryRequirements); + VkMemoryAllocateInfo memoryAllocateInfo = {}; + memoryAllocateInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; memoryAllocateInfo.allocationSize = memoryRequirements.size; for(memoryAllocateInfo.memoryTypeIndex = 0; memoryAllocateInfo.memoryTypeIndex < physicalDeviceMemoryProps.memoryTypeCount; memoryAllocateInfo.memoryTypeIndex++){ if(memoryRequirements.memoryTypeBits & (1<logicalDev,&imageViewCreateInfo,0,&imageView) != VK_SUCCESS) throw Exception("Failed to create texture image view."); + } -Texture::~Texture(){ +TextureBase::~TextureBase(){ vkDestroyImageView(pcomp->logicalDev,imageView,0); vkFreeMemory(pcomp->logicalDev,deviceMemory,0); vkDestroyImage(pcomp->logicalDev,image,0); +} + +const std::vector> TextureBase::formatSizeMap = { + {VK_FORMAT_R8G8B8A8_UNORM,4} +}; + +TextureStaged::TextureStaged(uint _w, uint _h, VkFormat _format, const CompositorInterface *_pcomp) : TextureBase(_w,_h,_format,_pcomp){ + // + //staging buffer + VkBufferCreateInfo bufferCreateInfo = {}; + bufferCreateInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; + bufferCreateInfo.size = formatSizeMap[formatIndex].second*w*h;//(*m).second*w*h; + bufferCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; + bufferCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; + if(vkCreateBuffer(pcomp->logicalDev,&bufferCreateInfo,0,&stagingBuffer) != VK_SUCCESS) + throw Exception("Failed to create a staging buffer."); + VkPhysicalDeviceMemoryProperties physicalDeviceMemoryProps; + vkGetPhysicalDeviceMemoryProperties(pcomp->physicalDev,&physicalDeviceMemoryProps); + + VkMemoryRequirements memoryRequirements; + vkGetBufferMemoryRequirements(pcomp->logicalDev,stagingBuffer,&memoryRequirements); + + VkMemoryAllocateInfo memoryAllocateInfo = {}; + memoryAllocateInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; + memoryAllocateInfo.allocationSize = memoryRequirements.size; + for(memoryAllocateInfo.memoryTypeIndex = 0; memoryAllocateInfo.memoryTypeIndex < physicalDeviceMemoryProps.memoryTypeCount; memoryAllocateInfo.memoryTypeIndex++){ + if(memoryRequirements.memoryTypeBits & (1<logicalDev,&memoryAllocateInfo,0,&stagingMemory) != VK_SUCCESS) + throw Exception("Failed to allocate staging buffer memory."); + vkBindBufferMemory(pcomp->logicalDev,stagingBuffer,stagingMemory,0); + + stagingMemorySize = memoryRequirements.size; +} + +TextureStaged::~TextureStaged(){ vkFreeMemory(pcomp->logicalDev,stagingMemory,0); vkDestroyBuffer(pcomp->logicalDev,stagingBuffer,0); } -const void * Texture::Map() const{ +const void * TextureStaged::Map() const{ void *pdata; if(vkMapMemory(pcomp->logicalDev,stagingMemory,0,stagingMemorySize,0,&pdata) != VK_SUCCESS) return 0; return pdata; } -void Texture::Unmap(const VkCommandBuffer *pcommandBuffer, const VkRect2D *prects, uint rectCount){ +void TextureStaged::Unmap(const VkCommandBuffer *pcommandBuffer, const VkRect2D *prects, uint rectCount){ vkUnmapMemory(pcomp->logicalDev,stagingMemory); VkImageSubresourceRange imageSubresourceRange = {}; @@ -150,19 +168,6 @@ void Texture::Unmap(const VkCommandBuffer *pcommandBuffer, const VkRect2D *prect bufferImageCopyBuffer[i].bufferImageHeight = h; } vkCmdCopyBufferToImage(*pcommandBuffer,stagingBuffer,image,VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,rectCount,bufferImageCopyBuffer.data()); - /*VkBufferImageCopy bufferImageCopy = {}; - bufferImageCopy.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - bufferImageCopy.imageSubresource.mipLevel = 0; - bufferImageCopy.imageSubresource.baseArrayLayer = 0; - bufferImageCopy.imageSubresource.layerCount = 1; - bufferImageCopy.imageExtent.width = w;//w/4; //w - bufferImageCopy.imageExtent.height = h;//h - bufferImageCopy.imageExtent.depth = 1; - bufferImageCopy.imageOffset = (VkOffset3D){0,0,0};//(VkOffset3D){w/4,0,0}; //x,y - bufferImageCopy.bufferOffset = 0;//w/4*4; //(w*y+x)*format - bufferImageCopy.bufferRowLength = w; - bufferImageCopy.bufferImageHeight = h; - vkCmdCopyBufferToImage(*pcommandBuffer,stagingBuffer,image,VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,1,&bufferImageCopy);*/ //create in transfer stage, use in fragment shader stage imageMemoryBarrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; @@ -175,6 +180,97 @@ void Texture::Unmap(const VkCommandBuffer *pcommandBuffer, const VkRect2D *prect imageLayout = imageMemoryBarrier.newLayout; } +TexturePixmap::TexturePixmap(uint _w, uint _h, const CompositorInterface *_pcomp) : TextureBase(_w,_h,VK_FORMAT_R8G8B8A8_UNORM,_pcomp){ + pcomp11 = dynamic_cast(pcomp); + if(!pcomp11) //hack, solve this! + return; +} + +TexturePixmap::~TexturePixmap(){ + // +} + +//only pixmaps that correspond to the created texture in size should be attached +void TexturePixmap::Attach(xcb_pixmap_t pixmap){ + xcb_dri3_buffer_from_pixmap_cookie_t bufferFromPixmapCookie = xcb_dri3_buffer_from_pixmap(pcomp11->pbackend->pcon,pixmap); + xcb_dri3_buffer_from_pixmap_reply_t *pbufferFromPixmapReply = xcb_dri3_buffer_from_pixmap_reply(pcomp11->pbackend->pcon,bufferFromPixmapCookie,0); + + dmafd = xcb_dri3_buffer_from_pixmap_reply_fds(pcomp11->pbackend->pcon,pbufferFromPixmapReply)[0]; //TODO: get all planes? + + struct gbm_import_fd_data gbmImportFdData = { + .fd = dmafd, + .width = w, + .height = h, + .stride = pbufferFromPixmapReply->stride, + .format = GBM_FORMAT_ARGB8888 + }; + pgbmBufferObject = gbm_bo_import(pcomp11->pgbmdev,GBM_BO_IMPORT_FD,&gbmImportFdData,0); + if(!pgbmBufferObject) + throw Exception("Failed to import GBM buffer object.\n"); + + VkSubresourceLayout subresourceLayout = {}; + subresourceLayout.offset = 0; + subresourceLayout.size = (uint)pbufferFromPixmapReply->stride*h; + subresourceLayout.rowPitch = (uint)pbufferFromPixmapReply->stride; + subresourceLayout.arrayPitch = subresourceLayout.size; + subresourceLayout.depthPitch = subresourceLayout.size; + + VkImageDrmFormatModifierExplicitCreateInfoEXT imageDrmFormatModifierExpCreateInfo = {}; + imageDrmFormatModifierExpCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT; + imageDrmFormatModifierExpCreateInfo.drmFormatModifier = 0; + imageDrmFormatModifierExpCreateInfo.drmFormatModifierPlaneCount = 1; + imageDrmFormatModifierExpCreateInfo.pPlaneLayouts = &subresourceLayout; + + VkExternalMemoryImageCreateInfo externalMemoryCreateInfo = {}; + externalMemoryCreateInfo.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO; + externalMemoryCreateInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT; + externalMemoryCreateInfo.pNext = &imageDrmFormatModifierExpCreateInfo; + + VkImageCreateInfo imageCreateInfo = {}; + imageCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; + imageCreateInfo.imageType = VK_IMAGE_TYPE_2D; + imageCreateInfo.extent.width = w; + imageCreateInfo.extent.height = h; + imageCreateInfo.extent.depth = 1; + imageCreateInfo.mipLevels = 1; + imageCreateInfo.arrayLayers = 1; + imageCreateInfo.format = VK_FORMAT_R8G8B8A8_UNORM; //todo: format from image reply? + imageCreateInfo.tiling = VK_IMAGE_TILING_LINEAR; + imageCreateInfo.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; + imageCreateInfo.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; + imageCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; + imageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT; + imageCreateInfo.flags = 0; + imageCreateInfo.pNext = &externalMemoryCreateInfo; + /*if(vkCreateImage(pcomp->logicalDev,&imageCreateInfo,0,&image) != VK_SUCCESS) + throw Exception("Failed to create an image."); + + VkMemoryFdPropertiesKHR memoryFdProps; + if(((PFN_vkGetMemoryFdPropertiesKHR)vkGetInstanceProcAddr(pcomp11->instance,"vkGetMemoryFdPropertiesKHR"))(pcomp->logicalDev,VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,dmafd,&memoryFdProps) != VK_SUCCESS) + throw Exception("Failed to get memory fd properties.");*/ + + // + free(pbufferFromPixmapReply); + +} + +void TexturePixmap::Detach(){ + gbm_bo_destroy(pgbmBufferObject); + close(dmafd); +} + +void TexturePixmap::Update(const VkCommandBuffer *pcommandBuffer){ + // +} + +Texture::Texture(uint _w, uint _h, const CompositorInterface *_pcomp) : TextureBase(_w,_h,VK_FORMAT_R8G8B8A8_UNORM,_pcomp), TextureStaged(_w,_h,VK_FORMAT_R8G8B8A8_UNORM,_pcomp), TexturePixmap(_w,_h,_pcomp){ + // +} + +Texture::~Texture(){ + // +} + ShaderModule::ShaderModule(const char *_pname, const Blob *pblob, const CompositorInterface *_pcomp) : pcomp(_pcomp), pname(mstrdup(_pname)){ VkShaderModuleCreateInfo shaderModuleCreateInfo = {}; shaderModuleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; @@ -238,10 +334,6 @@ ShaderModule::~ShaderModule(){ vkDestroyShaderModule(pcomp->logicalDev,shaderModule,0); } -const std::vector> Texture::formatSizeMap = { - {VK_FORMAT_R8G8B8A8_UNORM,4} -}; - Pipeline::Pipeline(ShaderModule *_pvertexShader, ShaderModule *_pgeometryShader, ShaderModule *_pfragmentShader, const CompositorInterface *_pcomp) : pshaderModule{_pvertexShader,_pgeometryShader,_pfragmentShader}, pcomp(_pcomp){ // VkPipelineVertexInputStateCreateInfo vertexInputStateCreateInfo = {}; diff --git a/src/CompositorResource.h b/src/CompositorResource.h index f3a5098..9dc2cee 100644 --- a/src/CompositorResource.h +++ b/src/CompositorResource.h @@ -4,32 +4,63 @@ #include #include +struct gbm_bo; + namespace Compositor{ -//texture class for shader reads -class Texture{ +class TextureBase{ public: - Texture(uint, uint, VkFormat, const class CompositorInterface *pcomp); - ~Texture(); - const void * Map() const; - void Unmap(const VkCommandBuffer *, const VkRect2D *, uint); + TextureBase(uint, uint, VkFormat, const class CompositorInterface *); + virtual ~TextureBase(); + // + uint w, h; + uint formatIndex; + VkImageLayout imageLayout; - const class CompositorInterface *pcomp; VkImage image; - VkImageLayout imageLayout; VkImageView imageView; VkDeviceMemory deviceMemory; + const class CompositorInterface *pcomp; + + static const std::vector> formatSizeMap; +}; + +//texture class for shader reads +class TextureStaged : virtual public TextureBase{ +public: + TextureStaged(uint, uint, VkFormat, const class CompositorInterface *); + virtual ~TextureStaged(); + const void * Map() const; + void Unmap(const VkCommandBuffer *, const VkRect2D *, uint); + VkBuffer stagingBuffer; VkDeviceMemory stagingMemory; uint stagingMemorySize; - uint w, h; - uint formatIndex; std::vector bufferImageCopyBuffer; //to avoid repeated dynamic allocations each time texture is updated in multiple regions - static const std::vector> formatSizeMap; + //const class CompositorInterface *pcomp; +}; + +class TexturePixmap : virtual public TextureBase{ +public: + TexturePixmap(uint, uint, const class CompositorInterface *); + virtual ~TexturePixmap(); + void Attach(xcb_pixmap_t); + void Detach(); + void Update(const VkCommandBuffer *); + + sint dmafd; + struct gbm_bo *pgbmBufferObject; + const class X11Compositor *pcomp11; +}; + +class Texture : public TextureStaged, public TexturePixmap{ +public: + Texture(uint, uint, const class CompositorInterface *); + ~Texture(); }; class ShaderModule{ diff --git a/src/backend.h b/src/backend.h index 13c93ed..db3322e 100644 --- a/src/backend.h +++ b/src/backend.h @@ -12,6 +12,7 @@ class X11ClientFrame; class X11Background; class X11Compositor; class X11DebugCompositor; +class TexturePixmap; } namespace WManager{ @@ -146,6 +147,7 @@ friend class Compositor::X11ClientFrame; friend class Compositor::X11Background; friend class Compositor::X11Compositor; friend class Compositor::X11DebugCompositor; +friend class Compositor::TexturePixmap; public: X11Backend(); virtual ~X11Backend(); diff --git a/src/compositor.cpp b/src/compositor.cpp index 548e461..7c102a8 100644 --- a/src/compositor.cpp +++ b/src/compositor.cpp @@ -9,6 +9,10 @@ #include #include +#include //temp +#include +#include + namespace Compositor{ ColorFrame::ColorFrame(const char *pshaderName[Pipeline::SHADER_MODULE_COUNT], CompositorInterface *_pcomp) : pcomp(_pcomp), passignedSet(0), time(0.0f), shaderUserFlags(0), shaderFlags(0), oldShaderFlags(0){ @@ -204,8 +208,8 @@ void CompositorInterface::InitializeRenderEngine(){ VK_EXT_DEBUG_REPORT_EXTENSION_NAME, "VK_KHR_surface", "VK_KHR_xcb_surface", - //"VK_KHR_get_physical_device_properties2", - //VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME + "VK_KHR_get_physical_device_properties2", + "VK_KHR_external_memory_capabilities" }; DebugPrintf(stdout,"Enumerating required extensions\n"); uint extFound = 0; @@ -376,7 +380,13 @@ void CompositorInterface::InitializeRenderEngine(){ vkEnumerateDeviceExtensionProperties(physicalDev,0,&devExtCount,pdevExtProps); //device extensions - const char *pdevExtensions[] = {VK_KHR_SWAPCHAIN_EXTENSION_NAME,VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME}; + const char *pdevExtensions[] = { + VK_KHR_SWAPCHAIN_EXTENSION_NAME, + VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME, + VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME, + VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME, + VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME + }; DebugPrintf(stdout,"Enumerating required device extensions\n"); uint devExtFound = 0; for(uint i = 0; i < devExtCount; ++i) @@ -1103,7 +1113,7 @@ Texture * CompositorInterface::CreateTexture(uint w, uint h){ textureCache.pop_back(); printf("----------- found cached texture\n"); - }else ptexture = new Texture(w,h,VK_FORMAT_R8G8B8A8_UNORM,this); + }else ptexture = new Texture(w,h,this); return ptexture; } @@ -1212,12 +1222,15 @@ X11ClientFrame::X11ClientFrame(WManager::Container *pcontainer, const Backend::X //------ pcomp->AddDamageRegion(this); + ptexture->Attach(windowPixmap); } X11ClientFrame::~X11ClientFrame(){ xcb_shm_detach(pbackend->pcon,segment); shmdt(pchpixels); + ptexture->Detach(); + xcb_damage_destroy(pbackend->pcon,damage); xcb_composite_unredirect_window(pbackend->pcon,window,XCB_COMPOSITE_REDIRECT_MANUAL); @@ -1300,6 +1313,10 @@ void X11ClientFrame::AdjustSurface1(){ }else if(oldRect.x != rect.x || oldRect.y != rect.y) pcomp->AddDamageRegion(this); + + ptexture->Detach(); + + ptexture->Attach(windowPixmap); } X11Background::X11Background(xcb_pixmap_t _pixmap, uint _w, uint _h, const char *_pshaderName[Pipeline::SHADER_MODULE_COUNT], X11Compositor *_pcomp) : w(_w), h(_h), ClientFrame(_w,_h,_pshaderName,_pcomp), pcomp11(_pcomp), pixmap(_pixmap){ @@ -1438,9 +1455,23 @@ void X11Compositor::Start(){ DebugPrintf(stdout,"SHM %u.%u\n",pshmReply->major_version,pshmReply->minor_version); free(pshmReply); + xcb_dri3_query_version_cookie_t dri3Cookie = xcb_dri3_query_version(pbackend->pcon,XCB_DRI3_MAJOR_VERSION,XCB_DRI3_MINOR_VERSION); + xcb_dri3_query_version_reply_t *pdri3Reply = xcb_dri3_query_version_reply(pbackend->pcon,dri3Cookie,0); + if(!pdri3Reply) + throw Exception("DRI3 extension unavailable.\n"); + DebugPrintf(stdout,"DRI3 %u.%u\n",pdri3Reply->major_version,pdri3Reply->minor_version); + free(pdri3Reply); + xcb_flush(pbackend->pcon); InitializeRenderEngine(); + + cardfd = open("/dev/dri/card1",O_RDWR|FD_CLOEXEC); + if(cardfd < 0) + throw Exception("Failed to open /dev/dri/card*\n"); + pgbmdev = gbm_create_device(cardfd); + if(!pgbmdev) + throw Exception("Failed to create GBM device.\n"); } void X11Compositor::Stop(){ @@ -1450,6 +1481,9 @@ void X11Compositor::Stop(){ delete pcolorBackground; DestroyRenderEngine(); + gbm_device_destroy(pgbmdev); + close(cardfd); + xcb_xfixes_set_window_shape_region(pbackend->pcon,overlay,XCB_SHAPE_SK_BOUNDING,0,0,XCB_XFIXES_REGION_NONE); xcb_xfixes_set_window_shape_region(pbackend->pcon,overlay,XCB_SHAPE_SK_INPUT,0,0,XCB_XFIXES_REGION_NONE); diff --git a/src/compositor.h b/src/compositor.h index e143ba4..3d15b18 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -7,6 +7,9 @@ #include #include #include +#include + +struct gbm_device; namespace Backend{ class X11Backend; @@ -61,6 +64,9 @@ friend class CompositorInterface; }; class CompositorInterface{ +friend class TextureBase; +friend class TextureStaged; +friend class TexturePixmap; friend class Texture; friend class ShaderModule; friend class Pipeline; @@ -235,6 +241,7 @@ class X11Background : public ClientFrame{ //Default compositor assumes XCB for its surface class X11Compositor : public CompositorInterface{ +friend class TexturePixmap; public: //Derivatives of compositor classes should not point to their default corresponding backend classes (Backend::Default in this case). This is to allow the compositor to be independent of the backend implementation, as long as it's based on X11 here. X11Compositor(const Configuration *, const Backend::X11Backend *); @@ -248,6 +255,8 @@ class X11Compositor : public CompositorInterface{ void SetBackgroundPixmap(const Backend::BackendPixmapProperty *); VkExtent2D GetExtent() const; const Backend::X11Backend *pbackend; + struct gbm_device *pgbmdev; + sint cardfd; //X11Background *pbackground; xcb_window_t overlay; protected: