Skip to content

Commit

Permalink
Merge branch 'main' into ue4-nastys-patch-env
Browse files Browse the repository at this point in the history
  • Loading branch information
italomandara committed Jul 10, 2023
2 parents 0f36b1f + 2db85ea commit 7917632
Show file tree
Hide file tree
Showing 33 changed files with 1,069 additions and 123 deletions.
4 changes: 4 additions & 0 deletions Common/MVKCommonEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ extern "C" {
#endif

/** Building with Xcode versions. iOS version also covers tvOS. */
#ifndef MVK_XCODE_15
# define MVK_XCODE_15 ((__MAC_OS_X_VERSION_MAX_ALLOWED >= 140000) || \
(__IPHONE_OS_VERSION_MAX_ALLOWED >= 170000))
#endif
#ifndef MVK_XCODE_14_3
# define MVK_XCODE_14_3 ((__MAC_OS_X_VERSION_MAX_ALLOWED >= 130300) || \
(__IPHONE_OS_VERSION_MAX_ALLOWED >= 160400))
Expand Down
9 changes: 9 additions & 0 deletions Common/MVKOSExtensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ double mvkGetTimestampPeriod();
*/
double mvkGetElapsedMilliseconds(uint64_t startTimestamp = 0, uint64_t endTimestamp = 0);

/** Returns the current absolute time in nanoseconds. */
uint64_t mvkGetAbsoluteTime();

/** Ensures the block is executed on the main thread. */
void mvkDispatchToMainAndWait(dispatch_block_t block);

Expand Down Expand Up @@ -164,3 +167,9 @@ uint64_t mvkGetUsedMemorySize();

/** Returns the size of a page of host memory on this platform. */
uint64_t mvkGetHostMemoryPageSize();

#pragma mark -
#pragma mark Threading

/** Returns the amount of avaliable CPU cores. */
uint32_t mvkGetAvaliableCPUCores();
15 changes: 12 additions & 3 deletions Common/MVKOSExtensions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ MVKOSVersion mvkOSVersion() {

static uint64_t _mvkTimestampBase;
static double _mvkTimestampPeriod;
static mach_timebase_info_data_t _mvkMachTimebase;

uint64_t mvkGetTimestamp() { return mach_absolute_time() - _mvkTimestampBase; }

Expand All @@ -50,6 +51,8 @@ MVKOSVersion mvkOSVersion() {
return (double)(endTimestamp - startTimestamp) * _mvkTimestampPeriod / 1e6;
}

uint64_t mvkGetAbsoluteTime() { return mach_continuous_time() * _mvkMachTimebase.numer / _mvkMachTimebase.denom; }

// Initialize timestamping capabilities on app startup.
//Called automatically when the framework is loaded and initialized.
static bool _mvkTimestampsInitialized = false;
Expand All @@ -58,9 +61,8 @@ MVKOSVersion mvkOSVersion() {
_mvkTimestampsInitialized = true;

_mvkTimestampBase = mach_absolute_time();
mach_timebase_info_data_t timebase;
mach_timebase_info(&timebase);
_mvkTimestampPeriod = (double)timebase.numer / (double)timebase.denom;
mach_timebase_info(&_mvkMachTimebase);
_mvkTimestampPeriod = (double)_mvkMachTimebase.numer / (double)_mvkMachTimebase.denom;
}

void mvkDispatchToMainAndWait(dispatch_block_t block) {
Expand Down Expand Up @@ -138,3 +140,10 @@ uint64_t mvkGetUsedMemorySize() {

uint64_t mvkGetHostMemoryPageSize() { return sysconf(_SC_PAGESIZE); }

#pragma mark -
#pragma mark Threading

/** Returns the amount of avaliable CPU cores. */
uint32_t mvkGetAvaliableCPUCores() {
return (uint32_t)[[NSProcessInfo processInfo] activeProcessorCount];
}
5 changes: 5 additions & 0 deletions Docs/MoltenVK_Runtime_UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ In addition to core *Vulkan* functionality, **MoltenVK** also supports the foll
- `VK_KHR_shader_draw_parameters`
- `VK_KHR_shader_float_controls`
- `VK_KHR_shader_float16_int8`
- `VK_KHR_shader_non_semantic_info`
- `VK_KHR_shader_subgroup_extended_types` *(requires Metal 2.1 on Mac or Metal 2.2 and Apple family 4 on iOS)*
- `VK_KHR_spirv_1_4`
- `VK_KHR_storage_buffer_storage_class`
Expand All @@ -350,7 +351,9 @@ In addition to core *Vulkan* functionality, **MoltenVK** also supports the foll
- `VK_KHR_timeline_semaphore`
- `VK_KHR_uniform_buffer_standard_layout`
- `VK_KHR_variable_pointers`
- `VK_EXT_4444_formats` *(requires 16-bit formats and either native texture swizzling or manual swizzling to be enabled)*
- `VK_EXT_buffer_device_address` *(requires GPU Tier 2 argument buffers support)*
- `VK_EXT_calibrated_timestamps` *(requires Metal 2.2)*
- `VK_EXT_debug_marker`
- `VK_EXT_debug_report`
- `VK_EXT_debug_utils`
Expand All @@ -375,6 +378,8 @@ In addition to core *Vulkan* functionality, **MoltenVK** also supports the foll
- `VK_EXT_shader_atomic_float` *(requires Metal 3.0)*
- `VK_EXT_shader_demote_to_helper_invocation` *(requires Metal Shading Language 2.3)*
- `VK_EXT_shader_stencil_export` *(requires Mac GPU family 2 or iOS GPU family 5)*
- `VK_EXT_shader_subgroup_ballot` *(requires Mac GPU family 2 or Apple GPU family 4)*
- `VK_EXT_shader_subgroup_vote` *(requires Mac GPU family 2 or Apple GPU family 4)*
- `VK_EXT_shader_viewport_index_layer`
- `VK_EXT_subgroup_size_control` *(requires Metal 2.1 on Mac or Metal 2.2 and Apple family 4 on iOS)*
- `VK_EXT_surface_maintenance1`
Expand Down
6 changes: 6 additions & 0 deletions Docs/Whats_New.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ MoltenVK 1.2.5
Released TBD

- Add support for extensions:
- `VK_KHR_shader_non_semantic_info`
- `VK_EXT_4444_formats`
- `VK_EXT_calibrated_timestamps`
- `VK_EXT_shader_demote_to_helper_invocation`
- `VK_EXT_shader_subgroup_ballot`
- `VK_EXT_shader_subgroup_vote`
- Add support for `VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN`.
- Ensure non-dispatch compute commands don't interfere with compute encoding state used by dispatch commands.
- Support `VK_PRESENT_MODE_IMMEDIATE_KHR` if `VkPresentTimeGOOGLE::desiredPresentTime` is zero.
- Support maximizing the concurrent executing compilation tasks via `MVKConfiguration::shouldMaximizeConcurrentCompilation`
Expand Down
2 changes: 1 addition & 1 deletion ExternalRevisions/SPIRV-Cross_repo_revision
Original file line number Diff line number Diff line change
@@ -1 +1 @@
55750be7886a96008b964e75e1eb4a5a6c369a2a
aafcc207ea82308722124db2575aa95f42cb99c9
9 changes: 9 additions & 0 deletions MoltenVK/MoltenVK/API/mvk_datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,15 @@ MTLTextureSwizzle mvkMTLTextureSwizzleFromVkComponentSwizzle(VkComponentSwizzle
/** Returns all four Metal texture swizzles from the Vulkan component mapping. */
MTLTextureSwizzleChannels mvkMTLTextureSwizzleChannelsFromVkComponentMapping(VkComponentMapping vkMapping);

/** Maps a clear color according to the specified VkComponentSwizzle. */
float mvkVkClearColorFloatValueFromVkComponentSwizzle(float *colors, uint32_t index, VkComponentSwizzle vkSwizzle);

/** Maps a clear color according to the specified VkComponentSwizzle. */
uint32_t mvkVkClearColorUIntValueFromVkComponentSwizzle(uint32_t *colors, uint32_t index, VkComponentSwizzle vkSwizzle);

/** Maps a clear color according to the specified VkComponentSwizzle. */
int32_t mvkVkClearColorIntValueFromVkComponentSwizzle(int32_t *colors, uint32_t index, VkComponentSwizzle vkSwizzle);


#pragma mark Mipmaps

Expand Down
12 changes: 12 additions & 0 deletions MoltenVK/MoltenVK/Commands/MVKCmdDraw.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class MVKCmdDraw : public MVKCommand {
uint32_t firstInstance);

void encode(MVKCommandEncoder* cmdEncoder) override;
void encodeIndexedIndirect(MVKCommandEncoder* cmdEncoder);

protected:
MVKCommandTypePool<MVKCommand>* getTypePool(MVKCommandPool* cmdPool) override;
Expand Down Expand Up @@ -120,6 +121,7 @@ class MVKCmdDrawIndexed : public MVKCommand {

protected:
MVKCommandTypePool<MVKCommand>* getTypePool(MVKCommandPool* cmdPool) override;
void encodeIndexedIndirect(MVKCommandEncoder* cmdEncoder);

uint32_t _firstIndex;
uint32_t _indexCount;
Expand All @@ -146,6 +148,7 @@ class MVKCmdDrawIndirect : public MVKCommand {

protected:
MVKCommandTypePool<MVKCommand>* getTypePool(MVKCommandPool* cmdPool) override;
void encodeIndexedIndirect(MVKCommandEncoder* cmdEncoder);

id<MTLBuffer> _mtlIndirectBuffer;
VkDeviceSize _mtlIndirectBufferOffset;
Expand All @@ -167,7 +170,15 @@ class MVKCmdDrawIndexedIndirect : public MVKCommand {
uint32_t count,
uint32_t stride);

VkResult setContent(MVKCommandBuffer* cmdBuff,
id<MTLBuffer> indirectMTLBuff,
VkDeviceSize indirectMTLBuffOffset,
uint32_t drawCount,
uint32_t stride,
uint32_t directCmdFirstInstance);

void encode(MVKCommandEncoder* cmdEncoder) override;
void encode(MVKCommandEncoder* cmdEncoder, const MVKIndexMTLBufferBinding& ibbOrig);

protected:
MVKCommandTypePool<MVKCommand>* getTypePool(MVKCommandPool* cmdPool) override;
Expand All @@ -176,4 +187,5 @@ class MVKCmdDrawIndexedIndirect : public MVKCommand {
VkDeviceSize _mtlIndirectBufferOffset;
uint32_t _mtlIndirectBufferStride;
uint32_t _drawCount;
uint32_t _directCmdFirstInstance;
};
Loading

0 comments on commit 7917632

Please sign in to comment.