Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/metal/mtl_context.hh
| Show All 11 Lines | |||||
| #include "GPU_common_types.h" | #include "GPU_common_types.h" | ||||
| #include "GPU_context.h" | #include "GPU_context.h" | ||||
| #include "mtl_backend.hh" | #include "mtl_backend.hh" | ||||
| #include "mtl_capabilities.hh" | #include "mtl_capabilities.hh" | ||||
| #include "mtl_common.hh" | #include "mtl_common.hh" | ||||
| #include "mtl_framebuffer.hh" | #include "mtl_framebuffer.hh" | ||||
| #include "mtl_memory.hh" | #include "mtl_memory.hh" | ||||
| #include "mtl_shader.hh" | |||||
| #include "mtl_shader_interface.hh" | |||||
| #include "mtl_texture.hh" | #include "mtl_texture.hh" | ||||
| #include <Cocoa/Cocoa.h> | #include <Cocoa/Cocoa.h> | ||||
| #include <Metal/Metal.h> | #include <Metal/Metal.h> | ||||
| #include <QuartzCore/QuartzCore.h> | #include <QuartzCore/QuartzCore.h> | ||||
| @class CAMetalLayer; | @class CAMetalLayer; | ||||
| @class MTLCommandQueue; | @class MTLCommandQueue; | ||||
| @class MTLRenderPipelineState; | @class MTLRenderPipelineState; | ||||
| namespace blender::gpu { | namespace blender::gpu { | ||||
| /* Forward Declarations */ | /* Forward Declarations */ | ||||
| class MTLContext; | class MTLContext; | ||||
| class MTLCommandBufferManager; | class MTLCommandBufferManager; | ||||
| class MTLShader; | |||||
| class MTLUniformBuf; | class MTLUniformBuf; | ||||
| /* Structs containing information on current binding state for textures and samplers. */ | /* Structs containing information on current binding state for textures and samplers. */ | ||||
| struct MTLTextureBinding { | struct MTLTextureBinding { | ||||
| bool used; | bool used; | ||||
| /* Same value as index in bindings array. */ | /* Same value as index in bindings array. */ | ||||
| uint texture_slot_index; | uint slot_index; | ||||
| gpu::MTLTexture *texture_resource; | gpu::MTLTexture *texture_resource; | ||||
| }; | }; | ||||
| struct MTLSamplerBinding { | struct MTLSamplerBinding { | ||||
| bool used; | bool used; | ||||
| MTLSamplerState state; | MTLSamplerState state; | ||||
| bool operator==(MTLSamplerBinding const &other) const | bool operator==(MTLSamplerBinding const &other) const | ||||
| { | { | ||||
| return (used == other.used && state == other.state); | return (used == other.used && state == other.state); | ||||
| } | } | ||||
| }; | }; | ||||
| /* Metal Context Render Pass State -- Used to track active RenderCommandEncoder state based on | /* Metal Context Render Pass State -- Used to track active RenderCommandEncoder state based on | ||||
| * bound MTLFrameBuffer's.Owned by MTLContext. */ | * bound MTLFrameBuffer's.Owned by MTLContext. */ | ||||
| struct MTLRenderPassState { | class MTLRenderPassState { | ||||
| friend class MTLContext; | friend class MTLContext; | ||||
| public: | |||||
| MTLRenderPassState(MTLContext &context, MTLCommandBufferManager &command_buffer_manager) | MTLRenderPassState(MTLContext &context, MTLCommandBufferManager &command_buffer_manager) | ||||
| : ctx(context), cmd(command_buffer_manager){}; | : ctx(context), cmd(command_buffer_manager){}; | ||||
| /* Given a RenderPassState is associated with a live RenderCommandEncoder, | /* Given a RenderPassState is associated with a live RenderCommandEncoder, | ||||
| * this state sits within the MTLCommandBufferManager. */ | * this state sits within the MTLCommandBufferManager. */ | ||||
| MTLContext &ctx; | MTLContext &ctx; | ||||
| MTLCommandBufferManager &cmd; | MTLCommandBufferManager &cmd; | ||||
| ▲ Show 20 Lines • Show All 495 Lines • ▼ Show 20 Lines | |||||
| /** MTLContext -- Core render loop and state management. **/ | /** MTLContext -- Core render loop and state management. **/ | ||||
| /* NOTE(Metal): Partial MTLContext stub to provide wrapper functionality | /* NOTE(Metal): Partial MTLContext stub to provide wrapper functionality | ||||
| * for work-in-progress MTL* classes. */ | * for work-in-progress MTL* classes. */ | ||||
| class MTLContext : public Context { | class MTLContext : public Context { | ||||
| friend class MTLBackend; | friend class MTLBackend; | ||||
| private: | private: | ||||
| /* Null buffers for empty/unintialized bindings. | |||||
| * Null attribute buffer follows default attribute format of OpenGL Backend. */ | |||||
| id<MTLBuffer> null_buffer_; /* All zero's. */ | |||||
fclem: Style: Use `/**/` even for end of line comments. | |||||
| id<MTLBuffer> null_attribute_buffer_; /* Value float4(0.0,0.0,0.0,1.0). */ | |||||
| /* Compute and specialization caches. */ | /* Compute and specialization caches. */ | ||||
| MTLContextTextureUtils texture_utils_; | MTLContextTextureUtils texture_utils_; | ||||
| /* Texture Samplers. */ | /* Texture Samplers. */ | ||||
| /* Cache of generated MTLSamplerState objects based on permutations of `eGPUSamplerState`. */ | /* Cache of generated MTLSamplerState objects based on permutations of `eGPUSamplerState`. */ | ||||
| id<MTLSamplerState> sampler_state_cache_[GPU_SAMPLER_MAX]; | id<MTLSamplerState> sampler_state_cache_[GPU_SAMPLER_MAX]; | ||||
| id<MTLSamplerState> default_sampler_state_ = nil; | id<MTLSamplerState> default_sampler_state_ = nil; | ||||
| ▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | public: | ||||
| { | { | ||||
| return this->memory_manager; | return this->memory_manager; | ||||
| } | } | ||||
| static MTLBufferPool &get_global_memory_manager() | static MTLBufferPool &get_global_memory_manager() | ||||
| { | { | ||||
| return MTLContext::global_memory_manager; | return MTLContext::global_memory_manager; | ||||
| } | } | ||||
| /* Uniform Buffer Bindings to command encoders. */ | |||||
Not Done Inline ActionsIs this comment refering to the get_null_* functions (I doubt)? Feels like a left over comment from a deleted line. fclem: Is this comment refering to the `get_null_*` functions (I doubt)? Feels like a left over… | |||||
| id<MTLBuffer> get_null_buffer(); | |||||
| id<MTLBuffer> get_null_attribute_buffer(); | |||||
| }; | }; | ||||
| } // namespace blender::gpu | } // namespace blender::gpu | ||||
Style: Use /**/ even for end of line comments.