Skip to content
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

Fix MacOS Build #114

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plugins/metal/src/metal_material_constant_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Halley
public:
explicit MetalMaterialConstantBuffer(MetalVideo& video);
~MetalMaterialConstantBuffer();
void update(const MaterialDataBlock& dataBlock) override;
void update(gsl::span<const gsl::byte> data) override;
void bindVertex(id<MTLRenderCommandEncoder> encoder, int bindPoint);
void bindFragment(id<MTLRenderCommandEncoder> encoder, int bindPoint);
private:
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/metal/src/metal_material_constant_buffer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@

MetalMaterialConstantBuffer::~MetalMaterialConstantBuffer() {}

void MetalMaterialConstantBuffer::update(const MaterialDataBlock& dataBlock) {
void MetalMaterialConstantBuffer::update(gsl::span<const gsl::byte> data) {
// We must pad up to a multiple of 16 (float4)
// TODO we ought to move this somewhere it won't be called so often.
auto data = dataBlock.getData();
const size_t padding = alignUp<char>(data.size_bytes(), 16);

auto padded = malloc(data.size_bytes() + padding);
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/metal/src/metal_painter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using namespace Halley;

MetalPainter::MetalPainter(MetalVideo& video, Resources& resources)
: Painter(resources)
: Painter(video, resources)
, video(video)
, indexBuffer(nil)
{}
Expand Down Expand Up @@ -43,7 +43,8 @@
[encoder setRenderPipelineState:pipelineState];

// Metal requires the global material to be bound for each material pass, as it has no 'global' state.
static_cast<MetalMaterialConstantBuffer&>(halleyGlobalMaterial->getDataBlocks().front().getConstantBuffer()).bindVertex(encoder, 0);
// static_cast<MetalMaterialConstantBuffer&>(halleyGlobalMaterial->getDataBlocks().front().getConstantBuffer()).bindVertex(encoder, 0);
static_cast<MetalMaterialConstantBuffer&>(getConstantBuffer(halleyGlobalMaterial->getDataBlocks().front())).bindVertex(encoder, 0);

// Bind textures
int texIndex = 0;
Expand Down Expand Up @@ -127,13 +128,12 @@
void MetalPainter::setMaterialData(const Material& material) {
for (auto& dataBlock : material.getDataBlocks()) {
if (dataBlock.getType() != MaterialDataBlockType::SharedExternal) {
static_cast<MetalMaterialConstantBuffer&>(dataBlock.getConstantBuffer()).bindFragment(encoder, 0);
static_cast<MetalMaterialConstantBuffer&>(getConstantBuffer(dataBlock)).bindFragment(encoder, 0);
}
}
}

void MetalPainter::onUpdateProjection(Material& material) {
material.uploadData(*this);
setMaterialData(material);
}

Expand Down