File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 2727#if __CC_METAL_SUPPORTED_AND_ENABLED
2828
2929#import " CCTexture_Private.h"
30+ #import " CCShader_Private.h"
3031
3132@implementation CCMetalContext
3233
@@ -215,7 +216,15 @@ -(void)prepare
215216 id <MTLLibrary > library = context.library ;
216217 #warning TEMP Hard coded shaders.
217218 pipelineStateDescriptor.vertexFunction = [library newFunctionWithName: @" CCVertexFunctionDefault" ];
218- pipelineStateDescriptor.fragmentFunction = [library newFunctionWithName: @" CCFragmentFunctionDefaultTextureColor" ];
219+ if (_shader == [CCShader positionColorShader ]){
220+ pipelineStateDescriptor.fragmentFunction = [library newFunctionWithName: @" CCFragmentFunctionDefaultColor" ];
221+ } else if (_shader == [CCShader positionTextureColorShader ]){
222+ pipelineStateDescriptor.fragmentFunction = [library newFunctionWithName: @" CCFragmentFunctionDefaultTextureColor" ];
223+ } else if (_shader == [CCShader positionTextureA8ColorShader ]){
224+ pipelineStateDescriptor.fragmentFunction = [library newFunctionWithName: @" CCFragmentFunctionDefaultTextureA8Color" ];
225+ } else {
226+ pipelineStateDescriptor.fragmentFunction = [library newFunctionWithName: @" TempUnsupported" ];
227+ }
219228
220229 NSDictionary *blendOptions = _blendMode.options ;
221230 MTLRenderPipelineColorAttachmentDescriptor *colorDescriptor = [MTLRenderPipelineColorAttachmentDescriptor new ];
Original file line number Diff line number Diff line change @@ -56,4 +56,13 @@ CCFragmentFunctionDefaultTextureA8Color(
5656 return in.color *mainTexture.sample (mainTextureSampler, in.texCoord1 ).a ;
5757}
5858
59+ fragment half4
60+ TempUnsupported (
61+ CCFragData in [[stage_in]],
62+ texture2d<half> mainTexture [[texture(0 )]],
63+ sampler mainTextureSampler [[sampler(0 )]]
64+ ){
65+ return half4 (1 , 0 , 1 , 1 );
66+ }
67+
5968// TODO "alpha test" shader
You can’t perform that action at this time.
0 commit comments