LCOV - code coverage report
Current view: top level - xenolith/core - XLCoreDevice.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 4 5 80.0 %
Date: 2024-05-12 00:16:13 Functions: 4 5 80.0 %

          Line data    Source code
       1             : /**
       2             :  Copyright (c) 2023 Stappler LLC <admin@stappler.dev>
       3             : 
       4             :  Permission is hereby granted, free of charge, to any person obtaining a copy
       5             :  of this software and associated documentation files (the "Software"), to deal
       6             :  in the Software without restriction, including without limitation the rights
       7             :  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
       8             :  copies of the Software, and to permit persons to whom the Software is
       9             :  furnished to do so, subject to the following conditions:
      10             : 
      11             :  The above copyright notice and this permission notice shall be included in
      12             :  all copies or substantial portions of the Software.
      13             : 
      14             :  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      15             :  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      16             :  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      17             :  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      18             :  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      19             :  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
      20             :  THE SOFTWARE.
      21             :  **/
      22             : 
      23             : #ifndef XENOLITH_CORE_XLCOREDEVICE_H_
      24             : #define XENOLITH_CORE_XLCOREDEVICE_H_
      25             : 
      26             : #include "XLCoreQueueData.h"
      27             : #include "XLCoreObject.h"
      28             : #include "XLCoreImageStorage.h"
      29             : 
      30             : namespace STAPPLER_VERSIONIZED stappler::xenolith::core {
      31             : 
      32             : class Instance;
      33             : class Object;
      34             : class Loop;
      35             : 
      36             : class Device : public Ref {
      37             : public:
      38             :         using DescriptorType = core::DescriptorType;
      39             :         using ImageStorage = core::ImageStorage;
      40             : 
      41             :         Device();
      42             :         virtual ~Device();
      43             : 
      44             :         virtual bool init(const Instance *instance);
      45             :         virtual void end();
      46             : 
      47             :         Rc<Shader> getProgram(StringView);
      48             :         Rc<Shader> addProgram(Rc<Shader>);
      49             : 
      50             :         void addObject(Object *);
      51             :         void removeObject(Object *);
      52             : 
      53             :         uint32_t getSamplersCount() const { return _samplersCount; }
      54             :         bool isSamplersCompiled() const { return _samplersCompiled; }
      55             : 
      56          16 :         uint32_t getTextureLayoutImagesCount() const { return _textureLayoutImagesCount; }
      57          16 :         uint32_t getTextureLayoutBuffersCount() const { return _textureLayoutBuffersCount; }
      58             : 
      59          21 :         const Vector<ImageFormat> &getSupportedDepthStencilFormat() const { return _depthFormats; }
      60             :         const Vector<ImageFormat> &getSupportedColorFormat() const { return _colorFormats; }
      61             : 
      62             :         virtual void onLoopStarted(Loop &);
      63             :         virtual void onLoopEnded(Loop &);
      64             : 
      65             :         virtual bool supportsUpdateAfterBind(DescriptorType) const;
      66             : 
      67             :         virtual Rc<ImageObject> getEmptyImageObject() const = 0;
      68             :         virtual Rc<ImageObject> getSolidImageObject() const = 0;
      69             : 
      70             :         virtual Rc<Framebuffer> makeFramebuffer(const QueuePassData *, SpanView<Rc<ImageView>>);
      71             :         virtual Rc<ImageStorage> makeImage(const ImageInfoData &);
      72             :         virtual Rc<Semaphore> makeSemaphore();
      73             :         virtual Rc<ImageView> makeImageView(const Rc<ImageObject> &, const ImageViewInfo &);
      74             : 
      75          10 :         uint32_t getPresentatonMask() const { return _presentMask; }
      76             : 
      77           0 :         virtual void waitIdle() const { }
      78             : 
      79             : protected:
      80             :         friend class Loop;
      81             : 
      82             :         void clearShaders();
      83             :         void invalidateObjects();
      84             : 
      85             :         bool _started = false;
      86             :         const Instance *_glInstance = nullptr;
      87             :         Mutex _shaderMutex;
      88             :         Mutex _objectMutex;
      89             : 
      90             :         Map<String, Rc<Shader>> _shaders;
      91             : 
      92             :         HashSet<Object *> _objects;
      93             : 
      94             :         Vector<SamplerInfo> _samplersInfo;
      95             :         Vector<ImageFormat> _depthFormats;
      96             :         Vector<ImageFormat> _colorFormats;
      97             : 
      98             :         uint32_t _samplersCount = 0;
      99             :         bool _samplersCompiled = false;
     100             :         uint32_t _textureLayoutImagesCount = 0;
     101             :         uint32_t _textureLayoutBuffersCount = 0;
     102             : 
     103             :         std::thread::id _loopThreadId;
     104             :         uint32_t _presentMask = 0;
     105             : };
     106             : 
     107             : }
     108             : 
     109             : #endif /* XENOLITH_CORE_XLCOREDEVICE_H_ */

Generated by: LCOV version 1.14