mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-07-16 04:07:08 +12:00
compile shaders to a metallib file
This commit is contained in:
parent
5741de2cad
commit
3005468b3f
5 changed files with 50 additions and 6 deletions
12
src/core/renderer_mtl/objc_helper.mm
Normal file
12
src/core/renderer_mtl/objc_helper.mm
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include "renderer_mtl/objc_helper.hpp"
|
||||
|
||||
// TODO: change the include
|
||||
#import <Metal/Metal.h>
|
||||
|
||||
namespace Metal {
|
||||
|
||||
dispatch_data_t createDispatchData(const void* data, size_t size) {
|
||||
return dispatch_data_create(data, size, dispatch_get_global_queue(0, 0), ^{});
|
||||
}
|
||||
|
||||
} // namespace Metal
|
|
@ -1,5 +1,6 @@
|
|||
#include "PICA/gpu.hpp"
|
||||
#include "renderer_mtl/renderer_mtl.hpp"
|
||||
#include "renderer_mtl/objc_helper.hpp"
|
||||
|
||||
#include <cmrc/cmrc.hpp>
|
||||
#include <cstddef>
|
||||
|
@ -124,11 +125,11 @@ void RendererMTL::initGraphicsContext(SDL_Window* window) {
|
|||
|
||||
// Load shaders
|
||||
auto mtlResources = cmrc::RendererMTL::get_filesystem();
|
||||
auto shaderSource = mtlResources.open("metal_shaders.metal");
|
||||
std::string source(shaderSource.begin(), shaderSource.size());
|
||||
MTL::CompileOptions* compileOptions = MTL::CompileOptions::alloc()->init();
|
||||
auto shaderSource = mtlResources.open("metal_shaders.metallib");
|
||||
//MTL::CompileOptions* compileOptions = MTL::CompileOptions::alloc()->init();
|
||||
NS::Error* error = nullptr;
|
||||
MTL::Library* library = device->newLibrary(NS::String::string(source.c_str(), NS::ASCIIStringEncoding), compileOptions, &error);
|
||||
MTL::Library* library = device->newLibrary(Metal::createDispatchData(shaderSource.begin(), shaderSource.size()), &error);
|
||||
//MTL::Library* library = device->newLibrary(NS::String::string(source.c_str(), NS::ASCIIStringEncoding), compileOptions, &error);
|
||||
if (error) {
|
||||
Helpers::panic("Error loading shaders: %s", error->description()->cString(NS::ASCIIStringEncoding));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue