Lot more Metal changes
This commit is contained in:
@@ -14,40 +14,33 @@
|
||||
using namespace Seele;
|
||||
using namespace Seele::Metal;
|
||||
|
||||
Shader::Shader(PGraphics graphics, Gfx::SeShaderStageFlags stage)
|
||||
: stage(stage), graphics(graphics) {}
|
||||
Shader::Shader(PGraphics graphics, Gfx::SeShaderStageFlags stage) : stage(stage), graphics(graphics) {}
|
||||
|
||||
Shader::~Shader() {
|
||||
if (function) {
|
||||
function->release();
|
||||
library->release();
|
||||
}
|
||||
if (function) {
|
||||
function->release();
|
||||
library->release();
|
||||
}
|
||||
}
|
||||
|
||||
void Shader::create(const ShaderCreateInfo &createInfo) {
|
||||
Map<std::string, uint32> paramMapping;
|
||||
auto [kernelBlob, entryPoint] =
|
||||
generateShader(createInfo);
|
||||
std::cout << (char *)kernelBlob->getBufferPointer() << std::endl;
|
||||
hash = CRC::Calculate(kernelBlob->getBufferPointer(),
|
||||
kernelBlob->getBufferSize(), CRC::CRC_32());
|
||||
NS::Error *error;
|
||||
MTL::CompileOptions *options = MTL::CompileOptions::alloc()->init();
|
||||
library = graphics->getDevice()->newLibrary(
|
||||
NS::String::string((char *)kernelBlob->getBufferPointer(),
|
||||
NS::ASCIIStringEncoding),
|
||||
options, &error);
|
||||
options->release();
|
||||
if (error) {
|
||||
std::cout << error->localizedDescription()->cString(NS::ASCIIStringEncoding)
|
||||
<< std::endl;
|
||||
}
|
||||
function = library->newFunction(NS::String::string(
|
||||
entryPoint.c_str(), NS::ASCIIStringEncoding));
|
||||
if (!function) {
|
||||
assert(false);
|
||||
}
|
||||
|
||||
void Shader::create(const ShaderCreateInfo& createInfo) {
|
||||
auto [kernelBlob, entryPoint] = generateShader(createInfo);
|
||||
std::ofstream test("test.metal");
|
||||
test.write((char*)kernelBlob->getBufferPointer(), kernelBlob->getBufferSize());
|
||||
test.close();
|
||||
hash = CRC::Calculate(kernelBlob->getBufferPointer(), kernelBlob->getBufferSize(), CRC::CRC_32());
|
||||
NS::Error* error;
|
||||
MTL::CompileOptions* options = MTL::CompileOptions::alloc()->init();
|
||||
library = graphics->getDevice()->newLibrary(NS::String::string((char*)kernelBlob->getBufferPointer(), NS::ASCIIStringEncoding), options,
|
||||
&error);
|
||||
options->release();
|
||||
if (error) {
|
||||
std::cout << error->localizedDescription()->cString(NS::ASCIIStringEncoding) << std::endl;
|
||||
}
|
||||
function = library->newFunction(NS::String::string(entryPoint.c_str(), NS::ASCIIStringEncoding));
|
||||
if (!function) {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
uint32 Shader::getShaderHash() const { return hash; }
|
||||
|
||||
Reference in New Issue
Block a user