Skip to content

Commit

Permalink
[gfx] Metal graphics support (shader-slang#4324)
Browse files Browse the repository at this point in the history
* fix double semicolons

* fix another double semicolon

* wait for init data upload

* remove obsolete setData

* refactor swapchain to work on virtual back buffers

* buffer/texture use breakable device reference

* refactor input layout

* create render command encoder

* add todo

* refactor framebuffer layout

* refactor framebuffer

* refactor shader program

* translatePrimitiveType

* add more translate functions

* refactor framebuffer

* refactor render pass

* implement graphics pipeline state

* add depth stencil state

* initial render command encoder support

* comment
  • Loading branch information
skallweitNV committed Jun 10, 2024
1 parent 0974463 commit 6857dd5
Show file tree
Hide file tree
Showing 25 changed files with 750 additions and 369 deletions.
2 changes: 1 addition & 1 deletion slang-gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ struct DepthStencilDesc
DepthStencilOpDesc frontFace;
DepthStencilOpDesc backFace;

uint32_t stencilRef = 0;
uint32_t stencilRef = 0; // TODO: this should be removed
};

struct RasterizerDesc
Expand Down
2 changes: 1 addition & 1 deletion source/compiler-core/slang-metal-compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace Slang
{
ComPtr<IDownstreamCompiler> innerCppCompiler;

ExecutableLocation metalcLocation = ExecutableLocation(path, "metal");;
ExecutableLocation metalcLocation = ExecutableLocation(path, "metal");

String metalSDKPath = path;

Expand Down
2 changes: 1 addition & 1 deletion tools/gfx/metal/metal-buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BufferResourceImpl : public BufferResource
public:
typedef BufferResource Parent;

RefPtr<DeviceImpl> m_device;
BreakableReference<DeviceImpl> m_device;
NS::SharedPtr<MTL::Buffer> m_buffer;

BufferResourceImpl(const IBufferResource::Desc& desc, DeviceImpl* device);
Expand Down
4 changes: 2 additions & 2 deletions tools/gfx/metal/metal-command-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ Result CommandBufferImpl::getNativeHandle(InteropHandle* outHandle)
return SLANG_E_NOT_IMPLEMENTED;
}

MTL::RenderCommandEncoder* CommandBufferImpl::getMetalRenderCommandEncoder()
MTL::RenderCommandEncoder* CommandBufferImpl::getMetalRenderCommandEncoder(MTL::RenderPassDescriptor* renderPassDesc)
{
if (!m_metalRenderCommandEncoder)
{
endMetalCommandEncoder();
// m_metalRenderCommandEncoder = NS::RetainPtr(m_commandBuffer->renderCommandEncoder());
m_metalRenderCommandEncoder = NS::RetainPtr(m_commandBuffer->renderCommandEncoder(renderPassDesc));
}
return m_metalRenderCommandEncoder.get();
}
Expand Down
2 changes: 1 addition & 1 deletion tools/gfx/metal/metal-command-buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CommandBufferImpl

void beginCommandBuffer();

MTL::RenderCommandEncoder* getMetalRenderCommandEncoder();
MTL::RenderCommandEncoder* getMetalRenderCommandEncoder(MTL::RenderPassDescriptor* renderPassDesc);
MTL::ComputeCommandEncoder* getMetalComputeCommandEncoder();
MTL::BlitCommandEncoder* getMetalBlitCommandEncoder();
void endMetalCommandEncoder();
Expand Down
Loading

0 comments on commit 6857dd5

Please sign in to comment.