Rename MVKFormats to MVKPixelFormats.
This commit is contained in:
parent
a9e5cb2914
commit
e9bbea96d1
@ -157,10 +157,10 @@
|
|||||||
A95B7D6A1D3EE486003183D3 /* MVKCommandEncoderState.h in Headers */ = {isa = PBXBuildFile; fileRef = A95B7D671D3EE486003183D3 /* MVKCommandEncoderState.h */; };
|
A95B7D6A1D3EE486003183D3 /* MVKCommandEncoderState.h in Headers */ = {isa = PBXBuildFile; fileRef = A95B7D671D3EE486003183D3 /* MVKCommandEncoderState.h */; };
|
||||||
A95B7D6B1D3EE486003183D3 /* MVKCommandEncoderState.mm in Sources */ = {isa = PBXBuildFile; fileRef = A95B7D681D3EE486003183D3 /* MVKCommandEncoderState.mm */; };
|
A95B7D6B1D3EE486003183D3 /* MVKCommandEncoderState.mm in Sources */ = {isa = PBXBuildFile; fileRef = A95B7D681D3EE486003183D3 /* MVKCommandEncoderState.mm */; };
|
||||||
A95B7D6C1D3EE486003183D3 /* MVKCommandEncoderState.mm in Sources */ = {isa = PBXBuildFile; fileRef = A95B7D681D3EE486003183D3 /* MVKCommandEncoderState.mm */; };
|
A95B7D6C1D3EE486003183D3 /* MVKCommandEncoderState.mm in Sources */ = {isa = PBXBuildFile; fileRef = A95B7D681D3EE486003183D3 /* MVKCommandEncoderState.mm */; };
|
||||||
A9653FBA24129C84005999D7 /* MVKFormats.h in Headers */ = {isa = PBXBuildFile; fileRef = A9653FB724129C84005999D7 /* MVKFormats.h */; };
|
A9653FBA24129C84005999D7 /* MVKPixelFormats.h in Headers */ = {isa = PBXBuildFile; fileRef = A9653FB724129C84005999D7 /* MVKPixelFormats.h */; };
|
||||||
A9653FBB24129C84005999D7 /* MVKFormats.h in Headers */ = {isa = PBXBuildFile; fileRef = A9653FB724129C84005999D7 /* MVKFormats.h */; };
|
A9653FBB24129C84005999D7 /* MVKPixelFormats.h in Headers */ = {isa = PBXBuildFile; fileRef = A9653FB724129C84005999D7 /* MVKPixelFormats.h */; };
|
||||||
A9653FBC24129C84005999D7 /* MVKFormats.mm in Sources */ = {isa = PBXBuildFile; fileRef = A9653FB924129C84005999D7 /* MVKFormats.mm */; };
|
A9653FBC24129C84005999D7 /* MVKPixelFormats.mm in Sources */ = {isa = PBXBuildFile; fileRef = A9653FB924129C84005999D7 /* MVKPixelFormats.mm */; };
|
||||||
A9653FBD24129C84005999D7 /* MVKFormats.mm in Sources */ = {isa = PBXBuildFile; fileRef = A9653FB924129C84005999D7 /* MVKFormats.mm */; };
|
A9653FBD24129C84005999D7 /* MVKPixelFormats.mm in Sources */ = {isa = PBXBuildFile; fileRef = A9653FB924129C84005999D7 /* MVKPixelFormats.mm */; };
|
||||||
A966A5DF23C535D000BBF9B4 /* MVKDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = A966A5DC23C535D000BBF9B4 /* MVKDescriptor.h */; };
|
A966A5DF23C535D000BBF9B4 /* MVKDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = A966A5DC23C535D000BBF9B4 /* MVKDescriptor.h */; };
|
||||||
A966A5E023C535D000BBF9B4 /* MVKDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = A966A5DC23C535D000BBF9B4 /* MVKDescriptor.h */; };
|
A966A5E023C535D000BBF9B4 /* MVKDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = A966A5DC23C535D000BBF9B4 /* MVKDescriptor.h */; };
|
||||||
A966A5E123C535D000BBF9B4 /* MVKDescriptor.mm in Sources */ = {isa = PBXBuildFile; fileRef = A966A5DE23C535D000BBF9B4 /* MVKDescriptor.mm */; };
|
A966A5E123C535D000BBF9B4 /* MVKDescriptor.mm in Sources */ = {isa = PBXBuildFile; fileRef = A966A5DE23C535D000BBF9B4 /* MVKDescriptor.mm */; };
|
||||||
@ -381,8 +381,8 @@
|
|||||||
A95870F71C90D29F009EB096 /* MVKCommandResourceFactory.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MVKCommandResourceFactory.mm; sourceTree = "<group>"; };
|
A95870F71C90D29F009EB096 /* MVKCommandResourceFactory.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MVKCommandResourceFactory.mm; sourceTree = "<group>"; };
|
||||||
A95B7D671D3EE486003183D3 /* MVKCommandEncoderState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVKCommandEncoderState.h; sourceTree = "<group>"; };
|
A95B7D671D3EE486003183D3 /* MVKCommandEncoderState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVKCommandEncoderState.h; sourceTree = "<group>"; };
|
||||||
A95B7D681D3EE486003183D3 /* MVKCommandEncoderState.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MVKCommandEncoderState.mm; sourceTree = "<group>"; };
|
A95B7D681D3EE486003183D3 /* MVKCommandEncoderState.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MVKCommandEncoderState.mm; sourceTree = "<group>"; };
|
||||||
A9653FB724129C84005999D7 /* MVKFormats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVKFormats.h; sourceTree = "<group>"; };
|
A9653FB724129C84005999D7 /* MVKPixelFormats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVKPixelFormats.h; sourceTree = "<group>"; };
|
||||||
A9653FB924129C84005999D7 /* MVKFormats.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MVKFormats.mm; sourceTree = "<group>"; };
|
A9653FB924129C84005999D7 /* MVKPixelFormats.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MVKPixelFormats.mm; sourceTree = "<group>"; };
|
||||||
A966A5DC23C535D000BBF9B4 /* MVKDescriptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVKDescriptor.h; sourceTree = "<group>"; };
|
A966A5DC23C535D000BBF9B4 /* MVKDescriptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVKDescriptor.h; sourceTree = "<group>"; };
|
||||||
A966A5DE23C535D000BBF9B4 /* MVKDescriptor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MVKDescriptor.mm; sourceTree = "<group>"; };
|
A966A5DE23C535D000BBF9B4 /* MVKDescriptor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MVKDescriptor.mm; sourceTree = "<group>"; };
|
||||||
A98149411FB6A3F7005F00B4 /* MVKBaseObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MVKBaseObject.mm; sourceTree = "<group>"; };
|
A98149411FB6A3F7005F00B4 /* MVKBaseObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MVKBaseObject.mm; sourceTree = "<group>"; };
|
||||||
@ -503,8 +503,8 @@
|
|||||||
A94FB7841C7DFB4800632CA3 /* MVKDevice.mm */,
|
A94FB7841C7DFB4800632CA3 /* MVKDevice.mm */,
|
||||||
A94FB7851C7DFB4800632CA3 /* MVKDeviceMemory.h */,
|
A94FB7851C7DFB4800632CA3 /* MVKDeviceMemory.h */,
|
||||||
A94FB7861C7DFB4800632CA3 /* MVKDeviceMemory.mm */,
|
A94FB7861C7DFB4800632CA3 /* MVKDeviceMemory.mm */,
|
||||||
A9653FB724129C84005999D7 /* MVKFormats.h */,
|
A9653FB724129C84005999D7 /* MVKPixelFormats.h */,
|
||||||
A9653FB924129C84005999D7 /* MVKFormats.mm */,
|
A9653FB924129C84005999D7 /* MVKPixelFormats.mm */,
|
||||||
A94FB7871C7DFB4800632CA3 /* MVKFramebuffer.h */,
|
A94FB7871C7DFB4800632CA3 /* MVKFramebuffer.h */,
|
||||||
A94FB7881C7DFB4800632CA3 /* MVKFramebuffer.mm */,
|
A94FB7881C7DFB4800632CA3 /* MVKFramebuffer.mm */,
|
||||||
A94FB7891C7DFB4800632CA3 /* MVKImage.h */,
|
A94FB7891C7DFB4800632CA3 /* MVKImage.h */,
|
||||||
@ -725,7 +725,7 @@
|
|||||||
A90C8DEA1F45354D009CB32C /* MVKCommandEncodingPool.h in Headers */,
|
A90C8DEA1F45354D009CB32C /* MVKCommandEncodingPool.h in Headers */,
|
||||||
A94FB8081C7DFB4800632CA3 /* MVKResource.h in Headers */,
|
A94FB8081C7DFB4800632CA3 /* MVKResource.h in Headers */,
|
||||||
A9E53DDD2100B197002781DD /* MTLTextureDescriptor+MoltenVK.h in Headers */,
|
A9E53DDD2100B197002781DD /* MTLTextureDescriptor+MoltenVK.h in Headers */,
|
||||||
A9653FBA24129C84005999D7 /* MVKFormats.h in Headers */,
|
A9653FBA24129C84005999D7 /* MVKPixelFormats.h in Headers */,
|
||||||
A981496B1FB6A998005F00B4 /* MVKStrings.h in Headers */,
|
A981496B1FB6A998005F00B4 /* MVKStrings.h in Headers */,
|
||||||
A94FB81C1C7DFB4800632CA3 /* MVKLayers.h in Headers */,
|
A94FB81C1C7DFB4800632CA3 /* MVKLayers.h in Headers */,
|
||||||
);
|
);
|
||||||
@ -795,7 +795,7 @@
|
|||||||
A90C8DEB1F45354D009CB32C /* MVKCommandEncodingPool.h in Headers */,
|
A90C8DEB1F45354D009CB32C /* MVKCommandEncodingPool.h in Headers */,
|
||||||
A94FB8091C7DFB4800632CA3 /* MVKResource.h in Headers */,
|
A94FB8091C7DFB4800632CA3 /* MVKResource.h in Headers */,
|
||||||
A9E53DDE2100B197002781DD /* MTLTextureDescriptor+MoltenVK.h in Headers */,
|
A9E53DDE2100B197002781DD /* MTLTextureDescriptor+MoltenVK.h in Headers */,
|
||||||
A9653FBB24129C84005999D7 /* MVKFormats.h in Headers */,
|
A9653FBB24129C84005999D7 /* MVKPixelFormats.h in Headers */,
|
||||||
A981496C1FB6A998005F00B4 /* MVKStrings.h in Headers */,
|
A981496C1FB6A998005F00B4 /* MVKStrings.h in Headers */,
|
||||||
A94FB81D1C7DFB4800632CA3 /* MVKLayers.h in Headers */,
|
A94FB81D1C7DFB4800632CA3 /* MVKLayers.h in Headers */,
|
||||||
);
|
);
|
||||||
@ -1022,7 +1022,7 @@
|
|||||||
A94FB82A1C7DFB4800632CA3 /* mvk_datatypes.mm in Sources */,
|
A94FB82A1C7DFB4800632CA3 /* mvk_datatypes.mm in Sources */,
|
||||||
A909F661213B190700FCD6BE /* MVKExtensions.mm in Sources */,
|
A909F661213B190700FCD6BE /* MVKExtensions.mm in Sources */,
|
||||||
A98149551FB6A3F7005F00B4 /* MVKFoundation.cpp in Sources */,
|
A98149551FB6A3F7005F00B4 /* MVKFoundation.cpp in Sources */,
|
||||||
A9653FBC24129C84005999D7 /* MVKFormats.mm in Sources */,
|
A9653FBC24129C84005999D7 /* MVKPixelFormats.mm in Sources */,
|
||||||
A94FB7E61C7DFB4800632CA3 /* MVKDevice.mm in Sources */,
|
A94FB7E61C7DFB4800632CA3 /* MVKDevice.mm in Sources */,
|
||||||
A9E53DF52100B302002781DD /* MTLRenderPassDescriptor+MoltenVK.m in Sources */,
|
A9E53DF52100B302002781DD /* MTLRenderPassDescriptor+MoltenVK.m in Sources */,
|
||||||
A966A5E123C535D000BBF9B4 /* MVKDescriptor.mm in Sources */,
|
A966A5E123C535D000BBF9B4 /* MVKDescriptor.mm in Sources */,
|
||||||
@ -1080,7 +1080,7 @@
|
|||||||
A94FB82B1C7DFB4800632CA3 /* mvk_datatypes.mm in Sources */,
|
A94FB82B1C7DFB4800632CA3 /* mvk_datatypes.mm in Sources */,
|
||||||
A909F662213B190700FCD6BE /* MVKExtensions.mm in Sources */,
|
A909F662213B190700FCD6BE /* MVKExtensions.mm in Sources */,
|
||||||
A98149561FB6A3F7005F00B4 /* MVKFoundation.cpp in Sources */,
|
A98149561FB6A3F7005F00B4 /* MVKFoundation.cpp in Sources */,
|
||||||
A9653FBD24129C84005999D7 /* MVKFormats.mm in Sources */,
|
A9653FBD24129C84005999D7 /* MVKPixelFormats.mm in Sources */,
|
||||||
A94FB7E71C7DFB4800632CA3 /* MVKDevice.mm in Sources */,
|
A94FB7E71C7DFB4800632CA3 /* MVKDevice.mm in Sources */,
|
||||||
A9E53DF62100B302002781DD /* MTLRenderPassDescriptor+MoltenVK.m in Sources */,
|
A9E53DF62100B302002781DD /* MTLRenderPassDescriptor+MoltenVK.m in Sources */,
|
||||||
A966A5E223C535D000BBF9B4 /* MVKDescriptor.mm in Sources */,
|
A966A5E223C535D000BBF9B4 /* MVKDescriptor.mm in Sources */,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* MVKFormats.h
|
* MVKPixelFormats.h
|
||||||
*
|
*
|
||||||
* Copyright (c) 2015-2020 The Brenwill Workshop Ltd. (http://www.brenwill.com)
|
* Copyright (c) 2015-2020 The Brenwill Workshop Ltd. (http://www.brenwill.com)
|
||||||
*
|
*
|
||||||
@ -91,10 +91,10 @@ typedef struct {
|
|||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark MVKFormats
|
#pragma mark MVKPixelFormats
|
||||||
|
|
||||||
/** Helper class to manage pixel format capabilities and conversions. */
|
/** Helper class to manage pixel format capabilities and conversions. */
|
||||||
class MVKFormats : public MVKBaseObject {
|
class MVKPixelFormats : public MVKBaseObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -261,9 +261,9 @@ public:
|
|||||||
|
|
||||||
#pragma mark Construction
|
#pragma mark Construction
|
||||||
|
|
||||||
MVKFormats(MVKVulkanAPIObject* apiObject, id<MTLDevice> mtlDevice);
|
MVKPixelFormats(MVKVulkanAPIObject* apiObject, id<MTLDevice> mtlDevice);
|
||||||
|
|
||||||
MVKFormats() : MVKFormats(nullptr, nil) {}
|
MVKPixelFormats() : MVKPixelFormats(nullptr, nil) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const MVKFormatDesc& formatDescForVkFormat(VkFormat vkFormat);
|
const MVKFormatDesc& formatDescForVkFormat(VkFormat vkFormat);
|
||||||
@ -272,8 +272,8 @@ protected:
|
|||||||
void initFormatCapabilities();
|
void initFormatCapabilities();
|
||||||
void buidFormatMaps();
|
void buidFormatMaps();
|
||||||
void modifyFormatCapabilitiesForMTLDevice(id<MTLDevice> mtlDevice);
|
void modifyFormatCapabilitiesForMTLDevice(id<MTLDevice> mtlDevice);
|
||||||
template<typename T>
|
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
void testFmt(const T v1, const T v2, const char* fmtName, const char* funcName);
|
void testFmt(const T v1, const T v2, const char* fmtName, const char* funcName);
|
||||||
void test();
|
void test();
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* MVKFormats.mm
|
* MVKPixelFormats.mm
|
||||||
*
|
*
|
||||||
* Copyright (c) 2015-2020 The Brenwill Workshop Ltd. (http://www.brenwill.com)
|
* Copyright (c) 2015-2020 The Brenwill Workshop Ltd. (http://www.brenwill.com)
|
||||||
*
|
*
|
||||||
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include "mvk_datatypes.hpp"
|
#include "mvk_datatypes.hpp"
|
||||||
#include "MVKEnvironment.h"
|
#include "MVKEnvironment.h"
|
||||||
#include "MVKFormats.h"
|
#include "MVKPixelFormats.h"
|
||||||
#include "MVKVulkanAPIObject.h"
|
#include "MVKVulkanAPIObject.h"
|
||||||
#include "MVKFoundation.h"
|
#include "MVKFoundation.h"
|
||||||
#include "MVKLogging.h"
|
#include "MVKLogging.h"
|
||||||
@ -177,17 +177,17 @@ using namespace std;
|
|||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark MVKFormats
|
#pragma mark MVKPixelFormats
|
||||||
|
|
||||||
bool MVKFormats::vkFormatIsSupported(VkFormat vkFormat) {
|
bool MVKPixelFormats::vkFormatIsSupported(VkFormat vkFormat) {
|
||||||
return formatDescForVkFormat(vkFormat).isSupported();
|
return formatDescForVkFormat(vkFormat).isSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MVKFormats::mtlPixelFormatIsSupported(MTLPixelFormat mtlFormat) {
|
bool MVKPixelFormats::mtlPixelFormatIsSupported(MTLPixelFormat mtlFormat) {
|
||||||
return formatDescForMTLPixelFormat(mtlFormat).isSupported();
|
return formatDescForMTLPixelFormat(mtlFormat).isSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MVKFormats::mtlPixelFormatIsDepthFormat(MTLPixelFormat mtlFormat) {
|
bool MVKPixelFormats::mtlPixelFormatIsDepthFormat(MTLPixelFormat mtlFormat) {
|
||||||
switch (mtlFormat) {
|
switch (mtlFormat) {
|
||||||
case MTLPixelFormatDepth32Float:
|
case MTLPixelFormatDepth32Float:
|
||||||
#if MVK_MACOS
|
#if MVK_MACOS
|
||||||
@ -201,7 +201,7 @@ bool MVKFormats::mtlPixelFormatIsDepthFormat(MTLPixelFormat mtlFormat) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MVKFormats::mtlPixelFormatIsStencilFormat(MTLPixelFormat mtlFormat) {
|
bool MVKPixelFormats::mtlPixelFormatIsStencilFormat(MTLPixelFormat mtlFormat) {
|
||||||
switch (mtlFormat) {
|
switch (mtlFormat) {
|
||||||
case MTLPixelFormatStencil8:
|
case MTLPixelFormatStencil8:
|
||||||
#if MVK_MACOS
|
#if MVK_MACOS
|
||||||
@ -216,7 +216,7 @@ bool MVKFormats::mtlPixelFormatIsStencilFormat(MTLPixelFormat mtlFormat) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MVKFormats::mtlPixelFormatIsPVRTCFormat(MTLPixelFormat mtlFormat) {
|
bool MVKPixelFormats::mtlPixelFormatIsPVRTCFormat(MTLPixelFormat mtlFormat) {
|
||||||
switch (mtlFormat) {
|
switch (mtlFormat) {
|
||||||
#if MVK_IOS
|
#if MVK_IOS
|
||||||
case MTLPixelFormatPVRTC_RGBA_2BPP:
|
case MTLPixelFormatPVRTC_RGBA_2BPP:
|
||||||
@ -234,15 +234,15 @@ bool MVKFormats::mtlPixelFormatIsPVRTCFormat(MTLPixelFormat mtlFormat) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MVKFormatType MVKFormats::getFormatTypeFromVkFormat(VkFormat vkFormat) {
|
MVKFormatType MVKPixelFormats::getFormatTypeFromVkFormat(VkFormat vkFormat) {
|
||||||
return formatDescForVkFormat(vkFormat).formatType;
|
return formatDescForVkFormat(vkFormat).formatType;
|
||||||
}
|
}
|
||||||
|
|
||||||
MVKFormatType MVKFormats::getFormatTypeFromMTLPixelFormat(MTLPixelFormat mtlFormat) {
|
MVKFormatType MVKPixelFormats::getFormatTypeFromMTLPixelFormat(MTLPixelFormat mtlFormat) {
|
||||||
return formatDescForMTLPixelFormat(mtlFormat).formatType;
|
return formatDescForMTLPixelFormat(mtlFormat).formatType;
|
||||||
}
|
}
|
||||||
|
|
||||||
MTLPixelFormat MVKFormats::getMTLPixelFormatFromVkFormat(VkFormat vkFormat,
|
MTLPixelFormat MVKPixelFormats::getMTLPixelFormatFromVkFormat(VkFormat vkFormat,
|
||||||
MTLPixelFormat mtlPixelFormatKnownUnsupported) {
|
MTLPixelFormat mtlPixelFormatKnownUnsupported) {
|
||||||
MTLPixelFormat mtlPixFmt = MTLPixelFormatInvalid;
|
MTLPixelFormat mtlPixFmt = MTLPixelFormatInvalid;
|
||||||
|
|
||||||
@ -275,53 +275,53 @@ MTLPixelFormat MVKFormats::getMTLPixelFormatFromVkFormat(VkFormat vkFormat,
|
|||||||
return mtlPixFmt;
|
return mtlPixFmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkFormat MVKFormats::getVkFormatFromMTLPixelFormat(MTLPixelFormat mtlFormat) {
|
VkFormat MVKPixelFormats::getVkFormatFromMTLPixelFormat(MTLPixelFormat mtlFormat) {
|
||||||
return formatDescForMTLPixelFormat(mtlFormat).vk;
|
return formatDescForMTLPixelFormat(mtlFormat).vk;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MVKFormats::getVkFormatBytesPerBlock(VkFormat vkFormat) {
|
uint32_t MVKPixelFormats::getVkFormatBytesPerBlock(VkFormat vkFormat) {
|
||||||
return formatDescForVkFormat(vkFormat).bytesPerBlock;
|
return formatDescForVkFormat(vkFormat).bytesPerBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MVKFormats::getMTLPixelFormatBytesPerBlock(MTLPixelFormat mtlFormat) {
|
uint32_t MVKPixelFormats::getMTLPixelFormatBytesPerBlock(MTLPixelFormat mtlFormat) {
|
||||||
return formatDescForMTLPixelFormat(mtlFormat).bytesPerBlock;
|
return formatDescForMTLPixelFormat(mtlFormat).bytesPerBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkExtent2D MVKFormats::getVkFormatBlockTexelSize(VkFormat vkFormat) {
|
VkExtent2D MVKPixelFormats::getVkFormatBlockTexelSize(VkFormat vkFormat) {
|
||||||
return formatDescForVkFormat(vkFormat).blockTexelSize;
|
return formatDescForVkFormat(vkFormat).blockTexelSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkExtent2D MVKFormats::getMTLPixelFormatBlockTexelSize(MTLPixelFormat mtlFormat) {
|
VkExtent2D MVKPixelFormats::getMTLPixelFormatBlockTexelSize(MTLPixelFormat mtlFormat) {
|
||||||
return formatDescForMTLPixelFormat(mtlFormat).blockTexelSize;
|
return formatDescForMTLPixelFormat(mtlFormat).blockTexelSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
float MVKFormats::getVkFormatBytesPerTexel(VkFormat vkFormat) {
|
float MVKPixelFormats::getVkFormatBytesPerTexel(VkFormat vkFormat) {
|
||||||
return formatDescForVkFormat(vkFormat).bytesPerTexel();
|
return formatDescForVkFormat(vkFormat).bytesPerTexel();
|
||||||
}
|
}
|
||||||
|
|
||||||
float MVKFormats::getMTLPixelFormatBytesPerTexel(MTLPixelFormat mtlFormat) {
|
float MVKPixelFormats::getMTLPixelFormatBytesPerTexel(MTLPixelFormat mtlFormat) {
|
||||||
return formatDescForMTLPixelFormat(mtlFormat).bytesPerTexel();
|
return formatDescForMTLPixelFormat(mtlFormat).bytesPerTexel();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t MVKFormats::getVkFormatBytesPerRow(VkFormat vkFormat, uint32_t texelsPerRow) {
|
size_t MVKPixelFormats::getVkFormatBytesPerRow(VkFormat vkFormat, uint32_t texelsPerRow) {
|
||||||
const MVKFormatDesc& fmtDesc = formatDescForVkFormat(vkFormat);
|
const MVKFormatDesc& fmtDesc = formatDescForVkFormat(vkFormat);
|
||||||
return mvkCeilingDivide(texelsPerRow, fmtDesc.blockTexelSize.width) * fmtDesc.bytesPerBlock;
|
return mvkCeilingDivide(texelsPerRow, fmtDesc.blockTexelSize.width) * fmtDesc.bytesPerBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t MVKFormats::getMTLPixelFormatBytesPerRow(MTLPixelFormat mtlFormat, uint32_t texelsPerRow) {
|
size_t MVKPixelFormats::getMTLPixelFormatBytesPerRow(MTLPixelFormat mtlFormat, uint32_t texelsPerRow) {
|
||||||
const MVKFormatDesc& fmtDesc = formatDescForMTLPixelFormat(mtlFormat);
|
const MVKFormatDesc& fmtDesc = formatDescForMTLPixelFormat(mtlFormat);
|
||||||
return mvkCeilingDivide(texelsPerRow, fmtDesc.blockTexelSize.width) * fmtDesc.bytesPerBlock;
|
return mvkCeilingDivide(texelsPerRow, fmtDesc.blockTexelSize.width) * fmtDesc.bytesPerBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t MVKFormats::getVkFormatBytesPerLayer(VkFormat vkFormat, size_t bytesPerRow, uint32_t texelRowsPerLayer) {
|
size_t MVKPixelFormats::getVkFormatBytesPerLayer(VkFormat vkFormat, size_t bytesPerRow, uint32_t texelRowsPerLayer) {
|
||||||
return mvkCeilingDivide(texelRowsPerLayer, formatDescForVkFormat(vkFormat).blockTexelSize.height) * bytesPerRow;
|
return mvkCeilingDivide(texelRowsPerLayer, formatDescForVkFormat(vkFormat).blockTexelSize.height) * bytesPerRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t MVKFormats::getMTLPixelFormatBytesPerLayer(MTLPixelFormat mtlFormat, size_t bytesPerRow, uint32_t texelRowsPerLayer) {
|
size_t MVKPixelFormats::getMTLPixelFormatBytesPerLayer(MTLPixelFormat mtlFormat, size_t bytesPerRow, uint32_t texelRowsPerLayer) {
|
||||||
return mvkCeilingDivide(texelRowsPerLayer, formatDescForMTLPixelFormat(mtlFormat).blockTexelSize.height) * bytesPerRow;
|
return mvkCeilingDivide(texelRowsPerLayer, formatDescForMTLPixelFormat(mtlFormat).blockTexelSize.height) * bytesPerRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkFormatProperties MVKFormats::getVkFormatProperties(VkFormat vkFormat, bool assumeGPUSupportsDefault) {
|
VkFormatProperties MVKPixelFormats::getVkFormatProperties(VkFormat vkFormat, bool assumeGPUSupportsDefault) {
|
||||||
VkFormatProperties fmtProps = {MVK_FMT_NO_FEATS, MVK_FMT_NO_FEATS, MVK_FMT_NO_FEATS};
|
VkFormatProperties fmtProps = {MVK_FMT_NO_FEATS, MVK_FMT_NO_FEATS, MVK_FMT_NO_FEATS};
|
||||||
const MVKFormatDesc& fmtDesc = formatDescForVkFormat(vkFormat);
|
const MVKFormatDesc& fmtDesc = formatDescForVkFormat(vkFormat);
|
||||||
if (assumeGPUSupportsDefault && fmtDesc.isSupported()) {
|
if (assumeGPUSupportsDefault && fmtDesc.isSupported()) {
|
||||||
@ -336,15 +336,15 @@ VkFormatProperties MVKFormats::getVkFormatProperties(VkFormat vkFormat, bool ass
|
|||||||
return fmtProps;
|
return fmtProps;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* MVKFormats::getVkFormatName(VkFormat vkFormat) {
|
const char* MVKPixelFormats::getVkFormatName(VkFormat vkFormat) {
|
||||||
return formatDescForVkFormat(vkFormat).vkName;
|
return formatDescForVkFormat(vkFormat).vkName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* MVKFormats::getMTLPixelFormatName(MTLPixelFormat mtlFormat) {
|
const char* MVKPixelFormats::getMTLPixelFormatName(MTLPixelFormat mtlFormat) {
|
||||||
return formatDescForMTLPixelFormat(mtlFormat).mtlName;
|
return formatDescForMTLPixelFormat(mtlFormat).mtlName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MVKFormats::enumerateSupportedFormats(VkFormatProperties properties, bool any, std::function<bool(VkFormat)> func) {
|
void MVKPixelFormats::enumerateSupportedFormats(VkFormatProperties properties, bool any, std::function<bool(VkFormat)> func) {
|
||||||
static const auto areFeaturesSupported = [any](uint32_t a, uint32_t b) {
|
static const auto areFeaturesSupported = [any](uint32_t a, uint32_t b) {
|
||||||
if (b == 0) return true;
|
if (b == 0) return true;
|
||||||
if (any)
|
if (any)
|
||||||
@ -365,7 +365,7 @@ void MVKFormats::enumerateSupportedFormats(VkFormatProperties properties, bool a
|
|||||||
}
|
}
|
||||||
|
|
||||||
#undef mvkMTLVertexFormatFromVkFormat
|
#undef mvkMTLVertexFormatFromVkFormat
|
||||||
MTLVertexFormat MVKFormats::getMTLVertexFormatFromVkFormat(VkFormat vkFormat) {
|
MTLVertexFormat MVKPixelFormats::getMTLVertexFormatFromVkFormat(VkFormat vkFormat) {
|
||||||
MTLVertexFormat mtlVtxFmt = MTLVertexFormatInvalid;
|
MTLVertexFormat mtlVtxFmt = MTLVertexFormatInvalid;
|
||||||
|
|
||||||
const MVKFormatDesc& fmtDesc = formatDescForVkFormat(vkFormat);
|
const MVKFormatDesc& fmtDesc = formatDescForVkFormat(vkFormat);
|
||||||
@ -393,7 +393,7 @@ MTLVertexFormat MVKFormats::getMTLVertexFormatFromVkFormat(VkFormat vkFormat) {
|
|||||||
return mtlVtxFmt;
|
return mtlVtxFmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
MTLClearColor MVKFormats::getMTLClearColorFromVkClearValue(VkClearValue vkClearValue,
|
MTLClearColor MVKPixelFormats::getMTLClearColorFromVkClearValue(VkClearValue vkClearValue,
|
||||||
VkFormat vkFormat) {
|
VkFormat vkFormat) {
|
||||||
MTLClearColor mtlClr;
|
MTLClearColor mtlClr;
|
||||||
switch (getFormatTypeFromVkFormat(vkFormat)) {
|
switch (getFormatTypeFromVkFormat(vkFormat)) {
|
||||||
@ -430,7 +430,7 @@ MTLClearColor MVKFormats::getMTLClearColorFromVkClearValue(VkClearValue vkClearV
|
|||||||
return mtlClr;
|
return mtlClr;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkImageUsageFlags MVKFormats::getVkImageUsageFlagsFromMTLTextureUsage(MTLTextureUsage mtlUsage,
|
VkImageUsageFlags MVKPixelFormats::getVkImageUsageFlagsFromMTLTextureUsage(MTLTextureUsage mtlUsage,
|
||||||
MTLPixelFormat mtlFormat) {
|
MTLPixelFormat mtlFormat) {
|
||||||
VkImageUsageFlags vkImageUsageFlags = 0;
|
VkImageUsageFlags vkImageUsageFlags = 0;
|
||||||
|
|
||||||
@ -455,19 +455,19 @@ VkImageUsageFlags MVKFormats::getVkImageUsageFlagsFromMTLTextureUsage(MTLTexture
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return a reference to the format description corresponding to the VkFormat.
|
// Return a reference to the format description corresponding to the VkFormat.
|
||||||
const MVKFormatDesc& MVKFormats::formatDescForVkFormat(VkFormat vkFormat) {
|
const MVKFormatDesc& MVKPixelFormats::formatDescForVkFormat(VkFormat vkFormat) {
|
||||||
uint16_t fmtIdx = (vkFormat < _vkFormatCoreCount) ? _fmtDescIndicesByVkFormatsCore[vkFormat] : _fmtDescIndicesByVkFormatsExt[vkFormat];
|
uint16_t fmtIdx = (vkFormat < _vkFormatCoreCount) ? _fmtDescIndicesByVkFormatsCore[vkFormat] : _fmtDescIndicesByVkFormatsExt[vkFormat];
|
||||||
return _formatDescriptions[fmtIdx];
|
return _formatDescriptions[fmtIdx];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a reference to the format description corresponding to the MTLPixelFormat.
|
// Return a reference to the format description corresponding to the MTLPixelFormat.
|
||||||
const MVKFormatDesc& MVKFormats::formatDescForMTLPixelFormat(MTLPixelFormat mtlFormat) {
|
const MVKFormatDesc& MVKPixelFormats::formatDescForMTLPixelFormat(MTLPixelFormat mtlFormat) {
|
||||||
uint16_t fmtIdx = (mtlFormat < _mtlFormatCount) ? _fmtDescIndicesByMTLPixelFormats[mtlFormat] : 0;
|
uint16_t fmtIdx = (mtlFormat < _mtlFormatCount) ? _fmtDescIndicesByMTLPixelFormats[mtlFormat] : 0;
|
||||||
return _formatDescriptions[fmtIdx];
|
return _formatDescriptions[fmtIdx];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a reference to the format description corresponding to the MTLVertexFormat.
|
// Return a reference to the format description corresponding to the MTLVertexFormat.
|
||||||
const MVKFormatDesc& MVKFormats::formatDescForMTLVertexFormat(MTLVertexFormat mtlFormat) {
|
const MVKFormatDesc& MVKPixelFormats::formatDescForMTLVertexFormat(MTLVertexFormat mtlFormat) {
|
||||||
uint16_t fmtIdx = (mtlFormat < _mtlVertexFormatCount) ? _fmtDescIndicesByMTLVertexFormats[mtlFormat] : 0;
|
uint16_t fmtIdx = (mtlFormat < _mtlVertexFormatCount) ? _fmtDescIndicesByMTLVertexFormats[mtlFormat] : 0;
|
||||||
return _formatDescriptions[fmtIdx];
|
return _formatDescriptions[fmtIdx];
|
||||||
}
|
}
|
||||||
@ -475,7 +475,7 @@ const MVKFormatDesc& MVKFormats::formatDescForMTLVertexFormat(MTLVertexFormat mt
|
|||||||
|
|
||||||
#pragma mark Construction
|
#pragma mark Construction
|
||||||
|
|
||||||
MVKFormats::MVKFormats(MVKVulkanAPIObject* apiObject, id<MTLDevice> mtlDevice) : _apiObject(apiObject) {
|
MVKPixelFormats::MVKPixelFormats(MVKVulkanAPIObject* apiObject, id<MTLDevice> mtlDevice) : _apiObject(apiObject) {
|
||||||
initFormatCapabilities();
|
initFormatCapabilities();
|
||||||
modifyFormatCapabilitiesForMTLDevice(mtlDevice);
|
modifyFormatCapabilitiesForMTLDevice(mtlDevice);
|
||||||
buidFormatMaps();
|
buidFormatMaps();
|
||||||
@ -488,7 +488,7 @@ MVKFormats::MVKFormats(MVKVulkanAPIObject* apiObject, id<MTLDevice> mtlDevice) :
|
|||||||
|
|
||||||
static const MVKOSVersion kMTLFmtNA = numeric_limits<MVKOSVersion>::max();
|
static const MVKOSVersion kMTLFmtNA = numeric_limits<MVKOSVersion>::max();
|
||||||
|
|
||||||
void MVKFormats::initFormatCapabilities() {
|
void MVKPixelFormats::initFormatCapabilities() {
|
||||||
|
|
||||||
MVKLogInfo("sizeof MVKFormatDesc %lu.", sizeof(MVKFormatDesc));
|
MVKLogInfo("sizeof MVKFormatDesc %lu.", sizeof(MVKFormatDesc));
|
||||||
|
|
||||||
@ -747,7 +747,7 @@ void MVKFormats::initFormatCapabilities() {
|
|||||||
// to map the value in one architecture (as an array index) to the corresponding value in the
|
// to map the value in one architecture (as an array index) to the corresponding value in the
|
||||||
// other architecture. Values that exist in one API but not the other are given a default value.
|
// other architecture. Values that exist in one API but not the other are given a default value.
|
||||||
// Vulkan extension formats have very large values, and are tracked in a separate map.
|
// Vulkan extension formats have very large values, and are tracked in a separate map.
|
||||||
void MVKFormats::buidFormatMaps() {
|
void MVKPixelFormats::buidFormatMaps() {
|
||||||
|
|
||||||
// Set all VkFormats and MTLPixelFormats to undefined/invalid
|
// Set all VkFormats and MTLPixelFormats to undefined/invalid
|
||||||
mvkClear(_fmtDescIndicesByVkFormatsCore, _vkFormatCoreCount);
|
mvkClear(_fmtDescIndicesByVkFormatsCore, _vkFormatCoreCount);
|
||||||
@ -780,7 +780,7 @@ void MVKFormats::buidFormatMaps() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Modifies the format capability tables based on the capabilities of the specific MTLDevice
|
// Modifies the format capability tables based on the capabilities of the specific MTLDevice
|
||||||
void MVKFormats::modifyFormatCapabilitiesForMTLDevice(id<MTLDevice> mtlDevice) {}
|
void MVKPixelFormats::modifyFormatCapabilitiesForMTLDevice(id<MTLDevice> mtlDevice) {}
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
@ -788,7 +788,8 @@ void MVKFormats::modifyFormatCapabilitiesForMTLDevice(id<MTLDevice> mtlDevice) {
|
|||||||
|
|
||||||
// Validate the functionality of this class against the previous format data within MoltenVK.
|
// Validate the functionality of this class against the previous format data within MoltenVK.
|
||||||
// This is a temporary function to confirm that converting to using this class matches existing behaviour at first.
|
// This is a temporary function to confirm that converting to using this class matches existing behaviour at first.
|
||||||
void MVKFormats::test() {
|
void MVKPixelFormats::test() {
|
||||||
|
if (_apiObject) { return; } // Only test default formats
|
||||||
|
|
||||||
#define MVK_TEST_FMT(V1, V2) testFmt(V1, V2, fd.vkName, #V1)
|
#define MVK_TEST_FMT(V1, V2) testFmt(V1, V2, fd.vkName, #V1)
|
||||||
|
|
||||||
@ -852,15 +853,8 @@ void MVKFormats::test() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void MVKFormats::testFmt(const T v1, const T v2, const char* fmtName, const char* funcName) {
|
void MVKPixelFormats::testFmt(const T v1, const T v2, const char* fmtName, const char* funcName) {
|
||||||
MVKAssert(mvkAreEqual(&v1,&v2), "Results not equal for format %s on test %s.", fmtName, funcName);
|
MVKAssert(mvkAreEqual(&v1,&v2), "Results not equal for format %s on test %s.", fmtName, funcName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const MVKPixelFormats _defaultFormats;
|
||||||
//static bool _mvkFormatsTest = false;
|
|
||||||
//__attribute__((constructor)) static void MVKTestFormats() {
|
|
||||||
// if (_mvkFormatsTest ) { return; }
|
|
||||||
// _mvkFormatsTest = true;
|
|
||||||
//
|
|
||||||
// MVKFormats fmts;
|
|
||||||
//}
|
|
Loading…
x
Reference in New Issue
Block a user