-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: apple support #89
Draft
pollend
wants to merge
18
commits into
NVIDIAGameWorks:main
Choose a base branch
from
pollend:feature/apple-metal-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
7014d7f
feat: apple support
pollend 1db2c0a
feat: add templte classes
pollend 8a5b5d8
feat: add command queue mtl
pollend d2acc0e
add ds_store
pollend 6ecdb4f
feat: update commanQueuMTL
pollend a123c5d
feat: add conversion and start texture
pollend b769e9e
feat: add more to api
pollend 3505ba1
feat: fix build
pollend 346beb2
feat: add graphics queu
pollend ab5a362
feat: add interface
pollend 7aad81d
feat: add descriptor
pollend ada4491
fix compiling errors
pollend 0818af8
feat: start on command buffer logic
pollend 07f9b2d
add command buffer type
pollend 0697e07
start working on command buffer
pollend 8868d96
feat: begin shader load logic
pollend 56f38db
fix compiling errors
pollend b727121
feat: cleanup
pollend File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# apple | ||
.DS_Store | ||
|
||
# cmake | ||
CMakeFiles/ | ||
.cmake/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// © 2021 NVIDIA Corporation | ||
|
||
#pragma once | ||
|
||
#include "NRIDeviceCreation.h" | ||
|
||
NriNamespaceBegin | ||
|
||
typedef void* MTLBufferHandle; | ||
typedef void* MTLTextureHandle; | ||
typedef void* MTLDeviceHandle; | ||
|
||
NriStruct(DeviceCreationMTLDesc) | ||
{ | ||
bool enableNRIValidation; | ||
MTLDeviceHandle MtlDevice; | ||
}; | ||
|
||
NriStruct(CommandBufferMTLDesc) | ||
{ | ||
|
||
}; | ||
|
||
NriStruct(BufferMTLDesc) | ||
{ | ||
MTLBufferHandle buffer; | ||
void* mappedMemory; | ||
//MTLResourceOptions options; | ||
}; | ||
|
||
NriStruct(TextureMTLDesc) | ||
{ | ||
//MTLTextureHandle mtlTexture; | ||
//MTLTextureDescriptor* descriptor; | ||
}; | ||
|
||
NriStruct(MemoryMTLDesc) | ||
{ | ||
MTLBufferHandle buffer; | ||
void* mappedMemory; | ||
//MTLResourceOptions options; | ||
}; | ||
|
||
NRI_API Nri(Result) NRI_CALL nriCreateDeviceFromMtlDevice(const NriRef(DeviceCreationMTLDesc) deviceDesc, NriRef(Device*) device); | ||
|
||
NriNamespaceEnd | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// © 2021 NVIDIA Corporation | ||
#pragma once | ||
|
||
#import <MetalKit/MetalKit.h> | ||
|
||
namespace nri { | ||
|
||
struct DeviceMTL; | ||
struct MemoryMTL; | ||
|
||
struct BufferMTL { | ||
|
||
inline BufferMTL(DeviceMTL& device) | ||
: m_Device(device) { | ||
} | ||
|
||
inline id<MTLBuffer> GetHandle() const { | ||
return pBuffer; | ||
} | ||
|
||
|
||
inline DeviceMTL& GetDevice() const { | ||
return m_Device; | ||
} | ||
|
||
inline const BufferDesc& GetDesc() const { | ||
return m_Desc; | ||
} | ||
|
||
~BufferMTL(); | ||
|
||
Result Create(const BufferDesc& bufferDesc); | ||
Result Create(const BufferVKDesc& bufferDesc); | ||
Result Create(const AllocateBufferDesc& bufferDesc); | ||
|
||
private: | ||
DeviceMTL& m_Device; | ||
id<MTLBuffer> pBuffer; | ||
uint8_t* m_MappedMemory = nullptr; | ||
uint64_t m_MappedMemoryOffset = 0; | ||
uint64_t m_MappedMemoryRangeSize = 0; | ||
uint64_t m_MappedMemoryRangeOffset = 0; | ||
BufferDesc m_Desc = {}; | ||
bool m_OwnsNativeObjects = true; | ||
}; | ||
|
||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "SharedMTL.h" | ||
|
||
#include "BufferMTL.h" | ||
|
||
using namespace nri; | ||
|
||
|
||
Result BufferMTL::Create(const BufferDesc& bufferDesc) { | ||
return Result::SUCCESS; | ||
} | ||
|
||
Result BufferMTL::Create(const BufferVKDesc& bufferDesc) { | ||
return Result::SUCCESS; | ||
} | ||
|
||
Result BufferMTL::Create(const AllocateBufferDesc& bufferDesc) { | ||
return Result::SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// © 2021 NVIDIA Corporation | ||
|
||
#pragma once | ||
|
||
namespace nri { | ||
|
||
struct DeviceMTL; | ||
struct CommandQueueMTL; | ||
|
||
struct CommandAllocatorMTL { | ||
inline CommandAllocatorMTL(DeviceMTL& device) | ||
: m_Device(device) { | ||
} | ||
|
||
inline DeviceMTL& GetDevice() const { | ||
return m_Device; | ||
} | ||
|
||
~CommandAllocatorMTL(); | ||
|
||
|
||
Result Create(const CommandQueue& commandQueue); | ||
|
||
//================================================================================================================ | ||
// NRI | ||
//================================================================================================================ | ||
|
||
Result CreateCommandBuffer(CommandBuffer*& commandBuffer); | ||
|
||
private: | ||
struct CommandQueueMTL* m_CommandQueue; | ||
DeviceMTL& m_Device; | ||
}; | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// © 2021 NVIDIA Corporation | ||
|
||
#pragma region[ Core ] | ||
|
||
static void NRI_CALL SetCommandAllocatorDebugName(CommandAllocator& commandAllocator, const char* name) { | ||
//((CommandAllocatorVK&)commandAllocator).SetDebugName(name); | ||
} | ||
|
||
static Result NRI_CALL CreateCommandBuffer(CommandAllocator& commandAllocator, CommandBuffer*& commandBuffer) { | ||
return ((CommandAllocatorMTL&)commandAllocator).CreateCommandBuffer(commandBuffer); | ||
} | ||
|
||
static void NRI_CALL ResetCommandAllocator(CommandAllocator& commandAllocator) { | ||
//((CommandAllocatorVK&)commandAllocator).Reset(); | ||
} | ||
|
||
#pragma endregion | ||
|
||
Define_Core_CommandAllocator_PartiallyFillFunctionTable(VK); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "SharedMTL.h" | ||
|
||
#include "CommandAllocatorMTL.h" | ||
|
||
#include "CommandQueueMTL.h" | ||
|
||
using namespace nri; | ||
|
||
CommandAllocatorMTL::~CommandAllocatorMTL() { | ||
|
||
} | ||
|
||
Result CommandAllocatorMTL::Create(const CommandQueue& commandQueue) { | ||
m_CommandQueue = &(CommandQueueMTL&)commandQueue; | ||
return Result::SUCCESS; | ||
} | ||
|
||
//================================================================================================================ | ||
// NRI | ||
//================================================================================================================ | ||
|
||
Result CommandAllocatorMTL::CreateCommandBuffer(CommandBuffer*& commandBuffer) { | ||
|
||
|
||
return Result::SUCCESS; | ||
} | ||
|
||
#include "CommandAllocatorMTL.hpp" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like these are #defined in apple framework.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind to add these undefs to the interface.