mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
metal: add internal compute encoder APIs
This commit is contained in:
@@ -129,6 +129,10 @@ public:
|
|||||||
id<MTLBlitCommandEncoder> getBlitEncoder() const { return blitEncoder; }
|
id<MTLBlitCommandEncoder> getBlitEncoder() const { return blitEncoder; }
|
||||||
void submitBlitEncoder();
|
void submitBlitEncoder();
|
||||||
|
|
||||||
|
id<MTLComputeCommandEncoder> useComputeEncoder();
|
||||||
|
id<MTLComputeCommandEncoder> getComputeEncoder() const { return computeEncoder; }
|
||||||
|
void submitComputeEncoder();
|
||||||
|
|
||||||
id<MTLSamplerState> getCachedSampler(const SamplerState &s);
|
id<MTLSamplerState> getCachedSampler(const SamplerState &s);
|
||||||
|
|
||||||
StreamBuffer *getUniformBuffer() const { return uniformBuffer; }
|
StreamBuffer *getUniformBuffer() const { return uniformBuffer; }
|
||||||
@@ -206,6 +210,7 @@ private:
|
|||||||
id<MTLCommandBuffer> commandBuffer;
|
id<MTLCommandBuffer> commandBuffer;
|
||||||
id<MTLRenderCommandEncoder> renderEncoder;
|
id<MTLRenderCommandEncoder> renderEncoder;
|
||||||
id<MTLBlitCommandEncoder> blitEncoder;
|
id<MTLBlitCommandEncoder> blitEncoder;
|
||||||
|
id<MTLComputeCommandEncoder> computeEncoder;
|
||||||
|
|
||||||
CAMetalLayer *metalLayer;
|
CAMetalLayer *metalLayer;
|
||||||
id<CAMetalDrawable> activeDrawable;
|
id<CAMetalDrawable> activeDrawable;
|
||||||
|
|||||||
@@ -488,6 +488,7 @@ void Graphics::submitCommandBuffer(SubmitType type)
|
|||||||
{
|
{
|
||||||
submitRenderEncoder(type);
|
submitRenderEncoder(type);
|
||||||
submitBlitEncoder();
|
submitBlitEncoder();
|
||||||
|
submitComputeEncoder();
|
||||||
|
|
||||||
if (commandBuffer != nil)
|
if (commandBuffer != nil)
|
||||||
{
|
{
|
||||||
@@ -528,6 +529,7 @@ id<MTLRenderCommandEncoder> Graphics::useRenderEncoder()
|
|||||||
if (renderEncoder == nil)
|
if (renderEncoder == nil)
|
||||||
{
|
{
|
||||||
submitBlitEncoder();
|
submitBlitEncoder();
|
||||||
|
submitComputeEncoder();
|
||||||
|
|
||||||
// Pass desc info for non-backbuffer render targets are set up in
|
// Pass desc info for non-backbuffer render targets are set up in
|
||||||
// setRenderTargetsInternal.
|
// setRenderTargetsInternal.
|
||||||
@@ -630,6 +632,7 @@ id<MTLBlitCommandEncoder> Graphics::useBlitEncoder()
|
|||||||
if (blitEncoder == nil)
|
if (blitEncoder == nil)
|
||||||
{
|
{
|
||||||
submitRenderEncoder(SUBMIT_STORE);
|
submitRenderEncoder(SUBMIT_STORE);
|
||||||
|
submitComputeEncoder();
|
||||||
blitEncoder = [useCommandBuffer() blitCommandEncoder];
|
blitEncoder = [useCommandBuffer() blitCommandEncoder];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -645,6 +648,27 @@ void Graphics::submitBlitEncoder()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id<MTLComputeCommandEncoder> Graphics::useComputeEncoder()
|
||||||
|
{
|
||||||
|
if (computeEncoder == nil)
|
||||||
|
{
|
||||||
|
submitRenderEncoder(SUBMIT_STORE);
|
||||||
|
submitBlitEncoder();
|
||||||
|
computeEncoder = [useCommandBuffer() computeCommandEncoder];
|
||||||
|
}
|
||||||
|
|
||||||
|
return computeEncoder;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Graphics::submitComputeEncoder()
|
||||||
|
{
|
||||||
|
if (computeEncoder != nil)
|
||||||
|
{
|
||||||
|
[computeEncoder endEncoding];
|
||||||
|
computeEncoder = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool isClampOne(SamplerState::WrapMode w)
|
static bool isClampOne(SamplerState::WrapMode w)
|
||||||
{
|
{
|
||||||
return w == SamplerState::WRAP_CLAMP_ONE;
|
return w == SamplerState::WRAP_CLAMP_ONE;
|
||||||
@@ -1096,10 +1120,10 @@ void Graphics::drawQuads(int start, int count, const VertexAttributes &attribute
|
|||||||
}}
|
}}
|
||||||
|
|
||||||
bool Graphics::dispatch(int x, int y, int z)
|
bool Graphics::dispatch(int x, int y, int z)
|
||||||
{
|
{ @autoreleasepool {
|
||||||
// TODO
|
// TODO
|
||||||
return false;
|
return false;
|
||||||
}
|
}}
|
||||||
|
|
||||||
void Graphics::setRenderTargetsInternal(const RenderTargets &rts, int w, int h, int /*pixelw*/, int /*pixelh*/, bool /*hasSRGBtexture*/)
|
void Graphics::setRenderTargetsInternal(const RenderTargets &rts, int w, int h, int /*pixelw*/, int /*pixelh*/, bool /*hasSRGBtexture*/)
|
||||||
{ @autoreleasepool {
|
{ @autoreleasepool {
|
||||||
|
|||||||
Reference in New Issue
Block a user