@@ -48,7 +48,7 @@ DecompressBlockBC1(cmpBuffer,imgBuffer,null)
48
48
49
49
Includes Compressonator core with interfaces for multi-threading, mipmap generation, file access of images and HPC pipeline interfaces.
50
50
51
- **Example Mip Level Processing**
51
+ **Example Mip Level Processing using CPU **
52
52
53
53
```c++
54
54
@@ -109,7 +109,94 @@ CMP_MipSet MipSetCmp;
109
109
memset(&MipSetCmp, 0, sizeof(CMP_MipSet));
110
110
111
111
//===============================================
112
- // Compress the texture using Compressonator Lib
112
+ // Compress the texture using Framework Lib
113
+ //===============================================
114
+ cmp_status = CMP_ProcessTexture(&MipSetIn, &MipSetCmp, kernel_options, CompressionCallback);
115
+ if (cmp_status != CMP_OK) {
116
+ ...
117
+ }
118
+
119
+ //----------------------------------------------------------------
120
+ // Save the result into a DDS file
121
+ //----------------------------------------------------------------
122
+ cmp_status = CMP_SaveTexture(pszDestFile, &MipSetCmp);
123
+
124
+ CMP_FreeMipSet(&MipSetIn);
125
+ CMP_FreeMipSet(&MipSetCmp);
126
+
127
+ ```
128
+
129
+ ** Example GPU based processing using OpenCL**
130
+
131
+ ``` c++
132
+
133
+ // See Example 4 source for full details, Note: Only MD x64 build is used for GPU processing
134
+ // SDK files required for application:
135
+ // CMP_Framework.h
136
+ // CMP_Framework_xx.lib For static libs xx is either MD or MDd,
137
+ // When using DLL's make sure the CMP_Framework_xx_DLL.dll is in exe path
138
+ //
139
+ // File(s) required to run with the built application
140
+ //
141
+ // Using OpenCL (OCL)
142
+ // CMP_GPU_OCL_MD_DLL.dll or CMP_GPU_OCL_MDd_DLL.dll
143
+ // Encode Kernel files in plugins/compute folder
144
+ // BC1_Encode_Kernel.cpp
145
+ // BC1_Encode_Kernel.h
146
+ // BCn_Common_kernel.h
147
+ // Common_Def.h
148
+ //
149
+ // Using DirectX (DXC)
150
+ // CMP_GPU_DXC_MD_DLL.dll or CMP_GPU_DXC_MDd_DLL.dll
151
+ // Encode Kernel files in plugins/compute folder
152
+ // BC1_Encode_Kernel.hlsl
153
+ // BCn_Common_kernel.h
154
+ // Common_Def.h
155
+
156
+ #include " CMP_Framework.h"
157
+
158
+ CMP_FORMAT destFormat = CMP_FORMAT_BC1;
159
+
160
+ // ---------------
161
+ // Load the image
162
+ // ---------------
163
+ CMP_MipSet MipSetIn;
164
+ memset (&MipSetIn, 0, sizeof(CMP_MipSet));
165
+ if (CMP_LoadTexture(pszSourceFile, &MipSetIn) != CMP_OK) {
166
+ std::printf("Error: Loading source file!\n");
167
+ return -1;
168
+ }
169
+
170
+ //-----------------------------------------------------
171
+ // when using GPU: The texture must have width and height as a multiple of 4
172
+ // Check texture for width and height
173
+ //-----------------------------------------------------
174
+ if ((MipSetIn.m_nWidth % 4) > 0 || (MipSetIn.m_nHeight % 4) > 0) {
175
+ std::printf("Error: Texture width and height must be multiple of 4\n");
176
+ return -1;
177
+ }
178
+
179
+ //----------------------------------------------------------------------------------------------------------
180
+ // Set the target compression format and the host framework to use
181
+ // For this example OpenCL is been used
182
+ //-----------------------------------------------------------------------------------------------------------
183
+ KernelOptions kernel_options;
184
+ memset(&kernel_options, 0, sizeof(KernelOptions));
185
+
186
+ kernel_options.encodeWith = CMP_GPU_OCL; // Using OpenCL GPU Encoder, can replace with DXC for DirectX
187
+ kernel_options.format = destFormat; // Set the format to process
188
+ kernel_options.fquality = fQuality; // Set the quality of the result
189
+
190
+ //--------------------------------------------------------------
191
+ // Setup a results buffer for the processed file,
192
+ // the content will be set after the source texture is processed
193
+ // in the call to CMP_ProcessTexture()
194
+ //--------------------------------------------------------------
195
+ CMP_MipSet MipSetCmp;
196
+ memset(&MipSetCmp, 0, sizeof(CMP_MipSet));
197
+
198
+ //===============================================
199
+ // Compress the texture using Framework Lib
113
200
//===============================================
114
201
cmp_status = CMP_ProcessTexture(&MipSetIn, &MipSetCmp, kernel_options, CompressionCallback);
115
202
if (cmp_status != CMP_OK) {
0 commit comments