Rename nxt -> dawn for dawn_wsi.h declarations

Also does the initial complete formatting of files in src/include
This commit is contained in:
Corentin Wallez
2018-07-18 14:38:34 +02:00
committed by Corentin Wallez
parent 3e371b146d
commit 05c90ee4cb
19 changed files with 154 additions and 146 deletions

View File

@@ -23,33 +23,32 @@ namespace nxt {
#define CR_GLIBCXX_4_7_0 20120322
#define CR_GLIBCXX_4_5_4 20120702
#define CR_GLIBCXX_4_6_4 20121127
#if defined(__GLIBCXX__) && \
(__GLIBCXX__ < CR_GLIBCXX_4_7_0 || __GLIBCXX__ == CR_GLIBCXX_4_5_4 || \
__GLIBCXX__ == CR_GLIBCXX_4_6_4)
#define CR_USE_FALLBACKS_FOR_OLD_GLIBCXX
#if defined(__GLIBCXX__) && (__GLIBCXX__ < CR_GLIBCXX_4_7_0 || __GLIBCXX__ == CR_GLIBCXX_4_5_4 || \
__GLIBCXX__ == CR_GLIBCXX_4_6_4)
# define CR_USE_FALLBACKS_FOR_OLD_GLIBCXX
#endif
#if defined(CR_USE_FALLBACKS_FOR_OLD_GLIBCXX)
template <typename T>
struct UnderlyingType {
using type = __underlying_type(T);
using type = __underlying_type(T);
};
#else
template <typename T>
using UnderlyingType = std::underlying_type<T>;
#endif
template<typename T>
template <typename T>
struct IsNXTBitmask {
static constexpr bool enable = false;
};
template<typename T, typename Enable = void>
template <typename T, typename Enable = void>
struct LowerBitmask {
static constexpr bool enable = false;
};
template<typename T>
template <typename T>
struct LowerBitmask<T, typename std::enable_if<IsNXTBitmask<T>::enable>::type> {
static constexpr bool enable = true;
using type = T;
@@ -58,7 +57,7 @@ namespace nxt {
}
};
template<typename T>
template <typename T>
struct BoolConvertible {
using Integral = typename UnderlyingType<T>::type;
@@ -74,7 +73,7 @@ namespace nxt {
Integral value;
};
template<typename T>
template <typename T>
struct LowerBitmask<BoolConvertible<T>> {
static constexpr bool enable = true;
using type = T;
@@ -83,44 +82,47 @@ namespace nxt {
}
};
template<typename T>
template <typename T>
constexpr bool HasZeroOrOneBits(T value) {
using Integral = typename UnderlyingType<T>::type;
return (static_cast<Integral>(value) & (static_cast<Integral>(value) - 1)) == 0;
}
template<typename T1, typename T2, typename = typename std::enable_if<
LowerBitmask<T1>::enable && LowerBitmask<T2>::enable
>::type>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator | (T1 left, T2 right) {
template <typename T1,
typename T2,
typename = typename std::enable_if<LowerBitmask<T1>::enable &&
LowerBitmask<T2>::enable>::type>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator|(T1 left, T2 right) {
using T = typename LowerBitmask<T1>::type;
using Integral = typename UnderlyingType<T>::type;
return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) |
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
}
template<typename T1, typename T2, typename = typename std::enable_if<
LowerBitmask<T1>::enable && LowerBitmask<T2>::enable
>::type>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator & (T1 left, T2 right) {
template <typename T1,
typename T2,
typename = typename std::enable_if<LowerBitmask<T1>::enable &&
LowerBitmask<T2>::enable>::type>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator&(T1 left, T2 right) {
using T = typename LowerBitmask<T1>::type;
using Integral = typename UnderlyingType<T>::type;
return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) &
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
}
template<typename T1, typename T2, typename = typename std::enable_if<
LowerBitmask<T1>::enable && LowerBitmask<T2>::enable
>::type>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator ^ (T1 left, T2 right) {
template <typename T1,
typename T2,
typename = typename std::enable_if<LowerBitmask<T1>::enable &&
LowerBitmask<T2>::enable>::type>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator^(T1 left, T2 right) {
using T = typename LowerBitmask<T1>::type;
using Integral = typename UnderlyingType<T>::type;
return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) ^
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
}
template<typename T1>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator ~ (T1 t) {
template <typename T1>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator~(T1 t) {
using T = typename LowerBitmask<T1>::type;
using Integral = typename UnderlyingType<T>::type;
return ~static_cast<Integral>(LowerBitmask<T1>::Lower(t));
@@ -155,6 +157,6 @@ namespace nxt {
l = l ^ r;
return l;
}
}
} // namespace nxt
#endif // NXT_ENUM_CLASS_BITMASKS_H_
#endif // NXT_ENUM_CLASS_BITMASKS_H_

View File

@@ -12,14 +12,14 @@
//* See the License for the specific language governing permissions and
//* limitations under the License.
#ifndef NXT_WSI_H
#define NXT_WSI_H
#ifndef DAWN_WSI_H
#define DAWN_WSI_H
#include <dawn/dawn.h>
// Error message (or nullptr if there was no error)
typedef const char* nxtSwapChainError;
constexpr nxtSwapChainError NXT_SWAP_CHAIN_NO_ERROR = nullptr;
typedef const char* dawnSwapChainError;
constexpr dawnSwapChainError DAWN_SWAP_CHAIN_NO_ERROR = nullptr;
typedef struct {
/// Backend-specific texture id/name/pointer
@@ -28,54 +28,58 @@ typedef struct {
uint64_t u64;
uint32_t u32;
} texture;
} nxtSwapChainNextTexture;
} dawnSwapChainNextTexture;
typedef struct {
/// Initialize the swap chain implementation.
/// (*wsiContext) is one of nxtWSIContext{D3D12,Metal,GL}
/// (*wsiContext) is one of dawnWSIContext{D3D12,Metal,GL}
void (*Init)(void* userData, void* wsiContext);
/// Destroy the swap chain implementation.
void (*Destroy)(void* userData);
/// Configure/reconfigure the swap chain.
nxtSwapChainError (*Configure)(void* userData, nxtTextureFormat format, nxtTextureUsageBit allowedUsage, uint32_t width, uint32_t height);
dawnSwapChainError (*Configure)(void* userData,
nxtTextureFormat format,
nxtTextureUsageBit allowedUsage,
uint32_t width,
uint32_t height);
/// Acquire the next texture from the swap chain.
nxtSwapChainError (*GetNextTexture)(void* userData, nxtSwapChainNextTexture* nextTexture);
dawnSwapChainError (*GetNextTexture)(void* userData, dawnSwapChainNextTexture* nextTexture);
/// Present the last acquired texture to the screen.
nxtSwapChainError (*Present)(void* userData);
dawnSwapChainError (*Present)(void* userData);
/// Each function is called with userData as its first argument.
void* userData;
/// For use by the D3D12 and Vulkan backends: how the swapchain will use the texture.
nxtTextureUsageBit textureUsage;
} nxtSwapChainImplementation;
} dawnSwapChainImplementation;
#if defined(DAWN_ENABLE_BACKEND_D3D12) && defined(__cplusplus)
typedef struct {
nxtDevice device = nullptr;
} nxtWSIContextD3D12;
} dawnWSIContextD3D12;
#endif
#if defined(DAWN_ENABLE_BACKEND_METAL) && defined(__OBJC__)
#import <Metal/Metal.h>
# import <Metal/Metal.h>
typedef struct {
id<MTLDevice> device = nil;
} nxtWSIContextMetal;
} dawnWSIContextMetal;
#endif
#ifdef DAWN_ENABLE_BACKEND_OPENGL
typedef struct {
} nxtWSIContextGL;
} dawnWSIContextGL;
#endif
#ifdef DAWN_ENABLE_BACKEND_VULKAN
typedef struct {
} nxtWSIContextVulkan;
} dawnWSIContextVulkan;
#endif
#endif // NXT_WSI_H
#endif // DAWN_WSI_H