Commit defeda29 by Le Hoang Quyen Committed by Commit Bot

Metal: autogen for EXT_draw_buffers & ANGLE_framebuffer_blit

Bug: angleproject:2634 Change-Id: I8f8ee91fb673301b8bd97c359ee39c411e2bf8da Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2336124 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com>
parent add9b677
{ {
"src/libANGLE/renderer/metal/shaders/blit.metal": "src/libANGLE/renderer/metal/shaders/blit.metal":
"8a00929424273e07e4b63d4ab062f005", "f02720a0f3d9624b67bdb808cbc94c7f",
"src/libANGLE/renderer/metal/shaders/clear.metal": "src/libANGLE/renderer/metal/shaders/clear.metal":
"1c231afc6100433a79fce49046aa5965", "67da9886363c530132e5bc2199bab2db",
"src/libANGLE/renderer/metal/shaders/common.h": "src/libANGLE/renderer/metal/shaders/common.h":
"7f4fe9c0ee3fa9bee84ea6627df44e04", "5888cfe052e6e6332e8c7c8949e888fb",
"src/libANGLE/renderer/metal/shaders/compiled/compiled_default_metallib_2_1_debug_ios_autogen.inc":
"39f2302c254c8490b0f5b4782355a9e4",
"src/libANGLE/renderer/metal/shaders/compiled/compiled_default_metallib_2_1_debug_ios_sim_autogen.inc":
"ab9be1624a4f15fc12647771727302b0",
"src/libANGLE/renderer/metal/shaders/compiled/compiled_default_metallib_2_1_debug_mac_autogen.inc":
"35f17267fa21f1f96d8a781d45485e1a",
"src/libANGLE/renderer/metal/shaders/compiled/compiled_default_metallib_2_1_ios_autogen.inc":
"81c4b4d1012dbcb7aa738f49bbed1645",
"src/libANGLE/renderer/metal/shaders/compiled/compiled_default_metallib_2_1_ios_sim_autogen.inc":
"3446979c2d6504cb421e1f0004f5f15f",
"src/libANGLE/renderer/metal/shaders/compiled/compiled_default_metallib_2_1_mac_autogen.inc":
"7839cf16e8e45e6dffa9454dd5d7d3dc",
"src/libANGLE/renderer/metal/shaders/compiled/compiled_default_metallib_debug_ios_autogen.inc": "src/libANGLE/renderer/metal/shaders/compiled/compiled_default_metallib_debug_ios_autogen.inc":
"10478c8a544f5a79decd6707d7c222e1", "82ccf14797364f2c3c5dee14227b2c24",
"src/libANGLE/renderer/metal/shaders/compiled/compiled_default_metallib_debug_ios_sim_autogen.inc": "src/libANGLE/renderer/metal/shaders/compiled/compiled_default_metallib_debug_ios_sim_autogen.inc":
"781104f2c328281b8e12509bf24e2e3a", "28f453c423b4029ab876668e4f1e8b21",
"src/libANGLE/renderer/metal/shaders/compiled/compiled_default_metallib_debug_mac_autogen.inc": "src/libANGLE/renderer/metal/shaders/compiled/compiled_default_metallib_debug_mac_autogen.inc":
"e3c377c317b4219623068780b03441cd", "3f402a605d97be11664ee0bb642e616a",
"src/libANGLE/renderer/metal/shaders/compiled/compiled_default_metallib_ios_autogen.inc": "src/libANGLE/renderer/metal/shaders/compiled/compiled_default_metallib_ios_autogen.inc":
"1fc59139de5353ac94a58f2dfe70d1e7", "52c9275b8582f9e7c4a6b0b77c857a72",
"src/libANGLE/renderer/metal/shaders/compiled/compiled_default_metallib_ios_sim_autogen.inc": "src/libANGLE/renderer/metal/shaders/compiled/compiled_default_metallib_ios_sim_autogen.inc":
"32d664590f0a28063ea9e04d54126216", "259bdeb1bc17ab5098e2be4032f5d608",
"src/libANGLE/renderer/metal/shaders/compiled/compiled_default_metallib_mac_autogen.inc": "src/libANGLE/renderer/metal/shaders/compiled/compiled_default_metallib_mac_autogen.inc":
"1bdfb6157311f1e462d2d11b7868fd57", "e16bd5da4f614789be9e2545f2af4237",
"src/libANGLE/renderer/metal/shaders/compiled/mtl_default_shaders_autogen.inc": "src/libANGLE/renderer/metal/shaders/compiled/mtl_default_shaders_autogen.inc":
"1614e50c13ceab6e72a5bc2c2dc32056", "634a127f4e94f6bc3123e89850d010ee",
"src/libANGLE/renderer/metal/shaders/constants.h": "src/libANGLE/renderer/metal/shaders/constants.h":
"9bb6e63bf2b48a7a56978c787bde4850", "9bb6e63bf2b48a7a56978c787bde4850",
"src/libANGLE/renderer/metal/shaders/gen_indices.metal": "src/libANGLE/renderer/metal/shaders/gen_indices.metal":
"002511e2b980a7fca7e80cbda6a82712", "87a76d5e12825111c0595f69e79f5d20",
"src/libANGLE/renderer/metal/shaders/gen_mtl_internal_shaders.py": "src/libANGLE/renderer/metal/shaders/gen_mtl_internal_shaders.py":
"43375642abef54e634e4c803b53de7d0" "962d0f3229d91ab71ad555f9fa3fe0c3"
} }
\ No newline at end of file
...@@ -25,6 +25,7 @@ namespace mtl ...@@ -25,6 +25,7 @@ namespace mtl
namespace namespace
{ {
#define NUM_COLOR_OUTPUTS_CONSTANT_NAME @"kNumColorOutputs"
#define SOURCE_BUFFER_ALIGNED_CONSTANT_NAME @"kSourceBufferAligned" #define SOURCE_BUFFER_ALIGNED_CONSTANT_NAME @"kSourceBufferAligned"
#define SOURCE_IDX_IS_U8_CONSTANT_NAME @"kSourceIndexIsU8" #define SOURCE_IDX_IS_U8_CONSTANT_NAME @"kSourceIndexIsU8"
#define SOURCE_IDX_IS_U16_CONSTANT_NAME @"kSourceIndexIsU16" #define SOURCE_IDX_IS_U16_CONSTANT_NAME @"kSourceIndexIsU16"
...@@ -451,12 +452,26 @@ void ClearUtils::ensureRenderPipelineStateCacheInitialized(ContextMtl *ctx) ...@@ -451,12 +452,26 @@ void ClearUtils::ensureRenderPipelineStateCacheInitialized(ContextMtl *ctx)
{ {
ANGLE_MTL_OBJC_SCOPE ANGLE_MTL_OBJC_SCOPE
{ {
NSError *err = nil;
id<MTLLibrary> shaderLib = ctx->getDisplay()->getDefaultShadersLib(); id<MTLLibrary> shaderLib = ctx->getDisplay()->getDefaultShadersLib();
id<MTLFunction> vertexShader =
[[shaderLib newFunctionWithName:@"clearVS"] ANGLE_MTL_AUTORELEASE];
MTLFunctionConstantValues *funcConstants =
[[[MTLFunctionConstantValues alloc] init] ANGLE_MTL_AUTORELEASE];
// Use 1 color outputs for now.
uint32_t numOutputs = 1;
[funcConstants setConstantValue:&numOutputs
type:MTLDataTypeUInt
withName:NUM_COLOR_OUTPUTS_CONSTANT_NAME];
mClearRenderPipelineCache.setVertexShader( id<MTLFunction> fragmentShader =
ctx, [[shaderLib newFunctionWithName:@"clearVS"] ANGLE_MTL_AUTORELEASE]); [[shaderLib newFunctionWithName:@"clearFS" constantValues:funcConstants
mClearRenderPipelineCache.setFragmentShader( error:&err] ANGLE_MTL_AUTORELEASE];
ctx, [[shaderLib newFunctionWithName:@"clearFS"] ANGLE_MTL_AUTORELEASE]); ASSERT(fragmentShader);
mClearRenderPipelineCache.setVertexShader(ctx, vertexShader);
mClearRenderPipelineCache.setFragmentShader(ctx, fragmentShader);
} }
} }
...@@ -666,6 +681,12 @@ void ColorBlitUtils::ensureRenderPipelineStateCacheInitialized(ContextMtl *ctx, ...@@ -666,6 +681,12 @@ void ColorBlitUtils::ensureRenderPipelineStateCacheInitialized(ContextMtl *ctx,
type:MTLDataTypeBool type:MTLDataTypeBool
withName:UNMULTIPLY_ALPHA_CONSTANT_NAME]; withName:UNMULTIPLY_ALPHA_CONSTANT_NAME];
// Use 1 color outputs for now.
uint32_t numOutputs = 1;
[funcConstants setConstantValue:&numOutputs
type:MTLDataTypeUInt
withName:NUM_COLOR_OUTPUTS_CONSTANT_NAME];
// Set texture type constant // Set texture type constant
[funcConstants setConstantValue:&textureType [funcConstants setConstantValue:&textureType
type:MTLDataTypeInt type:MTLDataTypeInt
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include "common.h" #include "common.h"
using namespace rx::mtl_shader;
struct ClearParams struct ClearParams
{ {
float4 clearColor; float4 clearColor;
...@@ -19,7 +21,7 @@ vertex float4 clearVS(unsigned int vid [[ vertex_id ]], ...@@ -19,7 +21,7 @@ vertex float4 clearVS(unsigned int vid [[ vertex_id ]],
return float4(gCorners[vid], clearParams.clearDepth, 1.0); return float4(gCorners[vid], clearParams.clearDepth, 1.0);
} }
fragment float4 clearFS(constant ClearParams &clearParams [[buffer(0)]]) fragment MultipleColorOutputs<float> clearFS(constant ClearParams &clearParams [[buffer(0)]])
{ {
return clearParams.clearColor; return toMultipleColorOutputs(clearParams.clearColor);
} }
...@@ -23,7 +23,91 @@ ...@@ -23,7 +23,91 @@
using namespace metal; using namespace metal;
// Common constant defined number of color outputs
constant uint32_t kNumColorOutputs [[function_constant(0)]];
constant bool kColorOutputAvailable0 = kNumColorOutputs > 0;
constant bool kColorOutputAvailable1 = kNumColorOutputs > 1;
constant bool kColorOutputAvailable2 = kNumColorOutputs > 2;
constant bool kColorOutputAvailable3 = kNumColorOutputs > 3;
namespace rx
{
namespace mtl_shader
{
// Full screen triangle's vertices // Full screen triangle's vertices
constant float2 gCorners[3] = {float2(-1.0f, -1.0f), float2(3.0f, -1.0f), float2(-1.0f, 3.0f)}; constant float2 gCorners[3] = {float2(-1.0f, -1.0f), float2(3.0f, -1.0f), float2(-1.0f, 3.0f)};
template <typename T>
struct MultipleColorOutputs
{
vec<T, 4> color0 [[color(0), function_constant(kColorOutputAvailable0)]];
vec<T, 4> color1 [[color(1), function_constant(kColorOutputAvailable1)]];
vec<T, 4> color2 [[color(2), function_constant(kColorOutputAvailable2)]];
vec<T, 4> color3 [[color(3), function_constant(kColorOutputAvailable3)]];
};
#define ANGLE_ASSIGN_COLOR_OUPUT(STRUCT_VARIABLE, COLOR_INDEX, VALUE) \
do \
{ \
if (kColorOutputAvailable##COLOR_INDEX) \
{ \
STRUCT_VARIABLE.color##COLOR_INDEX = VALUE; \
} \
} while (0)
template <typename T>
static inline MultipleColorOutputs<T> toMultipleColorOutputs(vec<T, 4> color)
{
MultipleColorOutputs<T> re;
ANGLE_ASSIGN_COLOR_OUPUT(re, 0, color);
ANGLE_ASSIGN_COLOR_OUPUT(re, 1, color);
ANGLE_ASSIGN_COLOR_OUPUT(re, 2, color);
ANGLE_ASSIGN_COLOR_OUPUT(re, 3, color);
return re;
}
static inline float3 cubeTexcoords(float2 texcoords, int face)
{
texcoords = 2.0 * texcoords - 1.0;
switch (face)
{
case 0:
return float3(1.0, -texcoords.y, -texcoords.x);
case 1:
return float3(-1.0, -texcoords.y, texcoords.x);
case 2:
return float3(texcoords.x, 1.0, texcoords.y);
case 3:
return float3(texcoords.x, -1.0, -texcoords.y);
case 4:
return float3(texcoords.x, -texcoords.y, 1.0);
case 5:
return float3(-texcoords.x, -texcoords.y, -1.0);
}
return float3(texcoords, 0);
}
template <typename T>
static inline vec<T, 4> resolveTextureMS(texture2d_ms<T> srcTexture, uint2 coords)
{
uint samples = srcTexture.get_num_samples();
vec<T, 4> output(0);
for (uint sample = 0; sample < samples; ++sample)
{
output += srcTexture.read(coords, sample);
}
output = output / samples;
return output;
}
} // namespace mtl_shader
} // namespace rx
#endif /* LIBANGLE_RENDERER_METAL_SHADERS_COMMON_H_ */ #endif /* LIBANGLE_RENDERER_METAL_SHADERS_COMMON_H_ */
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -39,4 +39,30 @@ ...@@ -39,4 +39,30 @@
#include "compiled_default_metallib_debug_ios_autogen.inc" #include "compiled_default_metallib_debug_ios_autogen.inc"
#endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST #endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
#include "compiled_default_metallib_2_1_mac_autogen.inc"
#elif TARGET_OS_IOS && TARGET_OS_SIMULATOR // TARGET_OS_OSX || TARGET_OS_MACCATALYST
#include "compiled_default_metallib_2_1_ios_sim_autogen.inc"
#elif TARGET_OS_IOS // TARGET_OS_OSX || TARGET_OS_MACCATALYST
#include "compiled_default_metallib_2_1_ios_autogen.inc"
#endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
#include "compiled_default_metallib_2_1_debug_mac_autogen.inc"
#elif TARGET_OS_IOS && TARGET_OS_SIMULATOR // TARGET_OS_OSX || TARGET_OS_MACCATALYST
#include "compiled_default_metallib_2_1_debug_ios_sim_autogen.inc"
#elif TARGET_OS_IOS // TARGET_OS_OSX || TARGET_OS_MACCATALYST
#include "compiled_default_metallib_2_1_debug_ios_autogen.inc"
#endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
// clang-format on // clang-format on
...@@ -6,10 +6,13 @@ ...@@ -6,10 +6,13 @@
#include "common.h" #include "common.h"
constant bool kSourceBufferAligned[[function_constant(0)]]; using namespace rx::mtl_shader;
constant bool kSourceIndexIsU8[[function_constant(1)]];
constant bool kSourceIndexIsU16[[function_constant(2)]]; // function_constant(0) is already used by common.h
constant bool kSourceIndexIsU32[[function_constant(3)]]; constant bool kSourceBufferAligned[[function_constant(1)]];
constant bool kSourceIndexIsU8[[function_constant(2)]];
constant bool kSourceIndexIsU16[[function_constant(3)]];
constant bool kSourceIndexIsU32[[function_constant(4)]];
constant bool kSourceBufferUnaligned = !kSourceBufferAligned; constant bool kSourceBufferUnaligned = !kSourceBufferAligned;
constant bool kUseSourceBufferU8 = kSourceIndexIsU8 || kSourceBufferUnaligned; constant bool kUseSourceBufferU8 = kSourceIndexIsU8 || kSourceBufferUnaligned;
constant bool kUseSourceBufferU16 = kSourceIndexIsU16 && kSourceBufferAligned; constant bool kUseSourceBufferU16 = kSourceIndexIsU16 && kSourceBufferAligned;
......
...@@ -166,6 +166,12 @@ def main(): ...@@ -166,6 +166,12 @@ def main():
# yapf: disable # yapf: disable
os_specific_autogen_files = [ os_specific_autogen_files = [
'compiled/compiled_default_metallib_2_1_debug_ios_autogen.inc',
'compiled/compiled_default_metallib_2_1_debug_ios_sim_autogen.inc',
'compiled/compiled_default_metallib_2_1_debug_mac_autogen.inc',
'compiled/compiled_default_metallib_2_1_ios_autogen.inc',
'compiled/compiled_default_metallib_2_1_ios_sim_autogen.inc',
'compiled/compiled_default_metallib_2_1_mac_autogen.inc',
'compiled/compiled_default_metallib_debug_ios_autogen.inc', 'compiled/compiled_default_metallib_debug_ios_autogen.inc',
'compiled/compiled_default_metallib_debug_ios_sim_autogen.inc', 'compiled/compiled_default_metallib_debug_ios_sim_autogen.inc',
'compiled/compiled_default_metallib_debug_mac_autogen.inc', 'compiled/compiled_default_metallib_debug_mac_autogen.inc',
...@@ -210,6 +216,10 @@ def main(): ...@@ -210,6 +216,10 @@ def main():
boilerplate_code) boilerplate_code)
gen_precompiled_shaders(10.13, 11.0, 'compiled_default_metallib_debug', gen_precompiled_shaders(10.13, 11.0, 'compiled_default_metallib_debug',
'-gline-tables-only -MO', src_files, boilerplate_code) '-gline-tables-only -MO', src_files, boilerplate_code)
gen_precompiled_shaders(10.14, 12.0, 'compiled_default_metallib_2_1', '', src_files,
boilerplate_code)
gen_precompiled_shaders(10.14, 12.0, 'compiled_default_metallib_2_1_debug',
'-gline-tables-only -MO', src_files, boilerplate_code)
os.system('echo "// clang-format on" >> compiled/mtl_default_shaders_autogen.inc') os.system('echo "// clang-format on" >> compiled/mtl_default_shaders_autogen.inc')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment