diff --git a/src/common/DynamicLib.cpp b/src/common/DynamicLib.cpp index 059ed4b54c..979d486160 100644 --- a/src/common/DynamicLib.cpp +++ b/src/common/DynamicLib.cpp @@ -29,65 +29,65 @@ DynamicLib::~DynamicLib() { } DynamicLib::DynamicLib(DynamicLib&& other) { - std::swap(this->handle, other.handle); + std::swap(mHandle, other.mHandle); } DynamicLib& DynamicLib::operator=(DynamicLib&& other) { - std::swap(this->handle, other.handle); + std::swap(mHandle, other.mHandle); return *this; } bool DynamicLib::Valid() const { - return handle != nullptr; + return mHandle != nullptr; } bool DynamicLib::Open(const std::string& filename, std::string* error) { #if NXT_PLATFORM_WINDOWS - handle = LoadLibraryA(filename.c_str()); + mHandle = LoadLibraryA(filename.c_str()); - if (handle == nullptr && error != nullptr) { + if (mHandle == nullptr && error != nullptr) { *error = "Windows Error: " + std::to_string(GetLastError()); } #elif NXT_PLATFORM_POSIX - handle = dlopen(filename.c_str(), RTLD_NOW); + mHandle = dlopen(filename.c_str(), RTLD_NOW); - if (handle == nullptr && error != nullptr) { + if (mHandle == nullptr && error != nullptr) { *error = dlerror(); } #else #error "Unsupported platform for DynamicLib" #endif - return handle != nullptr; + return mHandle != nullptr; } void DynamicLib::Close() { - if (handle == nullptr) { + if (mHandle == nullptr) { return; } #if NXT_PLATFORM_WINDOWS - FreeLibrary(static_cast(handle)); + FreeLibrary(static_cast(mHandle)); #elif NXT_PLATFORM_POSIX - dlclose(handle); + dlclose(mHandle); #else #error "Unsupported platform for DynamicLib" #endif - handle = nullptr; + mHandle = nullptr; } void* DynamicLib::GetProc(const std::string& procName, std::string* error) const { void* proc = nullptr; #if NXT_PLATFORM_WINDOWS - proc = reinterpret_cast(GetProcAddress(static_cast(handle), procName.c_str())); + proc = reinterpret_cast(GetProcAddress(static_cast(mHandle), procName.c_str())); if (proc == nullptr && error != nullptr) { *error = "Windows Error: " + std::to_string(GetLastError()); } #elif NXT_PLATFORM_POSIX - proc = reinterpret_cast(dlsym(handle, procName.c_str())); + proc = reinterpret_cast(dlsym(mHandle, procName.c_str())); if (proc == nullptr && error != nullptr) { *error = dlerror(); diff --git a/src/common/DynamicLib.h b/src/common/DynamicLib.h index 004c40640a..25e52cb84f 100644 --- a/src/common/DynamicLib.h +++ b/src/common/DynamicLib.h @@ -48,7 +48,7 @@ class DynamicLib { } private: - void* handle = nullptr; + void* mHandle = nullptr; }; #endif // COMMON_DYNAMICLIB_H_ diff --git a/src/common/SerialQueue.h b/src/common/SerialQueue.h index 3cca0aa1e5..7edb196f3b 100644 --- a/src/common/SerialQueue.h +++ b/src/common/SerialQueue.h @@ -40,11 +40,11 @@ class SerialQueue { T& operator*() const; private: - StorageIterator storageIterator; - // Special case the serialIterator when it should be equal to storageIterator.begin() - // otherwise we could ask storageIterator.begin() when storageIterator is storage.end() - // which is invalid. storageIterator.begin() is tagged with a nullptr. - T* serialIterator; + StorageIterator mStorageIterator; + // Special case the mSerialIterator when it should be equal to mStorageIterator.begin() + // otherwise we could ask mStorageIterator.begin() when mStorageIterator is mStorage.end() + // which is invalid. mStorageIterator.begin() is tagged with a nullptr. + T* mSerialIterator; }; class ConstIterator { @@ -57,8 +57,8 @@ class SerialQueue { const T& operator*() const; private: - ConstStorageIterator storageIterator; - const T* serialIterator; + ConstStorageIterator mStorageIterator; + const T* mSerialIterator; }; class BeginEnd { @@ -69,8 +69,8 @@ class SerialQueue { Iterator end() const; private: - StorageIterator startIt; - StorageIterator endIt; + StorageIterator mStartIt; + StorageIterator mEndIt; }; class ConstBeginEnd { @@ -81,8 +81,8 @@ class SerialQueue { ConstIterator end() const; private: - ConstStorageIterator startIt; - ConstStorageIterator endIt; + ConstStorageIterator mStartIt; + ConstStorageIterator mEndIt; }; // The serial must be given in (not strictly) increasing order. @@ -110,90 +110,90 @@ class SerialQueue { // Returns the first StorageIterator that a serial bigger than serial. ConstStorageIterator FindUpTo(Serial serial) const; StorageIterator FindUpTo(Serial serial); - Storage storage; + Storage mStorage; }; // SerialQueue template void SerialQueue::Enqueue(const T& value, Serial serial) { - NXT_ASSERT(Empty() || storage.back().first <= serial); + NXT_ASSERT(Empty() || mStorage.back().first <= serial); - if (Empty() || storage.back().first < serial) { - storage.emplace_back(SerialPair(serial, {})); + if (Empty() || mStorage.back().first < serial) { + mStorage.emplace_back(SerialPair(serial, {})); } - storage.back().second.emplace_back(value); + mStorage.back().second.emplace_back(value); } template void SerialQueue::Enqueue(T&& value, Serial serial) { - NXT_ASSERT(Empty() || storage.back().first <= serial); + NXT_ASSERT(Empty() || mStorage.back().first <= serial); - if (Empty() || storage.back().first < serial) { - storage.emplace_back(SerialPair(serial, {})); + if (Empty() || mStorage.back().first < serial) { + mStorage.emplace_back(SerialPair(serial, {})); } - storage.back().second.emplace_back(value); + mStorage.back().second.emplace_back(value); } template void SerialQueue::Enqueue(const std::vector& values, Serial serial) { NXT_ASSERT(values.size() > 0); - NXT_ASSERT(Empty() || storage.back().first <= serial); - storage.emplace_back(SerialPair(serial, {values})); + NXT_ASSERT(Empty() || mStorage.back().first <= serial); + mStorage.emplace_back(SerialPair(serial, {values})); } template void SerialQueue::Enqueue(std::vector&& values, Serial serial) { NXT_ASSERT(values.size() > 0); - NXT_ASSERT(Empty() || storage.back().first <= serial); - storage.emplace_back(SerialPair(serial, {values})); + NXT_ASSERT(Empty() || mStorage.back().first <= serial); + mStorage.emplace_back(SerialPair(serial, {values})); } template bool SerialQueue::Empty() const { - return storage.empty(); + return mStorage.empty(); } template typename SerialQueue::ConstBeginEnd SerialQueue::IterateAll() const { - return {storage.begin(), storage.end()}; + return {mStorage.begin(), mStorage.end()}; } template typename SerialQueue::ConstBeginEnd SerialQueue::IterateUpTo(Serial serial) const { - return {storage.begin(), FindUpTo(serial)}; + return {mStorage.begin(), FindUpTo(serial)}; } template typename SerialQueue::BeginEnd SerialQueue::IterateAll() { - return {storage.begin(), storage.end()}; + return {mStorage.begin(), mStorage.end()}; } template typename SerialQueue::BeginEnd SerialQueue::IterateUpTo(Serial serial) { - return {storage.begin(), FindUpTo(serial)}; + return {mStorage.begin(), FindUpTo(serial)}; } template void SerialQueue::Clear() { - storage.clear(); + mStorage.clear(); } template void SerialQueue::ClearUpTo(Serial serial) { - storage.erase(storage.begin(), FindUpTo(serial)); + mStorage.erase(mStorage.begin(), FindUpTo(serial)); } template Serial SerialQueue::FirstSerial() const { NXT_ASSERT(!Empty()); - return storage.front().first; + return mStorage.front().first; } template typename SerialQueue::ConstStorageIterator SerialQueue::FindUpTo(Serial serial) const { - auto it = storage.begin(); - while (it != storage.end() && it->first <= serial) { + auto it = mStorage.begin(); + while (it != mStorage.end() && it->first <= serial) { it ++; } return it; @@ -201,8 +201,8 @@ typename SerialQueue::ConstStorageIterator SerialQueue::FindUpTo(Serial se template typename SerialQueue::StorageIterator SerialQueue::FindUpTo(Serial serial) { - auto it = storage.begin(); - while (it != storage.end() && it->first <= serial) { + auto it = mStorage.begin(); + while (it != mStorage.end() && it->first <= serial) { it ++; } return it; @@ -212,39 +212,39 @@ typename SerialQueue::StorageIterator SerialQueue::FindUpTo(Serial serial) template SerialQueue::BeginEnd::BeginEnd(typename SerialQueue::StorageIterator start, typename SerialQueue::StorageIterator end) - : startIt(start), endIt(end) { + : mStartIt(start), mEndIt(end) { } template typename SerialQueue::Iterator SerialQueue::BeginEnd::begin() const { - return {startIt}; + return {mStartIt}; } template typename SerialQueue::Iterator SerialQueue::BeginEnd::end() const { - return {endIt}; + return {mEndIt}; } // SerialQueue::Iterator template SerialQueue::Iterator::Iterator(typename SerialQueue::StorageIterator start) - : storageIterator(start), serialIterator(nullptr) { + : mStorageIterator(start), mSerialIterator(nullptr) { } template typename SerialQueue::Iterator& SerialQueue::Iterator::operator++() { - T* vectorData = storageIterator->second.data(); + T* vectorData = mStorageIterator->second.data(); - if (serialIterator == nullptr) { - serialIterator = vectorData + 1; + if (mSerialIterator == nullptr) { + mSerialIterator = vectorData + 1; } else { - serialIterator ++; + mSerialIterator ++; } - if (serialIterator >= vectorData + storageIterator->second.size()) { - serialIterator = nullptr; - storageIterator ++; + if (mSerialIterator >= vectorData + mStorageIterator->second.size()) { + mSerialIterator = nullptr; + mStorageIterator ++; } return *this; @@ -252,7 +252,7 @@ typename SerialQueue::Iterator& SerialQueue::Iterator::operator++() { template bool SerialQueue::Iterator::operator==(const typename SerialQueue::Iterator& other) const { - return other.storageIterator == storageIterator && other.serialIterator == serialIterator; + return other.mStorageIterator == mStorageIterator && other.mSerialIterator == mSerialIterator; } template @@ -262,49 +262,49 @@ bool SerialQueue::Iterator::operator!=(const typename SerialQueue::Iterato template T& SerialQueue::Iterator::operator*() const { - if (serialIterator == nullptr) { - return *storageIterator->second.begin(); + if (mSerialIterator == nullptr) { + return *mStorageIterator->second.begin(); } - return *serialIterator; + return *mSerialIterator; } // SerialQueue::ConstBeginEnd template SerialQueue::ConstBeginEnd::ConstBeginEnd(typename SerialQueue::ConstStorageIterator start, typename SerialQueue::ConstStorageIterator end) - : startIt(start), endIt(end) { + : mStartIt(start), mEndIt(end) { } template typename SerialQueue::ConstIterator SerialQueue::ConstBeginEnd::begin() const { - return {startIt}; + return {mStartIt}; } template typename SerialQueue::ConstIterator SerialQueue::ConstBeginEnd::end() const { - return {endIt}; + return {mEndIt}; } // SerialQueue::ConstIterator template SerialQueue::ConstIterator::ConstIterator(typename SerialQueue::ConstStorageIterator start) - : storageIterator(start), serialIterator(nullptr) { + : mStorageIterator(start), mSerialIterator(nullptr) { } template typename SerialQueue::ConstIterator& SerialQueue::ConstIterator::operator++() { - const T* vectorData = storageIterator->second.data(); + const T* vectorData = mStorageIterator->second.data(); - if (serialIterator == nullptr) { - serialIterator = vectorData + 1; + if (mSerialIterator == nullptr) { + mSerialIterator = vectorData + 1; } else { - serialIterator ++; + mSerialIterator ++; } - if (serialIterator >= vectorData + storageIterator->second.size()) { - serialIterator = nullptr; - storageIterator ++; + if (mSerialIterator >= vectorData + mStorageIterator->second.size()) { + mSerialIterator = nullptr; + mStorageIterator ++; } return *this; @@ -312,7 +312,7 @@ typename SerialQueue::ConstIterator& SerialQueue::ConstIterator::operator+ template bool SerialQueue::ConstIterator::operator==(const typename SerialQueue::ConstIterator& other) const { - return other.storageIterator == storageIterator && other.serialIterator == serialIterator; + return other.mStorageIterator == mStorageIterator && other.mSerialIterator == mSerialIterator; } template @@ -322,10 +322,10 @@ bool SerialQueue::ConstIterator::operator!=(const typename SerialQueue::Co template const T& SerialQueue::ConstIterator::operator*() const { - if (serialIterator == nullptr) { - return *storageIterator->second.begin(); + if (mSerialIterator == nullptr) { + return *mStorageIterator->second.begin(); } - return *serialIterator; + return *mSerialIterator; } #endif // COMMON_SERIALQUEUE_H_ diff --git a/src/utils/BackendBinding.cpp b/src/utils/BackendBinding.cpp index d3e65742c9..1d520b3bb5 100644 --- a/src/utils/BackendBinding.cpp +++ b/src/utils/BackendBinding.cpp @@ -35,7 +35,7 @@ namespace utils { #endif void BackendBinding::SetWindow(GLFWwindow* window) { - this->window = window; + mWindow = window; } BackendBinding* CreateBinding(BackendType type) { diff --git a/src/utils/BackendBinding.h b/src/utils/BackendBinding.h index f8cdba1c8e..d7328d2c2c 100644 --- a/src/utils/BackendBinding.h +++ b/src/utils/BackendBinding.h @@ -43,7 +43,7 @@ namespace utils { void SetWindow(GLFWwindow* window); protected: - GLFWwindow* window = nullptr; + GLFWwindow* mWindow = nullptr; }; BackendBinding* CreateBinding(BackendType type); diff --git a/src/utils/D3D12Binding.cpp b/src/utils/D3D12Binding.cpp index dcd22ee12f..fb10f2857d 100644 --- a/src/utils/D3D12Binding.cpp +++ b/src/utils/D3D12Binding.cpp @@ -123,26 +123,26 @@ namespace utils { } private: - nxtDevice backendDevice = nullptr; - nxtProcTable procs = {}; + nxtDevice mBackendDevice = nullptr; + nxtProcTable mProcs = {}; static constexpr unsigned int kFrameCount = 2; - HWND window = 0; - ComPtr factory = {}; - ComPtr commandQueue = {}; - ComPtr swapChain = {}; - ComPtr renderTargetResources[kFrameCount] = {}; + HWND mWindow = 0; + ComPtr mFactory = {}; + ComPtr mCommandQueue = {}; + ComPtr mSwapChain = {}; + ComPtr mRenderTargetResources[kFrameCount] = {}; // Frame synchronization. Updated every frame - uint32_t renderTargetIndex = 0; - uint32_t previousRenderTargetIndex = 0; - uint64_t lastSerialRenderTargetWasUsed[kFrameCount] = {}; + uint32_t mRenderTargetIndex = 0; + uint32_t mPreviousRenderTargetIndex = 0; + uint64_t mLastSerialRenderTargetWasUsed[kFrameCount] = {}; - D3D12_RESOURCE_STATES renderTargetResourceState; + D3D12_RESOURCE_STATES mRenderTargetResourceState; SwapChainImplD3D12(HWND window, nxtProcTable procs) - : window(window), procs(procs), factory(CreateFactory()) { + : mWindow(window), mProcs(procs), mFactory(CreateFactory()) { } ~SwapChainImplD3D12() { @@ -152,8 +152,8 @@ namespace utils { friend class SwapChainImpl; void Init(nxtWSIContextD3D12* ctx) { - backendDevice = ctx->device; - commandQueue = backend::d3d12::GetCommandQueue(backendDevice); + mBackendDevice = ctx->device; + mCommandQueue = backend::d3d12::GetCommandQueue(mBackendDevice); } nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit allowedUsage, @@ -175,73 +175,73 @@ namespace utils { swapChainDesc.SampleDesc.Quality = 0; ComPtr swapChain1; - ASSERT_SUCCESS(factory->CreateSwapChainForHwnd( - commandQueue.Get(), - window, + ASSERT_SUCCESS(mFactory->CreateSwapChainForHwnd( + mCommandQueue.Get(), + mWindow, &swapChainDesc, nullptr, nullptr, &swapChain1 )); - ASSERT_SUCCESS(swapChain1.As(&swapChain)); + ASSERT_SUCCESS(swapChain1.As(&mSwapChain)); for (uint32_t n = 0; n < kFrameCount; ++n) { - ASSERT_SUCCESS(swapChain->GetBuffer(n, IID_PPV_ARGS(&renderTargetResources[n]))); + ASSERT_SUCCESS(mSwapChain->GetBuffer(n, IID_PPV_ARGS(&mRenderTargetResources[n]))); } // Get the initial render target and arbitrarily choose a "previous" render target that's different - previousRenderTargetIndex = renderTargetIndex = swapChain->GetCurrentBackBufferIndex(); - previousRenderTargetIndex = renderTargetIndex == 0 ? 1 : 0; + mPreviousRenderTargetIndex = mRenderTargetIndex = mSwapChain->GetCurrentBackBufferIndex(); + mPreviousRenderTargetIndex = mRenderTargetIndex == 0 ? 1 : 0; // Initial the serial for all render targets - const uint64_t initialSerial = backend::d3d12::GetSerial(backendDevice); + const uint64_t initialSerial = backend::d3d12::GetSerial(mBackendDevice); for (uint32_t n = 0; n < kFrameCount; ++n) { - lastSerialRenderTargetWasUsed[n] = initialSerial; + mLastSerialRenderTargetWasUsed[n] = initialSerial; } return NXT_SWAP_CHAIN_NO_ERROR; } nxtSwapChainError GetNextTexture(nxtSwapChainNextTexture* nextTexture) { - nextTexture->texture = renderTargetResources[renderTargetIndex].Get(); + nextTexture->texture = mRenderTargetResources[mRenderTargetIndex].Get(); return NXT_SWAP_CHAIN_NO_ERROR; } nxtSwapChainError Present() { // Current frame already transitioned to Present by the application, but // we need to flush the D3D12 backend's pending transitions. - procs.deviceTick(backendDevice); + mProcs.deviceTick(mBackendDevice); - ASSERT_SUCCESS(swapChain->Present(1, 0)); + ASSERT_SUCCESS(mSwapChain->Present(1, 0)); // Transition last frame's render target back to being a render target - if (renderTargetResourceState != D3D12_RESOURCE_STATE_PRESENT) { + if (mRenderTargetResourceState != D3D12_RESOURCE_STATE_PRESENT) { ComPtr commandList = {}; - backend::d3d12::OpenCommandList(backendDevice, &commandList); + backend::d3d12::OpenCommandList(mBackendDevice, &commandList); D3D12_RESOURCE_BARRIER resourceBarrier; - resourceBarrier.Transition.pResource = renderTargetResources[previousRenderTargetIndex].Get(); + resourceBarrier.Transition.pResource = mRenderTargetResources[mPreviousRenderTargetIndex].Get(); resourceBarrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT; - resourceBarrier.Transition.StateAfter = renderTargetResourceState; + resourceBarrier.Transition.StateAfter = mRenderTargetResourceState; resourceBarrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; resourceBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; resourceBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; commandList->ResourceBarrier(1, &resourceBarrier); ASSERT_SUCCESS(commandList->Close()); - backend::d3d12::ExecuteCommandLists(backendDevice, { commandList.Get() }); + backend::d3d12::ExecuteCommandLists(mBackendDevice, { commandList.Get() }); } - backend::d3d12::NextSerial(backendDevice); + backend::d3d12::NextSerial(mBackendDevice); - previousRenderTargetIndex = renderTargetIndex; - renderTargetIndex = swapChain->GetCurrentBackBufferIndex(); + mPreviousRenderTargetIndex = mRenderTargetIndex; + mRenderTargetIndex = mSwapChain->GetCurrentBackBufferIndex(); // If the next render target is not ready to be rendered yet, wait until it is ready. // If the last completed serial is less than the last requested serial for this render target, // then the commands previously executed on this render target have not yet completed - backend::d3d12::WaitForSerial(backendDevice, lastSerialRenderTargetWasUsed[renderTargetIndex]); + backend::d3d12::WaitForSerial(mBackendDevice, mLastSerialRenderTargetWasUsed[mRenderTargetIndex]); - lastSerialRenderTargetWasUsed[renderTargetIndex] = backend::d3d12::GetSerial(backendDevice); + mLastSerialRenderTargetWasUsed[mRenderTargetIndex] = backend::d3d12::GetSerial(mBackendDevice); return NXT_SWAP_CHAIN_NO_ERROR; } @@ -254,25 +254,25 @@ namespace utils { } void GetProcAndDevice(nxtProcTable* procs, nxtDevice* device) override { - factory = CreateFactory(); - ASSERT(GetHardwareAdapter(factory.Get(), &hardwareAdapter)); + mFactory = CreateFactory(); + ASSERT(GetHardwareAdapter(mFactory.Get(), &mHardwareAdapter)); ASSERT_SUCCESS(D3D12CreateDevice( - hardwareAdapter.Get(), + mHardwareAdapter.Get(), D3D_FEATURE_LEVEL_11_0, - IID_PPV_ARGS(&d3d12Device) + IID_PPV_ARGS(&mD3d12Device) )); - backend::d3d12::Init(d3d12Device, procs, device); - backendDevice = *device; - procTable = *procs; + backend::d3d12::Init(mD3d12Device, procs, device); + mBackendDevice = *device; + mProcTable = *procs; } uint64_t GetSwapChainImplementation() override { - if (swapchainImpl.userData == nullptr) { - HWND win32Window = glfwGetWin32Window(window); - swapchainImpl = SwapChainImplD3D12::Create(win32Window, procTable); + if (mSwapchainImpl.userData == nullptr) { + HWND win32Window = glfwGetWin32Window(mWindow); + mSwapchainImpl = SwapChainImplD3D12::Create(win32Window, mProcTable); } - return reinterpret_cast(&swapchainImpl); + return reinterpret_cast(&mSwapchainImpl); } nxtTextureFormat GetPreferredSwapChainTextureFormat() override { @@ -280,14 +280,14 @@ namespace utils { } private: - nxtDevice backendDevice = nullptr; - nxtSwapChainImplementation swapchainImpl = {}; - nxtProcTable procTable = {}; + nxtDevice mBackendDevice = nullptr; + nxtSwapChainImplementation mSwapchainImpl = {}; + nxtProcTable mProcTable = {}; // Initialization - ComPtr factory; - ComPtr hardwareAdapter; - ComPtr d3d12Device; + ComPtr mFactory; + ComPtr mHardwareAdapter; + ComPtr mD3d12Device; static bool GetHardwareAdapter(IDXGIFactory4* factory, IDXGIAdapter1** hardwareAdapter) { *hardwareAdapter = nullptr; diff --git a/src/utils/MetalBinding.mm b/src/utils/MetalBinding.mm index 36b3a58971..f15de5b762 100644 --- a/src/utils/MetalBinding.mm +++ b/src/utils/MetalBinding.mm @@ -43,29 +43,29 @@ namespace utils { } private: - id nsWindow = nil; - id mtlDevice = nil; - id commandQueue = nil; + id mNsWindow = nil; + id mMtlDevice = nil; + id mCommandQueue = nil; - CAMetalLayer* layer = nullptr; - id currentDrawable = nil; - id currentTexture = nil; + CAMetalLayer* mLayer = nullptr; + id mCurrentDrawable = nil; + id mCurrentTexture = nil; SwapChainImplMTL(id nsWindow) - : nsWindow(nsWindow) { + : mNsWindow(nsWindow) { } ~SwapChainImplMTL() { - [currentTexture release]; - [currentDrawable release]; + [mCurrentTexture release]; + [mCurrentDrawable release]; } // For GenerateSwapChainImplementation friend class SwapChainImpl; void Init(nxtWSIContextMetal* ctx) { - mtlDevice = ctx->device; - commandQueue = [mtlDevice newCommandQueue]; + mMtlDevice = ctx->device; + mCommandQueue = [mMtlDevice newCommandQueue]; } nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit, @@ -76,41 +76,41 @@ namespace utils { ASSERT(width > 0); ASSERT(height > 0); - NSView* contentView = [nsWindow contentView]; + NSView* contentView = [mNsWindow contentView]; [contentView setWantsLayer: YES]; CGSize size = {}; size.width = width; size.height = height; - layer = [CAMetalLayer layer]; - [layer setDevice: mtlDevice]; - [layer setPixelFormat: MTLPixelFormatBGRA8Unorm]; - [layer setFramebufferOnly: YES]; - [layer setDrawableSize: size]; + mLayer = [CAMetalLayer layer]; + [mLayer setDevice: mMtlDevice]; + [mLayer setPixelFormat: MTLPixelFormatBGRA8Unorm]; + [mLayer setFramebufferOnly: YES]; + [mLayer setDrawableSize: size]; - [contentView setLayer: layer]; + [contentView setLayer: mLayer]; return NXT_SWAP_CHAIN_NO_ERROR; } nxtSwapChainError GetNextTexture(nxtSwapChainNextTexture* nextTexture) { - [currentDrawable release]; - currentDrawable = [layer nextDrawable]; - [currentDrawable retain]; + [mCurrentDrawable release]; + mCurrentDrawable = [mLayer nextDrawable]; + [mCurrentDrawable retain]; - [currentTexture release]; - currentTexture = currentDrawable.texture; - [currentTexture retain]; + [mCurrentTexture release]; + mCurrentTexture = mCurrentDrawable.texture; + [mCurrentTexture retain]; - nextTexture->texture = reinterpret_cast(currentTexture); + nextTexture->texture = reinterpret_cast(mCurrentTexture); return NXT_SWAP_CHAIN_NO_ERROR; } nxtSwapChainError Present() { - id commandBuffer = [commandQueue commandBuffer]; - [commandBuffer presentDrawable: currentDrawable]; + id commandBuffer = [mCommandQueue commandBuffer]; + [commandBuffer presentDrawable: mCurrentDrawable]; [commandBuffer commit]; return NXT_SWAP_CHAIN_NO_ERROR; @@ -123,17 +123,17 @@ namespace utils { glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); } void GetProcAndDevice(nxtProcTable* procs, nxtDevice* device) override { - metalDevice = MTLCreateSystemDefaultDevice(); + mMetalDevice = MTLCreateSystemDefaultDevice(); - backend::metal::Init(metalDevice, procs, device); - backendDevice = *device; + backend::metal::Init(mMetalDevice, procs, device); + mBackendDevice = *device; } uint64_t GetSwapChainImplementation() override { - if (swapchainImpl.userData == nullptr) { - swapchainImpl = SwapChainImplMTL::Create(glfwGetCocoaWindow(window)); + if (mSwapchainImpl.userData == nullptr) { + mSwapchainImpl = SwapChainImplMTL::Create(glfwGetCocoaWindow(mWindow)); } - return reinterpret_cast(&swapchainImpl); + return reinterpret_cast(&mSwapchainImpl); } nxtTextureFormat GetPreferredSwapChainTextureFormat() override { @@ -141,9 +141,9 @@ namespace utils { } private: - id metalDevice = nil; - nxtDevice backendDevice = nullptr; - nxtSwapChainImplementation swapchainImpl = {}; + id mMetalDevice = nil; + nxtDevice mBackendDevice = nullptr; + nxtSwapChainImplementation mSwapchainImpl = {}; }; BackendBinding* CreateMetalBinding() { diff --git a/src/utils/OpenGLBinding.cpp b/src/utils/OpenGLBinding.cpp index 5618dcebdf..5367c711c1 100644 --- a/src/utils/OpenGLBinding.cpp +++ b/src/utils/OpenGLBinding.cpp @@ -39,34 +39,34 @@ namespace utils { } private: - GLFWwindow* window = nullptr; - uint32_t cfgWidth = 0; - uint32_t cfgHeight = 0; - GLuint backFBO = 0; - GLuint backTexture = 0; + GLFWwindow* mWindow = nullptr; + uint32_t mWidth = 0; + uint32_t mHeight = 0; + GLuint mBackFBO = 0; + GLuint mBackTexture = 0; SwapChainImplGL(GLFWwindow* window) - : window(window) { + : mWindow(window) { } ~SwapChainImplGL() { - glDeleteTextures(1, &backTexture); - glDeleteFramebuffers(1, &backFBO); + glDeleteTextures(1, &mBackTexture); + glDeleteFramebuffers(1, &mBackFBO); } // For GenerateSwapChainImplementation friend class SwapChainImpl; void Init(nxtWSIContextGL*) { - glGenTextures(1, &backTexture); - glBindTexture(GL_TEXTURE_2D, backTexture); + glGenTextures(1, &mBackTexture); + glBindTexture(GL_TEXTURE_2D, mBackTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); - glGenFramebuffers(1, &backFBO); - glBindFramebuffer(GL_READ_FRAMEBUFFER, backFBO); + glGenFramebuffers(1, &mBackFBO); + glBindFramebuffer(GL_READ_FRAMEBUFFER, mBackFBO); glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, backTexture, 0); + GL_TEXTURE_2D, mBackTexture, 0); } nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit, @@ -76,10 +76,10 @@ namespace utils { } ASSERT(width > 0); ASSERT(height > 0); - cfgWidth = width; - cfgHeight = height; + mWidth = width; + mHeight = height; - glBindTexture(GL_TEXTURE_2D, backTexture); + glBindTexture(GL_TEXTURE_2D, mBackTexture); // Reallocate the texture glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); @@ -88,16 +88,16 @@ namespace utils { } nxtSwapChainError GetNextTexture(nxtSwapChainNextTexture* nextTexture) { - nextTexture->texture = reinterpret_cast(static_cast(backTexture)); + nextTexture->texture = reinterpret_cast(static_cast(mBackTexture)); return NXT_SWAP_CHAIN_NO_ERROR; } nxtSwapChainError Present() { - glBindFramebuffer(GL_READ_FRAMEBUFFER, backFBO); + glBindFramebuffer(GL_READ_FRAMEBUFFER, mBackFBO); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); - glBlitFramebuffer(0, 0, cfgWidth, cfgHeight, 0, 0, cfgWidth, cfgHeight, + glBlitFramebuffer(0, 0, mWidth, mHeight, 0, 0, mWidth, mHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST); - glfwSwapBuffers(window); + glfwSwapBuffers(mWindow); return NXT_SWAP_CHAIN_NO_ERROR; } @@ -119,17 +119,17 @@ namespace utils { #endif } void GetProcAndDevice(nxtProcTable* procs, nxtDevice* device) override { - glfwMakeContextCurrent(window); + glfwMakeContextCurrent(mWindow); backend::opengl::Init(reinterpret_cast(glfwGetProcAddress), procs, device); - backendDevice = *device; + mBackendDevice = *device; } uint64_t GetSwapChainImplementation() override { - if (swapchainImpl.userData == nullptr) { - swapchainImpl = SwapChainImplGL::Create(window); + if (mSwapchainImpl.userData == nullptr) { + mSwapchainImpl = SwapChainImplGL::Create(mWindow); } - return reinterpret_cast(&swapchainImpl); + return reinterpret_cast(&mSwapchainImpl); } nxtTextureFormat GetPreferredSwapChainTextureFormat() override { @@ -137,8 +137,8 @@ namespace utils { } private: - nxtDevice backendDevice = nullptr; - nxtSwapChainImplementation swapchainImpl = {}; + nxtDevice mBackendDevice = nullptr; + nxtSwapChainImplementation mSwapchainImpl = {}; }; BackendBinding* CreateOpenGLBinding() { diff --git a/src/utils/VulkanBinding.cpp b/src/utils/VulkanBinding.cpp index 8ed48a2a58..3e1f1f735a 100644 --- a/src/utils/VulkanBinding.cpp +++ b/src/utils/VulkanBinding.cpp @@ -70,17 +70,17 @@ namespace utils { backend::vulkan::Init(procs, device); } uint64_t GetSwapChainImplementation() override { - if (swapchainImpl.userData == nullptr) { - swapchainImpl = SwapChainImplVulkan::Create(window); + if (mSwapchainImpl.userData == nullptr) { + mSwapchainImpl = SwapChainImplVulkan::Create(mWindow); } - return reinterpret_cast(&swapchainImpl); + return reinterpret_cast(&mSwapchainImpl); } nxtTextureFormat GetPreferredSwapChainTextureFormat() override { return NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM; } private: - nxtSwapChainImplementation swapchainImpl = {}; + nxtSwapChainImplementation mSwapchainImpl = {}; }; diff --git a/src/wire/TerribleCommandBuffer.cpp b/src/wire/TerribleCommandBuffer.cpp index 7dcfb10a45..e05d7298e3 100644 --- a/src/wire/TerribleCommandBuffer.cpp +++ b/src/wire/TerribleCommandBuffer.cpp @@ -20,22 +20,22 @@ namespace wire { TerribleCommandBuffer::TerribleCommandBuffer() { } - TerribleCommandBuffer::TerribleCommandBuffer(CommandHandler* handler) : handler(handler) { + TerribleCommandBuffer::TerribleCommandBuffer(CommandHandler* handler) : mHandler(handler) { } void TerribleCommandBuffer::SetHandler(CommandHandler* handler) { - this->handler = handler; + mHandler = handler; } void* TerribleCommandBuffer::GetCmdSpace(size_t size) { - if (size > sizeof(buffer)) { + if (size > sizeof(mBuffer)) { return nullptr; } - uint8_t* result = &buffer[offset]; - offset += size; + uint8_t* result = &mBuffer[mOffset]; + mOffset += size; - if (offset > sizeof(buffer)) { + if (mOffset > sizeof(mBuffer)) { Flush(); return GetCmdSpace(size); } @@ -44,8 +44,8 @@ namespace wire { } void TerribleCommandBuffer::Flush() { - handler->HandleCommands(buffer, offset); - offset = 0; + mHandler->HandleCommands(mBuffer, mOffset); + mOffset = 0; } } diff --git a/src/wire/TerribleCommandBuffer.h b/src/wire/TerribleCommandBuffer.h index 32cd3d422d..691da0a2f9 100644 --- a/src/wire/TerribleCommandBuffer.h +++ b/src/wire/TerribleCommandBuffer.h @@ -33,9 +33,9 @@ class TerribleCommandBuffer : public CommandSerializer { void Flush() override; private: - CommandHandler* handler = nullptr; - size_t offset = 0; - uint8_t buffer[10000000]; + CommandHandler* mHandler = nullptr; + size_t mOffset = 0; + uint8_t mBuffer[10000000]; }; }