SlideShare ist ein Scribd-Unternehmen logo
1 von 17
PowerVR
Low Level GLSL Optimisation
이민웅
Shader Study
http://cdn.imgtec.com/sdk-documentation/PowerVR%20Low%20level%20GLSL%20Optimisation.pdf
Low Level GLSL Optimisation
• https://www.imgtec.com/blog/low-level-glsl-optimisation-for-
powervr/
• 원문
• PowerVR Series 6 기준
• Low Level 마지막 최적화용
• http://www.humus.name/Articles/Persson_LowLevelThinking.pdf
• 재원씨발표
• http://www.humus.name/Articles/Persson_LowlevelShaderOptimizat
ion.pdf
• 개발자가 놓칠 수 있는 저 수준 최적화
PowerVR Rogue architecture
• 셰이더를 실행하는 데 필요한 사이클 수에 따라 달라짐
• 아키텍처는 물론 구성에 따라 단일 사이클 내에서 USC (통합 쉐
이더 클러스터), ALU (산술 및 논리 유닛) 파이프 라인에서 여러
명령어를 실행하기위한 다양한 옵션을 제공
• 두 개의 F16 SOP (Sum of Products) 명령
• F32 - F16 변환 및 이동 / 출력 / 팩 명령을 모두 한 번에 실행
• FP32 / INT32 MAD / UNPACK 명령어, 테스트 (조건부) 명령어 및
move / output / pack 명령어와 함께 FP32 Multiply-Add 명령어
(MAD)를 한 사이클 만에 실행
• USC 코어를 활용하기 위해 MAD 형식으로 작성
USC(Unified Shader Cluster)
통합 쉐이더 클러스터
ALU (Arithmetic and Logic Unit)
산술 및 논리 유닛
SOP (Sum of Products)
Multiply-Add instruction (MAD)
MAD
• USC 코어를 가장 효과적으로 활용
• Multiply-Add 의 표현식
fragColor.x = (t.x + t.y) * (t.x - t.y); //2 cycles
{sop, sop, sopmov}
{sop, sop}
-->
fragColor.x = t.x * t.x + (-t.y * t.y); //1 cycle
{sop, sop}
Division
• 역수로 나누기를 작성하는 것
fragColor.x = (t.x * t.y + t.z) / t.x; //3
cycles
{sop, sop, sopmov}
{frcp}
{sop, sop}
-->
fragColor.x = t.y + t.z * (1.0 / t.x); //2
cycles
{frcp}
{sop, sop}
Sign
• -1 if x < 0, 1 if x > 0 를 sign으로 사용하는것 보다 조건식이
더 좋음
fragColor.x = sign(t.x) * t.y; //3 cycles
{mov, pck, tstgez, mov}
{mov, pck, tstgez, mov}
{sop, sop}
-->
fragColor.x = (t.x >= 0.0 ? 1.0 : -1.0) * t.y; //2 cycles
{mov, pck, tstgez, mov}
{sop, sop}
Rcp/rsqrt/sqrt
• sqrt(t.x) == t.x * inversesqrt(t.x); 같음
fragColor.x = sqrt(t.x) > 0.5 ? 0.5 : 1.0; //3 cycles
{frsq}
{frcp}
{mov, mov, pck, tstg, mov}
-->
fragColor.x = (t.x * inversesqrt(t.x)) > 0.5 ? 0.5 : 1.0; //2 cycles
{frsq}
{fmul, pck, tstg, mov}
Abs/Neg/Saturate
fragColor.xyz = -normalize(t.xyz); //6 cycles
{fmul, mov}
{fmad, mov}
{fmad, mov}
{frsq}
{fmul, fmul, mov, mov}
{fmul, mov}
-->
fragColor.xyz = normalize(-t.xyz); //7 cycles
{mov, mov, mov}
{fmul, mov}
{fmad, mov}
{fmad, mov}
{frsq}
{fmul, fmul, mov, mov}
{fmul, mov}
fragColor.x = abs(t.x * t.y); //2 cycles
{sop, sop}
{mov, mov, mov}
-->
fragColor.x = abs(t.x) * abs(t.y); //1 cycle
{sop, sop}
fragColor.x = -dot(t.xyz, t.yzx); //3 cycles
{sop, sop, sopmov}
{sop, sop}
{mov, mov, mov}
-->
fragColor.x = dot(-t.xyz, t.yzx); //2 cycles
{sop, sop, sopmov}
{sop, sop}
fragColor.x = 1.0 - clamp(t.x, 0.0, 1.0); //2 cycles
{sop, sop, sopmov}
{sop, sop}
-->
fragColor.x = clamp(1.0 - t.x, 0.0, 1.0); //1 cycle
{sop, sop}
Exp/Log
• PowerVR 에서는 2^n 명령어 지원
fragColor.x = exp2(t.x); //1 cycle
{fexp}
fragColor.x = log2(t.x); //1 cycle
{flog}
float pow( float x, float y )
{
return exp2(log2(x) * y); //3 cycles
{flog}
{sop, sop}
{fexp}
}
Sin/Cos/Sinh/Cosh
• 4 cycles 로 비용이 싸다
fragColor.x = sin(t.x); //4 cycles
{fred}
{fred}
{fsinc}
{fmul, mov} //+conditional 조건부
fragColor.x = sinh(t.x); //3 cycles
{fmul, fmul, mov, mov}
{fexp}
{sop, sop}
Asin/Acos/Atan/Degrees/Radians
• 하드웨어에서 지원 안함
• 매우 비용이 높다 사용하지 말자
fragColor.x = asin(t.x); //67 cycles
//USC code omitted due to length
fragColor.x = acos(t.x); //79 cycles
fragColor.x = atan(t.x); //12 cycles (lots of conditionals
Vector*Matrix
• 필요없는 계산은 하지말자
fragColor = t * m1; //4x4 matrix, 8 cycles
{mov}
{wdf}
{sop, sop, sopmov}
{sop, sop, sopmov}
{sop, sop}
{sop, sop, sopmov}
{sop, sop, sopmov}
{sop, sop}
fragColor.xyz = t.xyz * m2; //3x3 matrix, 4 cycles
{sop, sop, sopmov}
{sop, sop}
{sop, sop, sopmov}
{sop, sop}
Mixed Scalar/Vector math
• Normalize () / length () / distance
() / reflect () 등의 함수는 dot ()과
같은 함수를 많이 포함
• 두 작업에 공유 하위 표현식이 있다
는 것을 알면 사이클수를 줄일 수
있음
• 그러나 입력 순서가 허용하는 경우에
만 발생
fragColor.x = length(t-v); //7 cycles
fragColor.y = distance(v, t);
{sopmad, sopmad, sopmad, sopmad}
{sop, sop, sopmov}
{sopmad, sopmad, sopmad, sopmad}
{sop, sop, sopmov}
{sop, sop}
{frsq}
{frcp}
-->
fragColor.x = length(t-v); //9 cycles
fragColor.y = distance(t, v);
{mov}
{wdf}
{sopmad, sopmad, sopmad, sopmad}
{sop, sop, sopmov}
{sop, sop, sopmov}
{sop, sop}
{frsq}
{frcp}
{mov}
Operation grouping
• 스칼라연산은 그룹화가 중요
fragColor.xyz = t.xyz * t.x * t.y * t.wzx * t.z * t.w; //7 cycles
{sop, sop, sopmov}
{sop, sop, sopmov}
{sop, sop}
{sop, sop, sopmov}
{sop, sop}
{sop, sop, sopmov}
{sop, sop}
-->
fragColor.xyz = (t.x * t.y * t.z * t.w) * (t.xyz * t.wzx); //4 cycles
{sop, sop, sopmov}
{sop, sop, sopmov}
{sop, sop}
{sop, sop}
FP16 overview
• FP16 정밀도 및 변환
• 정밀도는 떨어져도 문제없음
• 최적화로 인해 변화가 있는지 없는지는 항상 체크
• 16-32비트 변환 비용이 무료
• FP16 SOP/MAD
• 잘 사용하면 단일 사이클로 만들수 있음 (1 cycle)
SOP/MAD FP16 pipeline
• 16-32비트 변환 비용이 무료
• SOP/MAD에서 다양한 사용법이 있음
4 MADs in one cycle.
fragColor.x = t.x * t.y + t.z;
fragColor.y = t.y * t.z + t.w;
fragColor.z = t.z * t.w + t.x;
fragColor.w = t.w * t.x + t.y;
{sopmad, sopmad, sopmad, sopmad}
//1 cycle
mediump vec4 fp16 = t;
highp vec4 res;
res.x = clamp(min(-fp16.y * abs(fp16.z), clamp(fp16.w, 0.0, 1.0) * abs(fp16.x)), 0.0, 1.0);
res.y = clamp(abs(fp16.w) * -fp16.z + clamp(fp16.x, 0.0, 1.0), 0.0, 1.0);
fragColor = res;
{sop, sop}

Weitere ähnliche Inhalte

Was ist angesagt?

R2서버정진욱
R2서버정진욱R2서버정진욱
R2서버정진욱jungjinwouk
 
사내스터디 발표 온라인게임서버이해 20100401
사내스터디 발표 온라인게임서버이해 20100401사내스터디 발표 온라인게임서버이해 20100401
사내스터디 발표 온라인게임서버이해 20100401guest91f89d83
 
[아꿈사/110528] 멀티코어cpu이야기 5,6장
[아꿈사/110528] 멀티코어cpu이야기 5,6장[아꿈사/110528] 멀티코어cpu이야기 5,6장
[아꿈사/110528] 멀티코어cpu이야기 5,6장sung ki choi
 
Design Pattern - Multithread Ch10
Design Pattern - Multithread Ch10Design Pattern - Multithread Ch10
Design Pattern - Multithread Ch10hyun soomyung
 
[OpenInfra Days Korea 2018] (Track 1) 컨테이너 시대에 딱 맞는 매니코어 기반의 ARM 서버
[OpenInfra Days Korea 2018] (Track 1) 컨테이너 시대에 딱 맞는 매니코어 기반의 ARM 서버[OpenInfra Days Korea 2018] (Track 1) 컨테이너 시대에 딱 맞는 매니코어 기반의 ARM 서버
[OpenInfra Days Korea 2018] (Track 1) 컨테이너 시대에 딱 맞는 매니코어 기반의 ARM 서버OpenStack Korea Community
 
LockFree Algorithm
LockFree AlgorithmLockFree Algorithm
LockFree AlgorithmMerry Merry
 
프로그래머가 몰랐던 멀티코어 CPU 이야기 - 15, 16장
프로그래머가 몰랐던 멀티코어  CPU 이야기 - 15, 16장프로그래머가 몰랐던 멀티코어  CPU 이야기 - 15, 16장
프로그래머가 몰랐던 멀티코어 CPU 이야기 - 15, 16장JangHyuk You
 
[0204 구경원] sse 병렬 프로그래밍
[0204 구경원] sse 병렬 프로그래밍[0204 구경원] sse 병렬 프로그래밍
[0204 구경원] sse 병렬 프로그래밍KyeongWon Koo
 
[ETHCon Korea 2019] Jung soonhyung 정순형
[ETHCon Korea 2019] Jung soonhyung 정순형[ETHCon Korea 2019] Jung soonhyung 정순형
[ETHCon Korea 2019] Jung soonhyung 정순형ethconkr
 
이권일 Sse 를 이용한 최적화와 실제 사용 예
이권일 Sse 를 이용한 최적화와 실제 사용 예이권일 Sse 를 이용한 최적화와 실제 사용 예
이권일 Sse 를 이용한 최적화와 실제 사용 예zupet
 
비동기 파일 로딩
비동기 파일 로딩비동기 파일 로딩
비동기 파일 로딩Bongseok Cho
 
Python의 계산성능 향상을 위해 Fortran, C, CUDA-C, OpenCL-C 코드들과 연동하기
Python의 계산성능 향상을 위해 Fortran, C, CUDA-C, OpenCL-C 코드들과 연동하기Python의 계산성능 향상을 위해 Fortran, C, CUDA-C, OpenCL-C 코드들과 연동하기
Python의 계산성능 향상을 위해 Fortran, C, CUDA-C, OpenCL-C 코드들과 연동하기Ki-Hwan Kim
 
[Live coding] 2회 5 23 (camp-exam_javalanguage)
[Live coding] 2회 5 23 (camp-exam_javalanguage)[Live coding] 2회 5 23 (camp-exam_javalanguage)
[Live coding] 2회 5 23 (camp-exam_javalanguage)동욱 하
 
[2D7]레기온즈로 살펴보는 확장 가능한 게임서버의 구현
[2D7]레기온즈로 살펴보는 확장 가능한 게임서버의 구현[2D7]레기온즈로 살펴보는 확장 가능한 게임서버의 구현
[2D7]레기온즈로 살펴보는 확장 가능한 게임서버의 구현NAVER D2
 
사례를 통해 살펴보는 프로파일링과 최적화 NDC2013
사례를 통해 살펴보는 프로파일링과 최적화 NDC2013사례를 통해 살펴보는 프로파일링과 최적화 NDC2013
사례를 통해 살펴보는 프로파일링과 최적화 NDC2013Esun Kim
 

Was ist angesagt? (20)

문자함수(2)
문자함수(2)문자함수(2)
문자함수(2)
 
문자함수(1)
문자함수(1)문자함수(1)
문자함수(1)
 
Lock free queue
Lock free queueLock free queue
Lock free queue
 
R2서버정진욱
R2서버정진욱R2서버정진욱
R2서버정진욱
 
사내스터디 발표 온라인게임서버이해 20100401
사내스터디 발표 온라인게임서버이해 20100401사내스터디 발표 온라인게임서버이해 20100401
사내스터디 발표 온라인게임서버이해 20100401
 
[아꿈사/110528] 멀티코어cpu이야기 5,6장
[아꿈사/110528] 멀티코어cpu이야기 5,6장[아꿈사/110528] 멀티코어cpu이야기 5,6장
[아꿈사/110528] 멀티코어cpu이야기 5,6장
 
Gcd ppt
Gcd pptGcd ppt
Gcd ppt
 
Design Pattern - Multithread Ch10
Design Pattern - Multithread Ch10Design Pattern - Multithread Ch10
Design Pattern - Multithread Ch10
 
[OpenInfra Days Korea 2018] (Track 1) 컨테이너 시대에 딱 맞는 매니코어 기반의 ARM 서버
[OpenInfra Days Korea 2018] (Track 1) 컨테이너 시대에 딱 맞는 매니코어 기반의 ARM 서버[OpenInfra Days Korea 2018] (Track 1) 컨테이너 시대에 딱 맞는 매니코어 기반의 ARM 서버
[OpenInfra Days Korea 2018] (Track 1) 컨테이너 시대에 딱 맞는 매니코어 기반의 ARM 서버
 
LockFree Algorithm
LockFree AlgorithmLockFree Algorithm
LockFree Algorithm
 
프로그래머가 몰랐던 멀티코어 CPU 이야기 - 15, 16장
프로그래머가 몰랐던 멀티코어  CPU 이야기 - 15, 16장프로그래머가 몰랐던 멀티코어  CPU 이야기 - 15, 16장
프로그래머가 몰랐던 멀티코어 CPU 이야기 - 15, 16장
 
[0204 구경원] sse 병렬 프로그래밍
[0204 구경원] sse 병렬 프로그래밍[0204 구경원] sse 병렬 프로그래밍
[0204 구경원] sse 병렬 프로그래밍
 
[ETHCon Korea 2019] Jung soonhyung 정순형
[ETHCon Korea 2019] Jung soonhyung 정순형[ETHCon Korea 2019] Jung soonhyung 정순형
[ETHCon Korea 2019] Jung soonhyung 정순형
 
이권일 Sse 를 이용한 최적화와 실제 사용 예
이권일 Sse 를 이용한 최적화와 실제 사용 예이권일 Sse 를 이용한 최적화와 실제 사용 예
이권일 Sse 를 이용한 최적화와 실제 사용 예
 
비동기 파일 로딩
비동기 파일 로딩비동기 파일 로딩
비동기 파일 로딩
 
Python의 계산성능 향상을 위해 Fortran, C, CUDA-C, OpenCL-C 코드들과 연동하기
Python의 계산성능 향상을 위해 Fortran, C, CUDA-C, OpenCL-C 코드들과 연동하기Python의 계산성능 향상을 위해 Fortran, C, CUDA-C, OpenCL-C 코드들과 연동하기
Python의 계산성능 향상을 위해 Fortran, C, CUDA-C, OpenCL-C 코드들과 연동하기
 
tcp ip study
tcp ip studytcp ip study
tcp ip study
 
[Live coding] 2회 5 23 (camp-exam_javalanguage)
[Live coding] 2회 5 23 (camp-exam_javalanguage)[Live coding] 2회 5 23 (camp-exam_javalanguage)
[Live coding] 2회 5 23 (camp-exam_javalanguage)
 
[2D7]레기온즈로 살펴보는 확장 가능한 게임서버의 구현
[2D7]레기온즈로 살펴보는 확장 가능한 게임서버의 구현[2D7]레기온즈로 살펴보는 확장 가능한 게임서버의 구현
[2D7]레기온즈로 살펴보는 확장 가능한 게임서버의 구현
 
사례를 통해 살펴보는 프로파일링과 최적화 NDC2013
사례를 통해 살펴보는 프로파일링과 최적화 NDC2013사례를 통해 살펴보는 프로파일링과 최적화 NDC2013
사례를 통해 살펴보는 프로파일링과 최적화 NDC2013
 

Ähnlich wie PowerVR Low Level GLSL Optimisation

[14.10.21] Far Cry and DX9 번역(shaderstudy)
[14.10.21] Far Cry and DX9 번역(shaderstudy)[14.10.21] Far Cry and DX9 번역(shaderstudy)
[14.10.21] Far Cry and DX9 번역(shaderstudy)해강
 
[Swift] Protocol (1/2)
[Swift] Protocol (1/2)[Swift] Protocol (1/2)
[Swift] Protocol (1/2)Bill Kim
 
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기zupet
 
Programming Cascading
Programming CascadingProgramming Cascading
Programming CascadingTaewook Eom
 
C Language I
C Language IC Language I
C Language ISuho Kwon
 
[OpenInfra Days Korea 2018] Day 2 - E1: 딥다이브 - OpenStack 생존기
[OpenInfra Days Korea 2018] Day 2 - E1: 딥다이브 - OpenStack 생존기[OpenInfra Days Korea 2018] Day 2 - E1: 딥다이브 - OpenStack 생존기
[OpenInfra Days Korea 2018] Day 2 - E1: 딥다이브 - OpenStack 생존기OpenStack Korea Community
 
제 7회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 7회 엑셈 수요 세미나 자료 연구컨텐츠팀제 7회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 7회 엑셈 수요 세미나 자료 연구컨텐츠팀EXEM
 
Ryu with OpenFlow 1.3, Traffic Monitor
Ryu with OpenFlow 1.3, Traffic MonitorRyu with OpenFlow 1.3, Traffic Monitor
Ryu with OpenFlow 1.3, Traffic Monitorjieun kim
 
[Main Session] 미래의 Java 미리보기 - 앰버와 발할라 프로젝트를 중심으로
[Main Session] 미래의 Java 미리보기 - 앰버와 발할라 프로젝트를 중심으로[Main Session] 미래의 Java 미리보기 - 앰버와 발할라 프로젝트를 중심으로
[Main Session] 미래의 Java 미리보기 - 앰버와 발할라 프로젝트를 중심으로Oracle Korea
 
Windows reversing study_basic_2
Windows reversing study_basic_2Windows reversing study_basic_2
Windows reversing study_basic_2Jinkyoung Kim
 
[D2] java 애플리케이션 트러블 슈팅 사례 & pinpoint
[D2] java 애플리케이션 트러블 슈팅 사례 & pinpoint [D2] java 애플리케이션 트러블 슈팅 사례 & pinpoint
[D2] java 애플리케이션 트러블 슈팅 사례 & pinpoint NAVER D2
 
Java mentoring of samsung scsc 2
Java mentoring of samsung scsc   2Java mentoring of samsung scsc   2
Java mentoring of samsung scsc 2도현 김
 
20150212 c++11 features used in crow
20150212 c++11 features used in crow20150212 c++11 features used in crow
20150212 c++11 features used in crowJaeseung Ha
 
[14.10.10] TressFX 번역(self)
[14.10.10] TressFX 번역(self)[14.10.10] TressFX 번역(self)
[14.10.10] TressFX 번역(self)해강
 
Implements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture ArrayImplements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture ArrayYEONG-CHEON YOU
 
프로그래밍 대회: C++11 이야기
프로그래밍 대회: C++11 이야기프로그래밍 대회: C++11 이야기
프로그래밍 대회: C++11 이야기Jongwook Choi
 

Ähnlich wie PowerVR Low Level GLSL Optimisation (20)

ES6 for Node.js Study 2주차
ES6 for Node.js Study 2주차ES6 for Node.js Study 2주차
ES6 for Node.js Study 2주차
 
[14.10.21] Far Cry and DX9 번역(shaderstudy)
[14.10.21] Far Cry and DX9 번역(shaderstudy)[14.10.21] Far Cry and DX9 번역(shaderstudy)
[14.10.21] Far Cry and DX9 번역(shaderstudy)
 
[Swift] Protocol (1/2)
[Swift] Protocol (1/2)[Swift] Protocol (1/2)
[Swift] Protocol (1/2)
 
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기
 
Programming Cascading
Programming CascadingProgramming Cascading
Programming Cascading
 
C Language I
C Language IC Language I
C Language I
 
[OpenInfra Days Korea 2018] Day 2 - E1: 딥다이브 - OpenStack 생존기
[OpenInfra Days Korea 2018] Day 2 - E1: 딥다이브 - OpenStack 생존기[OpenInfra Days Korea 2018] Day 2 - E1: 딥다이브 - OpenStack 생존기
[OpenInfra Days Korea 2018] Day 2 - E1: 딥다이브 - OpenStack 생존기
 
제 7회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 7회 엑셈 수요 세미나 자료 연구컨텐츠팀제 7회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 7회 엑셈 수요 세미나 자료 연구컨텐츠팀
 
Ryu with OpenFlow 1.3, Traffic Monitor
Ryu with OpenFlow 1.3, Traffic MonitorRyu with OpenFlow 1.3, Traffic Monitor
Ryu with OpenFlow 1.3, Traffic Monitor
 
[Main Session] 미래의 Java 미리보기 - 앰버와 발할라 프로젝트를 중심으로
[Main Session] 미래의 Java 미리보기 - 앰버와 발할라 프로젝트를 중심으로[Main Session] 미래의 Java 미리보기 - 앰버와 발할라 프로젝트를 중심으로
[Main Session] 미래의 Java 미리보기 - 앰버와 발할라 프로젝트를 중심으로
 
Java.next
Java.nextJava.next
Java.next
 
Windows reversing study_basic_2
Windows reversing study_basic_2Windows reversing study_basic_2
Windows reversing study_basic_2
 
Storm 훑어보기
Storm 훑어보기Storm 훑어보기
Storm 훑어보기
 
[D2] java 애플리케이션 트러블 슈팅 사례 & pinpoint
[D2] java 애플리케이션 트러블 슈팅 사례 & pinpoint [D2] java 애플리케이션 트러블 슈팅 사례 & pinpoint
[D2] java 애플리케이션 트러블 슈팅 사례 & pinpoint
 
Java mentoring of samsung scsc 2
Java mentoring of samsung scsc   2Java mentoring of samsung scsc   2
Java mentoring of samsung scsc 2
 
20150212 c++11 features used in crow
20150212 c++11 features used in crow20150212 c++11 features used in crow
20150212 c++11 features used in crow
 
[14.10.10] TressFX 번역(self)
[14.10.10] TressFX 번역(self)[14.10.10] TressFX 번역(self)
[14.10.10] TressFX 번역(self)
 
파이썬을 활용한 자연어 분석 - 2차
파이썬을 활용한 자연어 분석 - 2차파이썬을 활용한 자연어 분석 - 2차
파이썬을 활용한 자연어 분석 - 2차
 
Implements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture ArrayImplements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture Array
 
프로그래밍 대회: C++11 이야기
프로그래밍 대회: C++11 이야기프로그래밍 대회: C++11 이야기
프로그래밍 대회: C++11 이야기
 

Mehr von 민웅 이

Siggraph15 A Novel Sampling Algorithm for Fast and Stable Real-Time Volume Re...
Siggraph15 A Novel Sampling Algorithm for Fast and Stable Real-Time Volume Re...Siggraph15 A Novel Sampling Algorithm for Fast and Stable Real-Time Volume Re...
Siggraph15 A Novel Sampling Algorithm for Fast and Stable Real-Time Volume Re...민웅 이
 
제노블레이도 2 ray marching을사용한 구름 표현
제노블레이도 2 ray marching을사용한 구름 표현제노블레이도 2 ray marching을사용한 구름 표현
제노블레이도 2 ray marching을사용한 구름 표현민웅 이
 
자동 동적 3차원 입체시각
자동 동적 3차원 입체시각자동 동적 3차원 입체시각
자동 동적 3차원 입체시각민웅 이
 
Compute shader DX11
Compute shader DX11Compute shader DX11
Compute shader DX11민웅 이
 
Post processing in_color
Post processing in_colorPost processing in_color
Post processing in_color민웅 이
 
「스퀘어 에닉스 오픈 컨퍼런스 2012」「Agni's Philosophy」비하인드 스토리
「스퀘어 에닉스 오픈 컨퍼런스 2012」「Agni's Philosophy」비하인드 스토리「스퀘어 에닉스 오픈 컨퍼런스 2012」「Agni's Philosophy」비하인드 스토리
「스퀘어 에닉스 오픈 컨퍼런스 2012」「Agni's Philosophy」비하인드 스토리민웅 이
 
Valient killzone ps4 lighting
Valient killzone ps4 lightingValient killzone ps4 lighting
Valient killzone ps4 lighting민웅 이
 
크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)
크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)
크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)민웅 이
 
니시카와젠지의 3 d 게임 팬을 위한 ps4
니시카와젠지의 3 d 게임 팬을 위한 ps4니시카와젠지의 3 d 게임 팬을 위한 ps4
니시카와젠지의 3 d 게임 팬을 위한 ps4민웅 이
 
Microfacet brdf
Microfacet brdfMicrofacet brdf
Microfacet brdf민웅 이
 
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌민웅 이
 
Wrapped diffuse
Wrapped diffuseWrapped diffuse
Wrapped diffuse민웅 이
 
3D Engine Tools with C++/CLR
3D Engine Tools with C++/CLR3D Engine Tools with C++/CLR
3D Engine Tools with C++/CLR민웅 이
 
Light in screen_space(Light Pre Pass)
Light in screen_space(Light Pre Pass)Light in screen_space(Light Pre Pass)
Light in screen_space(Light Pre Pass)민웅 이
 
Gamma and linear color-space
Gamma and linear color-spaceGamma and linear color-space
Gamma and linear color-space민웅 이
 
Cheap realisticskinshading kor
Cheap realisticskinshading korCheap realisticskinshading kor
Cheap realisticskinshading kor민웅 이
 
Deferred decal
Deferred decalDeferred decal
Deferred decal민웅 이
 

Mehr von 민웅 이 (18)

Siggraph15 A Novel Sampling Algorithm for Fast and Stable Real-Time Volume Re...
Siggraph15 A Novel Sampling Algorithm for Fast and Stable Real-Time Volume Re...Siggraph15 A Novel Sampling Algorithm for Fast and Stable Real-Time Volume Re...
Siggraph15 A Novel Sampling Algorithm for Fast and Stable Real-Time Volume Re...
 
제노블레이도 2 ray marching을사용한 구름 표현
제노블레이도 2 ray marching을사용한 구름 표현제노블레이도 2 ray marching을사용한 구름 표현
제노블레이도 2 ray marching을사용한 구름 표현
 
자동 동적 3차원 입체시각
자동 동적 3차원 입체시각자동 동적 3차원 입체시각
자동 동적 3차원 입체시각
 
Compute shader DX11
Compute shader DX11Compute shader DX11
Compute shader DX11
 
Post processing in_color
Post processing in_colorPost processing in_color
Post processing in_color
 
「스퀘어 에닉스 오픈 컨퍼런스 2012」「Agni's Philosophy」비하인드 스토리
「스퀘어 에닉스 오픈 컨퍼런스 2012」「Agni's Philosophy」비하인드 스토리「스퀘어 에닉스 오픈 컨퍼런스 2012」「Agni's Philosophy」비하인드 스토리
「스퀘어 에닉스 오픈 컨퍼런스 2012」「Agni's Philosophy」비하인드 스토리
 
Valient killzone ps4 lighting
Valient killzone ps4 lightingValient killzone ps4 lighting
Valient killzone ps4 lighting
 
크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)
크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)
크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)
 
니시카와젠지의 3 d 게임 팬을 위한 ps4
니시카와젠지의 3 d 게임 팬을 위한 ps4니시카와젠지의 3 d 게임 팬을 위한 ps4
니시카와젠지의 3 d 게임 팬을 위한 ps4
 
Microfacet brdf
Microfacet brdfMicrofacet brdf
Microfacet brdf
 
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌
 
Wrapped diffuse
Wrapped diffuseWrapped diffuse
Wrapped diffuse
 
3D Engine Tools with C++/CLR
3D Engine Tools with C++/CLR3D Engine Tools with C++/CLR
3D Engine Tools with C++/CLR
 
Light in screen_space(Light Pre Pass)
Light in screen_space(Light Pre Pass)Light in screen_space(Light Pre Pass)
Light in screen_space(Light Pre Pass)
 
Gamma and linear color-space
Gamma and linear color-spaceGamma and linear color-space
Gamma and linear color-space
 
Cheap realisticskinshading kor
Cheap realisticskinshading korCheap realisticskinshading kor
Cheap realisticskinshading kor
 
Ceh
CehCeh
Ceh
 
Deferred decal
Deferred decalDeferred decal
Deferred decal
 

PowerVR Low Level GLSL Optimisation

  • 1. PowerVR Low Level GLSL Optimisation 이민웅 Shader Study http://cdn.imgtec.com/sdk-documentation/PowerVR%20Low%20level%20GLSL%20Optimisation.pdf
  • 2. Low Level GLSL Optimisation • https://www.imgtec.com/blog/low-level-glsl-optimisation-for- powervr/ • 원문 • PowerVR Series 6 기준 • Low Level 마지막 최적화용 • http://www.humus.name/Articles/Persson_LowLevelThinking.pdf • 재원씨발표 • http://www.humus.name/Articles/Persson_LowlevelShaderOptimizat ion.pdf • 개발자가 놓칠 수 있는 저 수준 최적화
  • 3. PowerVR Rogue architecture • 셰이더를 실행하는 데 필요한 사이클 수에 따라 달라짐 • 아키텍처는 물론 구성에 따라 단일 사이클 내에서 USC (통합 쉐 이더 클러스터), ALU (산술 및 논리 유닛) 파이프 라인에서 여러 명령어를 실행하기위한 다양한 옵션을 제공 • 두 개의 F16 SOP (Sum of Products) 명령 • F32 - F16 변환 및 이동 / 출력 / 팩 명령을 모두 한 번에 실행 • FP32 / INT32 MAD / UNPACK 명령어, 테스트 (조건부) 명령어 및 move / output / pack 명령어와 함께 FP32 Multiply-Add 명령어 (MAD)를 한 사이클 만에 실행 • USC 코어를 활용하기 위해 MAD 형식으로 작성
  • 4. USC(Unified Shader Cluster) 통합 쉐이더 클러스터 ALU (Arithmetic and Logic Unit) 산술 및 논리 유닛 SOP (Sum of Products) Multiply-Add instruction (MAD)
  • 5. MAD • USC 코어를 가장 효과적으로 활용 • Multiply-Add 의 표현식 fragColor.x = (t.x + t.y) * (t.x - t.y); //2 cycles {sop, sop, sopmov} {sop, sop} --> fragColor.x = t.x * t.x + (-t.y * t.y); //1 cycle {sop, sop}
  • 6. Division • 역수로 나누기를 작성하는 것 fragColor.x = (t.x * t.y + t.z) / t.x; //3 cycles {sop, sop, sopmov} {frcp} {sop, sop} --> fragColor.x = t.y + t.z * (1.0 / t.x); //2 cycles {frcp} {sop, sop}
  • 7. Sign • -1 if x < 0, 1 if x > 0 를 sign으로 사용하는것 보다 조건식이 더 좋음 fragColor.x = sign(t.x) * t.y; //3 cycles {mov, pck, tstgez, mov} {mov, pck, tstgez, mov} {sop, sop} --> fragColor.x = (t.x >= 0.0 ? 1.0 : -1.0) * t.y; //2 cycles {mov, pck, tstgez, mov} {sop, sop}
  • 8. Rcp/rsqrt/sqrt • sqrt(t.x) == t.x * inversesqrt(t.x); 같음 fragColor.x = sqrt(t.x) > 0.5 ? 0.5 : 1.0; //3 cycles {frsq} {frcp} {mov, mov, pck, tstg, mov} --> fragColor.x = (t.x * inversesqrt(t.x)) > 0.5 ? 0.5 : 1.0; //2 cycles {frsq} {fmul, pck, tstg, mov}
  • 9. Abs/Neg/Saturate fragColor.xyz = -normalize(t.xyz); //6 cycles {fmul, mov} {fmad, mov} {fmad, mov} {frsq} {fmul, fmul, mov, mov} {fmul, mov} --> fragColor.xyz = normalize(-t.xyz); //7 cycles {mov, mov, mov} {fmul, mov} {fmad, mov} {fmad, mov} {frsq} {fmul, fmul, mov, mov} {fmul, mov} fragColor.x = abs(t.x * t.y); //2 cycles {sop, sop} {mov, mov, mov} --> fragColor.x = abs(t.x) * abs(t.y); //1 cycle {sop, sop} fragColor.x = -dot(t.xyz, t.yzx); //3 cycles {sop, sop, sopmov} {sop, sop} {mov, mov, mov} --> fragColor.x = dot(-t.xyz, t.yzx); //2 cycles {sop, sop, sopmov} {sop, sop} fragColor.x = 1.0 - clamp(t.x, 0.0, 1.0); //2 cycles {sop, sop, sopmov} {sop, sop} --> fragColor.x = clamp(1.0 - t.x, 0.0, 1.0); //1 cycle {sop, sop}
  • 10. Exp/Log • PowerVR 에서는 2^n 명령어 지원 fragColor.x = exp2(t.x); //1 cycle {fexp} fragColor.x = log2(t.x); //1 cycle {flog} float pow( float x, float y ) { return exp2(log2(x) * y); //3 cycles {flog} {sop, sop} {fexp} }
  • 11. Sin/Cos/Sinh/Cosh • 4 cycles 로 비용이 싸다 fragColor.x = sin(t.x); //4 cycles {fred} {fred} {fsinc} {fmul, mov} //+conditional 조건부 fragColor.x = sinh(t.x); //3 cycles {fmul, fmul, mov, mov} {fexp} {sop, sop}
  • 12. Asin/Acos/Atan/Degrees/Radians • 하드웨어에서 지원 안함 • 매우 비용이 높다 사용하지 말자 fragColor.x = asin(t.x); //67 cycles //USC code omitted due to length fragColor.x = acos(t.x); //79 cycles fragColor.x = atan(t.x); //12 cycles (lots of conditionals
  • 13. Vector*Matrix • 필요없는 계산은 하지말자 fragColor = t * m1; //4x4 matrix, 8 cycles {mov} {wdf} {sop, sop, sopmov} {sop, sop, sopmov} {sop, sop} {sop, sop, sopmov} {sop, sop, sopmov} {sop, sop} fragColor.xyz = t.xyz * m2; //3x3 matrix, 4 cycles {sop, sop, sopmov} {sop, sop} {sop, sop, sopmov} {sop, sop}
  • 14. Mixed Scalar/Vector math • Normalize () / length () / distance () / reflect () 등의 함수는 dot ()과 같은 함수를 많이 포함 • 두 작업에 공유 하위 표현식이 있다 는 것을 알면 사이클수를 줄일 수 있음 • 그러나 입력 순서가 허용하는 경우에 만 발생 fragColor.x = length(t-v); //7 cycles fragColor.y = distance(v, t); {sopmad, sopmad, sopmad, sopmad} {sop, sop, sopmov} {sopmad, sopmad, sopmad, sopmad} {sop, sop, sopmov} {sop, sop} {frsq} {frcp} --> fragColor.x = length(t-v); //9 cycles fragColor.y = distance(t, v); {mov} {wdf} {sopmad, sopmad, sopmad, sopmad} {sop, sop, sopmov} {sop, sop, sopmov} {sop, sop} {frsq} {frcp} {mov}
  • 15. Operation grouping • 스칼라연산은 그룹화가 중요 fragColor.xyz = t.xyz * t.x * t.y * t.wzx * t.z * t.w; //7 cycles {sop, sop, sopmov} {sop, sop, sopmov} {sop, sop} {sop, sop, sopmov} {sop, sop} {sop, sop, sopmov} {sop, sop} --> fragColor.xyz = (t.x * t.y * t.z * t.w) * (t.xyz * t.wzx); //4 cycles {sop, sop, sopmov} {sop, sop, sopmov} {sop, sop} {sop, sop}
  • 16. FP16 overview • FP16 정밀도 및 변환 • 정밀도는 떨어져도 문제없음 • 최적화로 인해 변화가 있는지 없는지는 항상 체크 • 16-32비트 변환 비용이 무료 • FP16 SOP/MAD • 잘 사용하면 단일 사이클로 만들수 있음 (1 cycle)
  • 17. SOP/MAD FP16 pipeline • 16-32비트 변환 비용이 무료 • SOP/MAD에서 다양한 사용법이 있음 4 MADs in one cycle. fragColor.x = t.x * t.y + t.z; fragColor.y = t.y * t.z + t.w; fragColor.z = t.z * t.w + t.x; fragColor.w = t.w * t.x + t.y; {sopmad, sopmad, sopmad, sopmad} //1 cycle mediump vec4 fp16 = t; highp vec4 res; res.x = clamp(min(-fp16.y * abs(fp16.z), clamp(fp16.w, 0.0, 1.0) * abs(fp16.x)), 0.0, 1.0); res.y = clamp(abs(fp16.w) * -fp16.z + clamp(fp16.x, 0.0, 1.0), 0.0, 1.0); fragColor = res; {sop, sop}

Hinweis der Redaktion

  1. 일반적으로 PowerVR Rogue 아키텍처 GPU의 쉐이더 성능은 쉐이더를 실행하는 데 필요한 사이클 수에 따라 달라집니다. 구성에 따라 PowerVR Rogue 아키텍처는 단일 사이클 내에서 USC ALU 파이프 라인에서 여러 명령어를 실행하기위한 다양한 옵션을 제공 2 개의 F16 SOP 명령어와 F32 <-> F16 변환, mov / output / pack 명령어를 한 번에 실행 FP32 MAD 및 FP32 / INT32 MAD / UNPACK 명령어와 테스트 (조건부) 명령어와 mov / output / pack 명령어를 한 사이클에 실행 수행 할 비트 작업이있는 경우 한 번의 사이클에서 비트 단위 SHIFT / COUNT, 비트 단위 논리 연산, 비트 단위 시프트, 테스트 및 mov / 출력 / 팩 명령어를 실행할 수 있습니다. 한 번의 복잡한 작업 (예 : rcp)과 mov / output / pack 명령을 한 번에 실행할 수도 있습니다. 마지막으로 보간 / 샘플 명령과 일반 mov / output / pack 명령을 한 사이클에서 실행할 수 있습니다. 아래 그림과 같이 ALU를 최대한 활용하려면 아래의 파이프 라인에서 한 경로의 모든 단계를 사용하는 것이 가장 좋습니다.
  2. 부호 위치에 대한 최적화
  3. omitted due to length 길이 때문에 생략 된