2014 snapchat source code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.9 KiB

  1. //
  2. // SCExposureAdjustMetalRenderCommand.m
  3. // Snapchat
  4. //
  5. // Created by Michel Loenngren on 7/11/17.
  6. //
  7. //
  8. #import "SCExposureAdjustMetalRenderCommand.h"
  9. #import "SCCameraTweaks.h"
  10. #import "SCMetalUtils.h"
  11. #import <SCFoundation/SCAssertWrapper.h>
  12. @import Metal;
  13. @implementation SCExposureAdjustMetalRenderCommand
  14. #pragma mark - SCMetalRenderCommand
  15. - (id<MTLComputeCommandEncoder>)encodeMetalCommand:(id<MTLCommandBuffer>)commandBuffer
  16. pipelineState:(id<MTLComputePipelineState>)pipelineState
  17. textureResource:(SCMetalTextureResource *)textureResource
  18. {
  19. id<MTLComputeCommandEncoder> commandEncoder = [commandBuffer computeCommandEncoder];
  20. [commandEncoder setComputePipelineState:pipelineState];
  21. #if !TARGET_IPHONE_SIMULATOR
  22. [commandEncoder setTexture:textureResource.sourceYTexture atIndex:0];
  23. [commandEncoder setTexture:textureResource.sourceUVTexture atIndex:1];
  24. [commandEncoder setTexture:textureResource.destinationYTexture atIndex:2];
  25. [commandEncoder setTexture:textureResource.destinationUVTexture atIndex:3];
  26. #endif
  27. return commandEncoder;
  28. }
  29. #pragma mark - SCMetalModuleFunctionProvider
  30. - (NSString *)functionName
  31. {
  32. if (SCCameraExposureAdjustmentMode() == 1) {
  33. return @"kernel_exposure_adjust";
  34. } else if (SCCameraExposureAdjustmentMode() == 2) {
  35. return @"kernel_exposure_adjust_nightvision";
  36. } else if (SCCameraExposureAdjustmentMode() == 3) {
  37. return @"kernel_exposure_adjust_inverted_nightvision";
  38. } else {
  39. SCAssertFail(@"Incorrect value from SCCameraExposureAdjustmentMode() %ld",
  40. (long)SCCameraExposureAdjustmentMode());
  41. return nil;
  42. }
  43. }
  44. - (BOOL)requiresDepthData
  45. {
  46. return NO;
  47. }
  48. - (NSString *)description
  49. {
  50. return
  51. [NSString sc_stringWithFormat:@"SCExposureAdjustMetalRenderCommand (shader function = %@)", self.functionName];
  52. }
  53. @end