Skip to content

Commit

Permalink
Accept MSAA render targets in MetalBlitter (google#1194)
Browse files Browse the repository at this point in the history
  • Loading branch information
bejado authored May 22, 2019
1 parent dd0e084 commit 6d3cbb8
Show file tree
Hide file tree
Showing 5 changed files with 242 additions and 108 deletions.
39 changes: 35 additions & 4 deletions filament/backend/src/metal/MetalBlitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

#include <backend/DriverEnums.h>

#include <tsl/robin_map.h>
#include <utils/Hash.h>

namespace filament {
namespace backend {
namespace metal {
Expand Down Expand Up @@ -58,19 +61,47 @@ class MetalBlitter {
void blit(const BlitArgs& args);

/**
* Free global resources. Should be called at least once per process when no further calls to
* blit will occur.
* Free resources. Should be called at least once per process when no further calls to blit will
* occur.
*/
static void shutdown() noexcept;
void shutdown() noexcept;

private:

static void setupColorAttachment(const BlitArgs& args, MTLRenderPassDescriptor* descriptor);
static void setupDepthAttachment(const BlitArgs& args, MTLRenderPassDescriptor* descriptor);
void ensureFunctions();

struct BlitFunctionKey {
bool blitColor;
bool blitDepth;
bool msaaColorSource;
bool msaaDepthSource;

bool operator==(const BlitFunctionKey& rhs) const noexcept {
return blitColor == rhs.blitColor &&
blitDepth == rhs.blitDepth &&
msaaColorSource == rhs.msaaDepthSource &&
msaaDepthSource == rhs.msaaDepthSource;
}

BlitFunctionKey() {
std::memset(this, 0, sizeof(BlitFunctionKey));
}
};

void blitFastPath(bool& blitColor, bool& blitDepth, const BlitArgs& args);
id<MTLFunction> compileFragmentFunction(BlitFunctionKey key);
id<MTLFunction> getBlitVertexFunction();
id<MTLFunction> getBlitFragmentFunction(BlitFunctionKey key);

MetalContext& mContext;

using HashFn = utils::hash::MurmurHashFn<BlitFunctionKey>;
using Function = id<MTLFunction>;
tsl::robin_map<BlitFunctionKey, Function, HashFn> mBlitFunctions;

id<MTLFunction> mVertexFunction = nil;

};

} // namespace metal
Expand Down
Loading

0 comments on commit 6d3cbb8

Please sign in to comment.