Minor RenderStream cleanups
This commit is contained in:
committed by
Mathias Agopian
parent
45beccc68b
commit
39b9d30d1a
@@ -119,6 +119,8 @@ struct CommandType<void (Driver::*)(ARGS...)> {
|
||||
/*
|
||||
* Command is templated on a specific method of Driver, using CommandType's template
|
||||
* parameter.
|
||||
* Note that we're never calling this method (which is why it doesn't appear in the
|
||||
* template parameter below). The actual call is made through Command::execute().
|
||||
*/
|
||||
template<void(Driver::*)(ARGS...)>
|
||||
class Command : public CommandBase {
|
||||
@@ -158,6 +160,9 @@ struct CommandType<void (Driver::*)(ARGS...)> {
|
||||
};
|
||||
};
|
||||
|
||||
// convert an method of "class Driver" into a Command<> type
|
||||
#define COMMAND_TYPE(method) CommandType<decltype(&Driver::method)>::Command<&Driver::method>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
class CustomCommand : public CommandBase {
|
||||
@@ -196,8 +201,7 @@ public:
|
||||
#define DECL_DRIVER_API(methodName, paramsDecl, params) \
|
||||
inline void methodName(paramsDecl) { \
|
||||
DEBUG_COMMAND(methodName, params); \
|
||||
using CmdType = CommandType<decltype(&Driver::methodName)>; \
|
||||
using Cmd = CmdType::Command<&Driver::methodName>; \
|
||||
using Cmd = COMMAND_TYPE(methodName); \
|
||||
void* const p = allocateCommand(CommandBase::align(sizeof(Cmd))); \
|
||||
new(p) Cmd(mDispatcher->methodName##_, params); \
|
||||
}
|
||||
@@ -212,8 +216,7 @@ public:
|
||||
inline RetType methodName(paramsDecl) { \
|
||||
DEBUG_COMMAND(methodName, params); \
|
||||
RetType result = mDriver->methodName##S(); \
|
||||
using CmdType = CommandType<decltype(&Driver::methodName##R)>; \
|
||||
using Cmd = CmdType::Command<&Driver::methodName##R>; \
|
||||
using Cmd = COMMAND_TYPE(methodName##R); \
|
||||
void* const p = allocateCommand(CommandBase::align(sizeof(Cmd))); \
|
||||
new(p) Cmd(mDispatcher->methodName##_, RetType(result), params); \
|
||||
return result; \
|
||||
|
||||
@@ -50,10 +50,10 @@ template<typename ConcreteDriver>
|
||||
class ConcreteDispatcher final : public Dispatcher {
|
||||
public:
|
||||
// initialize the dispatch table
|
||||
explicit ConcreteDispatcher(ConcreteDriver* driver) noexcept : Dispatcher() {
|
||||
explicit ConcreteDispatcher() noexcept : Dispatcher() {
|
||||
#define DECL_DRIVER_API_SYNCHRONOUS(RetType, methodName, paramsDecl, params)
|
||||
#define DECL_DRIVER_API(methodName, paramsDecl, params) methodName##_ = methodName;
|
||||
#define DECL_DRIVER_API_RETURN(RetType, methodName, paramsDecl, params) methodName##_ = methodName;
|
||||
#define DECL_DRIVER_API(methodName, paramsDecl, params) methodName##_ = &ConcreteDispatcher::methodName;
|
||||
#define DECL_DRIVER_API_RETURN(RetType, methodName, paramsDecl, params) methodName##_ = &ConcreteDispatcher::methodName;
|
||||
#include "driver/DriverAPI.inc"
|
||||
}
|
||||
private:
|
||||
@@ -61,16 +61,14 @@ private:
|
||||
#define DECL_DRIVER_API(methodName, paramsDecl, params) \
|
||||
static void methodName(Driver& driver, CommandBase* base, intptr_t* next) { \
|
||||
SYSTRACE() \
|
||||
using Type = CommandType<decltype(&Driver::methodName)>; \
|
||||
using Cmd = typename Type::template Command<&Driver::methodName>; \
|
||||
using Cmd = COMMAND_TYPE(methodName); \
|
||||
ConcreteDriver& concreteDriver = static_cast<ConcreteDriver&>(driver); \
|
||||
Cmd::execute(&ConcreteDriver::methodName, concreteDriver, base, next); \
|
||||
}
|
||||
#define DECL_DRIVER_API_RETURN(RetType, methodName, paramsDecl, params) \
|
||||
static void methodName(Driver& driver, CommandBase* base, intptr_t* next) { \
|
||||
SYSTRACE() \
|
||||
using Type = CommandType<decltype(&Driver::methodName##R)>; \
|
||||
using Cmd = typename Type::template Command<&Driver::methodName##R>; \
|
||||
using Cmd = COMMAND_TYPE(methodName##R); \
|
||||
ConcreteDriver& concreteDriver = static_cast<ConcreteDriver&>(driver); \
|
||||
Cmd::execute(&ConcreteDriver::methodName##R, concreteDriver, base, next); \
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ Driver* MetalDriver::create(MetalPlatform* const platform) {
|
||||
}
|
||||
|
||||
MetalDriver::MetalDriver(driver::MetalPlatform* platform) noexcept
|
||||
: DriverBase(new ConcreteDispatcher<MetalDriver>(this)),
|
||||
: DriverBase(new ConcreteDispatcher<MetalDriver>()),
|
||||
mPlatform(*platform),
|
||||
pImpl(new MetalDriverImpl) {
|
||||
pImpl->mDriverPool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
@@ -28,7 +28,7 @@ Driver* NoopDriver::create() {
|
||||
return new NoopDriver();
|
||||
}
|
||||
|
||||
NoopDriver::NoopDriver() noexcept : DriverBase(new ConcreteDispatcher<NoopDriver>(this)) {
|
||||
NoopDriver::NoopDriver() noexcept : DriverBase(new ConcreteDispatcher<NoopDriver>()) {
|
||||
}
|
||||
|
||||
NoopDriver::~NoopDriver() noexcept = default;
|
||||
|
||||
@@ -98,7 +98,7 @@ Driver* OpenGLDriver::create(
|
||||
}
|
||||
|
||||
OpenGLDriver::OpenGLDriver(OpenGLPlatform* platform) noexcept
|
||||
: DriverBase(new ConcreteDispatcher<OpenGLDriver>(this)),
|
||||
: DriverBase(new ConcreteDispatcher<OpenGLDriver>()),
|
||||
mHandleArena("Handles", 2U * 1024U * 1024U), // TODO: set the amount in configuration
|
||||
mSamplerMap(32),
|
||||
mPlatform(*platform) {
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace driver {
|
||||
|
||||
VulkanDriver::VulkanDriver(VulkanPlatform* platform,
|
||||
const char* const* ppEnabledExtensions, uint32_t enabledExtensionCount) noexcept :
|
||||
DriverBase(new ConcreteDispatcher<VulkanDriver>(this)),
|
||||
DriverBase(new ConcreteDispatcher<VulkanDriver>()),
|
||||
mContextManager(*platform), mStagePool(mContext), mFramebufferCache(mContext),
|
||||
mSamplerCache(mContext) {
|
||||
mContext.rasterState = mBinder.getDefaultRasterState();
|
||||
|
||||
Reference in New Issue
Block a user