summaryrefslogtreecommitdiff
path: root/tools/gfx/metal/metal-shader-program.cpp
diff options
context:
space:
mode:
authorskallweitNV <64953474+skallweitNV@users.noreply.github.com>2024-06-06 18:08:38 +0200
committerGitHub <noreply@github.com>2024-06-06 09:08:38 -0700
commit8ea3854d94eb1ff213be716a38493d601784810b (patch)
tree071be96574be4afa54afe0a1fe0d66f10eb2cd80 /tools/gfx/metal/metal-shader-program.cpp
parent40d48bf1742cf21cc1ad3dd00d11fb04f37e512f (diff)
work on gfx metal backend (#4287)
* implement sampler state * implement input layout * implement fence object * buffer implementation * texture implementation * cleanup * add adapter enumeration * supported formats and allocation info * work on device and implement readBufferResource * skeleton for transient resource heap * initial work on command queue / buffers / encoders * fix uploading initial buffer data * implement buffer resource view * string utility functions * wip query pool implementation * cleanup * swapchain * wip * remove plain buffer view * extend gfxGetDeviceTypeName with metal * basic support for resource binding with compute shaders * needed for metal bindings * replace assert(0) with SLANG_UNIMPLEMENTED_X
Diffstat (limited to 'tools/gfx/metal/metal-shader-program.cpp')
-rw-r--r--tools/gfx/metal/metal-shader-program.cpp23
1 files changed, 8 insertions, 15 deletions
diff --git a/tools/gfx/metal/metal-shader-program.cpp b/tools/gfx/metal/metal-shader-program.cpp
index 05f5f9b53..1b998bc57 100644
--- a/tools/gfx/metal/metal-shader-program.cpp
+++ b/tools/gfx/metal/metal-shader-program.cpp
@@ -1,7 +1,7 @@
// metal-shader-program.cpp
#include "metal-shader-program.h"
-
#include "metal-device.h"
+#include "metal-util.h"
namespace gfx
{
@@ -20,23 +20,16 @@ ShaderProgramImpl::~ShaderProgramImpl()
{
}
-void ShaderProgramImpl::comFree() { }
-
-Result ShaderProgramImpl::createShaderModule(
- slang::EntryPointReflection* entryPointInfo, ComPtr<ISlangBlob> kernelCode)
+Result ShaderProgramImpl::createShaderModule(slang::EntryPointReflection* entryPointInfo, ComPtr<ISlangBlob> kernelCode)
{
- if (entryPointInfo == nullptr || kernelCode == nullptr || kernelCode->getBufferSize() == 0)
- {
- return SLANG_E_INVALID_ARG;
- }
-
- auto realEntryPointName = entryPointInfo->getNameOverride();
- std::string sourceStr(static_cast<const char*>(kernelCode->getBufferPointer()), kernelCode->getBufferSize());
- NS::String *nsSourceString = NS::String::alloc()->init(sourceStr.c_str(), NS::UTF8StringEncoding);
+ m_codeBlobs.add(kernelCode);
+ const char* realEntryPointName = entryPointInfo->getNameOverride();
+ dispatch_data_t data = dispatch_data_create(kernelCode->getBufferPointer(), kernelCode->getBufferSize(), dispatch_get_main_queue(), NULL);
NS::Error* error;
- MTL::Library* library = m_device->m_device->newLibrary(nsSourceString, nullptr, &error);
- if (library == nullptr)
+ NS::SharedPtr<MTL::Library> library = NS::TransferPtr(m_device->m_device->newLibrary(data, &error));
+ if (!library)
{
+ // TODO use better mechanism for reporting errors
std::cout << error->localizedDescription()->utf8String() << std::endl;
return SLANG_E_INVALID_ARG;
}