diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ddb38e60d..a074b136e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -687,10 +687,6 @@ if (FILAMENT_SUPPORTS_VULKAN) add_subdirectory(${EXTERNAL}/vkmemalloc/tnt) endif() -if (APPLE) - add_subdirectory(${EXTERNAL}/moltenvk/tnt) -endif() - set(FILAMENT_SAMPLES_BINARY_DIR ${PROJECT_BINARY_DIR}/samples) if (WEBGL) diff --git a/README.md b/README.md index a4535e05e4..b4dba5bc70 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ repositories { } dependencies { - implementation 'com.google.android.filament:filament-android:1.23.0' + implementation 'com.google.android.filament:filament-android:1.23.1' } ``` @@ -51,7 +51,7 @@ Here are all the libraries available in the group `com.google.android.filament`: iOS projects can use CocoaPods to install the latest release: ``` -pod 'Filament', '~> 1.23.0' +pod 'Filament', '~> 1.23.1' ``` ### Snapshots diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index bab44384cf..fb0eb585a7 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -5,6 +5,17 @@ A new header is inserted each time a *tag* is created. ## main branch +## v1.23.1 + +- gltfio: support skinning with bones that do not belong to any scene. +- gltfio: add `attachSkin` / `detachSkin` method to FilamentAsset. +- gltfio: ubershader mode: set sheen to `OPAQUE`. +- Metal: fix issues seen with dynamic resolution on M1 Macs. +- engine: add a "global" mode for render primitive's `blendOrder`. +- engine: remove `RenderManager::setGeometryAt(index, count)`. [⚠️ **API Change**] +- engine: fix overallocation by about 17MB. +- WebGL: Add JS bindings for Texture class methods. + ## v1.23.0 - engine: Changed UBOs layout [⚠️ **Material breakage**]. diff --git a/android/filament-android/src/main/cpp/RenderableManager.cpp b/android/filament-android/src/main/cpp/RenderableManager.cpp index 5eb495653e..6a1b32c622 100644 --- a/android/filament-android/src/main/cpp/RenderableManager.cpp +++ b/android/filament-android/src/main/cpp/RenderableManager.cpp @@ -120,6 +120,14 @@ Java_com_google_android_filament_RenderableManager_nBuilderBlendOrder(JNIEnv*, j builder->blendOrder((size_t) index, (uint16_t) blendOrder); } +extern "C" +JNIEXPORT void JNICALL +Java_com_google_android_filament_RenderableManager_nBuilderGlobalBlendOrderEnabled(JNIEnv*, jclass, + jlong nativeBuilder, jint index, jboolean enabled) { + RenderableManager::Builder *builder = (RenderableManager::Builder *) nativeBuilder; + builder->globalBlendOrderEnabled((size_t) index, (bool) enabled); +} + extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_RenderableManager_nBuilderBoundingBox(JNIEnv*, jclass, jlong nativeBuilder, jfloat cx, jfloat cy, jfloat cz, jfloat ex, jfloat ey, jfloat ez) { @@ -422,15 +430,6 @@ Java_com_google_android_filament_RenderableManager_nSetGeometryAt__JIIIJJII(JNIE (size_t) offset, (size_t) count); } -extern "C" JNIEXPORT void JNICALL -Java_com_google_android_filament_RenderableManager_nSetGeometryAt__JIIIII(JNIEnv*, jclass, - jlong nativeRenderableManager, jint i, jint primitiveIndex, jint primitiveType, jint offset, - jint count) { - RenderableManager *rm = (RenderableManager *) nativeRenderableManager; - rm->setGeometryAt((RenderableManager::Instance) i, (size_t) primitiveIndex, - (RenderableManager::PrimitiveType) primitiveType, (size_t) offset, (size_t) count); -} - extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_RenderableManager_nSetBlendOrderAt(JNIEnv*, jclass, jlong nativeRenderableManager, jint i, jint primitiveIndex, jint blendOrder) { @@ -439,6 +438,14 @@ Java_com_google_android_filament_RenderableManager_nSetBlendOrderAt(JNIEnv*, jcl (uint16_t) blendOrder); } +extern "C" JNIEXPORT void JNICALL +Java_com_google_android_filament_RenderableManager_nSetGlobalBlendOrderEnabledAt(JNIEnv*, jclass, + jlong nativeRenderableManager, jint i, jint primitiveIndex, jboolean enabled) { + RenderableManager *rm = (RenderableManager *) nativeRenderableManager; + rm->setGlobalBlendOrderEnabledAt((RenderableManager::Instance) i, (size_t) primitiveIndex, + (bool) enabled); +} + extern "C" JNIEXPORT jint JNICALL Java_com_google_android_filament_RenderableManager_nGetEnabledAttributesAt(JNIEnv*, jclass, jlong nativeRenderableManager, jint i, jint primitiveIndex) { diff --git a/android/filament-android/src/main/java/com/google/android/filament/RenderableManager.java b/android/filament-android/src/main/java/com/google/android/filament/RenderableManager.java index 58b479e4cc..ddb2cce5ca 100644 --- a/android/filament-android/src/main/java/com/google/android/filament/RenderableManager.java +++ b/android/filament-android/src/main/java/com/google/android/filament/RenderableManager.java @@ -191,7 +191,9 @@ public class RenderableManager { } /** - * Sets an ordering index for blended primitives that all live at the same Z value. + * Sets the drawing order for blended primitives. The drawing order is either global or + * local (default) to this Renderable. In either case, the Renderable priority takes + * precedence. * * @param index the primitive of interest * @param blendOrder draw order number (0 by default). Only the lowest 15 bits are used. @@ -203,6 +205,18 @@ public class RenderableManager { return this; } + /** + * Sets whether the blend order is global or local to this Renderable (by default). + * + * @param index the primitive of interest + * @param enabled true for global, false for local blend ordering. + */ + @NonNull + public Builder globalBlendOrderEnabled(@IntRange(from = 0) int index, boolean enabled) { + nBuilderGlobalBlendOrderEnabled(mNativeBuilder, index, enabled); + return this; + } + /** * The axis-aligned bounding box of the renderable. * @@ -792,18 +806,9 @@ public class RenderableManager { 0, indices.getIndexCount()); } - /** - * Changes the geometry for the given primitive. - * - * @see Builder#geometry Builder.geometry - */ - public void setGeometryAt(@EntityInstance int i, @IntRange(from = 0) int primitiveIndex, - @NonNull PrimitiveType type, @IntRange(from = 0) int offset, @IntRange(from = 0) int count) { - nSetGeometryAt(mNativeObject, i, primitiveIndex, type.getValue(), offset, count); - } - - /** - * Changes the ordering index for blended primitives that all live at the same Z value. + /** + * Changes the drawing order for blended primitives. The drawing order is either global or + * local (default) to this Renderable. In either case, the Renderable priority takes precedence. * * @see Builder#blendOrder * @@ -816,6 +821,20 @@ public class RenderableManager { nSetBlendOrderAt(mNativeObject, instance, primitiveIndex, blendOrder); } + /** + * Changes whether the blend order is global or local to this Renderable (by default). + * + * @see Builder#globalBlendOrderEnabled + * + * @param instance the renderable of interest + * @param primitiveIndex the primitive of interest + * @param enabled true for global, false for local blend ordering. + */ + public void setGlobalBlendOrderEnabledAt(@EntityInstance int instance, @IntRange(from = 0) int primitiveIndex, + boolean enabled) { + nSetGlobalBlendOrderEnabledAt(mNativeObject, instance, primitiveIndex, enabled); + } + /** * Retrieves the set of enabled attribute slots in the given primitive's VertexBuffer. */ @@ -853,6 +872,7 @@ public class RenderableManager { private static native void nBuilderGeometry(long nativeBuilder, int index, int value, long nativeVertexBuffer, long nativeIndexBuffer, int offset, int minIndex, int maxIndex, int count); private static native void nBuilderMaterial(long nativeBuilder, int index, long nativeMaterialInstance); private static native void nBuilderBlendOrder(long nativeBuilder, int index, int blendOrder); + private static native void nBuilderGlobalBlendOrderEnabled(long nativeBuilder, int index, boolean enabled); private static native void nBuilderBoundingBox(long nativeBuilder, float cx, float cy, float cz, float ex, float ey, float ez); private static native void nBuilderLayerMask(long nativeBuilder, int select, int value); private static native void nBuilderPriority(long nativeBuilder, int priority); @@ -891,7 +911,7 @@ public class RenderableManager { private static native void nSetMaterialInstanceAt(long nativeRenderableManager, int i, int primitiveIndex, long nativeMaterialInstance); private static native long nGetMaterialInstanceAt(long nativeRenderableManager, int i, int primitiveIndex); private static native void nSetGeometryAt(long nativeRenderableManager, int i, int primitiveIndex, int primitiveType, long nativeVertexBuffer, long nativeIndexBuffer, int offset, int count); - private static native void nSetGeometryAt(long nativeRenderableManager, int i, int primitiveIndex, int primitiveType, int offset, int count); private static native void nSetBlendOrderAt(long nativeRenderableManager, int i, int primitiveIndex, int blendOrder); + private static native void nSetGlobalBlendOrderEnabledAt(long nativeRenderableManager, int i, int primitiveIndex, boolean enabled); private static native int nGetEnabledAttributesAt(long nativeRenderableManager, int i, int primitiveIndex); } diff --git a/android/gltfio-android/CMakeLists.txt b/android/gltfio-android/CMakeLists.txt index 765581a25d..5ad0e42b43 100644 --- a/android/gltfio-android/CMakeLists.txt +++ b/android/gltfio-android/CMakeLists.txt @@ -23,6 +23,10 @@ add_library(basis_transcoder STATIC IMPORTED) set_target_properties(basis_transcoder PROPERTIES IMPORTED_LOCATION ${FILAMENT_DIR}/lib/${ANDROID_ABI}/libbasis_transcoder.a) +add_library(zstd STATIC IMPORTED) +set_target_properties(zstd PROPERTIES IMPORTED_LOCATION + ${FILAMENT_DIR}/lib/${ANDROID_ABI}/libzstd.a) + add_library(utils STATIC IMPORTED) set_target_properties(utils PROPERTIES IMPORTED_LOCATION ${FILAMENT_DIR}/lib/${ANDROID_ABI}/libutils.a) @@ -108,9 +112,9 @@ set_target_properties(gltfio-jni PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_ if(GLTFIO_LITE) target_compile_definitions(gltfio-jni PUBLIC GLTFIO_LITE=1) - target_link_libraries(gltfio-jni filament-jni utils log stb ktxreader basis_transcoder gltfio_resources_lite) + target_link_libraries(gltfio-jni filament-jni utils log stb ktxreader basis_transcoder zstd gltfio_resources_lite) else() - target_link_libraries(gltfio-jni filament-jni utils log stb ktxreader basis_transcoder gltfio_resources) + target_link_libraries(gltfio-jni filament-jni utils log stb ktxreader basis_transcoder zstd gltfio_resources) # Enable Draco in the non-lite variant of gltfio. target_link_libraries(gltfio-jni dracodec) diff --git a/android/gltfio-android/src/main/cpp/FilamentAsset.cpp b/android/gltfio-android/src/main/cpp/FilamentAsset.cpp index 37aa3cfa17..2dfbcd0cf3 100644 --- a/android/gltfio-android/src/main/cpp/FilamentAsset.cpp +++ b/android/gltfio-android/src/main/cpp/FilamentAsset.cpp @@ -340,3 +340,19 @@ Java_com_google_android_filament_gltfio_FilamentAsset_nReleaseSourceData(JNIEnv* FilamentAsset* asset = (FilamentAsset*) nativeAsset; asset->releaseSourceData(); } + +extern "C" JNIEXPORT void JNICALL +Java_com_google_android_filament_gltfio_FilamentAsset_nAttachSkin(JNIEnv* env, jclass, + jlong nativeAsset, jint skinIndex, jint targetEntity) { + FilamentAsset* asset = (FilamentAsset*) nativeAsset; + Entity target = Entity::import(targetEntity); + asset->attachSkin(skinIndex, target); +} + +extern "C" JNIEXPORT void JNICALL +Java_com_google_android_filament_gltfio_FilamentAsset_nDetachSkin(JNIEnv* env, jclass, + jlong nativeAsset, jint skinIndex, jint targetEntity) { + FilamentAsset* asset = (FilamentAsset*) nativeAsset; + Entity target = Entity::import(targetEntity); + asset->detachSkin(skinIndex, target); +} diff --git a/android/gltfio-android/src/main/java/com/google/android/filament/gltfio/FilamentAsset.java b/android/gltfio-android/src/main/java/com/google/android/filament/gltfio/FilamentAsset.java index ed7af8e0dc..c314b500bd 100644 --- a/android/gltfio-android/src/main/java/com/google/android/filament/gltfio/FilamentAsset.java +++ b/android/gltfio-android/src/main/java/com/google/android/filament/gltfio/FilamentAsset.java @@ -241,17 +241,37 @@ public class FilamentAsset { return result; } + /** + * Attaches the given skin to the given node, which must have an associated mesh with + * BONE_INDICES and BONE_WEIGHTS attributes. + * + * This is a no-op if the given skin index or target is invalid. + */ + public void attachSkin(@IntRange(from = 0) int skinIndex, @Entity int target) { + nAttachSkin(getNativeObject(), skinIndex, target); + } + + /** + * Attaches the given skin to the given node, which must have an associated mesh with + * BONE_INDICES and BONE_WEIGHTS attributes. + * + * This is a no-op if the given skin index or target is invalid. + */ + public void detachSkin(@IntRange(from = 0) int skinIndex, @Entity int target) { + nDetachSkin(getNativeObject(), skinIndex, target); + } + /** * Gets the joint count at skin index in this asset. */ - public int getJointCountAt(int skinIndex) { + public int getJointCountAt(@IntRange(from = 0) int skinIndex) { return nGetJointCountAt(getNativeObject(), skinIndex); } /** * Gets joints at skin index in this asset. */ - public @NonNull @Entity int[] getJointsAt(int skinIndex) { + public @NonNull @Entity int[] getJointsAt(@IntRange(from = 0) int skinIndex) { int[] result = new int[getJointCountAt(skinIndex)]; nGetJointsAt(getNativeObject(), skinIndex, result); return result; @@ -345,6 +365,9 @@ public class FilamentAsset { private static native int nGetMorphTargetCount(long nativeAsset, int entity); private static native void nGetMorphTargetNames(long nativeAsset, int entity, String[] result); + private static native void nAttachSkin(long nativeAsset, int skinIndex, int entity); + private static native void nDetachSkin(long nativeAsset, int skinIndex, int entity); + private static native void nGetBoundingBox(long nativeAsset, float[] box); private static native String nGetName(long nativeAsset, int entity); private static native String nGetExtras(long nativeAsset, int entity); diff --git a/android/gradle.properties b/android/gradle.properties index 20b655f436..3cf81f4ca7 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.google.android.filament -VERSION_NAME=1.23.0 +VERSION_NAME=1.23.1 POM_DESCRIPTION=Real-time physically based rendering engine for Android. diff --git a/build/common/requirements.txt b/build/common/requirements.txt index dd91caf230..7685baf197 100644 --- a/build/common/requirements.txt +++ b/build/common/requirements.txt @@ -7,7 +7,7 @@ Deprecated==1.2.13 idna==3.3 pycparser==2.21 PyGithub==1.55 -PyJWT==2.3.0 +PyJWT==2.4.0 PyNaCl==1.5.0 requests==2.27.1 urllib3==1.26.9 diff --git a/filament/CMakeLists.txt b/filament/CMakeLists.txt index 9f80ab13e0..c4cb2a3f84 100644 --- a/filament/CMakeLists.txt +++ b/filament/CMakeLists.txt @@ -131,6 +131,7 @@ set(SRCS set(PRIVATE_HDRS src/Allocators.h + src/BufferPoolAllocator.h src/ColorSpace.h src/Culler.h src/DFG.h diff --git a/filament/README.md b/filament/README.md index 0a1ab374e1..961b7a9e21 100644 --- a/filament/README.md +++ b/filament/README.md @@ -49,6 +49,9 @@ To use the Vulkan backend on macOS you must also make the following libraries av - `libMoltenVK.dylib` - `libvulkan.1.dylib` +The easiest way to install those files is to use the macOS +[LunarG Vulkan SDK](https://www.lunarg.com/vulkan-sdk/) installer. + ## Linking against Filament This walkthrough will get you successfully compiling and linking native code diff --git a/filament/backend/CMakeLists.txt b/filament/backend/CMakeLists.txt index f8c6f76a1c..8aaad4186a 100644 --- a/filament/backend/CMakeLists.txt +++ b/filament/backend/CMakeLists.txt @@ -438,16 +438,3 @@ if (APPLE AND NOT IOS) target_link_libraries(backend_test_mac PRIVATE -force_load backend_test) endif() -if (APPLE AND NOT Vulkan_LIBRARY AND NOT FILAMENT_USE_SWIFTSHADER) - message(STATUS "No Vulkan SDK was found, using prebuilt MoltenVK.") - set(MOLTENVK_DIR "../../third_party/moltenvk") - configure_file( - ${MOLTENVK_DIR}/libvulkan.1.dylib - ${PROJECT_BINARY_DIR}/libvulkan.1.dylib COPYONLY) - configure_file( - ${MOLTENVK_DIR}/MoltenVK_icd.json - ${PROJECT_BINARY_DIR}/MoltenVK_icd.json COPYONLY) - configure_file( - ${MOLTENVK_DIR}/libMoltenVK.dylib - ${PROJECT_BINARY_DIR}/libMoltenVK.dylib COPYONLY) -endif() diff --git a/filament/backend/include/backend/DriverEnums.h b/filament/backend/include/backend/DriverEnums.h index a4236b6851..d659cc9c07 100644 --- a/filament/backend/include/backend/DriverEnums.h +++ b/filament/backend/include/backend/DriverEnums.h @@ -732,7 +732,7 @@ enum class SamplerCompareFunc : uint8_t { N //!< Never. The depth / stencil test always fails. }; -//! Sampler paramters +//! Sampler parameters struct SamplerParams { // NOLINT union { struct { diff --git a/filament/backend/include/private/backend/DriverAPI.inc b/filament/backend/include/private/backend/DriverAPI.inc index 856690b8f7..56128bb8ca 100644 --- a/filament/backend/include/private/backend/DriverAPI.inc +++ b/filament/backend/include/private/backend/DriverAPI.inc @@ -217,7 +217,14 @@ DECL_DRIVER_API_R_N(backend::TextureHandle, importTexture, DECL_DRIVER_API_R_N(backend::SamplerGroupHandle, createSamplerGroup, uint32_t, size) -DECL_DRIVER_API_R_0(backend::RenderPrimitiveHandle, createRenderPrimitive) +DECL_DRIVER_API_R_N(backend::RenderPrimitiveHandle, createRenderPrimitive, + backend::VertexBufferHandle, vbh, + backend::IndexBufferHandle, ibh, + backend::PrimitiveType, pt, + uint32_t, offset, + uint32_t, minIndex, + uint32_t, maxIndex, + uint32_t, count) DECL_DRIVER_API_R_N(backend::ProgramHandle, createProgram, backend::Program&&, program) @@ -377,19 +384,6 @@ DECL_DRIVER_API_0(endRenderPass) DECL_DRIVER_API_0(nextSubpass) -DECL_DRIVER_API_N(setRenderPrimitiveBuffer, - backend::RenderPrimitiveHandle, rph, - backend::VertexBufferHandle, vbh, - backend::IndexBufferHandle, ibh) - -DECL_DRIVER_API_N(setRenderPrimitiveRange, - backend::RenderPrimitiveHandle, rph, - backend::PrimitiveType, pt, - uint32_t, offset, - uint32_t, minIndex, - uint32_t, maxIndex, - uint32_t, count) - DECL_DRIVER_API_N(beginTimerQuery, backend::TimerQueryHandle, query) diff --git a/filament/backend/src/metal/MetalDriver.h b/filament/backend/src/metal/MetalDriver.h index ee16a86277..82738bf919 100644 --- a/filament/backend/src/metal/MetalDriver.h +++ b/filament/backend/src/metal/MetalDriver.h @@ -118,6 +118,12 @@ private: mHandleAllocator.deallocate(handle, p); } + inline void setRenderPrimitiveBuffer(Handle rph, + Handle vbh, Handle ibh); + + inline void setRenderPrimitiveRange(Handle rph, PrimitiveType pt, + uint32_t offset, uint32_t minIndex, uint32_t maxIndex, uint32_t count); + void enumerateSamplerGroups(const MetalProgram* program, ShaderType shaderType, const std::function& f); void enumerateBoundUniformBuffers(const std::function sbh, uint32_t size) mContext->samplerGroups.insert(construct_handle(sbh, size)); } -void MetalDriver::createRenderPrimitiveR(Handle rph, int dummy) { +void MetalDriver::createRenderPrimitiveR(Handle rph, + Handle vbh, Handle ibh, + PrimitiveType pt, uint32_t offset, + uint32_t minIndex, uint32_t maxIndex, uint32_t count) { construct_handle(rph); + MetalDriver::setRenderPrimitiveBuffer(rph, vbh, ibh); + MetalDriver::setRenderPrimitiveRange(rph, pt, offset, minIndex, maxIndex, count); } void MetalDriver::createProgramR(Handle rph, Program&& program) { @@ -1068,33 +1073,13 @@ void MetalDriver::blit(TargetBufferFlags buffers, dstRect.left >= 0 && dstRect.bottom >= 0, "Source and destination rects must be positive."); - // Metal's texture coordinates have (0, 0) at the top-left of the texture, but Filament's - // coordinates have (0, 0) at bottom-left. - const NSInteger srcHeight = - srcTarget->isDefaultRenderTarget() ? - mContext->currentReadSwapChain->getSurfaceHeight() : srcTarget->height; - MTLRegion srcRegion = MTLRegionMake2D( - (NSUInteger) srcRect.left, - srcHeight - (NSUInteger) srcRect.bottom - srcRect.height, - srcRect.width, srcRect.height); - - const NSInteger dstHeight = - dstTarget->isDefaultRenderTarget() ? - mContext->currentDrawSwapChain->getSurfaceHeight() : dstTarget->height; - MTLRegion dstRegion = MTLRegionMake2D( - (NSUInteger) dstRect.left, - dstHeight - (NSUInteger) dstRect.bottom - dstRect.height, - dstRect.width, dstRect.height); - auto isBlitableTextureType = [](MTLTextureType t) { return t == MTLTextureType2D || t == MTLTextureType2DMultisample || t == MTLTextureType2DArray; }; - MetalBlitter::BlitArgs args; - args.filter = filter; - args.source.region = srcRegion; - args.destination.region = dstRegion; + // MetalBlitter supports blitting color and depth simultaneously, but for simplicitly we'll blit + // them separately. In practice, Filament only ever blits a single buffer at a time anyway. if (any(buffers & TargetBufferFlags::COLOR_ALL)) { // We always blit from/to the COLOR0 attachment. @@ -1106,12 +1091,17 @@ void MetalDriver::blit(TargetBufferFlags buffers, isBlitableTextureType(dstColorAttachment.getTexture().textureType), "Metal does not support blitting to/from non-2D textures."); + MetalBlitter::BlitArgs args; + args.filter = filter; + args.source.region = srcColorAttachment.getRegionFromClientRect(srcRect); + args.destination.region = dstColorAttachment.getRegionFromClientRect(dstRect); args.source.color = srcColorAttachment.getTexture(); args.destination.color = dstColorAttachment.getTexture(); args.source.level = srcColorAttachment.level; args.destination.level = dstColorAttachment.level; args.source.slice = srcColorAttachment.layer; args.destination.slice = dstColorAttachment.layer; + mContext->blitter->blit(getPendingCommandBuffer(mContext), args); } } @@ -1124,34 +1114,19 @@ void MetalDriver::blit(TargetBufferFlags buffers, isBlitableTextureType(dstDepthAttachment.getTexture().textureType), "Metal does not support blitting to/from non-2D textures."); + MetalBlitter::BlitArgs args; + args.filter = filter; + args.source.region = srcDepthAttachment.getRegionFromClientRect(srcRect); + args.destination.region = dstDepthAttachment.getRegionFromClientRect(dstRect); args.source.depth = srcDepthAttachment.getTexture(); args.destination.depth = dstDepthAttachment.getTexture(); - - if (args.blitColor()) { - // If blitting color, we've already set the source and destination levels and slices. - // Check that they match the requested depth levels/slices. - ASSERT_PRECONDITION(args.source.level == srcDepthAttachment.level, - "Color and depth source LOD must match. (%d != %d)", - args.source.level, srcDepthAttachment.level); - ASSERT_PRECONDITION(args.destination.level == dstDepthAttachment.level, - "Color and depth destination LOD must match. (%d != %d)", - args.destination.level, dstDepthAttachment.level); - ASSERT_PRECONDITION(args.source.slice == srcDepthAttachment.layer, - "Color and depth source layer must match. (%d != %d)", - args.source.slice, srcDepthAttachment.layer); - ASSERT_PRECONDITION(args.destination.slice == dstDepthAttachment.layer, - "Color and depth destination layer must match. (%d != %d)", - args.destination.slice, dstDepthAttachment.layer); - } - args.source.level = srcDepthAttachment.level; args.destination.level = dstDepthAttachment.level; args.source.slice = srcDepthAttachment.layer; args.destination.slice = dstDepthAttachment.layer; + mContext->blitter->blit(getPendingCommandBuffer(mContext), args); } } - - mContext->blitter->blit(getPendingCommandBuffer(mContext), args); } void MetalDriver::draw(PipelineState ps, Handle rph, uint32_t instanceCount) { diff --git a/filament/backend/src/metal/MetalHandles.h b/filament/backend/src/metal/MetalHandles.h index f26a683e1a..52f04266f4 100644 --- a/filament/backend/src/metal/MetalHandles.h +++ b/filament/backend/src/metal/MetalHandles.h @@ -257,6 +257,16 @@ public: return texture ? texture.pixelFormat : MTLPixelFormatInvalid; } + MTLRegion getRegionFromClientRect(Viewport rect) { + // Convert the Filament rect into Metal texture coordinates, taking into account Metal's + // inverted texture space and the mip level. Note that the underlying Texture could be + // larger than the RenderTarget. Metal's texture coordinates have (0, 0) at the top-left + // of the texture, but Filament's coordinates have (0, 0) at bottom-left. + const auto mipheight = texture.height >> level; + return MTLRegionMake2D((NSUInteger)rect.left, + mipheight - (NSUInteger)rect.bottom - rect.height, rect.width, rect.height); + } + explicit operator bool() const { return texture != nil; } diff --git a/filament/backend/src/noop/NoopDriver.cpp b/filament/backend/src/noop/NoopDriver.cpp index b3f95099d9..17a5d689b4 100644 --- a/filament/backend/src/noop/NoopDriver.cpp +++ b/filament/backend/src/noop/NoopDriver.cpp @@ -262,15 +262,6 @@ void NoopDriver::endRenderPass(int) { void NoopDriver::nextSubpass(int) { } -void NoopDriver::setRenderPrimitiveBuffer(Handle rph, - Handle vbh, Handle ibh) { -} - -void NoopDriver::setRenderPrimitiveRange(Handle rph, - PrimitiveType pt, uint32_t offset, - uint32_t minIndex, uint32_t maxIndex, uint32_t count) { -} - void NoopDriver::makeCurrent(Handle drawSch, Handle readSch) { } diff --git a/filament/backend/src/opengl/OpenGLDriver.cpp b/filament/backend/src/opengl/OpenGLDriver.cpp index 53ac7ab59e..19709fc9f2 100644 --- a/filament/backend/src/opengl/OpenGLDriver.cpp +++ b/filament/backend/src/opengl/OpenGLDriver.cpp @@ -431,11 +431,37 @@ void OpenGLDriver::createBufferObjectR(Handle boh, CHECK_GL_ERROR(utils::slog.e) } -void OpenGLDriver::createRenderPrimitiveR(Handle rph, int) { +void OpenGLDriver::createRenderPrimitiveR(Handle rph, + Handle vbh, Handle ibh, + PrimitiveType pt, uint32_t offset, + uint32_t minIndex, uint32_t maxIndex, uint32_t count) { DEBUG_MARKER() + auto& gl = mContext; + + GLVertexBuffer const* const eb = handle_cast(vbh); + GLIndexBuffer const* const ib = handle_cast(ibh); + assert_invariant(ib->elementSize == 2 || ib->elementSize == 4); + GLRenderPrimitive* rp = handle_cast(rph); + rp->gl.indicesSize = (ib->elementSize == 4u) ? 4u : 2u; + rp->gl.vertexBufferWithObjects = vbh; + rp->type = pt; + rp->offset = offset * rp->gl.indicesSize; + rp->count = count; + rp->minIndex = minIndex; + rp->maxIndex = maxIndex > minIndex ? maxIndex : rp->maxVertexCount - 1; // sanitize max index + glGenVertexArrays(1, &rp->gl.vao); + + gl.bindVertexArray(&rp->gl); + + // update the VBO bindings in the VAO + updateVertexArrayObject(rp, eb); + + // this records the index buffer into the currently bound VAO + gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, ib->gl.buffer); + CHECK_GL_ERROR(utils::slog.e) } @@ -2371,47 +2397,6 @@ GLsizei OpenGLDriver::getAttachments(AttachmentArray& attachments, return attachmentCount; } -void OpenGLDriver::setRenderPrimitiveBuffer(Handle rph, - Handle vbh, Handle ibh) { - DEBUG_MARKER() - auto& gl = mContext; - - if (rph) { - GLRenderPrimitive* const rp = handle_cast(rph); - GLVertexBuffer const* const eb = handle_cast(vbh); - GLIndexBuffer const* const ib = handle_cast(ibh); - - assert_invariant(ib->elementSize == 2 || ib->elementSize == 4); - - gl.bindVertexArray(&rp->gl); - CHECK_GL_ERROR(utils::slog.e) - - rp->gl.indicesSize = (ib->elementSize == 4u) ? 4u : 2u; - rp->gl.vertexBufferWithObjects = vbh; - - // update the VBO bindings in the VAO - updateVertexArrayObject(rp, eb); - - // this records the index buffer into the currently bound VAO - gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, ib->gl.buffer); - - CHECK_GL_ERROR(utils::slog.e) - } -} - -void OpenGLDriver::setRenderPrimitiveRange(Handle rph, - PrimitiveType pt, uint32_t offset, - uint32_t minIndex, uint32_t maxIndex, uint32_t count) { - DEBUG_MARKER() - - GLRenderPrimitive* const rp = handle_cast(rph); - rp->type = pt; - rp->offset = offset * rp->gl.indicesSize; - rp->count = count; - rp->minIndex = minIndex; - rp->maxIndex = maxIndex > minIndex ? maxIndex : rp->maxVertexCount - 1; // sanitize max index -} - // Sets up a scissor rectangle that automatically gets clipped against the viewport. void OpenGLDriver::setViewportScissor(Viewport const& viewportScissor) noexcept { auto& gl = mContext; diff --git a/filament/backend/src/vulkan/VulkanDriver.cpp b/filament/backend/src/vulkan/VulkanDriver.cpp index 5f01ff3c61..43bb196113 100644 --- a/filament/backend/src/vulkan/VulkanDriver.cpp +++ b/filament/backend/src/vulkan/VulkanDriver.cpp @@ -405,8 +405,13 @@ void VulkanDriver::createSamplerGroupR(Handle sbh, uint32_t coun construct(sbh, count); } -void VulkanDriver::createRenderPrimitiveR(Handle rph, int) { +void VulkanDriver::createRenderPrimitiveR(Handle rph, + Handle vbh, Handle ibh, + PrimitiveType pt, uint32_t offset, + uint32_t minIndex, uint32_t maxIndex, uint32_t count) { construct(rph); + VulkanDriver::setRenderPrimitiveBuffer(rph, vbh, ibh); + VulkanDriver::setRenderPrimitiveRange(rph, pt, offset, minIndex, maxIndex, count); } void VulkanDriver::destroyRenderPrimitive(Handle rph) { diff --git a/filament/backend/src/vulkan/VulkanDriver.h b/filament/backend/src/vulkan/VulkanDriver.h index 6be6a4033b..d69db710a9 100644 --- a/filament/backend/src/vulkan/VulkanDriver.h +++ b/filament/backend/src/vulkan/VulkanDriver.h @@ -133,6 +133,12 @@ private: mHandleAllocator.deallocate(handle, ptr); } + inline void setRenderPrimitiveBuffer(Handle rph, + Handle vbh, Handle ibh); + + inline void setRenderPrimitiveRange(Handle rph, PrimitiveType pt, + uint32_t offset, uint32_t minIndex, uint32_t maxIndex, uint32_t count); + void refreshSwapChain(); void collectGarbage(); diff --git a/filament/backend/test/TrianglePrimitive.cpp b/filament/backend/test/TrianglePrimitive.cpp index a86f9a2c1f..4f0af416c0 100644 --- a/filament/backend/test/TrianglePrimitive.cpp +++ b/filament/backend/test/TrianglePrimitive.cpp @@ -58,10 +58,8 @@ TrianglePrimitive::TrianglePrimitive(filament::backend::DriverApi& driverApi, BufferDescriptor indexBufferDesc(gIndices, sizeof(short) * 3); mDriverApi.updateIndexBuffer(mIndexBuffer, std::move(indexBufferDesc), 0); - mRenderPrimitive = mDriverApi.createRenderPrimitive(0); - - mDriverApi.setRenderPrimitiveBuffer(mRenderPrimitive, mVertexBuffer, mIndexBuffer); - mDriverApi.setRenderPrimitiveRange(mRenderPrimitive, PrimitiveType::TRIANGLES, 0, 0, 2, 3); + mRenderPrimitive = mDriverApi.createRenderPrimitive( + mVertexBuffer, mIndexBuffer, PrimitiveType::TRIANGLES, 0, 0, 2, 3); } void TrianglePrimitive::updateVertices(const filament::math::float2 vertices[3]) noexcept { diff --git a/filament/backend/test/test_Blit.cpp b/filament/backend/test/test_Blit.cpp index 9671ee06b6..25bad59d48 100644 --- a/filament/backend/test/test_Blit.cpp +++ b/filament/backend/test/test_Blit.cpp @@ -876,6 +876,8 @@ TEST_F(BackendTest, BlitRegion) { constexpr int kDstTexHeight = 384; constexpr auto kDstTexFormat = TextureFormat::RGBA8; constexpr int kNumLevels = 3; + constexpr int kSrcLevel = 1; + constexpr int kDstLevel = 0; // Create a SwapChain and make it current. We don't really use it so the res doesn't matter. auto swapChain = api.createSwapChainHeadless(256, 256, 0); @@ -894,23 +896,12 @@ TEST_F(BackendTest, BlitRegion) { SamplerType::SAMPLER_2D, kNumLevels, kDstTexFormat, 1, kDstTexWidth, kDstTexHeight, 1, TextureUsage::SAMPLEABLE | TextureUsage::COLOR_ATTACHMENT); - // Create a RenderTarget for each texture's miplevel. - Handle srcRenderTargets[kNumLevels]; - Handle dstRenderTargets[kNumLevels]; - for (uint8_t level = 0; level < kNumLevels; level++) { - srcRenderTargets[level] = api.createRenderTarget( TargetBufferFlags::COLOR, - kSrcTexWidth >> level, kSrcTexHeight >> level, 1, { srcTexture, level, 0 }, {}, {}); - dstRenderTargets[level] = api.createRenderTarget( TargetBufferFlags::COLOR, - kDstTexWidth >> level, kDstTexHeight >> level, 1, { dstTexture, level, 0 }, {}, {}); - } - // Blit one-quarter of src level 1 to dst level 0. - const int srcLevel = 1; Viewport srcRect = { - .left = (kSrcTexWidth >> srcLevel) / 2, - .bottom = (kSrcTexHeight >> srcLevel) / 2, - .width = (kSrcTexWidth >> srcLevel) / 2, - .height = (kSrcTexHeight >> srcLevel) / 2, + .left = 0, + .bottom = 0, + .width = (kSrcTexWidth >> kSrcLevel) / 2, + .height = (kSrcTexHeight >> kSrcLevel) / 2, }; Viewport dstRect = { .left = 10, @@ -919,9 +910,18 @@ TEST_F(BackendTest, BlitRegion) { .height = kDstTexHeight - 10, }; - api.blit(TargetBufferFlags::COLOR0, dstRenderTargets[0], - dstRect, srcRenderTargets[srcLevel], - srcRect, SamplerMagFilter::LINEAR); + // Create a RenderTarget for each texture's miplevel. + // We purposely set the render target width and height to smaller than the texture, to check + // that this case is handled correctly. + Handle srcRenderTarget = + api.createRenderTarget(TargetBufferFlags::COLOR, srcRect.width, + srcRect.height, 1, {srcTexture, kSrcLevel, 0}, {}, {}); + Handle dstRenderTarget = + api.createRenderTarget(TargetBufferFlags::COLOR, kDstTexWidth >> kDstLevel, + kDstTexHeight >> kDstLevel, 1, {dstTexture, kDstLevel, 0}, {}, {}); + + api.blit(TargetBufferFlags::COLOR0, dstRenderTarget, dstRect, srcRenderTarget, srcRect, + SamplerMagFilter::LINEAR); // Push through an empty frame to allow the texture to upload and the blit to execute. api.beginFrame(0, 0); @@ -931,7 +931,7 @@ TEST_F(BackendTest, BlitRegion) { // Grab a screenshot. ScreenshotParams params { kDstTexWidth, kDstTexHeight, "BlitRegion.png" }; api.beginFrame(0, 0); - dumpScreenshot(api, dstRenderTargets[0], ¶ms); + dumpScreenshot(api, dstRenderTarget, ¶ms); api.commit(swapChain); api.endFrame(0); @@ -940,12 +940,23 @@ TEST_F(BackendTest, BlitRegion) { executeCommands(); getDriver().purge(); + // Check if the image matches perfectly to our golden run. + // + // TODO: for some reason, this test has very, very slight (as in one pixel) differences between + // OpenGL and Metal. So disable golden checking for now. + // Use the compare tool from ImageMagick to see visual differences: + // compare -verbose -metric mae BlitRegion_Metal.png BlitRegion_OpenGL.png difference.png + // + // const uint32_t expected = 0x74fa34ed; + // printf("Computed hash is 0x%8.8x, Expected 0x%8.8x\n", params.pixelHashResult, expected); + // EXPECT_TRUE(params.pixelHashResult == expected); + // Cleanup. api.destroyTexture(srcTexture); api.destroyTexture(dstTexture); api.destroySwapChain(swapChain); - for (auto rt : srcRenderTargets) api.destroyRenderTarget(rt); - for (auto rt : dstRenderTargets) api.destroyRenderTarget(rt); + api.destroyRenderTarget(srcRenderTarget); + api.destroyRenderTarget(dstRenderTarget); executeCommands(); } diff --git a/filament/include/filament/RenderableManager.h b/filament/include/filament/RenderableManager.h index 51b30e87f6..6e24a28376 100644 --- a/filament/include/filament/RenderableManager.h +++ b/filament/include/filament/RenderableManager.h @@ -205,10 +205,12 @@ public: * avoid using a separate View for the HUD. Note that priority is completely orthogonal to * Builder::layerMask, which merely controls visibility. * - * \see Builder::blendOrder() + * @param priority clamped to the range [0..7], defaults to 4; 7 is lowest priority + * (rendered last). * - * The priority is clamped to the range [0..7], defaults to 4; 7 is lowest priority - * (rendered last). + * @return Builder reference for chaining calls. + * + * @see Builder::blendOrder(), RenderableManager::setBlendOrderAt() */ Builder& priority(uint8_t priority) noexcept; @@ -337,17 +339,37 @@ public: */ Builder& morphing(uint8_t level, size_t primitiveIndex, MorphTargetBuffer* morphTargetBuffer, size_t offset, size_t count) noexcept; + inline Builder& morphing(uint8_t level, size_t primitiveIndex, MorphTargetBuffer* morphTargetBuffer) noexcept; /** - * Sets an ordering index for blended primitives that all live at the same Z value. + * Sets the drawing order for blended primitives. The drawing order is either global or + * local (default) to this Renderable. In either case, the Renderable priority takes + * precedence. * * @param primitiveIndex the primitive of interest * @param order draw order number (0 by default). Only the lowest 15 bits are used. + * + * @return Builder reference for chaining calls. + * + * @see globalBlendOrderEnabled */ Builder& blendOrder(size_t primitiveIndex, uint16_t order) noexcept; + /** + * Sets whether the blend order is global or local to this Renderable (by default). + * + * @param primitiveIndex the primitive of interest + * @param enabled true for global, false for local blend ordering. + * + * @return Builder reference for chaining calls. + * + * @see blendOrder + */ + Builder& globalBlendOrderEnabled(size_t primitiveIndex, bool enabled) noexcept; + + /** * Specifies the number of draw instance of this renderable. The default is 1 instance and * the maximum number of instances allowed is 65535. 0 is invalid. @@ -394,6 +416,7 @@ public: MaterialInstance const* materialInstance = nullptr; PrimitiveType type = PrimitiveType::TRIANGLES; uint16_t blendOrder = 0; + bool globalBlendOrderEnabled = false; struct { MorphTargetBuffer* buffer = nullptr; size_t offset = 0; @@ -578,24 +601,28 @@ public: size_t offset, size_t count) noexcept; /** - * Changes the active range of indices or topology for the given primitive. - * - * \see Builder::geometry() - */ - void setGeometryAt(Instance instance, size_t primitiveIndex, - PrimitiveType type, size_t offset, size_t count) noexcept; - - /** - * Changes the ordering index for blended primitives that all live at the same Z value. - * - * \see Builder::blendOrder() + * Changes the drawing order for blended primitives. The drawing order is either global or + * local (default) to this Renderable. In either case, the Renderable priority takes precedence. * * @param instance the renderable of interest * @param primitiveIndex the primitive of interest * @param order draw order number (0 by default). Only the lowest 15 bits are used. + * + * @see Builder::blendOrder(), setGlobalBlendOrderEnabledAt() */ void setBlendOrderAt(Instance instance, size_t primitiveIndex, uint16_t order) noexcept; + /** + * Changes whether the blend order is global or local to this Renderable (by default). + * + * @param instance the renderable of interest + * @param primitiveIndex the primitive of interest + * @param enabled true for global, false for local blend ordering. + * + * @see Builder::globalBlendOrderEnabled(), setBlendOrderAt() + */ + void setGlobalBlendOrderEnabledAt(Instance instance, size_t primitiveIndex, bool enabled) noexcept; + /** * Retrieves the set of enabled attribute slots in the given primitive's VertexBuffer. */ diff --git a/filament/src/BufferPoolAllocator.h b/filament/src/BufferPoolAllocator.h new file mode 100644 index 0000000000..fd1fe7ed00 --- /dev/null +++ b/filament/src/BufferPoolAllocator.h @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TNT_FILAMENT_BUFFERPOOLALLOCATOR_H +#define TNT_FILAMENT_BUFFERPOOLALLOCATOR_H + +#include +#include + +#include + +#include +#include + +namespace filament { + +/* + * A simple buffer pool-allocator. The pool has a fixed size and buffers held by the pool all have + * the same size which is defined by the most recent largest allocation request -- so buffers in the + * pool can only grow, unless the pool is reset. All buffers in the pool know their own size. + */ +template +class BufferPoolAllocator { +public: + using size_type = uint32_t; + + BufferPoolAllocator() = default; + + // pool is not copyable + BufferPoolAllocator(BufferPoolAllocator const& rhs) = delete; + BufferPoolAllocator& operator=(BufferPoolAllocator const& rhs) = delete; + + // pool is movable + BufferPoolAllocator(BufferPoolAllocator&& rhs) noexcept = default; + BufferPoolAllocator& operator=(BufferPoolAllocator&& rhs) noexcept = default; + + // free all buffers in the pool + ~BufferPoolAllocator() noexcept; + + // return a buffer of at least size bytes + void* get(size_type size) noexcept; + + // return a buffer to the pool + void put(void* buffer) noexcept; + + // empty the pool and reset the size to 0 + void reset() noexcept; + +private: + struct alignas(ALIGNMENT) Header { + size_type size; + }; + + static constexpr size_t ALLOCATION_ROUNDING = 4096; + + void deallocate(Header const* p) noexcept { + --mOutstandingBuffers; + mAllocator.free((void*)p, p->size + sizeof(Header)); + } + + void clearInternal() noexcept { + for (auto p: mEntries) { + assert_invariant(p->size == mSize); + deallocate(p); + } + mEntries.clear(); + } + + using Container = utils::FixedCapacityVector, false>; + size_type mSize = 0; // size of our buffers in the pool + size_type mOutstandingBuffers = 0; + Container mEntries = Container::with_capacity(POOL_SIZE); + AllocatorPolicy mAllocator; + LockingPolicy mLock; +}; + +template +BufferPoolAllocator::~BufferPoolAllocator() noexcept { + assert_invariant(mOutstandingBuffers == mEntries.size()); + clearInternal(); +} + +template +void BufferPoolAllocator::reset() noexcept { + std::lock_guard guard(mLock); + clearInternal(); + mSize = 0; +} + +template +void* BufferPoolAllocator::get(size_type size) noexcept { + std::lock_guard guard(mLock); + + // if the requested size is larger that our buffers in the pool, we just empty the pool + if (UTILS_UNLIKELY(size > mSize)) { + clearInternal(); // free all buffers + // round to 4K allocations to help cutting down on calling malloc. + size_t roundedSize = ((size + sizeof(Header)) + (ALLOCATION_ROUNDING - 1)) & ~(ALLOCATION_ROUNDING - 1); + mSize = roundedSize - sizeof(Header); // record the new buffer size + assert_invariant(mSize >= size); + } + + // if the pool is empty, allocate a new buffer of the pool buffer size (which may be + // larger than the requested size). + if (UTILS_UNLIKELY(mEntries.empty())) { + ++mOutstandingBuffers; + Header* p = (Header*)mAllocator.alloc(mSize + sizeof(Header), ALIGNMENT); + p->size = mSize; + return p + 1; + } + + // if we have an entry in the pool we know it's at least of the requested size + assert_invariant(mSize >= size); + // return the last entry + Header* p = mEntries.back(); + mEntries.pop_back(); + return p + 1; +} + +template +void BufferPoolAllocator::put(void* buffer) noexcept { + std::lock_guard guard(mLock); + + // retrieve this buffer's header + Header const* const p = static_cast
(buffer) - 1; + + // if the returned buffer is smaller than the current pool buffer size, or, the pool + // is full, just free that buffer. + if (UTILS_UNLIKELY(mEntries.size() == mEntries.capacity() || p->size < mSize)) { + deallocate(p); + return; + } + + // add this buffer to the pool + assert_invariant(p->size == mSize); + mEntries.push_back(const_cast
(p)); +} + +} // namespace filament + +#endif // TNT_FILAMENT_BUFFERPOOLALLOCATOR_H diff --git a/filament/src/PostProcessManager.cpp b/filament/src/PostProcessManager.cpp index f773768286..48722a087b 100644 --- a/filament/src/PostProcessManager.cpp +++ b/filament/src/PostProcessManager.cpp @@ -1118,8 +1118,8 @@ FrameGraphId PostProcessManager::gaussianBlurPass(FrameGraph& commitAndRender(hwTempRT, separableGaussianBlur, driver); // vertical pass - auto width = outDesc.width; - auto height = outDesc.height; + UTILS_UNUSED_IN_RELEASE auto width = outDesc.width; + UTILS_UNUSED_IN_RELEASE auto height = outDesc.height; assert_invariant(width == hwOutRT.params.viewport.width); assert_invariant(height == hwOutRT.params.viewport.height); diff --git a/filament/src/RenderPass.cpp b/filament/src/RenderPass.cpp index 4ff9cbe22a..91f210684d 100644 --- a/filament/src/RenderPass.cpp +++ b/filament/src/RenderPass.cpp @@ -53,6 +53,7 @@ RenderPass::~RenderPass() noexcept = default; RenderPass::Command* RenderPass::append(size_t count) noexcept { // this is like a "in-place" realloc(). Works only with LinearAllocator. Command* const curr = mCommandArena.alloc(count); + assert_invariant(curr); assert_invariant(mCommandBegin == nullptr || curr == mCommandEnd); if (mCommandBegin == nullptr) { mCommandBegin = mCommandEnd = curr; @@ -423,16 +424,24 @@ void RenderPass::generateCommandsImpl(uint32_t extraFlags, const bool blendPass = Pass(cmdColor.key & PASS_MASK) == Pass::BLENDED; if (blendPass) { // TODO: at least for transparent objects, AABB should be per primitive + // but that would break the "local" blend-order, which relies on + // all primitives having the same Z // blend pass: - // this will sort back-to-front for blended, and honor explicit ordering - // for a given Z value + // This will sort back-to-front for blended, and honor explicit ordering + // for a given Z value, or globally. cmdColor.key &= ~BLEND_ORDER_MASK; cmdColor.key &= ~BLEND_DISTANCE_MASK; + // write the distance cmdColor.key |= makeField(~distanceBits, BLEND_DISTANCE_MASK, BLEND_DISTANCE_SHIFT); + // clear the distance if global ordering is enabled + cmdColor.key &= ~select(primitive.isGlobalBlendOrderEnabled(), + BLEND_DISTANCE_MASK); + // write blend order cmdColor.key |= makeField(primitive.getBlendOrder(), BLEND_ORDER_MASK, BLEND_ORDER_SHIFT); + const TransparencyMode mode = mi->getTransparencyMode(); // handle transparent objects, two techniques: diff --git a/filament/src/RenderPass.h b/filament/src/RenderPass.h index fe46110f29..b8b6801d43 100644 --- a/filament/src/RenderPass.h +++ b/filament/src/RenderPass.h @@ -213,6 +213,11 @@ public: return boolish ? std::numeric_limits::max() : uint64_t(0); } + template + static CommandKey select(T boolish, uint64_t value) noexcept { + return boolish ? value : uint64_t(0); + } + struct PrimitiveInfo { // 48 bytes union { FMaterialInstance const* mi; diff --git a/filament/src/RenderPrimitive.cpp b/filament/src/RenderPrimitive.cpp index a6eae017d2..a46fbc4c21 100644 --- a/filament/src/RenderPrimitive.cpp +++ b/filament/src/RenderPrimitive.cpp @@ -30,7 +30,6 @@ void FRenderPrimitive::init(backend::DriverApi& driver, assert_invariant(entry.materialInstance); - mHandle = driver.createRenderPrimitive(); mMaterialInstance = upcast(entry.materialInstance); mBlendOrder = entry.blendOrder; @@ -43,10 +42,8 @@ void FRenderPrimitive::init(backend::DriverApi& driver, auto const& ebh = vertexBuffer->getHwHandle(); auto const& ibh = indexBuffer->getHwHandle(); - driver.setRenderPrimitiveBuffer(mHandle, ebh, ibh); - driver.setRenderPrimitiveRange(mHandle, entry.type, - (uint32_t)entry.offset, (uint32_t)entry.minIndex, (uint32_t)entry.maxIndex, - (uint32_t)entry.count); + mHandle = driver.createRenderPrimitive(ebh, ibh, entry.type, (uint32_t)entry.offset, + (uint32_t)entry.minIndex, (uint32_t)entry.maxIndex, (uint32_t)entry.count); mPrimitiveType = entry.type; mEnabledAttributes = enabledAttributes; @@ -55,32 +52,31 @@ void FRenderPrimitive::init(backend::DriverApi& driver, void FRenderPrimitive::terminate(FEngine& engine) { FEngine::DriverApi& driver = engine.getDriverApi(); - driver.destroyRenderPrimitive(mHandle); + if (mHandle) { + driver.destroyRenderPrimitive(mHandle); + } } void FRenderPrimitive::set(FEngine& engine, RenderableManager::PrimitiveType type, FVertexBuffer* vertices, FIndexBuffer* indices, size_t offset, size_t minIndex, size_t maxIndex, size_t count) noexcept { + AttributeBitset enabledAttributes = vertices->getDeclaredAttributes(); + auto const& ebh = vertices->getHwHandle(); auto const& ibh = indices->getHwHandle(); FEngine::DriverApi& driver = engine.getDriverApi(); - driver.setRenderPrimitiveBuffer(mHandle, ebh, ibh); - driver.setRenderPrimitiveRange(mHandle, type, + if (mHandle) { + driver.destroyRenderPrimitive(mHandle); + } + + mHandle = driver.createRenderPrimitive(ebh, ibh, type, (uint32_t)offset, (uint32_t)minIndex, (uint32_t)maxIndex, (uint32_t)count); mPrimitiveType = type; mEnabledAttributes = enabledAttributes; } -void FRenderPrimitive::set(FEngine& engine, RenderableManager::PrimitiveType type, size_t offset, - size_t minIndex, size_t maxIndex, size_t count) noexcept { - FEngine::DriverApi& driver = engine.getDriverApi(); - driver.setRenderPrimitiveRange(mHandle, type, - (uint32_t)offset, (uint32_t)minIndex, (uint32_t)maxIndex, (uint32_t)count); - mPrimitiveType = type; -} - } // namespace filament diff --git a/filament/src/RenderPrimitive.h b/filament/src/RenderPrimitive.h index 70188c3238..d8afc78561 100644 --- a/filament/src/RenderPrimitive.h +++ b/filament/src/RenderPrimitive.h @@ -42,9 +42,6 @@ public: FVertexBuffer* vertices, FIndexBuffer* indices, size_t offset, size_t minIndex, size_t maxIndex, size_t count) noexcept; - void set(FEngine& engine, RenderableManager::PrimitiveType type, - size_t offset, size_t minIndex, size_t maxIndex, size_t count) noexcept; - // frees driver resources, object becomes invalid void terminate(FEngine& engine); @@ -53,18 +50,26 @@ public: backend::PrimitiveType getPrimitiveType() const noexcept { return mPrimitiveType; } AttributeBitset getEnabledAttributes() const noexcept { return mEnabledAttributes; } uint16_t getBlendOrder() const noexcept { return mBlendOrder; } + bool isGlobalBlendOrderEnabled() const noexcept { return mGlobalBlendOrderEnabled; } void setMaterialInstance(FMaterialInstance const* mi) noexcept { mMaterialInstance = mi; } + void setBlendOrder(uint16_t order) noexcept { mBlendOrder = static_cast(order & 0x7FFF); } + void setGlobalBlendOrderEnabled(bool enabled) noexcept { + mGlobalBlendOrderEnabled = enabled; + } + private: FMaterialInstance const* mMaterialInstance = nullptr; - backend::Handle mHandle; - backend::PrimitiveType mPrimitiveType = backend::PrimitiveType::NONE; - AttributeBitset mEnabledAttributes; + backend::Handle mHandle = {}; + AttributeBitset mEnabledAttributes = {}; uint16_t mBlendOrder = 0; + bool mGlobalBlendOrderEnabled = false; + backend::PrimitiveType mPrimitiveType = backend::PrimitiveType::NONE; + UTILS_UNUSED uint8_t reserved[4] = {}; }; } // namespace filament diff --git a/filament/src/RenderableManager.cpp b/filament/src/RenderableManager.cpp index 7a85e4fb67..c99eab986a 100644 --- a/filament/src/RenderableManager.cpp +++ b/filament/src/RenderableManager.cpp @@ -102,6 +102,11 @@ void RenderableManager::setBlendOrderAt(Instance instance, size_t primitiveIndex upcast(this)->setBlendOrderAt(instance, 0, primitiveIndex, order); } +void RenderableManager::setGlobalBlendOrderEnabledAt(RenderableManager::Instance instance, + size_t primitiveIndex, bool enabled) noexcept { + upcast(this)->setGlobalBlendOrderEnabledAt(instance, 0, primitiveIndex, enabled); +} + AttributeBitset RenderableManager::getEnabledAttributesAt(Instance instance, size_t primitiveIndex) const noexcept { return upcast(this)->getEnabledAttributesAt(instance, 0, primitiveIndex); } @@ -113,11 +118,6 @@ void RenderableManager::setGeometryAt(Instance instance, size_t primitiveIndex, type, upcast(vertices), upcast(indices), offset, count); } -void RenderableManager::setGeometryAt(RenderableManager::Instance instance, size_t primitiveIndex, - RenderableManager::PrimitiveType type, size_t offset, size_t count) noexcept { - upcast(this)->setGeometryAt(instance, 0, primitiveIndex, type, offset, count); -} - void RenderableManager::setBones(Instance instance, RenderableManager::Bone const* transforms, size_t boneCount, size_t offset) { upcast(this)->setBones(instance, transforms, boneCount, offset); diff --git a/filament/src/UniformBuffer.h b/filament/src/UniformBuffer.h index a8e1abfecb..090ee76eec 100644 --- a/filament/src/UniformBuffer.h +++ b/filament/src/UniformBuffer.h @@ -95,7 +95,7 @@ public: * ----------------------------------------------- */ - // Note: we purposedly not include types that require conversion here + // Note: we purposely not include types that require conversion here // (e.g. bool and bool vectors) template struct is_supported_type { diff --git a/filament/src/components/RenderableManager.cpp b/filament/src/components/RenderableManager.cpp index d06b280970..45373f7159 100644 --- a/filament/src/components/RenderableManager.cpp +++ b/filament/src/components/RenderableManager.cpp @@ -27,6 +27,8 @@ #include "details/Material.h" #include "private/filament/SibGenerator.h" +#include "filament/RenderableManager.h" + #include @@ -210,13 +212,22 @@ RenderableManager::Builder& RenderableManager::Builder::morphing(uint8_t level, return *this; } -RenderableManager::Builder& RenderableManager::Builder::blendOrder(size_t index, uint16_t blendOrder) noexcept { +RenderableManager::Builder& RenderableManager::Builder::blendOrder( + size_t index, uint16_t blendOrder) noexcept { if (index < mImpl->mEntries.size()) { mImpl->mEntries[index].blendOrder = blendOrder; } return *this; } +RenderableManager::Builder& RenderableManager::Builder::globalBlendOrderEnabled( + size_t index, bool enabled) noexcept { + if (index < mImpl->mEntries.size()) { + mImpl->mEntries[index].globalBlendOrderEnabled = enabled; + } + return *this; +} + RenderableManager::Builder::Result RenderableManager::Builder::build(Engine& engine, Entity entity) { bool isEmpty = true; @@ -535,6 +546,16 @@ void FRenderableManager::setBlendOrderAt(Instance instance, uint8_t level, } } +void FRenderableManager::setGlobalBlendOrderEnabledAt(Instance instance, uint8_t level, + size_t primitiveIndex, bool enabled) noexcept { + if (instance) { + Slice& primitives = getRenderPrimitives(instance, level); + if (primitiveIndex < primitives.size()) { + primitives[primitiveIndex].setGlobalBlendOrderEnabled(enabled); + } + } +} + AttributeBitset FRenderableManager::getEnabledAttributesAt( Instance instance, uint8_t level, size_t primitiveIndex) const noexcept { if (instance) { @@ -558,16 +579,6 @@ void FRenderableManager::setGeometryAt(Instance instance, uint8_t level, size_t } } -void FRenderableManager::setGeometryAt(Instance instance, uint8_t level, size_t primitiveIndex, - PrimitiveType type, size_t offset, size_t count) noexcept { - if (instance) { - Slice& primitives = getRenderPrimitives(instance, level); - if (primitiveIndex < primitives.size()) { - primitives[primitiveIndex].set(mEngine, type, offset, 0, 0, count); - } - } -} - void FRenderableManager::setBones(Instance ci, Bone const* UTILS_RESTRICT transforms, size_t boneCount, size_t offset) { if (ci) { diff --git a/filament/src/components/RenderableManager.h b/filament/src/components/RenderableManager.h index ead1f9dc61..326360b67c 100644 --- a/filament/src/components/RenderableManager.h +++ b/filament/src/components/RenderableManager.h @@ -165,9 +165,8 @@ public: void setGeometryAt(Instance instance, uint8_t level, size_t primitiveIndex, PrimitiveType type, FVertexBuffer* vertices, FIndexBuffer* indices, size_t offset, size_t count) noexcept; - void setGeometryAt(Instance instance, uint8_t level, size_t primitiveIndex, - PrimitiveType type, size_t offset, size_t count) noexcept; void setBlendOrderAt(Instance instance, uint8_t level, size_t primitiveIndex, uint16_t blendOrder) noexcept; + void setGlobalBlendOrderEnabledAt(Instance instance, uint8_t level, size_t primitiveIndex, bool enabled) noexcept; AttributeBitset getEnabledAttributesAt(Instance instance, uint8_t level, size_t primitiveIndex) const noexcept; inline utils::Slice const& getRenderPrimitives(Instance instance, uint8_t level) const noexcept; inline utils::Slice& getRenderPrimitives(Instance instance, uint8_t level) noexcept; diff --git a/filament/src/details/Engine.cpp b/filament/src/details/Engine.cpp index a8b5c7cdf9..04eb26ae87 100644 --- a/filament/src/details/Engine.cpp +++ b/filament/src/details/Engine.cpp @@ -233,11 +233,9 @@ void FEngine::init() { mFullScreenTriangleIb->setBuffer(*this, { sFullScreenTriangleIndices, sizeof(sFullScreenTriangleIndices) }); - mFullScreenTriangleRph = driverApi.createRenderPrimitive(); - driverApi.setRenderPrimitiveBuffer(mFullScreenTriangleRph, - mFullScreenTriangleVb->getHwHandle(), mFullScreenTriangleIb->getHwHandle()); - driverApi.setRenderPrimitiveRange(mFullScreenTriangleRph, PrimitiveType::TRIANGLES, - 0, 0, 2, (uint32_t)mFullScreenTriangleIb->getIndexCount()); + mFullScreenTriangleRph = driverApi.createRenderPrimitive( + mFullScreenTriangleVb->getHwHandle(), mFullScreenTriangleIb->getHwHandle(), + PrimitiveType::TRIANGLES, 0, 0, 2, (uint32_t)mFullScreenTriangleIb->getIndexCount()); // Compute a clip-space [-1 to 1] to texture space [0 to 1] matrix, taking into account // backend differences. diff --git a/filament/src/details/Engine.h b/filament/src/details/Engine.h index 370b140de0..27e51a0bfb 100644 --- a/filament/src/details/Engine.h +++ b/filament/src/details/Engine.h @@ -107,8 +107,8 @@ class ResourceAllocator; class FEngine : public Engine { public: - inline void* operator new(std::size_t count) noexcept { - return utils::aligned_alloc(count * sizeof(FEngine), alignof(FEngine)); + inline void* operator new(std::size_t size) noexcept { + return utils::aligned_alloc(size, alignof(FEngine)); } inline void operator delete(void* p) noexcept { diff --git a/filament/src/details/Scene.cpp b/filament/src/details/Scene.cpp index d5eebfdb7c..be9cd947b4 100644 --- a/filament/src/details/Scene.cpp +++ b/filament/src/details/Scene.cpp @@ -25,6 +25,8 @@ #include "details/IndirectLight.h" #include "details/Skybox.h" +#include "BufferPoolAllocator.h" + #include #include #include @@ -147,6 +149,7 @@ void FScene::prepare(const mat4& worldOriginTransform, bool shadowReceiversAreCa worldAABB.halfExtent, // WORLD_AABB_EXTENT {}, // PRIMITIVES 0, // SUMMED_PRIMITIVE_COUNT + {}, // UBO scale // USER_DATA ); } @@ -197,28 +200,17 @@ void FScene::prepare(const mat4& worldOriginTransform, bool shadowReceiversAreCa } } -void FScene::updateUBOs( - Range visibleRenderables, - Handle renderableUbh) noexcept { - FEngine::DriverApi& driver = mEngine.getDriverApi(); +void FScene::prepareVisibleRenderables(Range visibleRenderables) noexcept { + RenderableSoa& sceneData = mRenderableData; FRenderableManager& rcm = mEngine.getRenderableManager(); - const size_t size = visibleRenderables.size() * sizeof(PerRenderableUib); - - // allocate space into the command stream directly - void* const buffer = driver.allocatePod(visibleRenderables.size()); - - bool hasContactShadows = false; - auto& sceneData = mRenderableData; + mHasContactShadows = false; for (uint32_t i : visibleRenderables) { - mat4f const& model = sceneData.elementAt(i); - FRenderableManager::Visibility visibility = sceneData.elementAt(i); - auto ri = sceneData.elementAt(i); + PerRenderableData& uboData = sceneData.elementAt(i); - const size_t offset = i * sizeof(PerRenderableUib); - - UniformBuffer::setUniform(buffer, - offset + offsetof(PerRenderableUib, worldFromModelMatrix), model); + auto const visibility = sceneData.elementAt(i); + auto const& model = sceneData.elementAt(i); + auto const ri = sceneData.elementAt(i); // Using mat3f::getTransformForNormals handles non-uniform scaling, but DOESN'T guarantee that // the transformed normals will have unit-length, therefore they need to be normalized @@ -241,41 +233,66 @@ void FScene::updateUBOs( m = -m; } - UniformBuffer::setUniform(buffer, - offset + offsetof(PerRenderableUib, worldFromModelNormalMatrix), m); + uboData.worldFromModelMatrix = model; - // Note that we cast bool to uint32_t. Booleans are byte-sized in C++, but we need to - // initialize all 32 bits in the UBO field. + uboData.worldFromModelNormalMatrix = m; - hasContactShadows = hasContactShadows || visibility.screenSpaceContactShadows; + uboData.flagsChannels = PerRenderableData::packFlagsChannels( + visibility.skinning, + visibility.morphing, + visibility.screenSpaceContactShadows, + sceneData.elementAt(i)); - UniformBuffer::setUniform(buffer, - offset + offsetof(PerRenderableUib, flagsChannels), - PerRenderableUib::packFlagsChannels( - visibility.skinning, - visibility.morphing, - visibility.screenSpaceContactShadows, - sceneData.elementAt(i))); + uboData.morphTargetCount = sceneData.elementAt(i).count; - UniformBuffer::setUniform(buffer, - offset + offsetof(PerRenderableUib, morphTargetCount), - sceneData.elementAt(i).count); - - UniformBuffer::setUniform(buffer, - offset + offsetof(PerRenderableUib, objectId), - rcm.getEntity(ri).getId()); // we could also store the entity in sceneData + uboData.objectId = rcm.getEntity(ri).getId(); // TODO: We need to find a better way to provide the scale information per object - UniformBuffer::setUniform(buffer, - offset + offsetof(PerRenderableUib, userData), - sceneData.elementAt(i)); + uboData.userData = sceneData.elementAt(i); + + mHasContactShadows = mHasContactShadows || visibility.screenSpaceContactShadows; + } +} + +void FScene::updateUBOs( + Range visibleRenderables, + Handle renderableUbh) noexcept { + FEngine::DriverApi& driver = mEngine.getDriverApi(); + + // store the UBO handle + mRenderableViewUbh = renderableUbh; + + // don't allocate more than 16 KiB directly into the render stream + static constexpr size_t MAX_STREAM_ALLOCATION_COUNT = 64; // 16 KiB + const size_t count = visibleRenderables.size(); + PerRenderableUib* buffer = [&]{ + if (count >= MAX_STREAM_ALLOCATION_COUNT) { + // use the heap allocator + return (PerRenderableUib*)mBufferPoolAllocator.get(count * sizeof(PerRenderableUib)); + } else { + // allocate space into the command stream directly + return driver.allocatePod(count); + } + }(); + + // copy our data into the UBO for each visible renderable + PerRenderableData const* const uboData = mRenderableData.data(); + for (uint32_t i : visibleRenderables) { + buffer[i].data = uboData[i]; } - // TODO: handle static objects separately - mHasContactShadows = hasContactShadows; - mRenderableViewUbh = renderableUbh; - driver.updateBufferObject(renderableUbh, { buffer, size }, 0); + // update the UBO + driver.updateBufferObject(renderableUbh, { + buffer, count * sizeof(PerRenderableUib), + +[](void* p, size_t s, void* user) { + if (s >= MAX_STREAM_ALLOCATION_COUNT * sizeof(PerRenderableUib)) { + FScene* const that = static_cast(user); + that->mBufferPoolAllocator.put(p); + } + }, this + }, 0); + // update skybox if (mSkybox) { mSkybox->commit(driver); } @@ -430,23 +447,27 @@ void FScene::setSkybox(FSkybox* skybox) noexcept { } bool FScene::hasContactShadows() const noexcept { + // at least some renderables in the scene must have contact-shadows enabled + // TODO: we should refine this with only the visible ones + if (!mHasContactShadows) { + return false; + } + // find out if at least one light has contact-shadow enabled - // TODO: cache the the result of this Loop in the LightManager - bool hasContactShadows = false; + // TODO: we could cache the the result of this Loop in the LightManager auto& lcm = mEngine.getLightManager(); const auto *pFirst = mLightData.begin(); const auto *pLast = mLightData.end(); - while (pFirst != pLast && !hasContactShadows) { + while (pFirst != pLast) { if (pFirst->isValid()) { auto const& shadowOptions = lcm.getShadowOptions(*pFirst); - hasContactShadows = shadowOptions.screenSpaceContactShadows; + if (shadowOptions.screenSpaceContactShadows) { + return true; + } } ++pFirst; } - - // at least some renderables in the scene must have contact-shadows enabled - // TODO: we should refine this with only the visible ones - return hasContactShadows && mHasContactShadows; + return false; } UTILS_NOINLINE diff --git a/filament/src/details/Scene.h b/filament/src/details/Scene.h index 3365a3bbb7..bd79755b2a 100644 --- a/filament/src/details/Scene.h +++ b/filament/src/details/Scene.h @@ -26,6 +26,8 @@ #include "components/RenderableManager.h" #include "components/TransformManager.h" +#include "BufferPoolAllocator.h" + #include #include @@ -68,6 +70,9 @@ public: void terminate(FEngine& engine); void prepare(const math::mat4& worldOriginTransform, bool shadowReceiversAreCasters) noexcept; + + void prepareVisibleRenderables(utils::Range visibleRenderables) noexcept; + void prepareDynamicLights(const CameraInfo& camera, ArenaScope& arena, backend::Handle lightUbh) noexcept; @@ -82,26 +87,27 @@ public: using VisibleMaskType = Culler::result_type; enum { - RENDERABLE_INSTANCE, // 4 | instance of the Renderable component - WORLD_TRANSFORM, // 16 | instance of the Transform component - VISIBILITY_STATE, // 2 | visibility data of the component - SKINNING_BUFFER, // 8 | bones uniform buffer handle, offset - MORPHING_BUFFER, // 16 | weights uniform buffer handle, count, morph targets - WORLD_AABB_CENTER, // 12 | world-space bounding box center of the renderable - VISIBLE_MASK, // 2 | each bit represents a visibility in a pass - CHANNELS, // 1 | currently light channels only - INSTANCE_COUNT, // 2 | draw instance count + RENDERABLE_INSTANCE, // 4 | instance of the Renderable component + WORLD_TRANSFORM, // 16 | instance of the Transform component + VISIBILITY_STATE, // 2 | visibility data of the component + SKINNING_BUFFER, // 8 | bones uniform buffer handle, offset + MORPHING_BUFFER, // 16 | weights uniform buffer handle, count, morph targets + WORLD_AABB_CENTER, // 12 | world-space bounding box center of the renderable + VISIBLE_MASK, // 2 | each bit represents a visibility in a pass + CHANNELS, // 1 | currently light channels only + INSTANCE_COUNT, // 2 | draw instance count // These are not needed anymore after culling - LAYERS, // 1 | layers - WORLD_AABB_EXTENT, // 12 | world-space bounding box half-extent of the renderable + LAYERS, // 1 | layers + WORLD_AABB_EXTENT, // 12 | world-space bounding box half-extent of the renderable // These are temporaries and should be stored out of line - PRIMITIVES, // 8 | level-of-detail'ed primitives - SUMMED_PRIMITIVE_COUNT, // 4 | summed visible primitive counts + PRIMITIVES, // 8 | level-of-detail'ed primitives + SUMMED_PRIMITIVE_COUNT, // 4 | summed visible primitive counts + UBO, // 128 | // FIXME: We need a better way to handle this - USER_DATA, // 4 | user data currently used to store the scale + USER_DATA, // 4 | user data currently used to store the scale }; using RenderableSoa = utils::StructureOfArrays< @@ -118,6 +124,7 @@ public: math::float3, // WORLD_AABB_EXTENT utils::Slice, // PRIMITIVES uint32_t, // SUMMED_PRIMITIVE_COUNT + PerRenderableData, // UBO // FIXME: We need a better way to handle this float // USER_DATA >; @@ -214,6 +221,7 @@ private: LightSoa mLightData; backend::Handle mRenderableViewUbh; // This is actually owned by the view. bool mHasContactShadows = false; + BufferPoolAllocator<3> mBufferPoolAllocator; }; FILAMENT_UPCAST(Scene) diff --git a/filament/src/details/View.cpp b/filament/src/details/View.cpp index 01aebcd7f9..f6230ec6f1 100644 --- a/filament/src/details/View.cpp +++ b/filament/src/details/View.cpp @@ -547,6 +547,8 @@ void FView::prepare(FEngine& engine, DriverApi& driver, ArenaScope& arena, mSpotLightShadowCasters = Range{ 0, iSpotLightCastersEnd }; merged = Range{ 0, iSpotLightCastersEnd }; + scene->prepareVisibleRenderables(merged); + // update those UBOs const size_t size = merged.size() * sizeof(PerRenderableUib); if (size) { diff --git a/ios/CocoaPods/Filament.podspec b/ios/CocoaPods/Filament.podspec index 13ab6c610a..6865e27409 100644 --- a/ios/CocoaPods/Filament.podspec +++ b/ios/CocoaPods/Filament.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |spec| spec.name = "Filament" - spec.version = "1.23.0" + spec.version = "1.23.1" spec.license = { :type => "Apache 2.0", :file => "LICENSE" } spec.homepage = "https://google.github.io/filament" spec.authors = "Google LLC." spec.summary = "Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WASM/WebGL." spec.platform = :ios, "11.0" - spec.source = { :http => "https://github.com/google/filament/releases/download/v1.23.0/filament-v1.23.0-ios.tgz" } + spec.source = { :http => "https://github.com/google/filament/releases/download/v1.23.1/filament-v1.23.1-ios.tgz" } # Fix linking error with Xcode 12; we do not yet support the simulator on Apple silicon. spec.pod_target_xcconfig = { diff --git a/ios/samples/gltf-viewer/gltf-viewer.xcodeproj/project.pbxproj b/ios/samples/gltf-viewer/gltf-viewer.xcodeproj/project.pbxproj index 25b36e5f2c..cf241bf27a 100644 --- a/ios/samples/gltf-viewer/gltf-viewer.xcodeproj/project.pbxproj +++ b/ios/samples/gltf-viewer/gltf-viewer.xcodeproj/project.pbxproj @@ -123,7 +123,7 @@ }; }; buildConfigurationList = 90327DE42AE5DF12C4BD2113 /* Build configuration list for PBXProject "gltf-viewer" */; - compatibilityVersion = "Xcode 11.0"; + compatibilityVersion = "Xcode 10.0"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( @@ -426,6 +426,7 @@ "-lgeometry", "-lstb", "-lbasis_transcoder", + "-lzstd", "-lcamutils", "-ldracodec", "-lviewer", @@ -480,6 +481,7 @@ "-lgeometry", "-lstb", "-lbasis_transcoder", + "-lzstd", "-lcamutils", "-ldracodec", "-lviewer", @@ -596,6 +598,7 @@ "-lgeometry", "-lstb", "-lbasis_transcoder", + "-lzstd", "-lcamutils", "-ldracodec", "-lviewer", @@ -650,6 +653,7 @@ "-lgeometry", "-lstb", "-lbasis_transcoder", + "-lzstd", "-lcamutils", "-ldracodec", "-lviewer", diff --git a/ios/samples/gltf-viewer/gltf-viewer.xcodeproj/xcshareddata/xcschemes/gltf-viewer Metal.xcscheme b/ios/samples/gltf-viewer/gltf-viewer.xcodeproj/xcshareddata/xcschemes/gltf-viewer Metal.xcscheme index 64c00f8bf9..14d2e3163e 100644 --- a/ios/samples/gltf-viewer/gltf-viewer.xcodeproj/xcshareddata/xcschemes/gltf-viewer Metal.xcscheme +++ b/ios/samples/gltf-viewer/gltf-viewer.xcodeproj/xcshareddata/xcschemes/gltf-viewer Metal.xcscheme @@ -1,7 +1,7 @@ + version = "1.3"> + version = "1.3"> { }; + struct mat33_std140 : public std::array { + mat33_std140& operator=(math::mat3f const& rhs) noexcept { + for (int i = 0; i < 3; i++) { + (*this)[i][0] = rhs[i][0]; + (*this)[i][1] = rhs[i][1]; + (*this)[i][2] = rhs[i][2]; + } + return *this; + } + }; + math::mat4f worldFromModelMatrix; - math::mat3f worldFromModelNormalMatrix; // this gets expanded to 48 bytes during the copy to the UBO - alignas(16) uint32_t morphTargetCount; + mat33_std140 worldFromModelNormalMatrix; + uint32_t morphTargetCount; uint32_t flagsChannels; // see packFlags() below (0x00000fll) uint32_t objectId; // used for picking // TODO: We need a better solution, this currently holds the average local scale for the renderable float userData; - math::float4 reserved[8]; static uint32_t packFlagsChannels( bool skinning, bool morphing, bool contactShadows, uint8_t channels) noexcept { @@ -191,8 +204,20 @@ struct alignas(256) PerRenderableUib { // NOLINT(cppcoreguidelines-pro-type-memb channels; } }; +static_assert(sizeof(PerRenderableData) == 128, + "sizeof(PerRenderableData) must be 128 bytes"); -static_assert(sizeof(PerRenderableUib) == 256, "sizeof(PerRenderableUib) must be 256 bytes"); +struct alignas(256) PerRenderableUib { // NOLINT(cppcoreguidelines-pro-type-member-init) + static constexpr utils::StaticString _name{ "ObjectUniforms" }; + PerRenderableData data; + math::float4 reserved[8]; +}; +// PerRenderableUib must have an alignment of 256 to be compatible with all versions of GLES. +static_assert(sizeof(PerRenderableUib) == 256, + "sizeof(PerRenderableUib) must be 256 bytes"); + +// ------------------------------------------------------------------------------------------------ +// MARK: - struct LightsUib { // NOLINT(cppcoreguidelines-pro-type-member-init) static constexpr utils::StaticString _name{ "LightsUniforms" }; @@ -213,7 +238,11 @@ struct LightsUib { // NOLINT(cppcoreguidelines-pro-type-member-init) return lightChannels | (castShadows ? 0x10000 : 0); } }; -static_assert(sizeof(LightsUib) == 64, "the actual UBO is an array of 256 mat4"); +static_assert(sizeof(LightsUib) == 64, + "the actual UBO is an array of 256 mat4"); + +// ------------------------------------------------------------------------------------------------ +// MARK: - // UBO for punctual (spot light) shadows. struct ShadowUib { // NOLINT(cppcoreguidelines-pro-type-member-init) @@ -230,14 +259,22 @@ struct ShadowUib { // NOLINT(cppcoreguidelines-pro-type-member-init) }; ShadowData shadows[CONFIG_MAX_SHADOW_CASTING_SPOTS]; }; -static_assert(sizeof(ShadowUib) <= 16384, "ShadowUib exceed max UBO size"); +static_assert(sizeof(ShadowUib) <= 16384, + "ShadowUib exceed max UBO size"); + +// ------------------------------------------------------------------------------------------------ +// MARK: - // UBO froxel record buffer. struct FroxelRecordUib { // NOLINT(cppcoreguidelines-pro-type-member-init) static constexpr utils::StaticString _name{ "FroxelRecordUniforms" }; math::uint4 records[1024]; }; -static_assert(sizeof(FroxelRecordUib) == 16384, "FroxelRecordUib should be exactly 16KiB"); +static_assert(sizeof(FroxelRecordUib) == 16384, + "FroxelRecordUib should be exactly 16KiB"); + +// ------------------------------------------------------------------------------------------------ +// MARK: - // This is not the UBO proper, but just an element of a bone array. struct PerRenderableUibBone { // NOLINT(cppcoreguidelines-pro-type-member-init) @@ -253,6 +290,9 @@ struct PerRenderableUibBone { // NOLINT(cppcoreguidelines-pro-type-member-init) static_assert(CONFIG_MAX_BONE_COUNT * sizeof(PerRenderableUibBone) <= 16384, "PerRenderableUibBone exceed max UBO size"); +// ------------------------------------------------------------------------------------------------ +// MARK: - + struct alignas(16) PerRenderableMorphingUib { static constexpr utils::StaticString _name{ "MorphingUniforms" }; // The array stride(the bytes between array elements) is always rounded up to the size of a vec4 in std140. diff --git a/libs/gltfio/include/gltfio/FilamentAsset.h b/libs/gltfio/include/gltfio/FilamentAsset.h index 505b047db4..45013768cb 100644 --- a/libs/gltfio/include/gltfio/FilamentAsset.h +++ b/libs/gltfio/include/gltfio/FilamentAsset.h @@ -238,6 +238,21 @@ public: */ const Entity* getJointsAt(size_t skinIndex) const noexcept; + /** + * Attaches the given skin to the given node, which must have an associated mesh with + * BONE_INDICES and BONE_WEIGHTS attributes. + * + * This is a no-op if the given skin index or target is invalid. + */ + void attachSkin(size_t skinIndex, Entity target) noexcept; + + /** + * Detaches the given skin from the given node. + * + * This is a no-op if the given skin index or target is invalid. + */ + void detachSkin(size_t skinIndex, Entity target) noexcept; + /** * Gets the morph target name at the given index in the given entity. */ diff --git a/libs/gltfio/include/gltfio/ResourceLoader.h b/libs/gltfio/include/gltfio/ResourceLoader.h index 9de8bc2f25..d8fbe7360e 100644 --- a/libs/gltfio/include/gltfio/ResourceLoader.h +++ b/libs/gltfio/include/gltfio/ResourceLoader.h @@ -54,8 +54,8 @@ struct ResourceConfiguration { //! do not need this, but it is useful for robustness. bool recomputeBoundingBoxes; - //! If true, ignore skinned primitives bind transform when compute bounding box. Implicitly true - //! for instanced asset. Only applicable when recomputeBoundingBoxes is set to true + //! If true, ignores skinning when computing bounding boxes. Implicitly true for instanced + //! assets. Only applicable when recomputeBoundingBoxes is set to true. bool ignoreBindTransform; }; diff --git a/libs/gltfio/materials/sheen.mat.in b/libs/gltfio/materials/sheen.mat.in index 2d94f36d9b..9cc191f7d7 100644 --- a/libs/gltfio/materials/sheen.mat.in +++ b/libs/gltfio/materials/sheen.mat.in @@ -2,7 +2,7 @@ material { name : sheen_${SHADINGMODEL}_${BLENDING}, requires : [ uv0, uv1, color ], shadingModel : ${SHADINGMODEL}, - blending : fade, + blending : opaque, depthWrite : true, doubleSided : ${DOUBLESIDED}, transparency : ${TRANSPARENCY}, diff --git a/libs/gltfio/src/Animator.cpp b/libs/gltfio/src/Animator.cpp index defdae3574..47c4ea8aa6 100644 --- a/libs/gltfio/src/Animator.cpp +++ b/libs/gltfio/src/Animator.cpp @@ -330,10 +330,10 @@ void Animator::updateBoneMatrices() { auto transformManager = mImpl->transformManager; auto update = [=](const SkinVector& skins, BoneVector& boneVector) { - for (const auto& skin : skins) { + for (const Skin& skin : skins) { size_t njoints = skin.joints.size(); boneVector.resize(njoints); - for (const auto& entity : skin.targets) { + for (Entity entity : skin.targets) { auto renderable = renderableManager->getInstance(entity); if (!renderable) { continue; diff --git a/libs/gltfio/src/AssetLoader.cpp b/libs/gltfio/src/AssetLoader.cpp index fe6f3d72e9..ea76e4ac24 100644 --- a/libs/gltfio/src/AssetLoader.cpp +++ b/libs/gltfio/src/AssetLoader.cpp @@ -319,6 +319,16 @@ void FAssetLoader::createAsset(const cgltf_data* srcAsset, size_t numInstances) } } + // Some exporters (e.g. Cinema4D) produce assets with a separate animation hierarchy and + // modeling hierarchy, where nodes in the former have no associated scene. We need to create + // transformable entities for "un-scened" nodes in case they have bones. + for (size_t i = 0, n = srcAsset->nodes_count; i < n; ++i) { + cgltf_node* node = &srcAsset->nodes[i]; + if (node->parent == nullptr && mRootNodes.find(node) == mRootNodes.end()) { + mRootNodes.insert({node, {}}); + } + } + mResult->mRenderableCount = 0; if (numInstances == 0) { diff --git a/libs/gltfio/src/FFilamentAsset.h b/libs/gltfio/src/FFilamentAsset.h index 4d85f86956..da94ecd914 100644 --- a/libs/gltfio/src/FFilamentAsset.h +++ b/libs/gltfio/src/FFilamentAsset.h @@ -212,6 +212,10 @@ struct FFilamentAsset : public FilamentAsset { const utils::Entity* getJointsAt(size_t skinIndex) const noexcept; + void attachSkin(size_t skinIndex, Entity target) noexcept; + + void detachSkin(size_t skinIndex, Entity target) noexcept; + const char* getMorphTargetNameAt(utils::Entity entity, size_t targetIndex) const noexcept; size_t getMorphTargetCountAt(utils::Entity entity) const noexcept; diff --git a/libs/gltfio/src/FFilamentInstance.h b/libs/gltfio/src/FFilamentInstance.h index 5a1ec35efa..52cfdd77fa 100644 --- a/libs/gltfio/src/FFilamentInstance.h +++ b/libs/gltfio/src/FFilamentInstance.h @@ -26,6 +26,7 @@ #include #include +#include #include @@ -44,9 +45,17 @@ class Animator; struct Skin { utils::CString name; - std::vector inverseBindMatrices; - std::vector joints; - std::vector targets; + + // The inverse bind matrices and joints arrays must have the same count. Each element + // corresponds to a single bone. We considered using the ECS to store these, but this would be + // complicated because a single node might be used as a bone in more than one skin, and its + // inverse bind matrix might be unique in each of these skins. + utils::FixedCapacityVector inverseBindMatrices; + utils::FixedCapacityVector joints; + + // The set of all nodes that are influenced by this skin. + // This is initially gleaned from the glTF file using the "skin" attribute of each node. + tsl::robin_set targets; }; struct VariantMapping { diff --git a/libs/gltfio/src/FilamentAsset.cpp b/libs/gltfio/src/FilamentAsset.cpp index 72467b5e2b..6a37330516 100644 --- a/libs/gltfio/src/FilamentAsset.cpp +++ b/libs/gltfio/src/FilamentAsset.cpp @@ -120,6 +120,20 @@ const utils::Entity* FFilamentAsset::getJointsAt(size_t skinIndex) const noexcep return mSkins[skinIndex].joints.data(); } +void FFilamentAsset::attachSkin(size_t skinIndex, Entity target) noexcept { + if (UTILS_UNLIKELY(mSkins.size() <= skinIndex || target.isNull())) { + return; + } + mSkins[skinIndex].targets.insert(target); +} + +void FFilamentAsset::detachSkin(size_t skinIndex, Entity target) noexcept { + if (UTILS_UNLIKELY(mSkins.size() <= skinIndex || target.isNull())) { + return; + } + mSkins[skinIndex].targets.erase(target); +} + const char* FFilamentAsset::getMorphTargetNameAt(utils::Entity entity, size_t targetIndex) const noexcept { if (!mResourcesLoaded) { @@ -381,6 +395,14 @@ const utils::Entity* FilamentAsset::getJointsAt(size_t skinIndex) const noexcept return upcast(this)->getJointsAt(skinIndex); } +void FilamentAsset::attachSkin(size_t skinIndex, Entity target) noexcept { + upcast(this)->attachSkin(skinIndex, target); +} + +void FilamentAsset::detachSkin(size_t skinIndex, Entity target) noexcept { + upcast(this)->detachSkin(skinIndex, target); +} + const char* FilamentAsset::getMorphTargetNameAt(utils::Entity entity, size_t targetIndex) const noexcept { return upcast(this)->getMorphTargetNameAt(entity, targetIndex); diff --git a/libs/gltfio/src/ResourceLoader.cpp b/libs/gltfio/src/ResourceLoader.cpp index 90ea9118a6..da19320a0e 100644 --- a/libs/gltfio/src/ResourceLoader.cpp +++ b/libs/gltfio/src/ResourceLoader.cpp @@ -85,10 +85,6 @@ struct ResourceLoader::Impl { bool mIgnoreBindTransform; std::string mGltfPath; - // This is used to calculate skinIndex when updateBoundingBoxes, so that the mapping between - // cgltf_node* and FFilamentInstance::Skin can be retrieved. This pointer doesn't need to be freed. - cgltf_skin* mSkinBaseAddress; - // User-provided resource data with URI string keys, populated with addResourceData(). // This is used on platforms without traditional file systems, such as Android, iOS, and WebGL. UriDataCache mUriDataCache; @@ -134,7 +130,7 @@ void importSkins(const cgltf_data* gltf, const NodeMap& nodeMap, SkinVector& dst if (node.skin) { int skinIndex = node.skin - &gltf->skins[0]; Entity entity = nodeMap.at(&node); - dstSkins[skinIndex].targets.push_back(entity); + dstSkins[skinIndex].targets.insert(entity); } } for (cgltf_size i = 0, len = gltf->skins_count; i < len; ++i) { @@ -145,23 +141,16 @@ void importSkins(const cgltf_data* gltf, const NodeMap& nodeMap, SkinVector& dst } // Build a list of transformables for this skin, one for each joint. - // TODO: We've seen models with joint nodes that do not belong to the scene's node graph. - // e.g. BrainStem after Draco compression. That's why we have a fallback here. AssetManager - // should maybe create an Entity for every glTF node, period. (regardless of hierarchy) - // https://github.com/CesiumGS/gltf-pipeline/issues/532 - dstSkin.joints.resize(srcSkin.joints_count); + dstSkin.joints = FixedCapacityVector(srcSkin.joints_count); for (cgltf_size i = 0, len = srcSkin.joints_count; i < len; ++i) { auto iter = nodeMap.find(srcSkin.joints[i]); - if (iter == nodeMap.end()) { - dstSkin.joints[i] = nodeMap.begin()->second; - } else { - dstSkin.joints[i] = iter->second; - } + assert_invariant(iter != nodeMap.end()); + dstSkin.joints[i] = iter->second; } // Retain a copy of the inverse bind matrices because the source blob could be evicted later. const cgltf_accessor* srcMatrices = srcSkin.inverse_bind_matrices; - dstSkin.inverseBindMatrices.resize(srcSkin.joints_count); + dstSkin.inverseBindMatrices = FixedCapacityVector(srcSkin.joints_count); if (srcMatrices) { auto dstMatrices = (uint8_t*) dstSkin.inverseBindMatrices.data(); uint8_t* bytes = (uint8_t*) srcMatrices->buffer_view->buffer->data; @@ -458,7 +447,6 @@ bool ResourceLoader::loadResources(FFilamentAsset* asset, bool async) { if (!pImpl->mIgnoreBindTransform) { pImpl->mIgnoreBindTransform = asset->isInstanced(); } - pImpl->mSkinBaseAddress = &gltf->skins[0]; updateBoundingBoxes(asset); } @@ -902,101 +890,105 @@ void ResourceLoader::updateBoundingBoxes(FFilamentAsset* asset) const { *result = aabb; }; - const size_t posAttrSize = cgltf_num_components(cgltf_type_vec3); - const size_t skinningAttrSize = cgltf_num_components(cgltf_type_vec4); - auto computeBoundingBoxSkinned = [&](const cgltf_primitive* prim, const Skin* skin, Aabb* result) { - Aabb aabb; - std::vector inverseGlobalTransforms(skin->targets.size()); - for (size_t i = 0; i < skin->targets.size(); i++) { - auto xformable = tm.getInstance(skin->targets[i]); - if (xformable) { - inverseGlobalTransforms[i] = inverse(tm.getWorldTransform(xformable)); - } - } - std::vector verts; - std::vector rawJoints; - std::vector weights; - for (cgltf_size slot = 0; slot < prim->attributes_count; slot++) { - const cgltf_attribute& attr = prim->attributes[slot]; - const cgltf_accessor* accessor = attr.data; - if (attr.type == cgltf_attribute_type_position && - cgltf_num_components(accessor->type) >= posAttrSize) { - verts.resize(accessor->count * posAttrSize); - cgltf_accessor_unpack_floats(accessor, &verts[0], accessor->count * posAttrSize); - } - if (attr.type == cgltf_attribute_type_joints && - cgltf_num_components(accessor->type) >= skinningAttrSize) { - rawJoints.resize(accessor->count * skinningAttrSize); - cgltf_accessor_unpack_floats(accessor, &rawJoints[0], accessor->count * skinningAttrSize); - } - if (attr.type == cgltf_attribute_type_weights && - cgltf_num_components(accessor->type) >= skinningAttrSize) { - weights.resize(accessor->count * skinningAttrSize); - cgltf_accessor_unpack_floats(accessor, &weights[0], accessor->count * skinningAttrSize); - } - } - std::vector jointIndices(rawJoints.begin(), rawJoints.end()); - auto primitiveCount = static_cast(verts.size() / posAttrSize); - for (size_t i = 0; i < primitiveCount; i++) { - float3 point(verts[posAttrSize * i], verts[posAttrSize * i + 1], verts[posAttrSize * i + 2]); - mat4f tmp = mat4f(0.0f); - for (size_t j = 0; j < skinningAttrSize; j++) { - size_t jointIndex = jointIndices[skinningAttrSize * i + j]; - float jointWeight = weights[skinningAttrSize * i + j]; - Entity jointEntity = skin->joints[jointIndex]; - mat4f globalJointTransform = tm.getWorldTransform(tm.getInstance(jointEntity)); - mat4f inverseBindMatrix = skin->inverseBindMatrices[jointIndex]; - tmp += jointWeight * globalJointTransform * inverseBindMatrix; - } - for (const auto& inverseGlobalTransform: inverseGlobalTransforms) { - mat4f skinMatrix = inverseGlobalTransform * tmp; - if (!pImpl->mNormalizeSkinningWeights) { - skinMatrix /= skinMatrix[3].w; + struct Prim { + cgltf_primitive const* prim; + Skin const* skin; + Entity node; + }; + + auto computeBoundingBoxSkinned = [&](const Prim& prim, Aabb* result) { + FixedCapacityVector verts; + FixedCapacityVector joints; + FixedCapacityVector weights; + for (cgltf_size slot = 0, n = prim.prim->attributes_count; slot < n; ++slot) { + const cgltf_attribute& attr = prim.prim->attributes[slot]; + const cgltf_accessor& accessor = *attr.data; + switch (attr.type) { + case cgltf_attribute_type_position: + verts = FixedCapacityVector(accessor.count); + cgltf_accessor_unpack_floats(&accessor, &verts.data()->x, accessor.count * 3); + break; + case cgltf_attribute_type_joints: { + FixedCapacityVector tmp(accessor.count); + cgltf_accessor_unpack_floats(&accessor, &tmp.data()->x, accessor.count * 4); + joints = FixedCapacityVector(accessor.count); + for (size_t i = 0, n = accessor.count; i < n; ++i) { + joints[i] = uint4(tmp[i]); } - float3 skinnedPoint = (point.x * skinMatrix[0] + - point.y * skinMatrix[1] + point.z * skinMatrix[2] + skinMatrix[3]).xyz; - aabb.min = min(aabb.min, skinnedPoint); - aabb.max = max(aabb.max, skinnedPoint); + break; } + case cgltf_attribute_type_weights: + weights = FixedCapacityVector(accessor.count); + cgltf_accessor_unpack_floats(&accessor, &weights.data()->x, accessor.count * 4); + break; + default: + break; + } + } + + Aabb aabb; + TransformManager::Instance transformable = tm.getInstance(prim.node); + const mat4f inverseGlobalTransform = inverse(tm.getWorldTransform(transformable)); + for (size_t i = 0, n = verts.size(); i < n; i++) { + float3 point = verts[i]; + mat4f tmp = mat4f(0.0f); + for (size_t j = 0; j < 4; j++) { + size_t jointIndex = joints[i][j]; + Entity jointEntity = prim.skin->joints[jointIndex]; + mat4f globalJointTransform = tm.getWorldTransform(tm.getInstance(jointEntity)); + mat4f inverseBindMatrix = prim.skin->inverseBindMatrices[jointIndex]; + tmp += weights[i][j] * globalJointTransform * inverseBindMatrix; + } + mat4f skinMatrix = inverseGlobalTransform * tmp; + if (!pImpl->mNormalizeSkinningWeights) { + skinMatrix /= skinMatrix[3].w; + } + float3 skinnedPoint = (point.x * skinMatrix[0] + + point.y * skinMatrix[1] + point.z * skinMatrix[2] + skinMatrix[3]).xyz; + aabb.min = min(aabb.min, skinnedPoint); + aabb.max = max(aabb.max, skinnedPoint); } *result = aabb; }; // Collect all mesh primitives that we wish to find bounds for. For each mesh primitive, we also - // collect the skin it bound to (nullptr if not skinned) for bounds computation. - std::vector> primitives; + // collect the skin it is bound to (nullptr if not skinned) for bounds computation. + size_t primCount = 0; for (auto iter : nodeMap) { - const Skin* skin = nullptr; - cgltf_skin* const cgltfSkin = iter.first->skin; - if (cgltfSkin) { - // importSkins unpacked cgltfSkin into FFilamentInstance::SkinVector bijectively so that - // the unpacked Skin can be retrieved given cgltfSkin index - int skinIndex = cgltfSkin - pImpl->mSkinBaseAddress; - skin = &asset->mSkins[skinIndex]; + const cgltf_mesh* mesh = iter.first->mesh; + if (mesh) { + primCount += mesh->primitives_count; } - const cgltf_mesh* cgltfMesh = iter.first->mesh; - if (cgltfMesh) { - for (cgltf_size index = 0, nprims = cgltfMesh->primitives_count; index < nprims; ++index) { - primitives.push_back({&cgltfMesh->primitives[index], skin}); + } + auto primitives = FixedCapacityVector::with_capacity(primCount); + const cgltf_skin* baseSkin = &asset->mSourceAsset->hierarchy->skins[0]; + for (auto iter : nodeMap) { + const cgltf_mesh* mesh = iter.first->mesh; + if (mesh) { + for (cgltf_size index = 0, nprims = mesh->primitives_count; index < nprims; ++index) { + primitives.push_back({&mesh->primitives[index], nullptr, iter.second}); + } + if (cgltf_skin* const skin = iter.first->skin; skin) { + primitives.back().skin = &asset->mSkins[skin - baseSkin]; } } } // Kick off a bounding box job for every primitive. - std::vector bounds(primitives.size()); + FixedCapacityVector bounds(primitives.size()); JobSystem* js = &pImpl->mEngine->getJobSystem(); JobSystem::Job* parent = js->createJob(); for (size_t i = 0; i < primitives.size(); ++i) { Aabb* result = &bounds[i]; - if (pImpl->mIgnoreBindTransform || !primitives[i].second) { - cgltf_primitive const* prim = primitives[i].first; + if (pImpl->mIgnoreBindTransform || primitives[i].skin == nullptr) { + cgltf_primitive const* prim = primitives[i].prim; js->run(jobs::createJob(*js, parent, [prim, result, computeBoundingBox] { computeBoundingBox(prim, result); })); } else { - std::pair skinnedPrimitive = primitives[i]; - js->run(jobs::createJob(*js, parent, [skinnedPrimitive, result, computeBoundingBoxSkinned] { - computeBoundingBoxSkinned(skinnedPrimitive.first, skinnedPrimitive.second, result); + const Prim& prim = primitives[i]; + js->run(jobs::createJob(*js, parent, [&prim, result, computeBoundingBoxSkinned] { + computeBoundingBoxSkinned(prim, result); })); } } diff --git a/libs/utils/include/utils/Allocator.h b/libs/utils/include/utils/Allocator.h index 48f742e25f..90c0acb328 100644 --- a/libs/utils/include/utils/Allocator.h +++ b/libs/utils/include/utils/Allocator.h @@ -162,7 +162,7 @@ public: } void free(void* p, size_t) noexcept { - free(p); + this->free(p); } ~HeapAllocator() noexcept = default; diff --git a/libs/utils/include/utils/memalign.h b/libs/utils/include/utils/memalign.h index 04cdf55501..001e3a24d7 100644 --- a/libs/utils/include/utils/memalign.h +++ b/libs/utils/include/utils/memalign.h @@ -30,15 +30,13 @@ namespace utils { inline void* aligned_alloc(size_t size, size_t align) noexcept { + // 'align' must be a power of two and a multiple of sizeof(void*) + align = (align < sizeof(void*)) ? sizeof(void*) : align; assert(align && !(align & align - 1)); + assert((align % sizeof(void*)) == 0); void* p = nullptr; - // must be a power of two and >= sizeof(void*) - while (align < sizeof(void*)) { - align <<= 1u; - } - #if defined(WIN32) p = ::_aligned_malloc(size, align); #else diff --git a/libs/utils/src/Log.cpp b/libs/utils/src/Log.cpp index 32f929a480..6571774ecb 100644 --- a/libs/utils/src/Log.cpp +++ b/libs/utils/src/Log.cpp @@ -82,7 +82,7 @@ ostream& LogStream::flush() noexcept { #endif break; } -#endif // ANDROID +#endif // __ANDROID__ buf.reset(); return *this; } diff --git a/libs/viewer/src/ViewerGui.cpp b/libs/viewer/src/ViewerGui.cpp index 66e6ca2771..bc530f8da8 100644 --- a/libs/viewer/src/ViewerGui.cpp +++ b/libs/viewer/src/ViewerGui.cpp @@ -408,10 +408,10 @@ void ViewerGui::setAsset(FilamentAsset* asset, FilamentInstance* instanceToAnim assert_invariant(mAnimator && "Call loadResources or asyncBeginLoad before setAsset."); updateRootTransform(); mScene->addEntities(asset->getLightEntities(), asset->getLightEntityCount()); - auto& tcm = mEngine->getRenderableManager(); + auto& rcm = mEngine->getRenderableManager(); for (size_t i = 0, n = asset->getRenderableEntityCount(); i < n; i++) { - auto ri = tcm.getInstance(asset->getRenderableEntities()[i]); - tcm.setScreenSpaceContactShadows(ri, true); + auto ri = rcm.getInstance(asset->getRenderableEntities()[i]); + rcm.setScreenSpaceContactShadows(ri, true); } } } diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index bd110bc3ff..c1e0509e95 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -268,28 +268,6 @@ if (NOT ANDROID) install(DIRECTORY ${PROJECT_BINARY_DIR}/assets/ibl/ DESTINATION bin/assets) endif() -# ================================================================================================== -# Copy the MoltenVK dylibs and JSON on MacOS -# ================================================================================================== - -if (APPLE AND NOT Vulkan_LIBRARY AND NOT FILAMENT_USE_SWIFTSHADER) - message(STATUS "No Vulkan SDK was found, using prebuilt MoltenVK.") - set(MOLTENVK_DIR "../third_party/moltenvk") - configure_file( - ${MOLTENVK_DIR}/libvulkan.1.dylib - ${PROJECT_BINARY_DIR}/libvulkan.1.dylib COPYONLY) - configure_file( - ${MOLTENVK_DIR}/MoltenVK_icd.json - ${PROJECT_BINARY_DIR}/MoltenVK_icd.json COPYONLY) - configure_file( - ${MOLTENVK_DIR}/libMoltenVK.dylib - ${PROJECT_BINARY_DIR}/libMoltenVK.dylib COPYONLY) - list(APPEND APP_SRCS - ${PROJECT_BINARY_DIR}/libvulkan.1.dylib - ${PROJECT_BINARY_DIR}/MoltenVK_icd.json - ${PROJECT_BINARY_DIR}/libMoltenVK.dylib) -endif() - # ================================================================================================== # Copy Assets # diff --git a/samples/gltf_viewer.cpp b/samples/gltf_viewer.cpp index 0749f48e41..f8ec57e8dd 100644 --- a/samples/gltf_viewer.cpp +++ b/samples/gltf_viewer.cpp @@ -138,7 +138,7 @@ static void printUsage(char* name) { " --recompute-aabb, -r\n" " Ignore the min/max attributes in the glTF file\n\n" " --ignore-bind-transform, -g\n" - " Ignore bind transform when recomputing aabb\n\n" + " Ignore bind transform when recomputing aabb (use with -r)\n\n" " --settings=, -t\n" " Apply the settings in the given JSON file\n\n" " --ubershader, -u\n" diff --git a/third_party/basisu/tnt/CMakeLists.txt b/third_party/basisu/tnt/CMakeLists.txt index e45c437fd9..8d79fc3cbd 100644 --- a/third_party/basisu/tnt/CMakeLists.txt +++ b/third_party/basisu/tnt/CMakeLists.txt @@ -4,7 +4,6 @@ cmake_minimum_required(VERSION 3.19) set(TRANSCODER_SRC ../transcoder/basisu_transcoder.cpp - ../zstd/zstd.c ) set(ENCODER_SRC @@ -51,9 +50,14 @@ else() set (BASIS_CONFIG ${BASIS_CONFIG} BASISD_SUPPORT_DXT5A=0 BASISD_SUPPORT_DXT1=0) endif() -add_library(basis_encoder ${ENCODER_SRC} ${TRANSCODER_SRC}) +add_library(zstd ../zstd/zstd.c) +add_library(basis_encoder ${ENCODER_SRC}) add_library(basis_transcoder ${TRANSCODER_SRC}) +target_link_libraries(basis_transcoder zstd) +target_link_libraries(basis_encoder basis_transcoder) + +target_include_directories(zstd PUBLIC ../zstd) target_include_directories(basis_encoder PUBLIC ../encoder) target_include_directories(basis_transcoder PUBLIC ../transcoder) @@ -61,7 +65,8 @@ target_compile_definitions(basis_encoder PRIVATE ${BASIS_CONFIG}) target_compile_definitions(basis_transcoder PRIVATE ${BASIS_CONFIG}) if (IS_HOST_PLATFORM) - add_executable(basisu ${ENCODER_SRC} ${TRANSCODER_SRC} ../basisu_tool.cpp) + add_executable(basisu ../basisu_tool.cpp) + target_link_libraries(basisu basis_encoder) target_compile_definitions(basisu PRIVATE ${BASIS_CONFIG}) install(TARGETS basisu DESTINATION bin) @@ -71,3 +76,4 @@ if (IS_HOST_PLATFORM) endif() install(TARGETS basis_transcoder ARCHIVE DESTINATION lib/${DIST_DIR}) +install(TARGETS zstd ARCHIVE DESTINATION lib/${DIST_DIR}) diff --git a/third_party/imgui/examples/libs/glfw/lib-vc2010-32/glfw3.lib b/third_party/imgui/examples/libs/glfw/lib-vc2010-32/glfw3.lib deleted file mode 100644 index 348abecfa9..0000000000 Binary files a/third_party/imgui/examples/libs/glfw/lib-vc2010-32/glfw3.lib and /dev/null differ diff --git a/third_party/imgui/examples/libs/glfw/lib-vc2010-64/glfw3.lib b/third_party/imgui/examples/libs/glfw/lib-vc2010-64/glfw3.lib deleted file mode 100644 index 768f308366..0000000000 Binary files a/third_party/imgui/examples/libs/glfw/lib-vc2010-64/glfw3.lib and /dev/null differ diff --git a/third_party/imgui/tnt/README.md b/third_party/imgui/tnt/README.md index 2bdf99cf69..b22c2186e9 100644 --- a/third_party/imgui/tnt/README.md +++ b/third_party/imgui/tnt/README.md @@ -12,6 +12,8 @@ unzip imgui.zip rsync -r imgui-1.77/ imgui/ --delete git checkout imgui/tnt rm -rf imgui-1.77 imgui.zip +rm imgui/examples/libs/glfw/lib-vc2010-32/*.lib +rm imgui/examples/libs/glfw/lib-vc2010-64/*.lib git add imgui ``` diff --git a/third_party/moltenvk/LICENSE b/third_party/moltenvk/LICENSE deleted file mode 100644 index d645695673..0000000000 --- a/third_party/moltenvk/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/third_party/moltenvk/MoltenVK_icd.json b/third_party/moltenvk/MoltenVK_icd.json deleted file mode 100644 index 60593301a5..0000000000 --- a/third_party/moltenvk/MoltenVK_icd.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "file_format_version" : "1.0.0", - "ICD": { - "library_path": "./libMoltenVK.dylib", - "api_version" : "1.0.0" - } -} diff --git a/third_party/moltenvk/README.md b/third_party/moltenvk/README.md deleted file mode 100644 index 5acc784068..0000000000 --- a/third_party/moltenvk/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# third_party/moltenvk - -This folder contains prebuilt dylib files extracted from `macOS/lib` in the following LunarG SDK: - - vulkansdk-macos-1.2.182.0.dmg - -The purpose of these files is to allow Filament developers to avoid installing the LunarG SDK. -However, to enable validation you must install the SDK. - -# Enabling validation on macOS - -If you wish to enable validation or use a newer version of MoltenVK than what is included in the -Filament repo, please do the following. - -1. Download and execute the latest dmg file from https://vulkan.lunarg.com/sdk/home - -2. To set environment variables such as VK_ICD_FILENAMES etc, go to the SDK folder and do - `source setup-env.sh`. diff --git a/third_party/moltenvk/libMoltenVK.dylib b/third_party/moltenvk/libMoltenVK.dylib deleted file mode 100755 index 9cf069dbf9..0000000000 Binary files a/third_party/moltenvk/libMoltenVK.dylib and /dev/null differ diff --git a/third_party/moltenvk/libvulkan.1.dylib b/third_party/moltenvk/libvulkan.1.dylib deleted file mode 100755 index ff138d4d2e..0000000000 Binary files a/third_party/moltenvk/libvulkan.1.dylib and /dev/null differ diff --git a/third_party/moltenvk/tnt/CMakeLists.txt b/third_party/moltenvk/tnt/CMakeLists.txt deleted file mode 100644 index 41765f1d72..0000000000 --- a/third_party/moltenvk/tnt/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(moltenvk) - -set(OUTPUT_LIBVK ${CMAKE_CURRENT_BINARY_DIR}/../libvulkan.1.dylib) -set(INPUT_LIBVK ${CMAKE_CURRENT_SOURCE_DIR}/../libvulkan.1.dylib) - -set(OUTPUT_ICD ${CMAKE_CURRENT_BINARY_DIR}/../libMoltenVK.dylib) -set(INPUT_ICD ${CMAKE_CURRENT_SOURCE_DIR}/../libMoltenVK.dylib) - -set(OUTPUT_JSON ${CMAKE_CURRENT_BINARY_DIR}/../MoltenVK_icd.json) -set(INPUT_JSON ${CMAKE_CURRENT_SOURCE_DIR}/../MoltenVK_icd.json) - -# Define a build step that simply copies the dylib to the destination. -add_custom_command( - OUTPUT ${OUTPUT_LIBVK} - COMMAND ${CMAKE_COMMAND} -E copy ${INPUT_LIBVK} ${OUTPUT_LIBVK}) - -add_custom_command( - OUTPUT ${OUTPUT_ICD} - COMMAND ${CMAKE_COMMAND} -E copy ${INPUT_ICD} ${OUTPUT_ICD}) - -add_custom_command( - OUTPUT ${OUTPUT_JSON} - COMMAND ${CMAKE_COMMAND} -E copy ${INPUT_JSON} ${OUTPUT_JSON}) - -# Define a fictional artifact called "moltenvk" that depends on the dylib. -add_custom_target(moltenvk ALL DEPENDS ${OUTPUT_LIBVK} ${OUTPUT_ICD} ${OUTPUT_JSON}) - -# Install all the molten files alongside libfilament in /usr/local/lib/${ARCH} -# Only install on Desktop- iOS links against ../ios/libMoltenVK.dylib -if(APPLE AND NOT IOS) - install(FILES ${OUTPUT_LIBVK} DESTINATION lib/${DIST_DIR}) - install(FILES ${OUTPUT_ICD} DESTINATION lib/${DIST_DIR}) - install(FILES ${OUTPUT_JSON} DESTINATION lib/${DIST_DIR}) -endif() diff --git a/third_party/spirv-tools/.gitignore b/third_party/spirv-tools/.gitignore index 22fb106d62..a87496a7d9 100644 --- a/third_party/spirv-tools/.gitignore +++ b/third_party/spirv-tools/.gitignore @@ -2,7 +2,7 @@ .ycm_extra_conf.py* *.pyc compile_commands.json -/build/ +/build*/ /buildtools/ /external/googletest /external/effcee @@ -18,6 +18,7 @@ bazel-bin bazel-genfiles bazel-out bazel-spirv-tools +bazel-SPIRV-Tools bazel-testlogs # Vim diff --git a/third_party/spirv-tools/Android.mk b/third_party/spirv-tools/Android.mk index bc748e535b..6dd18341da 100644 --- a/third_party/spirv-tools/Android.mk +++ b/third_party/spirv-tools/Android.mk @@ -106,8 +106,10 @@ SPVTOOLS_OPT_SRC_FILES := \ source/opt/eliminate_dead_constant_pass.cpp \ source/opt/eliminate_dead_functions_pass.cpp \ source/opt/eliminate_dead_functions_util.cpp \ + source/opt/eliminate_dead_input_components_pass.cpp \ source/opt/eliminate_dead_members_pass.cpp \ source/opt/feature_manager.cpp \ + source/opt/fix_func_call_arguments.cpp \ source/opt/fix_storage_class.cpp \ source/opt/flatten_decoration_pass.cpp \ source/opt/fold.cpp \ @@ -126,6 +128,7 @@ SPVTOOLS_OPT_SRC_FILES := \ source/opt/instruction.cpp \ source/opt/instruction_list.cpp \ source/opt/instrument_pass.cpp \ + source/opt/interface_var_sroa.cpp \ source/opt/interp_fixup_pass.cpp \ source/opt/ir_context.cpp \ source/opt/ir_loader.cpp \ @@ -156,6 +159,7 @@ SPVTOOLS_OPT_SRC_FILES := \ source/opt/redundancy_elimination.cpp \ source/opt/register_pressure.cpp \ source/opt/relax_float_ops_pass.cpp \ + source/opt/remove_dontinline_pass.cpp \ source/opt/remove_duplicates_pass.cpp \ source/opt/remove_unused_interface_variables_pass.cpp \ source/opt/replace_desc_array_access_using_var_index.cpp \ @@ -165,10 +169,11 @@ SPVTOOLS_OPT_SRC_FILES := \ source/opt/scalar_replacement_pass.cpp \ source/opt/set_spec_constant_default_value_pass.cpp \ source/opt/simplification_pass.cpp \ + source/opt/spread_volatile_semantics.cpp \ source/opt/ssa_rewrite_pass.cpp \ source/opt/strength_reduction_pass.cpp \ source/opt/strip_debug_info_pass.cpp \ - source/opt/strip_reflect_info_pass.cpp \ + source/opt/strip_nonsemantic_info_pass.cpp \ source/opt/struct_cfg_analysis.cpp \ source/opt/type_manager.cpp \ source/opt/types.cpp \ @@ -299,7 +304,7 @@ $(1)/build-version.inc: \ $(LOCAL_PATH)/utils/update_build_version.py \ $(LOCAL_PATH)/CHANGES @$(HOST_PYTHON) $(LOCAL_PATH)/utils/update_build_version.py \ - $(LOCAL_PATH) $(1)/build-version.inc + $(LOCAL_PATH)/CHANGES $(1)/build-version.inc @echo "[$(TARGET_ARCH_ABI)] Generate : build-version.inc <= CHANGES" $(LOCAL_PATH)/source/software_version.cpp: $(1)/build-version.inc endef diff --git a/third_party/spirv-tools/BUILD.bazel b/third_party/spirv-tools/BUILD.bazel index b2031dede2..914619afed 100644 --- a/third_party/spirv-tools/BUILD.bazel +++ b/third_party/spirv-tools/BUILD.bazel @@ -81,6 +81,7 @@ genrule( srcs = ["@spirv_headers//:spirv_xml_registry"], outs = ["generators.inc"], cmd = "$(location generate_registry_tables) --xml=$(location @spirv_headers//:spirv_xml_registry) --generator-output=$(location generators.inc)", + cmd_bat = "$(location //:generate_registry_tables) --xml=$(location @spirv_headers//:spirv_xml_registry) --generator-output=$(location generators.inc)", tools = [":generate_registry_tables"], ) @@ -93,7 +94,8 @@ genrule( name = "gen_build_version", srcs = ["CHANGES"], outs = ["build-version.inc"], - cmd = "SOURCE_DATE_EPOCH=0 $(location update_build_version) $$(dirname $(location CHANGES)) $(location build-version.inc)", + cmd = "SOURCE_DATE_EPOCH=0 $(location update_build_version) $(location CHANGES) $(location build-version.inc)", + cmd_bat = "set SOURCE_DATE_EPOCH=0 && $(location //:update_build_version) $(location CHANGES) $(location build-version.inc)", tools = [":update_build_version"], ) diff --git a/third_party/spirv-tools/BUILD.gn b/third_party/spirv-tools/BUILD.gn index 309d51373b..9f96c24d05 100644 --- a/third_party/spirv-tools/BUILD.gn +++ b/third_party/spirv-tools/BUILD.gn @@ -19,6 +19,17 @@ if (build_with_chromium) { import("//third_party/protobuf/proto_library.gni") } +# SPIRV-Tools may be part of multiple projects in the Chromium tree. +# Only enable building executables if this is the main copy. +abspath = get_path_info(".", "abspath") +spvtools_chromium_third_party = (abspath == "//third_party/vulkan-deps/spirv-tools/src/") +spvtools_build_executables = build_with_chromium && spvtools_chromium_third_party +# Fuchsia also requires building the executables. +# TODO(b/158002593): Avoid the use of dependent-specific variables. +if (defined(is_fuchsia_tree) && is_fuchsia_tree) { + spvtools_build_executables = true +} + spirv_headers = spirv_tools_spirv_headers_dir spirv_is_winuwp = is_win && target_os == "winuwp" @@ -245,12 +256,12 @@ action("spvtools_generators_inc") { action("spvtools_build_version") { script = "utils/update_build_version.py" - src_dir = "." + changes_file = "CHANGES" inc_file = "${target_gen_dir}/build-version.inc" outputs = [ inc_file ] args = [ - rebase_path(src_dir, root_build_dir), + rebase_path(changes_file, root_build_dir), rebase_path(inc_file, root_build_dir), ] } @@ -448,12 +459,14 @@ static_library("spvtools") { "source/util/bit_vector.cpp", "source/util/bit_vector.h", "source/util/bitutils.h", + "source/util/hash_combine.h", "source/util/hex_float.h", "source/util/ilist.h", "source/util/ilist_node.h", "source/util/make_unique.h", "source/util/parse_number.cpp", "source/util/parse_number.h", + "source/util/pooled_linked_list.h", "source/util/small_vector.h", "source/util/string_utils.cpp", "source/util/string_utils.h", @@ -609,11 +622,15 @@ static_library("spvtools_opt") { "source/opt/eliminate_dead_functions_pass.h", "source/opt/eliminate_dead_functions_util.cpp", "source/opt/eliminate_dead_functions_util.h", + "source/opt/eliminate_dead_input_components_pass.cpp", + "source/opt/eliminate_dead_input_components_pass.h", "source/opt/eliminate_dead_members_pass.cpp", "source/opt/eliminate_dead_members_pass.h", "source/opt/empty_pass.h", "source/opt/feature_manager.cpp", "source/opt/feature_manager.h", + "source/opt/fix_func_call_arguments.cpp", + "source/opt/fix_func_call_arguments.h", "source/opt/fix_storage_class.cpp", "source/opt/fix_storage_class.h", "source/opt/flatten_decoration_pass.cpp", @@ -650,6 +667,8 @@ static_library("spvtools_opt") { "source/opt/instruction_list.h", "source/opt/instrument_pass.cpp", "source/opt/instrument_pass.h", + "source/opt/interface_var_sroa.cpp", + "source/opt/interface_var_sroa.h", "source/opt/interp_fixup_pass.cpp", "source/opt/interp_fixup_pass.h", "source/opt/ir_builder.h", @@ -714,6 +733,8 @@ static_library("spvtools_opt") { "source/opt/register_pressure.h", "source/opt/relax_float_ops_pass.cpp", "source/opt/relax_float_ops_pass.h", + "source/opt/remove_dontinline_pass.cpp", + "source/opt/remove_dontinline_pass.h", "source/opt/remove_duplicates_pass.cpp", "source/opt/remove_duplicates_pass.h", "source/opt/remove_unused_interface_variables_pass.cpp", @@ -732,14 +753,16 @@ static_library("spvtools_opt") { "source/opt/set_spec_constant_default_value_pass.h", "source/opt/simplification_pass.cpp", "source/opt/simplification_pass.h", + "source/opt/spread_volatile_semantics.cpp", + "source/opt/spread_volatile_semantics.h", "source/opt/ssa_rewrite_pass.cpp", "source/opt/ssa_rewrite_pass.h", "source/opt/strength_reduction_pass.cpp", "source/opt/strength_reduction_pass.h", "source/opt/strip_debug_info_pass.cpp", "source/opt/strip_debug_info_pass.h", - "source/opt/strip_reflect_info_pass.cpp", - "source/opt/strip_reflect_info_pass.h", + "source/opt/strip_nonsemantic_info_pass.cpp", + "source/opt/strip_nonsemantic_info_pass.h", "source/opt/struct_cfg_analysis.cpp", "source/opt/struct_cfg_analysis.h", "source/opt/tree_iterator.h", @@ -869,7 +892,7 @@ static_library("spvtools_reduce") { configs += [ ":spvtools_internal_config" ] } -if (build_with_chromium) { +if (build_with_chromium && spvtools_build_executables) { # The spirv-fuzz library is only built when in a Chromium checkout # due to its dependency on protobuf. @@ -1298,7 +1321,7 @@ group("SPIRV-Tools") { # The tests are scoped to Chromium to avoid needing to write gtest integration. # See Chromium's third_party/googletest/BUILD.gn for a complete integration. -if (build_with_chromium) { +if (build_with_chromium && spvtools_build_executables) { test("spvtools_test") { sources = [ "test/assembly_context_test.cpp", @@ -1407,73 +1430,75 @@ source_set("spvtools_software_version") { configs += [ ":spvtools_internal_config" ] } -executable("spirv-as") { - sources = [ "tools/as/as.cpp" ] - deps = [ - ":spvtools", - ":spvtools_software_version", - ] - configs += [ ":spvtools_internal_config" ] +if (spvtools_build_executables) { + executable("spirv-as") { + sources = [ "tools/as/as.cpp" ] + deps = [ + ":spvtools", + ":spvtools_software_version", + ] + configs += [ ":spvtools_internal_config" ] + } + + executable("spirv-dis") { + sources = [ "tools/dis/dis.cpp" ] + deps = [ + ":spvtools", + ":spvtools_software_version", + ] + configs += [ ":spvtools_internal_config" ] + } + + executable("spirv-val") { + sources = [ "tools/val/val.cpp" ] + deps = [ + ":spvtools", + ":spvtools_software_version", + ":spvtools_util_cli_consumer", + ":spvtools_val", + ] + configs += [ ":spvtools_internal_config" ] + } + + executable("spirv-cfg") { + sources = [ + "tools/cfg/bin_to_dot.cpp", + "tools/cfg/bin_to_dot.h", + "tools/cfg/cfg.cpp", + ] + deps = [ + ":spvtools", + ":spvtools_software_version", + ] + configs += [ ":spvtools_internal_config" ] + } + + executable("spirv-opt") { + sources = [ "tools/opt/opt.cpp" ] + deps = [ + ":spvtools", + ":spvtools_opt", + ":spvtools_software_version", + ":spvtools_util_cli_consumer", + ":spvtools_val", + ] + configs += [ ":spvtools_internal_config" ] + } + + executable("spirv-link") { + sources = [ "tools/link/linker.cpp" ] + deps = [ + ":spvtools", + ":spvtools_link", + ":spvtools_opt", + ":spvtools_software_version", + ":spvtools_val", + ] + configs += [ ":spvtools_internal_config" ] + } } -executable("spirv-dis") { - sources = [ "tools/dis/dis.cpp" ] - deps = [ - ":spvtools", - ":spvtools_software_version", - ] - configs += [ ":spvtools_internal_config" ] -} - -executable("spirv-val") { - sources = [ "tools/val/val.cpp" ] - deps = [ - ":spvtools", - ":spvtools_software_version", - ":spvtools_util_cli_consumer", - ":spvtools_val", - ] - configs += [ ":spvtools_internal_config" ] -} - -executable("spirv-cfg") { - sources = [ - "tools/cfg/bin_to_dot.cpp", - "tools/cfg/bin_to_dot.h", - "tools/cfg/cfg.cpp", - ] - deps = [ - ":spvtools", - ":spvtools_software_version", - ] - configs += [ ":spvtools_internal_config" ] -} - -executable("spirv-opt") { - sources = [ "tools/opt/opt.cpp" ] - deps = [ - ":spvtools", - ":spvtools_opt", - ":spvtools_software_version", - ":spvtools_util_cli_consumer", - ":spvtools_val", - ] - configs += [ ":spvtools_internal_config" ] -} - -executable("spirv-link") { - sources = [ "tools/link/linker.cpp" ] - deps = [ - ":spvtools", - ":spvtools_link", - ":spvtools_opt", - ":spvtools_software_version", - ":spvtools_val", - ] - configs += [ ":spvtools_internal_config" ] -} - -if (!is_ios && !spirv_is_winuwp && build_with_chromium) { +if (!is_ios && !spirv_is_winuwp && build_with_chromium && spvtools_build_executables) { # iOS and UWP do not allow std::system calls which spirv-fuzz # requires. Additionally, spirv-fuzz is only built when in a # Chromium checkout due to its dependency on protobuf. @@ -1494,7 +1519,7 @@ if (!is_ios && !spirv_is_winuwp && build_with_chromium) { } } -if (!is_ios && !spirv_is_winuwp) { +if (!is_ios && !spirv_is_winuwp && spvtools_build_executables) { # iOS and UWP do not allow std::system calls which spirv-reduce # requires. @@ -1512,19 +1537,21 @@ if (!is_ios && !spirv_is_winuwp) { } } -group("all_spirv_tools") { - deps = [ - ":spirv-as", - ":spirv-cfg", - ":spirv-dis", - ":spirv-link", - ":spirv-opt", - ":spirv-val", - ] - if (!is_ios && !spirv_is_winuwp && build_with_chromium) { - deps += [ ":spirv-fuzz" ] - } - if (!is_ios && !spirv_is_winuwp) { - deps += [ ":spirv-reduce" ] +if (spvtools_build_executables){ + group("all_spirv_tools") { + deps = [ + ":spirv-as", + ":spirv-cfg", + ":spirv-dis", + ":spirv-link", + ":spirv-opt", + ":spirv-val", + ] + if (!is_ios && !spirv_is_winuwp && build_with_chromium) { + deps += [ ":spirv-fuzz" ] + } + if (!is_ios && !spirv_is_winuwp) { + deps += [ ":spirv-reduce" ] + } } } diff --git a/third_party/spirv-tools/CHANGES b/third_party/spirv-tools/CHANGES index ee232b6075..7984461b64 100644 --- a/third_party/spirv-tools/CHANGES +++ b/third_party/spirv-tools/CHANGES @@ -1,5 +1,69 @@ Revision history for SPIRV-Tools +v2022.3-dev 2022-04-07 + - Start v2022.3-dev + +v2022.2 2022-04-07 + - General + - Add OpModuleProcessed to debug opcode (#4694) + - Optimizer + - Complete handling of RayQueryKHR type (#4690) + - Have scalar replacement use undef instead of null (#4691) + - Optimize Instruction::Instruction (#4705) + - Handle propagation of arrays with decorations (#4717) + - spirv-opt: Add OpExecutionModeId support (#4719) + - Optimize Type::HashValue (#4707) + - Optimize DefUseManager allocations (#4709) + - Add pass to remove DontInline function control (#4747) + - Better handling of 0xFFFFFFFF when folding vector shuffle (#4743) + - Reset the id bound on the module in compact ids (#4744) + - spirv-opt: (WIP) Eliminate Dead Input Component Pass (#4720) + - Support SPV_KHR_uniform_group_instructions (#4734) + - Handle shaders without execution model in spread-volatile-semantics (#4766) + - Validator + - Fix handling of Nontemporal image operand (#4692) + - [spirv-val] Allow 0 Component Count for DebugTypeArray for Shader (#4706) + - spirv-val: Validate DebugTypeMatrix (#4732) + - spirv-val: Label Vulkan VUID 04734 (#4739) + - spirv-val: Label VUID 06491 (#4745) + - spirv-val: Disallow array of push constants (#4742) + - spirv-val: Label Vulkan RuntimeArray VUID (#4749) + - spirv-val: Add Vulkan Image VUID 06214 (#4750) + - spirv-val: Add Vulkan Dref not allowed 3D dim VUID (#4751) + - spirv-val: Label and add test for PSB Aligned (#4756) + - spirv-val: Add Vulkan 32-bit bit op Base (#4758) + - spirv-val: Add more Vulkan VUID labels (#4764) + - Diff + - Introduce spirv-diff (#4611) + - Stabilize the output of spirv-diff (#4698) + - spirv-diff: Handle OpSpecConstant array sizes (#4700) + - spirv-diff: Match OpSpecConstantComposite correctly (#4704) + - spirv-diff: Use GetSingleWord*Operand (#4768) + - spirv-diff: Basic support for OpTypeForwardPointer (#4761) + - spirv-diff: Fix OpTypeFunction matching w.r.t operand count (#4771) + +v2022.1 2022-01-26 + - General + - Add SPIR-V 1.6 support to wasm build (#4674) + - Improvements to disassembly within PassManager (#4677) + - Basic support for SPIR-V 1.6 (#4663) + - reflect debug (#4662) + - Fix endianness of string literals (#4622) + - Optimizer + - spirv-opt: add pass to Spread Volatile semantics (#4667) + - Fix constant propagation and folding of FClamp instructions (#4651) + - Manually fold floating point division by zero (#4637) + - Allow ADCE to remove dead inputs (#4629) + - Linker + - Linker improvements (#4679) + * test/linker: Code factorisation and small tweaks + * linker: Do not fail when going over limits + - Validator + - val: interface struct with builtins must be Block (#4665) + - Fuzzer + - Avoid id bound errors during opt fuzzing (#4658) + - Avoid uninitialised read when parsing hex float (#4646) + v2021.4 2021-11-11 - General - Add a WebAssembly build (#3752) diff --git a/third_party/spirv-tools/CMakeLists.txt b/third_party/spirv-tools/CMakeLists.txt index f2709dbb2b..53b3404d14 100755 --- a/third_party/spirv-tools/CMakeLists.txt +++ b/third_party/spirv-tools/CMakeLists.txt @@ -24,19 +24,14 @@ if (POLICY CMP0054) endif() set_property(GLOBAL PROPERTY USE_FOLDERS ON) -# Filament specific changes if (APPLE) set(CMAKE_MACOSX_RPATH ON) endif (APPLE) set(SPIRV_SKIP_EXECUTABLES_OPTION ON) set(SPIRV_SKIP_TESTS_OPTION ON) set(SKIP_SPIRV_TOOLS_INSTALL ON) -# End Filament specific changes project(spirv-tools) -# Filament specific changes -# enable_testing() -# End Filament specific changes set(SPIRV_TOOLS "SPIRV-Tools") include(GNUInstallDirs) @@ -82,9 +77,6 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "") set(CMAKE_BUILD_TYPE "Debug") endif() -# Filament specific changes -# option(SKIP_SPIRV_TOOLS_INSTALL "Skip installation" ${SKIP_SPIRV_TOOLS_INSTALL}) -# End Filament specific changes if(NOT ${SKIP_SPIRV_TOOLS_INSTALL}) set(ENABLE_SPIRV_TOOLS_INSTALL ON) endif() @@ -101,10 +93,8 @@ set(SPIRV_LIB_FUZZING_ENGINE_LINK_OPTIONS "" CACHE STRING "Used by OSS-Fuzz to c option(SPIRV_BUILD_LIBFUZZER_TARGETS "Build libFuzzer targets" OFF) -# Filament specific changes -# option(SPIRV_WERROR "Enable error on warning" ON) set(SPIRV_WERROR OFF) -# End Filament specific changes + if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND (NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))) set(COMPILER_IS_LIKE_GNU TRUE) endif() @@ -132,7 +122,7 @@ if(${COMPILER_IS_LIKE_GNU}) set(SPIRV_WARNINGS ${SPIRV_WARNINGS} -Werror) endif() elseif(MSVC) - set(SPIRV_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS /wd4800) + set(SPIRV_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS /wd4800 /wd4819) if(${SPIRV_WERROR}) set(SPIRV_WARNINGS ${SPIRV_WARNINGS} /WX) @@ -259,14 +249,12 @@ if(NOT COMMAND find_host_program) endif() # Tests require Python3 -# Filament specific changes if(CMAKE_VERSION VERSION_LESS "3.12" OR ${CMAKE_SYSTEM_NAME} MATCHES "Windows") find_host_package(PythonInterp 3 REQUIRED) else() find_package(Python3 COMPONENTS Interpreter) set(PYTHON_EXECUTABLE "${Python3_EXECUTABLE}") endif() -# End Filament specific changes # Check for symbol exports on Linux. # At the moment, this check will fail on the OSX build machines for the Android NDK. @@ -309,13 +297,13 @@ if(ENABLE_SPIRV_TOOLS_INSTALL) endif() # Defaults to OFF if the user didn't set it. -# Filament specific changes option(SPIRV_SKIP_EXECUTABLES "Skip building the executable and tests along with the library" ${SPIRV_SKIP_EXECUTABLES_OPTION}) option(SPIRV_SKIP_TESTS "Skip building tests along with the library" ${SPIRV_SKIP_TESTS_OPTION}) -# End Filament specific changes + + if ("${SPIRV_SKIP_EXECUTABLES}") set(SPIRV_SKIP_TESTS ON) endif() @@ -359,11 +347,6 @@ endif() add_subdirectory(source) add_subdirectory(tools) -# Filament specific changes -#add_subdirectory(test) -#add_subdirectory(examples) -# End Filament specific changes - if(ENABLE_SPIRV_TOOLS_INSTALL) install( FILES @@ -384,40 +367,3 @@ endif() set(SPIRV_LIBRARIES "-lSPIRV-Tools-opt -lSPIRV-Tools -lSPIRV-Tools-link") set(SPIRV_SHARED_LIBRARIES "-lSPIRV-Tools-shared") - -# Build pkg-config file -# Use a first-class target so it's regenerated when relevant files are updated. -# Filament specific changes -# add_custom_target(spirv-tools-pkg-config ALL -# COMMAND ${CMAKE_COMMAND} -# -DCHANGES_FILE=${CMAKE_CURRENT_SOURCE_DIR}/CHANGES -# -DTEMPLATE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/SPIRV-Tools.pc.in -# -DOUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools.pc -# -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -# -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} -# -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} -# -DSPIRV_LIBRARIES=${SPIRV_LIBRARIES} -# -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/write_pkg_config.cmake -# DEPENDS "CHANGES" "cmake/SPIRV-Tools.pc.in" "cmake/write_pkg_config.cmake") -# add_custom_target(spirv-tools-shared-pkg-config ALL -# COMMAND ${CMAKE_COMMAND} -# -DCHANGES_FILE=${CMAKE_CURRENT_SOURCE_DIR}/CHANGES -# -DTEMPLATE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/SPIRV-Tools-shared.pc.in -# -DOUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools-shared.pc -# -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -# -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} -# -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} -# -DSPIRV_SHARED_LIBRARIES=${SPIRV_SHARED_LIBRARIES} -# -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/write_pkg_config.cmake -# DEPENDS "CHANGES" "cmake/SPIRV-Tools-shared.pc.in" "cmake/write_pkg_config.cmake") -# End Filament specific changes - -# Install pkg-config file -if (ENABLE_SPIRV_TOOLS_INSTALL) - install( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools.pc - ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools-shared.pc - DESTINATION - ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -endif() diff --git a/third_party/spirv-tools/DEPS b/third_party/spirv-tools/DEPS index 2aaf11f926..abc3a76af2 100644 --- a/third_party/spirv-tools/DEPS +++ b/third_party/spirv-tools/DEPS @@ -4,9 +4,9 @@ vars = { 'github': 'https://github.com', 'effcee_revision': 'ddf5e2bb92957dc8a12c5392f8495333d6844133', - 'googletest_revision': 'bf0701daa9f5b30e5882e2f8f9a5280bcba87e77', - 're2_revision': '4244cd1cb492fa1d10986ec67f862964c073f844', - 'spirv_headers_revision': '814e728b30ddd0f4509233099a3ad96fd4318c07', + 'googletest_revision': '25dcdc7e8bfac8967f20fb2c0a628f5cf442188d', + 're2_revision': '0c5616df9c0aaa44c9440d87422012423d91c7d1', + 'spirv_headers_revision': 'b765c355f488837ca4c77980ba69484f3ff277f5', } deps = { diff --git a/third_party/spirv-tools/FILAMENT_README.md b/third_party/spirv-tools/FILAMENT_README.md index 23bb8a02bf..5020b06c78 100644 --- a/third_party/spirv-tools/FILAMENT_README.md +++ b/third_party/spirv-tools/FILAMENT_README.md @@ -1,9 +1,6 @@ -When updating spirv-tools to a new version, make sure to preserve all the changes marked with -the following in `CMakeLists.txt` and `source/CMakeLists.txt`: - -`# Filament specific changes` - -You can easily apply these changes by running the following command at Filament's root: +When updating spirv-tools to a new version there are several `CMakeLists.txt` files that need +to patched with Filament specific changes. This can be done by running the following command at +Filament's root: ``` git apply third_party/spirv-tools/filament-specific-changes.patch @@ -25,6 +22,13 @@ rm master.zip git add spirv-tools ``` -Edit the .gitignore so it doesn't prevent `spirv-headers` from being committed. +The patch file also edits the `.gitignore` to allow `spirv-headers` to be committed. Finally, remember to bring back the Filament-specific changes in CMakeLists. + +To restore this file and the patch file do: + +``` +git checkout main spirv-tools/FILAMENT_README.md +git checkout main spirv-tools/filament-specific-changes.patch +``` diff --git a/third_party/spirv-tools/README.md b/third_party/spirv-tools/README.md index 14db1e7045..e951e37f1a 100644 --- a/third_party/spirv-tools/README.md +++ b/third_party/spirv-tools/README.md @@ -212,6 +212,24 @@ issue](https://github.com/KhronosGroup/SPIRV-Tools/issues]) with "Fuzzer:" as the start of its title. +### Diff + +*Note:* The diff tool is still under development. + +The diff tool takes two SPIR-V files, either in binary or text format and +produces a diff-style comparison between the two. The instructions between the +src and dst modules are matched as best as the tool can, and output is produced +(in src id-space) that shows which instructions are removed in src, added in dst +or modified between them. The order of instructions are not retained. + +Matching instructions between two SPIR-V modules is not trivial, and thus a +number of heuristics are applied in this tool. In particular, without debug +information, match functions is nontrivial as they can be reordered. As such, +this tool is primarily useful to produce the diff of two SPIR-V modules derived +from the same source, for example before and after a modification to the shader, +before and after a transformation, or SPIR-V produced from different tools. + + ### Extras * [Utility filters](#utility-filters) @@ -399,7 +417,7 @@ targets, you need to install CMake Version 2.8.12 or later. - [Python 3](http://www.python.org/): for utility scripts and running the test suite. - [Bazel](https://bazel.build/) (optional): if building the source with Bazel, -you need to install Bazel Version 0.29.1 on your machine. Other versions may +you need to install Bazel Version 5.0.0 on your machine. Other versions may also work, but are not verified. - [Emscripten SDK](https://emscripten.org) (optional): if building the WebAssembly module. @@ -624,6 +642,15 @@ This is experimental. * `spirv-cfg` - the control flow graph dumper * `/tools/cfg` +### Diff tool + +*Warning:* This functionality is under development, and is incomplete. + +The diff tool produces a diff-style comparison between two SPIR-V modules. + +* `spirv-diff` - the standalone diff tool + * ``/tools/diff` + ### Utility filters * `spirv-lesspipe.sh` - Automatically disassembles `.spv` binary files for the diff --git a/third_party/spirv-tools/build_defs.bzl b/third_party/spirv-tools/build_defs.bzl index b2cd41b9a2..ef9a829463 100644 --- a/third_party/spirv-tools/build_defs.bzl +++ b/third_party/spirv-tools/build_defs.bzl @@ -68,6 +68,14 @@ def generate_core_tables(version = None): "--core-insts-output=$(location {3}) " + "--operand-kinds-output=$(location {4})" ).format(*fmtargs), + cmd_bat = ( + "$(location :generate_grammar_tables) " + + "--spirv-core-grammar=$(location {0}) " + + "--extinst-debuginfo-grammar=$(location {1}) " + + "--extinst-cldebuginfo100-grammar=$(location {2}) " + + "--core-insts-output=$(location {3}) " + + "--operand-kinds-output=$(location {4})" + ).format(*fmtargs), tools = [":generate_grammar_tables"], visibility = ["//visibility:private"], ) @@ -97,6 +105,14 @@ def generate_enum_string_mapping(version = None): "--extension-enum-output=$(location {3}) " + "--enum-string-mapping-output=$(location {4})" ).format(*fmtargs), + cmd_bat = ( + "$(location :generate_grammar_tables) " + + "--spirv-core-grammar=$(location {0}) " + + "--extinst-debuginfo-grammar=$(location {1}) " + + "--extinst-cldebuginfo100-grammar=$(location {2}) " + + "--extension-enum-output=$(location {3}) " + + "--enum-string-mapping-output=$(location {4})" + ).format(*fmtargs), tools = [":generate_grammar_tables"], visibility = ["//visibility:private"], ) @@ -118,6 +134,11 @@ def generate_opencl_tables(version = None): "--extinst-opencl-grammar=$(location {0}) " + "--opencl-insts-output=$(location {1})" ).format(*fmtargs), + cmd_bat = ( + "$(location :generate_grammar_tables) " + + "--extinst-opencl-grammar=$(location {0}) " + + "--opencl-insts-output=$(location {1})" + ).format(*fmtargs), tools = [":generate_grammar_tables"], visibility = ["//visibility:private"], ) @@ -139,6 +160,11 @@ def generate_glsl_tables(version = None): "--extinst-glsl-grammar=$(location {0}) " + "--glsl-insts-output=$(location {1})" ).format(*fmtargs), + cmd_bat = ( + "$(location :generate_grammar_tables) " + + "--extinst-glsl-grammar=$(location {0}) " + + "--glsl-insts-output=$(location {1})" + ).format(*fmtargs), tools = [":generate_grammar_tables"], visibility = ["//visibility:private"], ) @@ -161,6 +187,12 @@ def generate_vendor_tables(extension, operand_kind_prefix = ""): "--vendor-insts-output=$(location {1}) " + "--vendor-operand-kind-prefix={2}" ).format(*fmtargs), + cmd_bat = ( + "$(location :generate_grammar_tables) " + + "--extinst-vendor-grammar=$(location {0}) " + + "--vendor-insts-output=$(location {1}) " + + "--vendor-operand-kind-prefix={2}" + ).format(*fmtargs), tools = [":generate_grammar_tables"], visibility = ["//visibility:private"], ) @@ -179,6 +211,11 @@ def generate_extinst_lang_headers(name, grammar = None): "--extinst-grammar=$< " + "--extinst-output-path=$(location {0})" ).format(*fmtargs), + cmd_bat = ( + "$(location :generate_language_headers) " + + "--extinst-grammar=$< " + + "--extinst-output-path=$(location {0})" + ).format(*fmtargs), tools = [":generate_language_headers"], visibility = ["//visibility:private"], ) diff --git a/third_party/spirv-tools/external/CMakeLists.txt b/third_party/spirv-tools/external/CMakeLists.txt index 152cfc4211..a081e119bf 100644 --- a/third_party/spirv-tools/external/CMakeLists.txt +++ b/third_party/spirv-tools/external/CMakeLists.txt @@ -45,10 +45,6 @@ if (IS_DIRECTORY ${SPIRV_HEADER_DIR}) # Do this so enclosing projects can use SPIRV-Headers_SOURCE_DIR to find # headers to include. if (NOT DEFINED SPIRV-Headers_SOURCE_DIR) -# Filament specific changes - #set(SPIRV_HEADERS_SKIP_INSTALL ON) - #set(SPIRV_HEADERS_SKIP_EXAMPLES ON) -# End Filament specific changes add_subdirectory(${SPIRV_HEADER_DIR}) endif() else() diff --git a/third_party/spirv-tools/external/spirv-headers/CMakeLists.txt b/third_party/spirv-tools/external/spirv-headers/CMakeLists.txt index 5c746ff60c..d8d1d7e35b 100644 --- a/third_party/spirv-tools/external/spirv-headers/CMakeLists.txt +++ b/third_party/spirv-tools/external/spirv-headers/CMakeLists.txt @@ -49,11 +49,9 @@ add_custom_target(install-headers COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/include/spirv) -# Filament specific changes option(SPIRV_HEADERS_SKIP_EXAMPLES "Skip building examples" ON) option(SPIRV_HEADERS_SKIP_INSTALL "Skip install" ON) -# End Filament specific changes if(NOT ${SPIRV_HEADERS_SKIP_EXAMPLES}) set(SPIRV_HEADERS_ENABLE_EXAMPLES ON) @@ -89,9 +87,14 @@ if (SPIRV_HEADERS_ENABLE_INSTALL) set(namespace "${PROJECT_NAME}::") include(CMakePackageConfigHelpers) + + if (NOT CMAKE_VERSION VERSION_LESS 3.14) + set(arch_independent_str ARCH_INDEPENDENT) + endif() write_basic_package_version_file( "${version_config}" COMPATIBILITY SameMajorVersion + ${arch_independent_str} ) configure_package_config_file( diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/spir-v.xml b/third_party/spirv-tools/external/spirv-headers/include/spirv/spir-v.xml index 34453f83a9..7acaed34f0 100644 --- a/third_party/spirv-tools/external/spirv-headers/include/spirv/spir-v.xml +++ b/third_party/spirv-tools/external/spirv-headers/include/spirv/spir-v.xml @@ -55,7 +55,7 @@ - + @@ -82,7 +82,10 @@ - + + + + @@ -119,7 +122,7 @@ - + @@ -148,7 +151,7 @@ - + @@ -164,13 +167,14 @@ + - + @@ -190,8 +194,8 @@ - - + + diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.core.grammar.json b/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.core.grammar.json index 05784973d0..8b63c397b0 100644 --- a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.core.grammar.json +++ b/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.core.grammar.json @@ -26,8 +26,8 @@ ], "magic_number" : "0x07230203", "major_version" : 1, - "minor_version" : 5, - "revision" : 4, + "minor_version" : 6, + "revision" : 1, "instruction_printing_class" : [ { "tag" : "@exclude" @@ -1735,7 +1735,8 @@ { "kind" : "IdRef", "name" : "'x'" }, { "kind" : "IdRef", "name" : "'y'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "lastVersion" : "1.5" }, { "opname" : "OpOrdered", @@ -4109,7 +4110,7 @@ "SPV_KHR_terminate_invocation" ], "capabilities" : [ "Shader" ], - "version" : "None" + "version" : "1.6" }, { "opname" : "OpSubgroupBallotKHR", @@ -4182,6 +4183,21 @@ "capabilities" : [ "SubgroupVoteKHR" ], "version" : "None" }, + { + "opname" : "OpGroupNonUniformRotateKHR", + "class" : "Group", + "opcode" : 4431, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdScope", "name" : "'Execution'" }, + { "kind" : "IdRef", "name" : "'Value'" }, + { "kind" : "IdRef", "name" : "'Delta'" }, + { "kind" : "IdRef", "name" : "'ClusterSize'", "quantifier" : "?" } + ], + "capabilities" : [ "GroupNonUniformRotateKHR" ], + "version" : "None" + }, { "opname" : "OpSubgroupReadInvocationKHR", "class" : "Group", @@ -4260,6 +4276,20 @@ "extensions" : [ "SPV_KHR_ray_tracing" ], "version" : "None" }, + { + "opname" : "OpSDot", + "class" : "Arithmetic", + "opcode" : 4450, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Vector 1'" }, + { "kind" : "IdRef", "name" : "'Vector 2'" }, + { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } + ], + "capabilities" : [ "DotProduct" ], + "version" : "1.6" + }, { "opname" : "OpSDotKHR", "class" : "Arithmetic", @@ -4272,7 +4302,22 @@ { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } ], "capabilities" : [ "DotProductKHR" ], - "version" : "None" + "extensions" : [ "SPV_KHR_integer_dot_product" ], + "version" : "1.6" + }, + { + "opname" : "OpUDot", + "class" : "Arithmetic", + "opcode" : 4451, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Vector 1'" }, + { "kind" : "IdRef", "name" : "'Vector 2'" }, + { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } + ], + "capabilities" : [ "DotProduct" ], + "version" : "1.6" }, { "opname" : "OpUDotKHR", @@ -4286,7 +4331,22 @@ { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } ], "capabilities" : [ "DotProductKHR" ], - "version" : "None" + "extensions" : [ "SPV_KHR_integer_dot_product" ], + "version" : "1.6" + }, + { + "opname" : "OpSUDot", + "class" : "Arithmetic", + "opcode" : 4452, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Vector 1'" }, + { "kind" : "IdRef", "name" : "'Vector 2'" }, + { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } + ], + "capabilities" : [ "DotProduct" ], + "version" : "1.6" }, { "opname" : "OpSUDotKHR", @@ -4300,7 +4360,23 @@ { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } ], "capabilities" : [ "DotProductKHR" ], - "version" : "None" + "extensions" : [ "SPV_KHR_integer_dot_product" ], + "version" : "1.6" + }, + { + "opname" : "OpSDotAccSat", + "class" : "Arithmetic", + "opcode" : 4453, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Vector 1'" }, + { "kind" : "IdRef", "name" : "'Vector 2'" }, + { "kind" : "IdRef", "name" : "'Accumulator'" }, + { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } + ], + "capabilities" : [ "DotProduct" ], + "version" : "1.6" }, { "opname" : "OpSDotAccSatKHR", @@ -4315,7 +4391,23 @@ { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } ], "capabilities" : [ "DotProductKHR" ], - "version" : "None" + "extensions" : [ "SPV_KHR_integer_dot_product" ], + "version" : "1.6" + }, + { + "opname" : "OpUDotAccSat", + "class" : "Arithmetic", + "opcode" : 4454, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Vector 1'" }, + { "kind" : "IdRef", "name" : "'Vector 2'" }, + { "kind" : "IdRef", "name" : "'Accumulator'" }, + { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } + ], + "capabilities" : [ "DotProduct" ], + "version" : "1.6" }, { "opname" : "OpUDotAccSatKHR", @@ -4330,7 +4422,23 @@ { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } ], "capabilities" : [ "DotProductKHR" ], - "version" : "None" + "extensions" : [ "SPV_KHR_integer_dot_product" ], + "version" : "1.6" + }, + { + "opname" : "OpSUDotAccSat", + "class" : "Arithmetic", + "opcode" : 4455, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Vector 1'" }, + { "kind" : "IdRef", "name" : "'Vector 2'" }, + { "kind" : "IdRef", "name" : "'Accumulator'" }, + { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } + ], + "capabilities" : [ "DotProduct" ], + "version" : "1.6" }, { "opname" : "OpSUDotAccSatKHR", @@ -4345,7 +4453,8 @@ { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } ], "capabilities" : [ "DotProductKHR" ], - "version" : "None" + "extensions" : [ "SPV_KHR_integer_dot_product" ], + "version" : "1.6" }, { "opname" : "OpTypeRayQueryKHR", @@ -4924,13 +5033,19 @@ "extensions" : [ "SPV_EXT_fragment_shader_interlock" ], "version" : "None" }, + { + "opname" : "OpDemoteToHelperInvocation", + "class" : "Control-Flow", + "opcode" : 5380, + "capabilities" : [ "DemoteToHelperInvocation" ], + "version" : "1.6" + }, { "opname" : "OpDemoteToHelperInvocationEXT", - "class" : "Reserved", + "class" : "Control-Flow", "opcode" : 5380, "capabilities" : [ "DemoteToHelperInvocationEXT" ], - "extensions" : [ "SPV_EXT_demote_to_helper_invocation" ], - "version" : "None" + "version" : "1.6" }, { "opname" : "OpIsHelperInvocationEXT", @@ -7769,6 +7884,43 @@ "extensions" : [ "SPV_INTEL_unstructured_loop_controls" ], "version" : "None" }, + { + "opname" : "OpAliasDomainDeclINTEL", + "class" : "@exclude", + "opcode" : 5911, + "operands" : [ + { "kind" : "IdResult"}, + { "kind" : "IdRef", "quantifier" : "?", "name" : "'Name'" } + ], + "capabilities" : [ "MemoryAccessAliasingINTEL" ], + "extensions" : [ "SPV_INTEL_memory_access_aliasing" ], + "version" : "None" + }, + { + "opname" : "OpAliasScopeDeclINTEL", + "class" : "@exclude", + "opcode" : 5912, + "operands" : [ + { "kind" : "IdResult"}, + { "kind" : "IdRef", "name" : "'Alias Domain'"}, + { "kind" : "IdRef", "quantifier" : "?", "name" : "'Name'" } + ], + "capabilities" : [ "MemoryAccessAliasingINTEL" ], + "extensions" : [ "SPV_INTEL_memory_access_aliasing" ], + "version" : "None" + }, + { + "opname" : "OpAliasScopeListDeclINTEL", + "class" : "@exclude", + "opcode" : 5913, + "operands" : [ + { "kind" : "IdResult"}, + { "kind" : "IdRef", "quantifier" : "*", "name" : "'AliasScope1, AliasScope2, ...'" } + ], + "capabilities" : [ "MemoryAccessAliasingINTEL" ], + "extensions" : [ "SPV_INTEL_memory_access_aliasing" ], + "version" : "None" + }, { "opname" : "OpFixedSqrtINTEL", "class" : "@exclude", @@ -8412,6 +8564,142 @@ ], "capabilities" : [ "LongConstantCompositeINTEL" ], "version" : "None" + }, + { + "opname" : "OpControlBarrierArriveINTEL", + "class" : "Barrier", + "opcode" : 6142, + "operands" : [ + { "kind" : "IdScope", "name" : "'Execution'" }, + { "kind" : "IdScope", "name" : "'Memory'" }, + { "kind" : "IdMemorySemantics", "name" : "'Semantics'" } + ], + "capabilities" : [ "SplitBarrierINTEL" ], + "version" : "None" + }, + { + "opname" : "OpControlBarrierWaitINTEL", + "class" : "Barrier", + "opcode" : 6143, + "operands" : [ + { "kind" : "IdScope", "name" : "'Execution'" }, + { "kind" : "IdScope", "name" : "'Memory'" }, + { "kind" : "IdMemorySemantics", "name" : "'Semantics'" } + ], + "capabilities" : [ "SplitBarrierINTEL" ], + "version" : "None" + }, + { + "opname" : "OpGroupIMulKHR", + "class" : "Group", + "opcode" : 6401, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdScope", "name" : "'Execution'" }, + { "kind" : "GroupOperation", "name" : "'Operation'" }, + { "kind" : "IdRef", "name" : "'X'" } + ], + "capabilities" : [ "GroupUniformArithmeticKHR" ], + "version" : "None" + }, + { + "opname" : "OpGroupFMulKHR", + "class" : "Group", + "opcode" : 6402, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdScope", "name" : "'Execution'" }, + { "kind" : "GroupOperation", "name" : "'Operation'" }, + { "kind" : "IdRef", "name" : "'X'" } + ], + "capabilities" : [ "GroupUniformArithmeticKHR" ], + "version" : "None" + }, + { + "opname" : "OpGroupBitwiseAndKHR", + "class" : "Group", + "opcode" : 6403, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdScope", "name" : "'Execution'" }, + { "kind" : "GroupOperation", "name" : "'Operation'" }, + { "kind" : "IdRef", "name" : "'X'" } + ], + "capabilities" : [ "GroupUniformArithmeticKHR" ], + "version" : "None" + }, + { + "opname" : "OpGroupBitwiseOrKHR", + "class" : "Group", + "opcode" : 6404, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdScope", "name" : "'Execution'" }, + { "kind" : "GroupOperation", "name" : "'Operation'" }, + { "kind" : "IdRef", "name" : "'X'" } + ], + "capabilities" : [ "GroupUniformArithmeticKHR" ], + "version" : "None" + }, + { + "opname" : "OpGroupBitwiseXorKHR", + "class" : "Group", + "opcode" : 6405, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdScope", "name" : "'Execution'" }, + { "kind" : "GroupOperation", "name" : "'Operation'" }, + { "kind" : "IdRef", "name" : "'X'" } + ], + "capabilities" : [ "GroupUniformArithmeticKHR" ], + "version" : "None" + }, + { + "opname" : "OpGroupLogicalAndKHR", + "class" : "Group", + "opcode" : 6406, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdScope", "name" : "'Execution'" }, + { "kind" : "GroupOperation", "name" : "'Operation'" }, + { "kind" : "IdRef", "name" : "'X'" } + ], + "capabilities" : [ "GroupUniformArithmeticKHR" ], + "version" : "None" + }, + { + "opname" : "OpGroupLogicalOrKHR", + "class" : "Group", + "opcode" : 6407, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdScope", "name" : "'Execution'" }, + { "kind" : "GroupOperation", "name" : "'Operation'" }, + { "kind" : "IdRef", "name" : "'X'" } + ], + "capabilities" : [ "GroupUniformArithmeticKHR" ], + "version" : "None" + }, + { + "opname" : "OpGroupLogicalXorKHR", + "class" : "Group", + "opcode" : 6408, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdScope", "name" : "'Execution'" }, + { "kind" : "GroupOperation", "name" : "'Operation'" }, + { "kind" : "IdRef", "name" : "'X'" } + ], + "capabilities" : [ "GroupUniformArithmeticKHR" ], + "version" : "None" } ], "operand_kinds" : [ @@ -8558,6 +8846,11 @@ "value" : "0x2000", "version" : "1.4" }, + { + "enumerant" : "Nontemporal", + "value" : "0x4000", + "version" : "1.6" + }, { "enumerant" : "Offsets", "value" : "0x10000", @@ -8985,6 +9278,26 @@ "capabilities" : [ "VulkanMemoryModel" ], "extensions" : [ "SPV_KHR_vulkan_memory_model" ], "version" : "1.5" + }, + { + "enumerant" : "AliasScopeINTELMask", + "value" : "0x10000", + "parameters" : [ + { "kind" : "IdRef" } + ], + "capabilities" : [ "MemoryAccessAliasingINTEL" ], + "extensions" : [ "SPV_INTEL_memory_access_aliasing" ], + "version" : "None" + }, + { + "enumerant" : "NoAliasINTELMask", + "parameters" : [ + { "kind" : "IdRef" } + ], + "value" : "0x20000", + "capabilities" : [ "MemoryAccessAliasingINTEL" ], + "extensions" : [ "SPV_INTEL_memory_access_aliasing" ], + "version" : "None" } ] }, @@ -9136,6 +9449,10 @@ { "enumerant" : "CPP_for_OpenCL", "value" : 6 + }, + { + "enumerant" : "SYCL", + "value" : 7 } ] }, @@ -9812,6 +10129,15 @@ ], "capabilities" : [ "FPGAKernelAttributesINTEL" ], "version" : "None" + }, + { + "enumerant" : "NamedBarrierCountINTEL", + "value" : 6417, + "parameters" : [ + { "kind" : "LiteralInteger", "name" : "'Barrier Count'" } + ], + "capabilities" : [ "VectorComputeINTEL" ], + "version" : "None" } ] }, @@ -10877,12 +11203,12 @@ { "enumerant" : "Uniform", "value" : 26, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader", "UniformDecoration" ] }, { "enumerant" : "UniformId", "value" : 27, - "capabilities" : [ "Shader" ], + "capabilities" : [ "Shader", "UniformDecoration" ], "parameters" : [ { "kind" : "IdScope", "name" : "'Execution'" } ], @@ -11114,11 +11440,18 @@ "extensions" : [ "SPV_NV_mesh_shader" ], "version" : "None" }, + { + "enumerant" : "PerVertexKHR", + "value" : 5285, + "capabilities" : [ "FragmentBarycentricNV", "FragmentBarycentricKHR" ], + "extensions" : [ "SPV_NV_fragment_shader_barycentric", "SPV_KHR_fragment_shader_barycentric" ], + "version" : "None" + }, { "enumerant" : "PerVertexNV", "value" : 5285, - "capabilities" : [ "FragmentBarycentricNV" ], - "extensions" : [ "SPV_NV_fragment_shader_barycentric" ], + "capabilities" : [ "FragmentBarycentricNV", "FragmentBarycentricKHR" ], + "extensions" : [ "SPV_NV_fragment_shader_barycentric", "SPV_KHR_fragment_shader_barycentric" ], "version" : "None" }, { @@ -11467,6 +11800,24 @@ "capabilities" : [ "LoopFuseINTEL" ], "version" : "None" }, + { + "enumerant" : "AliasScopeINTEL", + "value" : 5914, + "parameters" : [ + { "kind" : "IdRef", "name" : "'Aliasing Scopes List'" } + ], + "capabilities" : [ "MemoryAccessAliasingINTEL" ], + "version" : "None" + }, + { + "enumerant" : "NoAliasINTEL", + "value" : 5915, + "parameters" : [ + { "kind" : "IdRef", "name" : "'Aliasing Scopes List'" } + ], + "capabilities" : [ "MemoryAccessAliasingINTEL" ], + "version" : "None" + }, { "enumerant" : "BufferLocationINTEL", "value" : 5921, @@ -11506,6 +11857,12 @@ "value" : 6087, "capabilities" : [ "VectorComputeINTEL" ], "version" : "None" + }, + { + "enumerant" : "MediaBlockIOINTEL", + "value" : 6140, + "capabilities" : [ "VectorComputeINTEL" ], + "version" : "None" } ] }, @@ -11973,18 +12330,32 @@ "extensions" : [ "SPV_NV_mesh_shader" ], "version" : "None" }, + { + "enumerant" : "BaryCoordKHR", + "value" : 5286, + "capabilities" : [ "FragmentBarycentricNV", "FragmentBarycentricKHR" ], + "extensions" : [ "SPV_NV_fragment_shader_barycentric", "SPV_KHR_fragment_shader_barycentric" ], + "version" : "None" + }, { "enumerant" : "BaryCoordNV", "value" : 5286, - "capabilities" : [ "FragmentBarycentricNV" ], - "extensions" : [ "SPV_NV_fragment_shader_barycentric" ], + "capabilities" : [ "FragmentBarycentricNV", "FragmentBarycentricKHR" ], + "extensions" : [ "SPV_NV_fragment_shader_barycentric", "SPV_KHR_fragment_shader_barycentric" ], + "version" : "None" + }, + { + "enumerant" : "BaryCoordNoPerspKHR", + "value" : 5287, + "capabilities" : [ "FragmentBarycentricNV", "FragmentBarycentricKHR" ], + "extensions" : [ "SPV_NV_fragment_shader_barycentric", "SPV_KHR_fragment_shader_barycentric" ], "version" : "None" }, { "enumerant" : "BaryCoordNoPerspNV", "value" : 5287, - "capabilities" : [ "FragmentBarycentricNV" ], - "extensions" : [ "SPV_NV_fragment_shader_barycentric" ], + "capabilities" : [ "FragmentBarycentricNV", "FragmentBarycentricKHR" ], + "extensions" : [ "SPV_NV_fragment_shader_barycentric", "SPV_KHR_fragment_shader_barycentric" ], "version" : "None" }, { @@ -12245,6 +12616,13 @@ "capabilities" : [ "ShaderSMBuiltinsNV" ], "extensions" : [ "SPV_NV_shader_sm_builtins" ], "version" : "None" + }, + { + "enumerant" : "CullMaskKHR", + "value" : 6021, + "capabilities" : [ "RayCullMaskKHR" ], + "extensions" : [ "SPV_KHR_ray_cull_mask" ], + "version" : "None" } ] }, @@ -12709,6 +13087,11 @@ "value" : 70, "version" : "1.5" }, + { + "enumerant" : "UniformDecoration", + "value" : 71, + "version" : "1.6" + }, { "enumerant" : "FragmentShadingRateKHR", "value" : 4422, @@ -13034,10 +13417,16 @@ "extensions" : [ "SPV_NV_shader_image_footprint" ], "version" : "None" }, + { + "enumerant" : "FragmentBarycentricKHR", + "value" : 5284, + "extensions" : [ "SPV_NV_fragment_shader_barycentric", "SPV_KHR_fragment_shader_barycentric" ], + "version" : "None" + }, { "enumerant" : "FragmentBarycentricNV", "value" : 5284, - "extensions" : [ "SPV_NV_fragment_shader_barycentric" ], + "extensions" : [ "SPV_NV_fragment_shader_barycentric", "SPV_KHR_fragment_shader_barycentric" ], "version" : "None" }, { @@ -13320,12 +13709,18 @@ "extensions" : [ "SPV_EXT_fragment_shader_interlock" ], "version" : "None" }, + { + "enumerant" : "DemoteToHelperInvocation", + "value" : 5379, + "capabilities" : [ "Shader" ], + "version" : "1.6" + }, { "enumerant" : "DemoteToHelperInvocationEXT", "value" : 5379, "capabilities" : [ "Shader" ], "extensions" : [ "SPV_EXT_demote_to_helper_invocation" ], - "version" : "None" + "version" : "1.6" }, { "enumerant" : "BindlessTextureNV", @@ -13528,6 +13923,12 @@ "extensions" : [ "SPV_INTEL_loop_fuse" ], "version" : "None" }, + { + "enumerant" : "MemoryAccessAliasingINTEL", + "value" : 5910, + "extensions" : [ "SPV_INTEL_memory_access_aliasing" ], + "version" : "None" + }, { "enumerant" : "FPGABufferLocationINTEL", "value" : 5920, @@ -13564,29 +13965,56 @@ "extensions" : [ "SPV_INTEL_fpga_reg" ], "version" : "None" }, + { + "enumerant" : "DotProductInputAll", + "value" : 6016, + "version" : "1.6" + }, { "enumerant" : "DotProductInputAllKHR", "value" : 6016, "extensions" : [ "SPV_KHR_integer_dot_product" ], - "version" : "None" + "version" : "1.6" + }, + { + "enumerant" : "DotProductInput4x8Bit", + "value" : 6017, + "capabilities" : [ "Int8" ], + "version" : "1.6" }, { "enumerant" : "DotProductInput4x8BitKHR", "value" : 6017, "capabilities" : [ "Int8" ], "extensions" : [ "SPV_KHR_integer_dot_product" ], - "version" : "None" + "version" : "1.6" + }, + { + "enumerant" : "DotProductInput4x8BitPacked", + "value" : 6018, + "version" : "1.6" }, { "enumerant" : "DotProductInput4x8BitPackedKHR", "value" : 6018, "extensions" : [ "SPV_KHR_integer_dot_product" ], - "version" : "None" + "version" : "1.6" + }, + { + "enumerant" : "DotProduct", + "value" : 6019, + "version" : "1.6" }, { "enumerant" : "DotProductKHR", "value" : 6019, "extensions" : [ "SPV_KHR_integer_dot_product" ], + "version" : "1.6" + }, + { + "enumerant" : "RayCullMaskKHR", + "value" : 6020, + "extensions" : [ "SPV_KHR_ray_cull_mask" ], "version" : "None" }, { @@ -13595,17 +14023,22 @@ "extensions" : [ "SPV_KHR_bit_instructions" ], "version" : "None" }, + { + "enumerant" : "GroupNonUniformRotateKHR", + "value" : 6026, + "capabilities" : [ "GroupNonUniform" ], + "extensions" : [ "SPV_KHR_subgroup_rotate" ], + "version" : "None" + }, { "enumerant" : "AtomicFloat32AddEXT", "value" : 6033, - "capabilities" : [ "Shader" ], "extensions" : [ "SPV_EXT_shader_atomic_float_add" ], "version" : "None" }, { "enumerant" : "AtomicFloat64AddEXT", "value" : 6034, - "capabilities" : [ "Shader" ], "extensions" : [ "SPV_EXT_shader_atomic_float_add" ], "version" : "None" }, @@ -13624,7 +14057,6 @@ { "enumerant" : "AtomicFloat16AddEXT", "value" : 6095, - "capabilities" : [ "Shader" ], "extensions" : [ "SPV_EXT_shader_atomic_float16_add" ], "version" : "None" }, @@ -13633,6 +14065,18 @@ "value" : 6114, "extensions" : [ "SPV_INTEL_debug_module" ], "version" : "None" + }, + { + "enumerant" : "SplitBarrierINTEL", + "value" : 6141, + "extensions" : [ "SPV_INTEL_split_barrier" ], + "version" : "None" + }, + { + "enumerant" : "GroupUniformArithmeticKHR", + "value" : 6400, + "extensions" : [ "SPV_KHR_uniform_group_instructions"], + "version" : "None" } ] }, @@ -13700,11 +14144,16 @@ "category" : "ValueEnum", "kind" : "PackedVectorFormat", "enumerants" : [ + { + "enumerant" : "PackedVectorFormat4x8Bit", + "value" : 0, + "version" : "1.6" + }, { "enumerant" : "PackedVectorFormat4x8BitKHR", "value" : 0, "extensions" : [ "SPV_KHR_integer_dot_product" ], - "version" : "None" + "version" : "1.6" } ] }, diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.cs b/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.cs index fd007ee5b7..73701e0e1d 100644 --- a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.cs +++ b/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.cs @@ -26,7 +26,7 @@ // the Binary Section of the SPIR-V specification. // Enumeration tokens for SPIR-V, in various styles: -// C, C++, C++11, JSON, Lua, Python, C#, D +// C, C++, C++11, JSON, Lua, Python, C#, D, Beef // // - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL // - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL @@ -36,6 +36,8 @@ // - C# will use enum classes in the Specification class located in the "Spv" namespace, // e.g.: Spv.Specification.SourceLanguage.GLSL // - D will have tokens under the "spv" module, e.g: spv.SourceLanguage.GLSL +// - Beef will use enum classes in the Specification class located in the "Spv" namespace, +// e.g.: Spv.Specification.SourceLanguage.GLSL // // Some tokens act like mask values, which can be OR'd together, // while others are mutually exclusive. The mask-like ones have @@ -48,8 +50,8 @@ namespace Spv public static class Specification { public const uint MagicNumber = 0x07230203; - public const uint Version = 0x00010500; - public const uint Revision = 4; + public const uint Version = 0x00010600; + public const uint Revision = 1; public const uint OpCodeMask = 0xffff; public const uint WordCountShift = 16; @@ -62,6 +64,7 @@ namespace Spv OpenCL_CPP = 4, HLSL = 5, CPP_for_OpenCL = 6, + SYCL = 7, } public enum ExecutionModel @@ -176,6 +179,7 @@ namespace Spv NoGlobalOffsetINTEL = 5895, NumSIMDWorkitemsINTEL = 5896, SchedulerTargetFmaxMhzINTEL = 5903, + NamedBarrierCountINTEL = 6417, } public enum StorageClass @@ -349,6 +353,7 @@ namespace Spv VolatileTexelKHR = 11, SignExtend = 12, ZeroExtend = 13, + Nontemporal = 14, Offsets = 16, } @@ -373,6 +378,7 @@ namespace Spv VolatileTexelKHR = 0x00000800, SignExtend = 0x00001000, ZeroExtend = 0x00002000, + Nontemporal = 0x00004000, Offsets = 0x00010000, } @@ -492,6 +498,7 @@ namespace Spv PerPrimitiveNV = 5271, PerViewNV = 5272, PerTaskNV = 5273, + PerVertexKHR = 5285, PerVertexNV = 5285, NonUniform = 5300, NonUniformEXT = 5300, @@ -537,11 +544,14 @@ namespace Spv PrefetchINTEL = 5902, StallEnableINTEL = 5905, FuseLoopsInFunctionINTEL = 5907, + AliasScopeINTEL = 5914, + NoAliasINTEL = 5915, BufferLocationINTEL = 5921, IOPipeStorageINTEL = 5944, FunctionFloatingPointModeINTEL = 6080, SingleElementVectorINTEL = 6085, VectorComputeCallableFunctionINTEL = 6087, + MediaBlockIOINTEL = 6140, } public enum BuiltIn @@ -626,7 +636,9 @@ namespace Spv LayerPerViewNV = 5279, MeshViewCountNV = 5280, MeshViewIndicesNV = 5281, + BaryCoordKHR = 5286, BaryCoordNV = 5286, + BaryCoordNoPerspKHR = 5287, BaryCoordNoPerspNV = 5287, FragSizeEXT = 5292, FragmentSizeNV = 5292, @@ -665,6 +677,7 @@ namespace Spv SMCountNV = 5375, WarpIDNV = 5376, SMIDNV = 5377, + CullMaskKHR = 6021, } public enum SelectionControlShift @@ -796,6 +809,8 @@ namespace Spv MakePointerVisibleKHR = 4, NonPrivatePointer = 5, NonPrivatePointerKHR = 5, + AliasScopeINTELMask = 16, + NoAliasINTELMask = 17, } public enum MemoryAccessMask @@ -810,6 +825,8 @@ namespace Spv MakePointerVisibleKHR = 0x00000010, NonPrivatePointer = 0x00000020, NonPrivatePointerKHR = 0x00000020, + AliasScopeINTELMask = 0x00010000, + NoAliasINTELMask = 0x00020000, } public enum Scope @@ -924,6 +941,7 @@ namespace Spv GroupNonUniformQuad = 68, ShaderLayer = 69, ShaderViewportIndex = 70, + UniformDecoration = 71, FragmentShadingRateKHR = 4422, SubgroupBallotKHR = 4423, DrawParameters = 4427, @@ -972,6 +990,7 @@ namespace Spv FragmentFullyCoveredEXT = 5265, MeshShadingNV = 5266, ImageFootprintNV = 5282, + FragmentBarycentricKHR = 5284, FragmentBarycentricNV = 5284, ComputeDerivativeGroupQuadsNV = 5288, FragmentDensityEXT = 5291, @@ -1016,6 +1035,7 @@ namespace Spv FragmentShaderShadingRateInterlockEXT = 5372, ShaderSMBuiltinsNV = 5373, FragmentShaderPixelInterlockEXT = 5378, + DemoteToHelperInvocation = 5379, DemoteToHelperInvocationEXT = 5379, BindlessTextureNV = 5390, SubgroupShuffleINTEL = 5568, @@ -1050,23 +1070,32 @@ namespace Spv FPGAMemoryAccessesINTEL = 5898, FPGAClusterAttributesINTEL = 5904, LoopFuseINTEL = 5906, + MemoryAccessAliasingINTEL = 5910, FPGABufferLocationINTEL = 5920, ArbitraryPrecisionFixedPointINTEL = 5922, USMStorageClassesINTEL = 5935, IOPipesINTEL = 5943, BlockingPipesINTEL = 5945, FPGARegINTEL = 5948, + DotProductInputAll = 6016, DotProductInputAllKHR = 6016, + DotProductInput4x8Bit = 6017, DotProductInput4x8BitKHR = 6017, + DotProductInput4x8BitPacked = 6018, DotProductInput4x8BitPackedKHR = 6018, + DotProduct = 6019, DotProductKHR = 6019, + RayCullMaskKHR = 6020, BitInstructions = 6025, + GroupNonUniformRotateKHR = 6026, AtomicFloat32AddEXT = 6033, AtomicFloat64AddEXT = 6034, LongConstantCompositeINTEL = 6089, OptNoneINTEL = 6094, AtomicFloat16AddEXT = 6095, DebugInfoModuleINTEL = 6114, + SplitBarrierINTEL = 6141, + GroupUniformArithmeticKHR = 6400, } public enum RayFlagsShift @@ -1168,6 +1197,7 @@ namespace Spv public enum PackedVectorFormat { + PackedVectorFormat4x8Bit = 0, PackedVectorFormat4x8BitKHR = 0, } @@ -1523,17 +1553,24 @@ namespace Spv OpSubgroupAllKHR = 4428, OpSubgroupAnyKHR = 4429, OpSubgroupAllEqualKHR = 4430, + OpGroupNonUniformRotateKHR = 4431, OpSubgroupReadInvocationKHR = 4432, OpTraceRayKHR = 4445, OpExecuteCallableKHR = 4446, OpConvertUToAccelerationStructureKHR = 4447, OpIgnoreIntersectionKHR = 4448, OpTerminateRayKHR = 4449, + OpSDot = 4450, OpSDotKHR = 4450, + OpUDot = 4451, OpUDotKHR = 4451, + OpSUDot = 4452, OpSUDotKHR = 4452, + OpSDotAccSat = 4453, OpSDotAccSatKHR = 4453, + OpUDotAccSat = 4454, OpUDotAccSatKHR = 4454, + OpSUDotAccSat = 4455, OpSUDotAccSatKHR = 4455, OpTypeRayQueryKHR = 4472, OpRayQueryInitializeKHR = 4473, @@ -1573,6 +1610,7 @@ namespace Spv OpCooperativeMatrixLengthNV = 5362, OpBeginInvocationInterlockEXT = 5364, OpEndInvocationInterlockEXT = 5365, + OpDemoteToHelperInvocation = 5380, OpDemoteToHelperInvocationEXT = 5380, OpIsHelperInvocationEXT = 5381, OpConvertUToImageNV = 5391, @@ -1782,6 +1820,9 @@ namespace Spv OpArbitraryFloatPowRINTEL = 5881, OpArbitraryFloatPowNINTEL = 5882, OpLoopControlINTEL = 5887, + OpAliasDomainDeclINTEL = 5911, + OpAliasScopeDeclINTEL = 5912, + OpAliasScopeListDeclINTEL = 5913, OpFixedSqrtINTEL = 5923, OpFixedRecipINTEL = 5924, OpFixedRsqrtINTEL = 5925, @@ -1820,6 +1861,16 @@ namespace Spv OpTypeStructContinuedINTEL = 6090, OpConstantCompositeContinuedINTEL = 6091, OpSpecConstantCompositeContinuedINTEL = 6092, + OpControlBarrierArriveINTEL = 6142, + OpControlBarrierWaitINTEL = 6143, + OpGroupIMulKHR = 6401, + OpGroupFMulKHR = 6402, + OpGroupBitwiseAndKHR = 6403, + OpGroupBitwiseOrKHR = 6404, + OpGroupBitwiseXorKHR = 6405, + OpGroupLogicalAndKHR = 6406, + OpGroupLogicalOrKHR = 6407, + OpGroupLogicalXorKHR = 6408, } } } diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.h b/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.h index 32e5b73efb..38f558748c 100644 --- a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.h +++ b/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.h @@ -31,7 +31,7 @@ /* ** Enumeration tokens for SPIR-V, in various styles: -** C, C++, C++11, JSON, Lua, Python, C#, D +** C, C++, C++11, JSON, Lua, Python, C#, D, Beef ** ** - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL ** - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL @@ -41,6 +41,8 @@ ** - C# will use enum classes in the Specification class located in the "Spv" namespace, ** e.g.: Spv.Specification.SourceLanguage.GLSL ** - D will have tokens under the "spv" module, e.g: spv.SourceLanguage.GLSL +** - Beef will use enum classes in the Specification class located in the "Spv" namespace, +** e.g.: Spv.Specification.SourceLanguage.GLSL ** ** Some tokens act like mask values, which can be OR'd together, ** while others are mutually exclusive. The mask-like ones have @@ -53,12 +55,12 @@ typedef unsigned int SpvId; -#define SPV_VERSION 0x10500 -#define SPV_REVISION 4 +#define SPV_VERSION 0x10600 +#define SPV_REVISION 1 static const unsigned int SpvMagicNumber = 0x07230203; -static const unsigned int SpvVersion = 0x00010500; -static const unsigned int SpvRevision = 4; +static const unsigned int SpvVersion = 0x00010600; +static const unsigned int SpvRevision = 1; static const unsigned int SpvOpCodeMask = 0xffff; static const unsigned int SpvWordCountShift = 16; @@ -70,6 +72,7 @@ typedef enum SpvSourceLanguage_ { SpvSourceLanguageOpenCL_CPP = 4, SpvSourceLanguageHLSL = 5, SpvSourceLanguageCPP_for_OpenCL = 6, + SpvSourceLanguageSYCL = 7, SpvSourceLanguageMax = 0x7fffffff, } SpvSourceLanguage; @@ -184,6 +187,7 @@ typedef enum SpvExecutionMode_ { SpvExecutionModeNoGlobalOffsetINTEL = 5895, SpvExecutionModeNumSIMDWorkitemsINTEL = 5896, SpvExecutionModeSchedulerTargetFmaxMhzINTEL = 5903, + SpvExecutionModeNamedBarrierCountINTEL = 6417, SpvExecutionModeMax = 0x7fffffff, } SpvExecutionMode; @@ -357,6 +361,7 @@ typedef enum SpvImageOperandsShift_ { SpvImageOperandsVolatileTexelKHRShift = 11, SpvImageOperandsSignExtendShift = 12, SpvImageOperandsZeroExtendShift = 13, + SpvImageOperandsNontemporalShift = 14, SpvImageOperandsOffsetsShift = 16, SpvImageOperandsMax = 0x7fffffff, } SpvImageOperandsShift; @@ -381,6 +386,7 @@ typedef enum SpvImageOperandsMask_ { SpvImageOperandsVolatileTexelKHRMask = 0x00000800, SpvImageOperandsSignExtendMask = 0x00001000, SpvImageOperandsZeroExtendMask = 0x00002000, + SpvImageOperandsNontemporalMask = 0x00004000, SpvImageOperandsOffsetsMask = 0x00010000, } SpvImageOperandsMask; @@ -498,6 +504,7 @@ typedef enum SpvDecoration_ { SpvDecorationPerPrimitiveNV = 5271, SpvDecorationPerViewNV = 5272, SpvDecorationPerTaskNV = 5273, + SpvDecorationPerVertexKHR = 5285, SpvDecorationPerVertexNV = 5285, SpvDecorationNonUniform = 5300, SpvDecorationNonUniformEXT = 5300, @@ -543,11 +550,14 @@ typedef enum SpvDecoration_ { SpvDecorationPrefetchINTEL = 5902, SpvDecorationStallEnableINTEL = 5905, SpvDecorationFuseLoopsInFunctionINTEL = 5907, + SpvDecorationAliasScopeINTEL = 5914, + SpvDecorationNoAliasINTEL = 5915, SpvDecorationBufferLocationINTEL = 5921, SpvDecorationIOPipeStorageINTEL = 5944, SpvDecorationFunctionFloatingPointModeINTEL = 6080, SpvDecorationSingleElementVectorINTEL = 6085, SpvDecorationVectorComputeCallableFunctionINTEL = 6087, + SpvDecorationMediaBlockIOINTEL = 6140, SpvDecorationMax = 0x7fffffff, } SpvDecoration; @@ -632,7 +642,9 @@ typedef enum SpvBuiltIn_ { SpvBuiltInLayerPerViewNV = 5279, SpvBuiltInMeshViewCountNV = 5280, SpvBuiltInMeshViewIndicesNV = 5281, + SpvBuiltInBaryCoordKHR = 5286, SpvBuiltInBaryCoordNV = 5286, + SpvBuiltInBaryCoordNoPerspKHR = 5287, SpvBuiltInBaryCoordNoPerspNV = 5287, SpvBuiltInFragSizeEXT = 5292, SpvBuiltInFragmentSizeNV = 5292, @@ -671,6 +683,7 @@ typedef enum SpvBuiltIn_ { SpvBuiltInSMCountNV = 5375, SpvBuiltInWarpIDNV = 5376, SpvBuiltInSMIDNV = 5377, + SpvBuiltInCullMaskKHR = 6021, SpvBuiltInMax = 0x7fffffff, } SpvBuiltIn; @@ -798,6 +811,8 @@ typedef enum SpvMemoryAccessShift_ { SpvMemoryAccessMakePointerVisibleKHRShift = 4, SpvMemoryAccessNonPrivatePointerShift = 5, SpvMemoryAccessNonPrivatePointerKHRShift = 5, + SpvMemoryAccessAliasScopeINTELMaskShift = 16, + SpvMemoryAccessNoAliasINTELMaskShift = 17, SpvMemoryAccessMax = 0x7fffffff, } SpvMemoryAccessShift; @@ -812,6 +827,8 @@ typedef enum SpvMemoryAccessMask_ { SpvMemoryAccessMakePointerVisibleKHRMask = 0x00000010, SpvMemoryAccessNonPrivatePointerMask = 0x00000020, SpvMemoryAccessNonPrivatePointerKHRMask = 0x00000020, + SpvMemoryAccessAliasScopeINTELMaskMask = 0x00010000, + SpvMemoryAccessNoAliasINTELMaskMask = 0x00020000, } SpvMemoryAccessMask; typedef enum SpvScope_ { @@ -924,6 +941,7 @@ typedef enum SpvCapability_ { SpvCapabilityGroupNonUniformQuad = 68, SpvCapabilityShaderLayer = 69, SpvCapabilityShaderViewportIndex = 70, + SpvCapabilityUniformDecoration = 71, SpvCapabilityFragmentShadingRateKHR = 4422, SpvCapabilitySubgroupBallotKHR = 4423, SpvCapabilityDrawParameters = 4427, @@ -972,6 +990,7 @@ typedef enum SpvCapability_ { SpvCapabilityFragmentFullyCoveredEXT = 5265, SpvCapabilityMeshShadingNV = 5266, SpvCapabilityImageFootprintNV = 5282, + SpvCapabilityFragmentBarycentricKHR = 5284, SpvCapabilityFragmentBarycentricNV = 5284, SpvCapabilityComputeDerivativeGroupQuadsNV = 5288, SpvCapabilityFragmentDensityEXT = 5291, @@ -1016,6 +1035,7 @@ typedef enum SpvCapability_ { SpvCapabilityFragmentShaderShadingRateInterlockEXT = 5372, SpvCapabilityShaderSMBuiltinsNV = 5373, SpvCapabilityFragmentShaderPixelInterlockEXT = 5378, + SpvCapabilityDemoteToHelperInvocation = 5379, SpvCapabilityDemoteToHelperInvocationEXT = 5379, SpvCapabilityBindlessTextureNV = 5390, SpvCapabilitySubgroupShuffleINTEL = 5568, @@ -1050,23 +1070,32 @@ typedef enum SpvCapability_ { SpvCapabilityFPGAMemoryAccessesINTEL = 5898, SpvCapabilityFPGAClusterAttributesINTEL = 5904, SpvCapabilityLoopFuseINTEL = 5906, + SpvCapabilityMemoryAccessAliasingINTEL = 5910, SpvCapabilityFPGABufferLocationINTEL = 5920, SpvCapabilityArbitraryPrecisionFixedPointINTEL = 5922, SpvCapabilityUSMStorageClassesINTEL = 5935, SpvCapabilityIOPipesINTEL = 5943, SpvCapabilityBlockingPipesINTEL = 5945, SpvCapabilityFPGARegINTEL = 5948, + SpvCapabilityDotProductInputAll = 6016, SpvCapabilityDotProductInputAllKHR = 6016, + SpvCapabilityDotProductInput4x8Bit = 6017, SpvCapabilityDotProductInput4x8BitKHR = 6017, + SpvCapabilityDotProductInput4x8BitPacked = 6018, SpvCapabilityDotProductInput4x8BitPackedKHR = 6018, + SpvCapabilityDotProduct = 6019, SpvCapabilityDotProductKHR = 6019, + SpvCapabilityRayCullMaskKHR = 6020, SpvCapabilityBitInstructions = 6025, + SpvCapabilityGroupNonUniformRotateKHR = 6026, SpvCapabilityAtomicFloat32AddEXT = 6033, SpvCapabilityAtomicFloat64AddEXT = 6034, SpvCapabilityLongConstantCompositeINTEL = 6089, SpvCapabilityOptNoneINTEL = 6094, SpvCapabilityAtomicFloat16AddEXT = 6095, SpvCapabilityDebugInfoModuleINTEL = 6114, + SpvCapabilitySplitBarrierINTEL = 6141, + SpvCapabilityGroupUniformArithmeticKHR = 6400, SpvCapabilityMax = 0x7fffffff, } SpvCapability; @@ -1166,6 +1195,7 @@ typedef enum SpvOverflowModes_ { } SpvOverflowModes; typedef enum SpvPackedVectorFormat_ { + SpvPackedVectorFormatPackedVectorFormat4x8Bit = 0, SpvPackedVectorFormatPackedVectorFormat4x8BitKHR = 0, SpvPackedVectorFormatMax = 0x7fffffff, } SpvPackedVectorFormat; @@ -1521,17 +1551,24 @@ typedef enum SpvOp_ { SpvOpSubgroupAllKHR = 4428, SpvOpSubgroupAnyKHR = 4429, SpvOpSubgroupAllEqualKHR = 4430, + SpvOpGroupNonUniformRotateKHR = 4431, SpvOpSubgroupReadInvocationKHR = 4432, SpvOpTraceRayKHR = 4445, SpvOpExecuteCallableKHR = 4446, SpvOpConvertUToAccelerationStructureKHR = 4447, SpvOpIgnoreIntersectionKHR = 4448, SpvOpTerminateRayKHR = 4449, + SpvOpSDot = 4450, SpvOpSDotKHR = 4450, + SpvOpUDot = 4451, SpvOpUDotKHR = 4451, + SpvOpSUDot = 4452, SpvOpSUDotKHR = 4452, + SpvOpSDotAccSat = 4453, SpvOpSDotAccSatKHR = 4453, + SpvOpUDotAccSat = 4454, SpvOpUDotAccSatKHR = 4454, + SpvOpSUDotAccSat = 4455, SpvOpSUDotAccSatKHR = 4455, SpvOpTypeRayQueryKHR = 4472, SpvOpRayQueryInitializeKHR = 4473, @@ -1571,6 +1608,7 @@ typedef enum SpvOp_ { SpvOpCooperativeMatrixLengthNV = 5362, SpvOpBeginInvocationInterlockEXT = 5364, SpvOpEndInvocationInterlockEXT = 5365, + SpvOpDemoteToHelperInvocation = 5380, SpvOpDemoteToHelperInvocationEXT = 5380, SpvOpIsHelperInvocationEXT = 5381, SpvOpConvertUToImageNV = 5391, @@ -1780,6 +1818,9 @@ typedef enum SpvOp_ { SpvOpArbitraryFloatPowRINTEL = 5881, SpvOpArbitraryFloatPowNINTEL = 5882, SpvOpLoopControlINTEL = 5887, + SpvOpAliasDomainDeclINTEL = 5911, + SpvOpAliasScopeDeclINTEL = 5912, + SpvOpAliasScopeListDeclINTEL = 5913, SpvOpFixedSqrtINTEL = 5923, SpvOpFixedRecipINTEL = 5924, SpvOpFixedRsqrtINTEL = 5925, @@ -1818,10 +1859,23 @@ typedef enum SpvOp_ { SpvOpTypeStructContinuedINTEL = 6090, SpvOpConstantCompositeContinuedINTEL = 6091, SpvOpSpecConstantCompositeContinuedINTEL = 6092, + SpvOpControlBarrierArriveINTEL = 6142, + SpvOpControlBarrierWaitINTEL = 6143, + SpvOpGroupIMulKHR = 6401, + SpvOpGroupFMulKHR = 6402, + SpvOpGroupBitwiseAndKHR = 6403, + SpvOpGroupBitwiseOrKHR = 6404, + SpvOpGroupBitwiseXorKHR = 6405, + SpvOpGroupLogicalAndKHR = 6406, + SpvOpGroupLogicalOrKHR = 6407, + SpvOpGroupLogicalXorKHR = 6408, SpvOpMax = 0x7fffffff, } SpvOp; #ifdef SPV_ENABLE_UTILITY_CODE +#ifndef __cplusplus +#include +#endif inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultType) { *hasResult = *hasResultType = false; switch (opcode) { @@ -2176,18 +2230,19 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpSubgroupAllKHR: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupAnyKHR: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupAllEqualKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformRotateKHR: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupReadInvocationKHR: *hasResult = true; *hasResultType = true; break; case SpvOpTraceRayKHR: *hasResult = false; *hasResultType = false; break; case SpvOpExecuteCallableKHR: *hasResult = false; *hasResultType = false; break; case SpvOpConvertUToAccelerationStructureKHR: *hasResult = true; *hasResultType = true; break; case SpvOpIgnoreIntersectionKHR: *hasResult = false; *hasResultType = false; break; case SpvOpTerminateRayKHR: *hasResult = false; *hasResultType = false; break; - case SpvOpSDotKHR: *hasResult = true; *hasResultType = true; break; - case SpvOpUDotKHR: *hasResult = true; *hasResultType = true; break; - case SpvOpSUDotKHR: *hasResult = true; *hasResultType = true; break; - case SpvOpSDotAccSatKHR: *hasResult = true; *hasResultType = true; break; - case SpvOpUDotAccSatKHR: *hasResult = true; *hasResultType = true; break; - case SpvOpSUDotAccSatKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpSDot: *hasResult = true; *hasResultType = true; break; + case SpvOpUDot: *hasResult = true; *hasResultType = true; break; + case SpvOpSUDot: *hasResult = true; *hasResultType = true; break; + case SpvOpSDotAccSat: *hasResult = true; *hasResultType = true; break; + case SpvOpUDotAccSat: *hasResult = true; *hasResultType = true; break; + case SpvOpSUDotAccSat: *hasResult = true; *hasResultType = true; break; case SpvOpTypeRayQueryKHR: *hasResult = true; *hasResultType = false; break; case SpvOpRayQueryInitializeKHR: *hasResult = false; *hasResultType = false; break; case SpvOpRayQueryTerminateKHR: *hasResult = false; *hasResultType = false; break; @@ -2224,7 +2279,7 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpCooperativeMatrixLengthNV: *hasResult = true; *hasResultType = true; break; case SpvOpBeginInvocationInterlockEXT: *hasResult = false; *hasResultType = false; break; case SpvOpEndInvocationInterlockEXT: *hasResult = false; *hasResultType = false; break; - case SpvOpDemoteToHelperInvocationEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpDemoteToHelperInvocation: *hasResult = false; *hasResultType = false; break; case SpvOpIsHelperInvocationEXT: *hasResult = true; *hasResultType = true; break; case SpvOpConvertUToImageNV: *hasResult = true; *hasResultType = true; break; case SpvOpConvertUToSamplerNV: *hasResult = true; *hasResultType = true; break; @@ -2431,6 +2486,9 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpArbitraryFloatPowRINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpArbitraryFloatPowNINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpLoopControlINTEL: *hasResult = false; *hasResultType = false; break; + case SpvOpAliasDomainDeclINTEL: *hasResult = true; *hasResultType = false; break; + case SpvOpAliasScopeDeclINTEL: *hasResult = true; *hasResultType = false; break; + case SpvOpAliasScopeListDeclINTEL: *hasResult = true; *hasResultType = false; break; case SpvOpFixedSqrtINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpFixedRecipINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpFixedRsqrtINTEL: *hasResult = true; *hasResultType = true; break; @@ -2469,6 +2527,16 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpTypeStructContinuedINTEL: *hasResult = false; *hasResultType = false; break; case SpvOpConstantCompositeContinuedINTEL: *hasResult = false; *hasResultType = false; break; case SpvOpSpecConstantCompositeContinuedINTEL: *hasResult = false; *hasResultType = false; break; + case SpvOpControlBarrierArriveINTEL: *hasResult = false; *hasResultType = false; break; + case SpvOpControlBarrierWaitINTEL: *hasResult = false; *hasResultType = false; break; + case SpvOpGroupIMulKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupFMulKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupBitwiseAndKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupBitwiseOrKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupBitwiseXorKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupLogicalAndKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupLogicalOrKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupLogicalXorKHR: *hasResult = true; *hasResultType = true; break; } } #endif /* SPV_ENABLE_UTILITY_CODE */ diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.hpp b/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.hpp index d66576d9b1..48d93d64c3 100644 --- a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.hpp +++ b/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.hpp @@ -26,7 +26,7 @@ // the Binary Section of the SPIR-V specification. // Enumeration tokens for SPIR-V, in various styles: -// C, C++, C++11, JSON, Lua, Python, C#, D +// C, C++, C++11, JSON, Lua, Python, C#, D, Beef // // - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL // - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL @@ -36,6 +36,8 @@ // - C# will use enum classes in the Specification class located in the "Spv" namespace, // e.g.: Spv.Specification.SourceLanguage.GLSL // - D will have tokens under the "spv" module, e.g: spv.SourceLanguage.GLSL +// - Beef will use enum classes in the Specification class located in the "Spv" namespace, +// e.g.: Spv.Specification.SourceLanguage.GLSL // // Some tokens act like mask values, which can be OR'd together, // while others are mutually exclusive. The mask-like ones have @@ -49,12 +51,12 @@ namespace spv { typedef unsigned int Id; -#define SPV_VERSION 0x10500 -#define SPV_REVISION 4 +#define SPV_VERSION 0x10600 +#define SPV_REVISION 1 static const unsigned int MagicNumber = 0x07230203; -static const unsigned int Version = 0x00010500; -static const unsigned int Revision = 4; +static const unsigned int Version = 0x00010600; +static const unsigned int Revision = 1; static const unsigned int OpCodeMask = 0xffff; static const unsigned int WordCountShift = 16; @@ -66,6 +68,7 @@ enum SourceLanguage { SourceLanguageOpenCL_CPP = 4, SourceLanguageHLSL = 5, SourceLanguageCPP_for_OpenCL = 6, + SourceLanguageSYCL = 7, SourceLanguageMax = 0x7fffffff, }; @@ -180,6 +183,7 @@ enum ExecutionMode { ExecutionModeNoGlobalOffsetINTEL = 5895, ExecutionModeNumSIMDWorkitemsINTEL = 5896, ExecutionModeSchedulerTargetFmaxMhzINTEL = 5903, + ExecutionModeNamedBarrierCountINTEL = 6417, ExecutionModeMax = 0x7fffffff, }; @@ -353,6 +357,7 @@ enum ImageOperandsShift { ImageOperandsVolatileTexelKHRShift = 11, ImageOperandsSignExtendShift = 12, ImageOperandsZeroExtendShift = 13, + ImageOperandsNontemporalShift = 14, ImageOperandsOffsetsShift = 16, ImageOperandsMax = 0x7fffffff, }; @@ -377,6 +382,7 @@ enum ImageOperandsMask { ImageOperandsVolatileTexelKHRMask = 0x00000800, ImageOperandsSignExtendMask = 0x00001000, ImageOperandsZeroExtendMask = 0x00002000, + ImageOperandsNontemporalMask = 0x00004000, ImageOperandsOffsetsMask = 0x00010000, }; @@ -494,6 +500,7 @@ enum Decoration { DecorationPerPrimitiveNV = 5271, DecorationPerViewNV = 5272, DecorationPerTaskNV = 5273, + DecorationPerVertexKHR = 5285, DecorationPerVertexNV = 5285, DecorationNonUniform = 5300, DecorationNonUniformEXT = 5300, @@ -539,11 +546,14 @@ enum Decoration { DecorationPrefetchINTEL = 5902, DecorationStallEnableINTEL = 5905, DecorationFuseLoopsInFunctionINTEL = 5907, + DecorationAliasScopeINTEL = 5914, + DecorationNoAliasINTEL = 5915, DecorationBufferLocationINTEL = 5921, DecorationIOPipeStorageINTEL = 5944, DecorationFunctionFloatingPointModeINTEL = 6080, DecorationSingleElementVectorINTEL = 6085, DecorationVectorComputeCallableFunctionINTEL = 6087, + DecorationMediaBlockIOINTEL = 6140, DecorationMax = 0x7fffffff, }; @@ -628,7 +638,9 @@ enum BuiltIn { BuiltInLayerPerViewNV = 5279, BuiltInMeshViewCountNV = 5280, BuiltInMeshViewIndicesNV = 5281, + BuiltInBaryCoordKHR = 5286, BuiltInBaryCoordNV = 5286, + BuiltInBaryCoordNoPerspKHR = 5287, BuiltInBaryCoordNoPerspNV = 5287, BuiltInFragSizeEXT = 5292, BuiltInFragmentSizeNV = 5292, @@ -667,6 +679,7 @@ enum BuiltIn { BuiltInSMCountNV = 5375, BuiltInWarpIDNV = 5376, BuiltInSMIDNV = 5377, + BuiltInCullMaskKHR = 6021, BuiltInMax = 0x7fffffff, }; @@ -794,6 +807,8 @@ enum MemoryAccessShift { MemoryAccessMakePointerVisibleKHRShift = 4, MemoryAccessNonPrivatePointerShift = 5, MemoryAccessNonPrivatePointerKHRShift = 5, + MemoryAccessAliasScopeINTELMaskShift = 16, + MemoryAccessNoAliasINTELMaskShift = 17, MemoryAccessMax = 0x7fffffff, }; @@ -808,6 +823,8 @@ enum MemoryAccessMask { MemoryAccessMakePointerVisibleKHRMask = 0x00000010, MemoryAccessNonPrivatePointerMask = 0x00000020, MemoryAccessNonPrivatePointerKHRMask = 0x00000020, + MemoryAccessAliasScopeINTELMaskMask = 0x00010000, + MemoryAccessNoAliasINTELMaskMask = 0x00020000, }; enum Scope { @@ -920,6 +937,7 @@ enum Capability { CapabilityGroupNonUniformQuad = 68, CapabilityShaderLayer = 69, CapabilityShaderViewportIndex = 70, + CapabilityUniformDecoration = 71, CapabilityFragmentShadingRateKHR = 4422, CapabilitySubgroupBallotKHR = 4423, CapabilityDrawParameters = 4427, @@ -968,6 +986,7 @@ enum Capability { CapabilityFragmentFullyCoveredEXT = 5265, CapabilityMeshShadingNV = 5266, CapabilityImageFootprintNV = 5282, + CapabilityFragmentBarycentricKHR = 5284, CapabilityFragmentBarycentricNV = 5284, CapabilityComputeDerivativeGroupQuadsNV = 5288, CapabilityFragmentDensityEXT = 5291, @@ -1012,6 +1031,7 @@ enum Capability { CapabilityFragmentShaderShadingRateInterlockEXT = 5372, CapabilityShaderSMBuiltinsNV = 5373, CapabilityFragmentShaderPixelInterlockEXT = 5378, + CapabilityDemoteToHelperInvocation = 5379, CapabilityDemoteToHelperInvocationEXT = 5379, CapabilityBindlessTextureNV = 5390, CapabilitySubgroupShuffleINTEL = 5568, @@ -1046,23 +1066,32 @@ enum Capability { CapabilityFPGAMemoryAccessesINTEL = 5898, CapabilityFPGAClusterAttributesINTEL = 5904, CapabilityLoopFuseINTEL = 5906, + CapabilityMemoryAccessAliasingINTEL = 5910, CapabilityFPGABufferLocationINTEL = 5920, CapabilityArbitraryPrecisionFixedPointINTEL = 5922, CapabilityUSMStorageClassesINTEL = 5935, CapabilityIOPipesINTEL = 5943, CapabilityBlockingPipesINTEL = 5945, CapabilityFPGARegINTEL = 5948, + CapabilityDotProductInputAll = 6016, CapabilityDotProductInputAllKHR = 6016, + CapabilityDotProductInput4x8Bit = 6017, CapabilityDotProductInput4x8BitKHR = 6017, + CapabilityDotProductInput4x8BitPacked = 6018, CapabilityDotProductInput4x8BitPackedKHR = 6018, + CapabilityDotProduct = 6019, CapabilityDotProductKHR = 6019, + CapabilityRayCullMaskKHR = 6020, CapabilityBitInstructions = 6025, + CapabilityGroupNonUniformRotateKHR = 6026, CapabilityAtomicFloat32AddEXT = 6033, CapabilityAtomicFloat64AddEXT = 6034, CapabilityLongConstantCompositeINTEL = 6089, CapabilityOptNoneINTEL = 6094, CapabilityAtomicFloat16AddEXT = 6095, CapabilityDebugInfoModuleINTEL = 6114, + CapabilitySplitBarrierINTEL = 6141, + CapabilityGroupUniformArithmeticKHR = 6400, CapabilityMax = 0x7fffffff, }; @@ -1162,6 +1191,7 @@ enum OverflowModes { }; enum PackedVectorFormat { + PackedVectorFormatPackedVectorFormat4x8Bit = 0, PackedVectorFormatPackedVectorFormat4x8BitKHR = 0, PackedVectorFormatMax = 0x7fffffff, }; @@ -1517,17 +1547,24 @@ enum Op { OpSubgroupAllKHR = 4428, OpSubgroupAnyKHR = 4429, OpSubgroupAllEqualKHR = 4430, + OpGroupNonUniformRotateKHR = 4431, OpSubgroupReadInvocationKHR = 4432, OpTraceRayKHR = 4445, OpExecuteCallableKHR = 4446, OpConvertUToAccelerationStructureKHR = 4447, OpIgnoreIntersectionKHR = 4448, OpTerminateRayKHR = 4449, + OpSDot = 4450, OpSDotKHR = 4450, + OpUDot = 4451, OpUDotKHR = 4451, + OpSUDot = 4452, OpSUDotKHR = 4452, + OpSDotAccSat = 4453, OpSDotAccSatKHR = 4453, + OpUDotAccSat = 4454, OpUDotAccSatKHR = 4454, + OpSUDotAccSat = 4455, OpSUDotAccSatKHR = 4455, OpTypeRayQueryKHR = 4472, OpRayQueryInitializeKHR = 4473, @@ -1567,6 +1604,7 @@ enum Op { OpCooperativeMatrixLengthNV = 5362, OpBeginInvocationInterlockEXT = 5364, OpEndInvocationInterlockEXT = 5365, + OpDemoteToHelperInvocation = 5380, OpDemoteToHelperInvocationEXT = 5380, OpIsHelperInvocationEXT = 5381, OpConvertUToImageNV = 5391, @@ -1776,6 +1814,9 @@ enum Op { OpArbitraryFloatPowRINTEL = 5881, OpArbitraryFloatPowNINTEL = 5882, OpLoopControlINTEL = 5887, + OpAliasDomainDeclINTEL = 5911, + OpAliasScopeDeclINTEL = 5912, + OpAliasScopeListDeclINTEL = 5913, OpFixedSqrtINTEL = 5923, OpFixedRecipINTEL = 5924, OpFixedRsqrtINTEL = 5925, @@ -1814,10 +1855,23 @@ enum Op { OpTypeStructContinuedINTEL = 6090, OpConstantCompositeContinuedINTEL = 6091, OpSpecConstantCompositeContinuedINTEL = 6092, + OpControlBarrierArriveINTEL = 6142, + OpControlBarrierWaitINTEL = 6143, + OpGroupIMulKHR = 6401, + OpGroupFMulKHR = 6402, + OpGroupBitwiseAndKHR = 6403, + OpGroupBitwiseOrKHR = 6404, + OpGroupBitwiseXorKHR = 6405, + OpGroupLogicalAndKHR = 6406, + OpGroupLogicalOrKHR = 6407, + OpGroupLogicalXorKHR = 6408, OpMax = 0x7fffffff, }; #ifdef SPV_ENABLE_UTILITY_CODE +#ifndef __cplusplus +#include +#endif inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { *hasResult = *hasResultType = false; switch (opcode) { @@ -2172,18 +2226,19 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpSubgroupAllKHR: *hasResult = true; *hasResultType = true; break; case OpSubgroupAnyKHR: *hasResult = true; *hasResultType = true; break; case OpSubgroupAllEqualKHR: *hasResult = true; *hasResultType = true; break; + case OpGroupNonUniformRotateKHR: *hasResult = true; *hasResultType = true; break; case OpSubgroupReadInvocationKHR: *hasResult = true; *hasResultType = true; break; case OpTraceRayKHR: *hasResult = false; *hasResultType = false; break; case OpExecuteCallableKHR: *hasResult = false; *hasResultType = false; break; case OpConvertUToAccelerationStructureKHR: *hasResult = true; *hasResultType = true; break; case OpIgnoreIntersectionKHR: *hasResult = false; *hasResultType = false; break; case OpTerminateRayKHR: *hasResult = false; *hasResultType = false; break; - case OpSDotKHR: *hasResult = true; *hasResultType = true; break; - case OpUDotKHR: *hasResult = true; *hasResultType = true; break; - case OpSUDotKHR: *hasResult = true; *hasResultType = true; break; - case OpSDotAccSatKHR: *hasResult = true; *hasResultType = true; break; - case OpUDotAccSatKHR: *hasResult = true; *hasResultType = true; break; - case OpSUDotAccSatKHR: *hasResult = true; *hasResultType = true; break; + case OpSDot: *hasResult = true; *hasResultType = true; break; + case OpUDot: *hasResult = true; *hasResultType = true; break; + case OpSUDot: *hasResult = true; *hasResultType = true; break; + case OpSDotAccSat: *hasResult = true; *hasResultType = true; break; + case OpUDotAccSat: *hasResult = true; *hasResultType = true; break; + case OpSUDotAccSat: *hasResult = true; *hasResultType = true; break; case OpTypeRayQueryKHR: *hasResult = true; *hasResultType = false; break; case OpRayQueryInitializeKHR: *hasResult = false; *hasResultType = false; break; case OpRayQueryTerminateKHR: *hasResult = false; *hasResultType = false; break; @@ -2220,7 +2275,7 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpCooperativeMatrixLengthNV: *hasResult = true; *hasResultType = true; break; case OpBeginInvocationInterlockEXT: *hasResult = false; *hasResultType = false; break; case OpEndInvocationInterlockEXT: *hasResult = false; *hasResultType = false; break; - case OpDemoteToHelperInvocationEXT: *hasResult = false; *hasResultType = false; break; + case OpDemoteToHelperInvocation: *hasResult = false; *hasResultType = false; break; case OpIsHelperInvocationEXT: *hasResult = true; *hasResultType = true; break; case OpConvertUToImageNV: *hasResult = true; *hasResultType = true; break; case OpConvertUToSamplerNV: *hasResult = true; *hasResultType = true; break; @@ -2427,6 +2482,9 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpArbitraryFloatPowRINTEL: *hasResult = true; *hasResultType = true; break; case OpArbitraryFloatPowNINTEL: *hasResult = true; *hasResultType = true; break; case OpLoopControlINTEL: *hasResult = false; *hasResultType = false; break; + case OpAliasDomainDeclINTEL: *hasResult = true; *hasResultType = false; break; + case OpAliasScopeDeclINTEL: *hasResult = true; *hasResultType = false; break; + case OpAliasScopeListDeclINTEL: *hasResult = true; *hasResultType = false; break; case OpFixedSqrtINTEL: *hasResult = true; *hasResultType = true; break; case OpFixedRecipINTEL: *hasResult = true; *hasResultType = true; break; case OpFixedRsqrtINTEL: *hasResult = true; *hasResultType = true; break; @@ -2465,6 +2523,16 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpTypeStructContinuedINTEL: *hasResult = false; *hasResultType = false; break; case OpConstantCompositeContinuedINTEL: *hasResult = false; *hasResultType = false; break; case OpSpecConstantCompositeContinuedINTEL: *hasResult = false; *hasResultType = false; break; + case OpControlBarrierArriveINTEL: *hasResult = false; *hasResultType = false; break; + case OpControlBarrierWaitINTEL: *hasResult = false; *hasResultType = false; break; + case OpGroupIMulKHR: *hasResult = true; *hasResultType = true; break; + case OpGroupFMulKHR: *hasResult = true; *hasResultType = true; break; + case OpGroupBitwiseAndKHR: *hasResult = true; *hasResultType = true; break; + case OpGroupBitwiseOrKHR: *hasResult = true; *hasResultType = true; break; + case OpGroupBitwiseXorKHR: *hasResult = true; *hasResultType = true; break; + case OpGroupLogicalAndKHR: *hasResult = true; *hasResultType = true; break; + case OpGroupLogicalOrKHR: *hasResult = true; *hasResultType = true; break; + case OpGroupLogicalXorKHR: *hasResult = true; *hasResultType = true; break; } } #endif /* SPV_ENABLE_UTILITY_CODE */ diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.hpp11 b/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.hpp11 index 677daf73bc..4de79fdbd1 100644 --- a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.hpp11 +++ b/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.hpp11 @@ -26,7 +26,7 @@ // the Binary Section of the SPIR-V specification. // Enumeration tokens for SPIR-V, in various styles: -// C, C++, C++11, JSON, Lua, Python, C#, D +// C, C++, C++11, JSON, Lua, Python, C#, D, Beef // // - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL // - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL @@ -36,6 +36,8 @@ // - C# will use enum classes in the Specification class located in the "Spv" namespace, // e.g.: Spv.Specification.SourceLanguage.GLSL // - D will have tokens under the "spv" module, e.g: spv.SourceLanguage.GLSL +// - Beef will use enum classes in the Specification class located in the "Spv" namespace, +// e.g.: Spv.Specification.SourceLanguage.GLSL // // Some tokens act like mask values, which can be OR'd together, // while others are mutually exclusive. The mask-like ones have @@ -49,12 +51,12 @@ namespace spv { typedef unsigned int Id; -#define SPV_VERSION 0x10500 -#define SPV_REVISION 4 +#define SPV_VERSION 0x10600 +#define SPV_REVISION 1 static const unsigned int MagicNumber = 0x07230203; -static const unsigned int Version = 0x00010500; -static const unsigned int Revision = 4; +static const unsigned int Version = 0x00010600; +static const unsigned int Revision = 1; static const unsigned int OpCodeMask = 0xffff; static const unsigned int WordCountShift = 16; @@ -66,6 +68,7 @@ enum class SourceLanguage : unsigned { OpenCL_CPP = 4, HLSL = 5, CPP_for_OpenCL = 6, + SYCL = 7, Max = 0x7fffffff, }; @@ -180,6 +183,7 @@ enum class ExecutionMode : unsigned { NoGlobalOffsetINTEL = 5895, NumSIMDWorkitemsINTEL = 5896, SchedulerTargetFmaxMhzINTEL = 5903, + NamedBarrierCountINTEL = 6417, Max = 0x7fffffff, }; @@ -353,6 +357,7 @@ enum class ImageOperandsShift : unsigned { VolatileTexelKHR = 11, SignExtend = 12, ZeroExtend = 13, + Nontemporal = 14, Offsets = 16, Max = 0x7fffffff, }; @@ -377,6 +382,7 @@ enum class ImageOperandsMask : unsigned { VolatileTexelKHR = 0x00000800, SignExtend = 0x00001000, ZeroExtend = 0x00002000, + Nontemporal = 0x00004000, Offsets = 0x00010000, }; @@ -494,6 +500,7 @@ enum class Decoration : unsigned { PerPrimitiveNV = 5271, PerViewNV = 5272, PerTaskNV = 5273, + PerVertexKHR = 5285, PerVertexNV = 5285, NonUniform = 5300, NonUniformEXT = 5300, @@ -539,11 +546,14 @@ enum class Decoration : unsigned { PrefetchINTEL = 5902, StallEnableINTEL = 5905, FuseLoopsInFunctionINTEL = 5907, + AliasScopeINTEL = 5914, + NoAliasINTEL = 5915, BufferLocationINTEL = 5921, IOPipeStorageINTEL = 5944, FunctionFloatingPointModeINTEL = 6080, SingleElementVectorINTEL = 6085, VectorComputeCallableFunctionINTEL = 6087, + MediaBlockIOINTEL = 6140, Max = 0x7fffffff, }; @@ -628,7 +638,9 @@ enum class BuiltIn : unsigned { LayerPerViewNV = 5279, MeshViewCountNV = 5280, MeshViewIndicesNV = 5281, + BaryCoordKHR = 5286, BaryCoordNV = 5286, + BaryCoordNoPerspKHR = 5287, BaryCoordNoPerspNV = 5287, FragSizeEXT = 5292, FragmentSizeNV = 5292, @@ -667,6 +679,7 @@ enum class BuiltIn : unsigned { SMCountNV = 5375, WarpIDNV = 5376, SMIDNV = 5377, + CullMaskKHR = 6021, Max = 0x7fffffff, }; @@ -794,6 +807,8 @@ enum class MemoryAccessShift : unsigned { MakePointerVisibleKHR = 4, NonPrivatePointer = 5, NonPrivatePointerKHR = 5, + AliasScopeINTELMask = 16, + NoAliasINTELMask = 17, Max = 0x7fffffff, }; @@ -808,6 +823,8 @@ enum class MemoryAccessMask : unsigned { MakePointerVisibleKHR = 0x00000010, NonPrivatePointer = 0x00000020, NonPrivatePointerKHR = 0x00000020, + AliasScopeINTELMask = 0x00010000, + NoAliasINTELMask = 0x00020000, }; enum class Scope : unsigned { @@ -920,6 +937,7 @@ enum class Capability : unsigned { GroupNonUniformQuad = 68, ShaderLayer = 69, ShaderViewportIndex = 70, + UniformDecoration = 71, FragmentShadingRateKHR = 4422, SubgroupBallotKHR = 4423, DrawParameters = 4427, @@ -968,6 +986,7 @@ enum class Capability : unsigned { FragmentFullyCoveredEXT = 5265, MeshShadingNV = 5266, ImageFootprintNV = 5282, + FragmentBarycentricKHR = 5284, FragmentBarycentricNV = 5284, ComputeDerivativeGroupQuadsNV = 5288, FragmentDensityEXT = 5291, @@ -1012,6 +1031,7 @@ enum class Capability : unsigned { FragmentShaderShadingRateInterlockEXT = 5372, ShaderSMBuiltinsNV = 5373, FragmentShaderPixelInterlockEXT = 5378, + DemoteToHelperInvocation = 5379, DemoteToHelperInvocationEXT = 5379, BindlessTextureNV = 5390, SubgroupShuffleINTEL = 5568, @@ -1046,23 +1066,32 @@ enum class Capability : unsigned { FPGAMemoryAccessesINTEL = 5898, FPGAClusterAttributesINTEL = 5904, LoopFuseINTEL = 5906, + MemoryAccessAliasingINTEL = 5910, FPGABufferLocationINTEL = 5920, ArbitraryPrecisionFixedPointINTEL = 5922, USMStorageClassesINTEL = 5935, IOPipesINTEL = 5943, BlockingPipesINTEL = 5945, FPGARegINTEL = 5948, + DotProductInputAll = 6016, DotProductInputAllKHR = 6016, + DotProductInput4x8Bit = 6017, DotProductInput4x8BitKHR = 6017, + DotProductInput4x8BitPacked = 6018, DotProductInput4x8BitPackedKHR = 6018, + DotProduct = 6019, DotProductKHR = 6019, + RayCullMaskKHR = 6020, BitInstructions = 6025, + GroupNonUniformRotateKHR = 6026, AtomicFloat32AddEXT = 6033, AtomicFloat64AddEXT = 6034, LongConstantCompositeINTEL = 6089, OptNoneINTEL = 6094, AtomicFloat16AddEXT = 6095, DebugInfoModuleINTEL = 6114, + SplitBarrierINTEL = 6141, + GroupUniformArithmeticKHR = 6400, Max = 0x7fffffff, }; @@ -1162,6 +1191,7 @@ enum class OverflowModes : unsigned { }; enum class PackedVectorFormat : unsigned { + PackedVectorFormat4x8Bit = 0, PackedVectorFormat4x8BitKHR = 0, Max = 0x7fffffff, }; @@ -1517,17 +1547,24 @@ enum class Op : unsigned { OpSubgroupAllKHR = 4428, OpSubgroupAnyKHR = 4429, OpSubgroupAllEqualKHR = 4430, + OpGroupNonUniformRotateKHR = 4431, OpSubgroupReadInvocationKHR = 4432, OpTraceRayKHR = 4445, OpExecuteCallableKHR = 4446, OpConvertUToAccelerationStructureKHR = 4447, OpIgnoreIntersectionKHR = 4448, OpTerminateRayKHR = 4449, + OpSDot = 4450, OpSDotKHR = 4450, + OpUDot = 4451, OpUDotKHR = 4451, + OpSUDot = 4452, OpSUDotKHR = 4452, + OpSDotAccSat = 4453, OpSDotAccSatKHR = 4453, + OpUDotAccSat = 4454, OpUDotAccSatKHR = 4454, + OpSUDotAccSat = 4455, OpSUDotAccSatKHR = 4455, OpTypeRayQueryKHR = 4472, OpRayQueryInitializeKHR = 4473, @@ -1567,6 +1604,7 @@ enum class Op : unsigned { OpCooperativeMatrixLengthNV = 5362, OpBeginInvocationInterlockEXT = 5364, OpEndInvocationInterlockEXT = 5365, + OpDemoteToHelperInvocation = 5380, OpDemoteToHelperInvocationEXT = 5380, OpIsHelperInvocationEXT = 5381, OpConvertUToImageNV = 5391, @@ -1776,6 +1814,9 @@ enum class Op : unsigned { OpArbitraryFloatPowRINTEL = 5881, OpArbitraryFloatPowNINTEL = 5882, OpLoopControlINTEL = 5887, + OpAliasDomainDeclINTEL = 5911, + OpAliasScopeDeclINTEL = 5912, + OpAliasScopeListDeclINTEL = 5913, OpFixedSqrtINTEL = 5923, OpFixedRecipINTEL = 5924, OpFixedRsqrtINTEL = 5925, @@ -1814,10 +1855,23 @@ enum class Op : unsigned { OpTypeStructContinuedINTEL = 6090, OpConstantCompositeContinuedINTEL = 6091, OpSpecConstantCompositeContinuedINTEL = 6092, + OpControlBarrierArriveINTEL = 6142, + OpControlBarrierWaitINTEL = 6143, + OpGroupIMulKHR = 6401, + OpGroupFMulKHR = 6402, + OpGroupBitwiseAndKHR = 6403, + OpGroupBitwiseOrKHR = 6404, + OpGroupBitwiseXorKHR = 6405, + OpGroupLogicalAndKHR = 6406, + OpGroupLogicalOrKHR = 6407, + OpGroupLogicalXorKHR = 6408, Max = 0x7fffffff, }; #ifdef SPV_ENABLE_UTILITY_CODE +#ifndef __cplusplus +#include +#endif inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { *hasResult = *hasResultType = false; switch (opcode) { @@ -2172,18 +2226,19 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case Op::OpSubgroupAllKHR: *hasResult = true; *hasResultType = true; break; case Op::OpSubgroupAnyKHR: *hasResult = true; *hasResultType = true; break; case Op::OpSubgroupAllEqualKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpGroupNonUniformRotateKHR: *hasResult = true; *hasResultType = true; break; case Op::OpSubgroupReadInvocationKHR: *hasResult = true; *hasResultType = true; break; case Op::OpTraceRayKHR: *hasResult = false; *hasResultType = false; break; case Op::OpExecuteCallableKHR: *hasResult = false; *hasResultType = false; break; case Op::OpConvertUToAccelerationStructureKHR: *hasResult = true; *hasResultType = true; break; case Op::OpIgnoreIntersectionKHR: *hasResult = false; *hasResultType = false; break; case Op::OpTerminateRayKHR: *hasResult = false; *hasResultType = false; break; - case Op::OpSDotKHR: *hasResult = true; *hasResultType = true; break; - case Op::OpUDotKHR: *hasResult = true; *hasResultType = true; break; - case Op::OpSUDotKHR: *hasResult = true; *hasResultType = true; break; - case Op::OpSDotAccSatKHR: *hasResult = true; *hasResultType = true; break; - case Op::OpUDotAccSatKHR: *hasResult = true; *hasResultType = true; break; - case Op::OpSUDotAccSatKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpSDot: *hasResult = true; *hasResultType = true; break; + case Op::OpUDot: *hasResult = true; *hasResultType = true; break; + case Op::OpSUDot: *hasResult = true; *hasResultType = true; break; + case Op::OpSDotAccSat: *hasResult = true; *hasResultType = true; break; + case Op::OpUDotAccSat: *hasResult = true; *hasResultType = true; break; + case Op::OpSUDotAccSat: *hasResult = true; *hasResultType = true; break; case Op::OpTypeRayQueryKHR: *hasResult = true; *hasResultType = false; break; case Op::OpRayQueryInitializeKHR: *hasResult = false; *hasResultType = false; break; case Op::OpRayQueryTerminateKHR: *hasResult = false; *hasResultType = false; break; @@ -2220,7 +2275,7 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case Op::OpCooperativeMatrixLengthNV: *hasResult = true; *hasResultType = true; break; case Op::OpBeginInvocationInterlockEXT: *hasResult = false; *hasResultType = false; break; case Op::OpEndInvocationInterlockEXT: *hasResult = false; *hasResultType = false; break; - case Op::OpDemoteToHelperInvocationEXT: *hasResult = false; *hasResultType = false; break; + case Op::OpDemoteToHelperInvocation: *hasResult = false; *hasResultType = false; break; case Op::OpIsHelperInvocationEXT: *hasResult = true; *hasResultType = true; break; case Op::OpConvertUToImageNV: *hasResult = true; *hasResultType = true; break; case Op::OpConvertUToSamplerNV: *hasResult = true; *hasResultType = true; break; @@ -2427,6 +2482,9 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case Op::OpArbitraryFloatPowRINTEL: *hasResult = true; *hasResultType = true; break; case Op::OpArbitraryFloatPowNINTEL: *hasResult = true; *hasResultType = true; break; case Op::OpLoopControlINTEL: *hasResult = false; *hasResultType = false; break; + case Op::OpAliasDomainDeclINTEL: *hasResult = true; *hasResultType = false; break; + case Op::OpAliasScopeDeclINTEL: *hasResult = true; *hasResultType = false; break; + case Op::OpAliasScopeListDeclINTEL: *hasResult = true; *hasResultType = false; break; case Op::OpFixedSqrtINTEL: *hasResult = true; *hasResultType = true; break; case Op::OpFixedRecipINTEL: *hasResult = true; *hasResultType = true; break; case Op::OpFixedRsqrtINTEL: *hasResult = true; *hasResultType = true; break; @@ -2465,6 +2523,16 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case Op::OpTypeStructContinuedINTEL: *hasResult = false; *hasResultType = false; break; case Op::OpConstantCompositeContinuedINTEL: *hasResult = false; *hasResultType = false; break; case Op::OpSpecConstantCompositeContinuedINTEL: *hasResult = false; *hasResultType = false; break; + case Op::OpControlBarrierArriveINTEL: *hasResult = false; *hasResultType = false; break; + case Op::OpControlBarrierWaitINTEL: *hasResult = false; *hasResultType = false; break; + case Op::OpGroupIMulKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpGroupFMulKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpGroupBitwiseAndKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpGroupBitwiseOrKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpGroupBitwiseXorKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpGroupLogicalAndKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpGroupLogicalOrKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpGroupLogicalXorKHR: *hasResult = true; *hasResultType = true; break; } } #endif /* SPV_ENABLE_UTILITY_CODE */ diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.json b/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.json index e925ab91c7..85d18b6b30 100644 --- a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.json +++ b/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.json @@ -36,7 +36,7 @@ ], [ "Enumeration tokens for SPIR-V, in various styles:", - " C, C++, C++11, JSON, Lua, Python, C#, D", + " C, C++, C++11, JSON, Lua, Python, C#, D, Beef", "", "- C will have tokens with a \"Spv\" prefix, e.g.: SpvSourceLanguageGLSL", "- C++ will have tokens in the \"spv\" name space, e.g.: spv::SourceLanguageGLSL", @@ -46,6 +46,8 @@ "- C# will use enum classes in the Specification class located in the \"Spv\" namespace,", " e.g.: Spv.Specification.SourceLanguage.GLSL", "- D will have tokens under the \"spv\" module, e.g: spv.SourceLanguage.GLSL", + "- Beef will use enum classes in the Specification class located in the \"Spv\" namespace,", + " e.g.: Spv.Specification.SourceLanguage.GLSL", "", "Some tokens act like mask values, which can be OR'd together,", "while others are mutually exclusive. The mask-like ones have", @@ -54,8 +56,8 @@ ] ], "MagicNumber": 119734787, - "Version": 66816, - "Revision": 4, + "Version": 67072, + "Revision": 1, "OpCodeMask": 65535, "WordCountShift": 16 }, @@ -72,7 +74,8 @@ "OpenCL_C": 3, "OpenCL_CPP": 4, "HLSL": 5, - "CPP_for_OpenCL": 6 + "CPP_for_OpenCL": 6, + "SYCL": 7 } }, { @@ -198,7 +201,8 @@ "MaxWorkDimINTEL": 5894, "NoGlobalOffsetINTEL": 5895, "NumSIMDWorkitemsINTEL": 5896, - "SchedulerTargetFmaxMhzINTEL": 5903 + "SchedulerTargetFmaxMhzINTEL": 5903, + "NamedBarrierCountINTEL": 6417 } }, { @@ -396,6 +400,7 @@ "VolatileTexelKHR": 11, "SignExtend": 12, "ZeroExtend": 13, + "Nontemporal": 14, "Offsets": 16 } }, @@ -521,6 +526,7 @@ "PerPrimitiveNV": 5271, "PerViewNV": 5272, "PerTaskNV": 5273, + "PerVertexKHR": 5285, "PerVertexNV": 5285, "NonUniform": 5300, "NonUniformEXT": 5300, @@ -566,11 +572,14 @@ "PrefetchINTEL": 5902, "StallEnableINTEL": 5905, "FuseLoopsInFunctionINTEL": 5907, + "AliasScopeINTEL": 5914, + "NoAliasINTEL": 5915, "BufferLocationINTEL": 5921, "IOPipeStorageINTEL": 5944, "FunctionFloatingPointModeINTEL": 6080, "SingleElementVectorINTEL": 6085, - "VectorComputeCallableFunctionINTEL": 6087 + "VectorComputeCallableFunctionINTEL": 6087, + "MediaBlockIOINTEL": 6140 } }, { @@ -658,7 +667,9 @@ "LayerPerViewNV": 5279, "MeshViewCountNV": 5280, "MeshViewIndicesNV": 5281, + "BaryCoordKHR": 5286, "BaryCoordNV": 5286, + "BaryCoordNoPerspKHR": 5287, "BaryCoordNoPerspNV": 5287, "FragSizeEXT": 5292, "FragmentSizeNV": 5292, @@ -696,7 +707,8 @@ "WarpsPerSMNV": 5374, "SMCountNV": 5375, "WarpIDNV": 5376, - "SMIDNV": 5377 + "SMIDNV": 5377, + "CullMaskKHR": 6021 } }, { @@ -781,7 +793,9 @@ "MakePointerVisible": 4, "MakePointerVisibleKHR": 4, "NonPrivatePointer": 5, - "NonPrivatePointerKHR": 5 + "NonPrivatePointerKHR": 5, + "AliasScopeINTELMask": 16, + "NoAliasINTELMask": 17 } }, { @@ -905,6 +919,7 @@ "GroupNonUniformQuad": 68, "ShaderLayer": 69, "ShaderViewportIndex": 70, + "UniformDecoration": 71, "FragmentShadingRateKHR": 4422, "SubgroupBallotKHR": 4423, "DrawParameters": 4427, @@ -953,6 +968,7 @@ "FragmentFullyCoveredEXT": 5265, "MeshShadingNV": 5266, "ImageFootprintNV": 5282, + "FragmentBarycentricKHR": 5284, "FragmentBarycentricNV": 5284, "ComputeDerivativeGroupQuadsNV": 5288, "FragmentDensityEXT": 5291, @@ -997,6 +1013,7 @@ "FragmentShaderShadingRateInterlockEXT": 5372, "ShaderSMBuiltinsNV": 5373, "FragmentShaderPixelInterlockEXT": 5378, + "DemoteToHelperInvocation": 5379, "DemoteToHelperInvocationEXT": 5379, "BindlessTextureNV": 5390, "SubgroupShuffleINTEL": 5568, @@ -1031,23 +1048,32 @@ "FPGAMemoryAccessesINTEL": 5898, "FPGAClusterAttributesINTEL": 5904, "LoopFuseINTEL": 5906, + "MemoryAccessAliasingINTEL": 5910, "FPGABufferLocationINTEL": 5920, "ArbitraryPrecisionFixedPointINTEL": 5922, "USMStorageClassesINTEL": 5935, "IOPipesINTEL": 5943, "BlockingPipesINTEL": 5945, "FPGARegINTEL": 5948, + "DotProductInputAll": 6016, "DotProductInputAllKHR": 6016, + "DotProductInput4x8Bit": 6017, "DotProductInput4x8BitKHR": 6017, + "DotProductInput4x8BitPacked": 6018, "DotProductInput4x8BitPackedKHR": 6018, + "DotProduct": 6019, "DotProductKHR": 6019, + "RayCullMaskKHR": 6020, "BitInstructions": 6025, + "GroupNonUniformRotateKHR": 6026, "AtomicFloat32AddEXT": 6033, "AtomicFloat64AddEXT": 6034, "LongConstantCompositeINTEL": 6089, "OptNoneINTEL": 6094, "AtomicFloat16AddEXT": 6095, - "DebugInfoModuleINTEL": 6114 + "DebugInfoModuleINTEL": 6114, + "SplitBarrierINTEL": 6141, + "GroupUniformArithmeticKHR": 6400 } }, { @@ -1155,6 +1181,7 @@ "Type": "Value", "Values": { + "PackedVectorFormat4x8Bit": 0, "PackedVectorFormat4x8BitKHR": 0 } }, @@ -1513,17 +1540,24 @@ "OpSubgroupAllKHR": 4428, "OpSubgroupAnyKHR": 4429, "OpSubgroupAllEqualKHR": 4430, + "OpGroupNonUniformRotateKHR": 4431, "OpSubgroupReadInvocationKHR": 4432, "OpTraceRayKHR": 4445, "OpExecuteCallableKHR": 4446, "OpConvertUToAccelerationStructureKHR": 4447, "OpIgnoreIntersectionKHR": 4448, "OpTerminateRayKHR": 4449, + "OpSDot": 4450, "OpSDotKHR": 4450, + "OpUDot": 4451, "OpUDotKHR": 4451, + "OpSUDot": 4452, "OpSUDotKHR": 4452, + "OpSDotAccSat": 4453, "OpSDotAccSatKHR": 4453, + "OpUDotAccSat": 4454, "OpUDotAccSatKHR": 4454, + "OpSUDotAccSat": 4455, "OpSUDotAccSatKHR": 4455, "OpTypeRayQueryKHR": 4472, "OpRayQueryInitializeKHR": 4473, @@ -1563,6 +1597,7 @@ "OpCooperativeMatrixLengthNV": 5362, "OpBeginInvocationInterlockEXT": 5364, "OpEndInvocationInterlockEXT": 5365, + "OpDemoteToHelperInvocation": 5380, "OpDemoteToHelperInvocationEXT": 5380, "OpIsHelperInvocationEXT": 5381, "OpConvertUToImageNV": 5391, @@ -1772,6 +1807,9 @@ "OpArbitraryFloatPowRINTEL": 5881, "OpArbitraryFloatPowNINTEL": 5882, "OpLoopControlINTEL": 5887, + "OpAliasDomainDeclINTEL": 5911, + "OpAliasScopeDeclINTEL": 5912, + "OpAliasScopeListDeclINTEL": 5913, "OpFixedSqrtINTEL": 5923, "OpFixedRecipINTEL": 5924, "OpFixedRsqrtINTEL": 5925, @@ -1809,7 +1847,17 @@ "OpTypeBufferSurfaceINTEL": 6086, "OpTypeStructContinuedINTEL": 6090, "OpConstantCompositeContinuedINTEL": 6091, - "OpSpecConstantCompositeContinuedINTEL": 6092 + "OpSpecConstantCompositeContinuedINTEL": 6092, + "OpControlBarrierArriveINTEL": 6142, + "OpControlBarrierWaitINTEL": 6143, + "OpGroupIMulKHR": 6401, + "OpGroupFMulKHR": 6402, + "OpGroupBitwiseAndKHR": 6403, + "OpGroupBitwiseOrKHR": 6404, + "OpGroupBitwiseXorKHR": 6405, + "OpGroupLogicalAndKHR": 6406, + "OpGroupLogicalOrKHR": 6407, + "OpGroupLogicalXorKHR": 6408 } } ] diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.lua b/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.lua index 0806dd78de..58df6f312b 100644 --- a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.lua +++ b/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.lua @@ -26,7 +26,7 @@ -- the Binary Section of the SPIR-V specification. -- Enumeration tokens for SPIR-V, in various styles: --- C, C++, C++11, JSON, Lua, Python, C#, D +-- C, C++, C++11, JSON, Lua, Python, C#, D, Beef -- -- - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL -- - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL @@ -36,6 +36,8 @@ -- - C# will use enum classes in the Specification class located in the "Spv" namespace, -- e.g.: Spv.Specification.SourceLanguage.GLSL -- - D will have tokens under the "spv" module, e.g: spv.SourceLanguage.GLSL +-- - Beef will use enum classes in the Specification class located in the "Spv" namespace, +-- e.g.: Spv.Specification.SourceLanguage.GLSL -- -- Some tokens act like mask values, which can be OR'd together, -- while others are mutually exclusive. The mask-like ones have @@ -44,8 +46,8 @@ spv = { MagicNumber = 0x07230203, - Version = 0x00010500, - Revision = 4, + Version = 0x00010600, + Revision = 1, OpCodeMask = 0xffff, WordCountShift = 16, @@ -57,6 +59,7 @@ spv = { OpenCL_CPP = 4, HLSL = 5, CPP_for_OpenCL = 6, + SYCL = 7, }, ExecutionModel = { @@ -167,6 +170,7 @@ spv = { NoGlobalOffsetINTEL = 5895, NumSIMDWorkitemsINTEL = 5896, SchedulerTargetFmaxMhzINTEL = 5903, + NamedBarrierCountINTEL = 6417, }, StorageClass = { @@ -332,6 +336,7 @@ spv = { VolatileTexelKHR = 11, SignExtend = 12, ZeroExtend = 13, + Nontemporal = 14, Offsets = 16, }, @@ -355,6 +360,7 @@ spv = { VolatileTexelKHR = 0x00000800, SignExtend = 0x00001000, ZeroExtend = 0x00002000, + Nontemporal = 0x00004000, Offsets = 0x00010000, }, @@ -467,6 +473,7 @@ spv = { PerPrimitiveNV = 5271, PerViewNV = 5272, PerTaskNV = 5273, + PerVertexKHR = 5285, PerVertexNV = 5285, NonUniform = 5300, NonUniformEXT = 5300, @@ -512,11 +519,14 @@ spv = { PrefetchINTEL = 5902, StallEnableINTEL = 5905, FuseLoopsInFunctionINTEL = 5907, + AliasScopeINTEL = 5914, + NoAliasINTEL = 5915, BufferLocationINTEL = 5921, IOPipeStorageINTEL = 5944, FunctionFloatingPointModeINTEL = 6080, SingleElementVectorINTEL = 6085, VectorComputeCallableFunctionINTEL = 6087, + MediaBlockIOINTEL = 6140, }, BuiltIn = { @@ -600,7 +610,9 @@ spv = { LayerPerViewNV = 5279, MeshViewCountNV = 5280, MeshViewIndicesNV = 5281, + BaryCoordKHR = 5286, BaryCoordNV = 5286, + BaryCoordNoPerspKHR = 5287, BaryCoordNoPerspNV = 5287, FragSizeEXT = 5292, FragmentSizeNV = 5292, @@ -639,6 +651,7 @@ spv = { SMCountNV = 5375, WarpIDNV = 5376, SMIDNV = 5377, + CullMaskKHR = 6021, }, SelectionControlShift = { @@ -761,6 +774,8 @@ spv = { MakePointerVisibleKHR = 4, NonPrivatePointer = 5, NonPrivatePointerKHR = 5, + AliasScopeINTELMask = 16, + NoAliasINTELMask = 17, }, MemoryAccessMask = { @@ -774,6 +789,8 @@ spv = { MakePointerVisibleKHR = 0x00000010, NonPrivatePointer = 0x00000020, NonPrivatePointerKHR = 0x00000020, + AliasScopeINTELMask = 0x00010000, + NoAliasINTELMask = 0x00020000, }, Scope = { @@ -882,6 +899,7 @@ spv = { GroupNonUniformQuad = 68, ShaderLayer = 69, ShaderViewportIndex = 70, + UniformDecoration = 71, FragmentShadingRateKHR = 4422, SubgroupBallotKHR = 4423, DrawParameters = 4427, @@ -930,6 +948,7 @@ spv = { FragmentFullyCoveredEXT = 5265, MeshShadingNV = 5266, ImageFootprintNV = 5282, + FragmentBarycentricKHR = 5284, FragmentBarycentricNV = 5284, ComputeDerivativeGroupQuadsNV = 5288, FragmentDensityEXT = 5291, @@ -974,6 +993,7 @@ spv = { FragmentShaderShadingRateInterlockEXT = 5372, ShaderSMBuiltinsNV = 5373, FragmentShaderPixelInterlockEXT = 5378, + DemoteToHelperInvocation = 5379, DemoteToHelperInvocationEXT = 5379, BindlessTextureNV = 5390, SubgroupShuffleINTEL = 5568, @@ -1008,23 +1028,32 @@ spv = { FPGAMemoryAccessesINTEL = 5898, FPGAClusterAttributesINTEL = 5904, LoopFuseINTEL = 5906, + MemoryAccessAliasingINTEL = 5910, FPGABufferLocationINTEL = 5920, ArbitraryPrecisionFixedPointINTEL = 5922, USMStorageClassesINTEL = 5935, IOPipesINTEL = 5943, BlockingPipesINTEL = 5945, FPGARegINTEL = 5948, + DotProductInputAll = 6016, DotProductInputAllKHR = 6016, + DotProductInput4x8Bit = 6017, DotProductInput4x8BitKHR = 6017, + DotProductInput4x8BitPacked = 6018, DotProductInput4x8BitPackedKHR = 6018, + DotProduct = 6019, DotProductKHR = 6019, + RayCullMaskKHR = 6020, BitInstructions = 6025, + GroupNonUniformRotateKHR = 6026, AtomicFloat32AddEXT = 6033, AtomicFloat64AddEXT = 6034, LongConstantCompositeINTEL = 6089, OptNoneINTEL = 6094, AtomicFloat16AddEXT = 6095, DebugInfoModuleINTEL = 6114, + SplitBarrierINTEL = 6141, + GroupUniformArithmeticKHR = 6400, }, RayFlagsShift = { @@ -1114,6 +1143,7 @@ spv = { }, PackedVectorFormat = { + PackedVectorFormat4x8Bit = 0, PackedVectorFormat4x8BitKHR = 0, }, @@ -1468,17 +1498,24 @@ spv = { OpSubgroupAllKHR = 4428, OpSubgroupAnyKHR = 4429, OpSubgroupAllEqualKHR = 4430, + OpGroupNonUniformRotateKHR = 4431, OpSubgroupReadInvocationKHR = 4432, OpTraceRayKHR = 4445, OpExecuteCallableKHR = 4446, OpConvertUToAccelerationStructureKHR = 4447, OpIgnoreIntersectionKHR = 4448, OpTerminateRayKHR = 4449, + OpSDot = 4450, OpSDotKHR = 4450, + OpUDot = 4451, OpUDotKHR = 4451, + OpSUDot = 4452, OpSUDotKHR = 4452, + OpSDotAccSat = 4453, OpSDotAccSatKHR = 4453, + OpUDotAccSat = 4454, OpUDotAccSatKHR = 4454, + OpSUDotAccSat = 4455, OpSUDotAccSatKHR = 4455, OpTypeRayQueryKHR = 4472, OpRayQueryInitializeKHR = 4473, @@ -1518,6 +1555,7 @@ spv = { OpCooperativeMatrixLengthNV = 5362, OpBeginInvocationInterlockEXT = 5364, OpEndInvocationInterlockEXT = 5365, + OpDemoteToHelperInvocation = 5380, OpDemoteToHelperInvocationEXT = 5380, OpIsHelperInvocationEXT = 5381, OpConvertUToImageNV = 5391, @@ -1727,6 +1765,9 @@ spv = { OpArbitraryFloatPowRINTEL = 5881, OpArbitraryFloatPowNINTEL = 5882, OpLoopControlINTEL = 5887, + OpAliasDomainDeclINTEL = 5911, + OpAliasScopeDeclINTEL = 5912, + OpAliasScopeListDeclINTEL = 5913, OpFixedSqrtINTEL = 5923, OpFixedRecipINTEL = 5924, OpFixedRsqrtINTEL = 5925, @@ -1765,6 +1806,16 @@ spv = { OpTypeStructContinuedINTEL = 6090, OpConstantCompositeContinuedINTEL = 6091, OpSpecConstantCompositeContinuedINTEL = 6092, + OpControlBarrierArriveINTEL = 6142, + OpControlBarrierWaitINTEL = 6143, + OpGroupIMulKHR = 6401, + OpGroupFMulKHR = 6402, + OpGroupBitwiseAndKHR = 6403, + OpGroupBitwiseOrKHR = 6404, + OpGroupBitwiseXorKHR = 6405, + OpGroupLogicalAndKHR = 6406, + OpGroupLogicalOrKHR = 6407, + OpGroupLogicalXorKHR = 6408, }, } diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.py b/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.py index ad41708063..7a02a108d7 100644 --- a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.py +++ b/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.py @@ -26,7 +26,7 @@ # the Binary Section of the SPIR-V specification. # Enumeration tokens for SPIR-V, in various styles: -# C, C++, C++11, JSON, Lua, Python, C#, D +# C, C++, C++11, JSON, Lua, Python, C#, D, Beef # # - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL # - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL @@ -36,6 +36,8 @@ # - C# will use enum classes in the Specification class located in the "Spv" namespace, # e.g.: Spv.Specification.SourceLanguage.GLSL # - D will have tokens under the "spv" module, e.g: spv.SourceLanguage.GLSL +# - Beef will use enum classes in the Specification class located in the "Spv" namespace, +# e.g.: Spv.Specification.SourceLanguage.GLSL # # Some tokens act like mask values, which can be OR'd together, # while others are mutually exclusive. The mask-like ones have @@ -44,8 +46,8 @@ spv = { 'MagicNumber' : 0x07230203, - 'Version' : 0x00010500, - 'Revision' : 4, + 'Version' : 0x00010600, + 'Revision' : 1, 'OpCodeMask' : 0xffff, 'WordCountShift' : 16, @@ -57,6 +59,7 @@ spv = { 'OpenCL_CPP' : 4, 'HLSL' : 5, 'CPP_for_OpenCL' : 6, + 'SYCL' : 7, }, 'ExecutionModel' : { @@ -167,6 +170,7 @@ spv = { 'NoGlobalOffsetINTEL' : 5895, 'NumSIMDWorkitemsINTEL' : 5896, 'SchedulerTargetFmaxMhzINTEL' : 5903, + 'NamedBarrierCountINTEL' : 6417, }, 'StorageClass' : { @@ -332,6 +336,7 @@ spv = { 'VolatileTexelKHR' : 11, 'SignExtend' : 12, 'ZeroExtend' : 13, + 'Nontemporal' : 14, 'Offsets' : 16, }, @@ -355,6 +360,7 @@ spv = { 'VolatileTexelKHR' : 0x00000800, 'SignExtend' : 0x00001000, 'ZeroExtend' : 0x00002000, + 'Nontemporal' : 0x00004000, 'Offsets' : 0x00010000, }, @@ -467,6 +473,7 @@ spv = { 'PerPrimitiveNV' : 5271, 'PerViewNV' : 5272, 'PerTaskNV' : 5273, + 'PerVertexKHR' : 5285, 'PerVertexNV' : 5285, 'NonUniform' : 5300, 'NonUniformEXT' : 5300, @@ -512,11 +519,14 @@ spv = { 'PrefetchINTEL' : 5902, 'StallEnableINTEL' : 5905, 'FuseLoopsInFunctionINTEL' : 5907, + 'AliasScopeINTEL' : 5914, + 'NoAliasINTEL' : 5915, 'BufferLocationINTEL' : 5921, 'IOPipeStorageINTEL' : 5944, 'FunctionFloatingPointModeINTEL' : 6080, 'SingleElementVectorINTEL' : 6085, 'VectorComputeCallableFunctionINTEL' : 6087, + 'MediaBlockIOINTEL' : 6140, }, 'BuiltIn' : { @@ -600,7 +610,9 @@ spv = { 'LayerPerViewNV' : 5279, 'MeshViewCountNV' : 5280, 'MeshViewIndicesNV' : 5281, + 'BaryCoordKHR' : 5286, 'BaryCoordNV' : 5286, + 'BaryCoordNoPerspKHR' : 5287, 'BaryCoordNoPerspNV' : 5287, 'FragSizeEXT' : 5292, 'FragmentSizeNV' : 5292, @@ -639,6 +651,7 @@ spv = { 'SMCountNV' : 5375, 'WarpIDNV' : 5376, 'SMIDNV' : 5377, + 'CullMaskKHR' : 6021, }, 'SelectionControlShift' : { @@ -761,6 +774,8 @@ spv = { 'MakePointerVisibleKHR' : 4, 'NonPrivatePointer' : 5, 'NonPrivatePointerKHR' : 5, + 'AliasScopeINTELMask' : 16, + 'NoAliasINTELMask' : 17, }, 'MemoryAccessMask' : { @@ -774,6 +789,8 @@ spv = { 'MakePointerVisibleKHR' : 0x00000010, 'NonPrivatePointer' : 0x00000020, 'NonPrivatePointerKHR' : 0x00000020, + 'AliasScopeINTELMask' : 0x00010000, + 'NoAliasINTELMask' : 0x00020000, }, 'Scope' : { @@ -882,6 +899,7 @@ spv = { 'GroupNonUniformQuad' : 68, 'ShaderLayer' : 69, 'ShaderViewportIndex' : 70, + 'UniformDecoration' : 71, 'FragmentShadingRateKHR' : 4422, 'SubgroupBallotKHR' : 4423, 'DrawParameters' : 4427, @@ -930,6 +948,7 @@ spv = { 'FragmentFullyCoveredEXT' : 5265, 'MeshShadingNV' : 5266, 'ImageFootprintNV' : 5282, + 'FragmentBarycentricKHR' : 5284, 'FragmentBarycentricNV' : 5284, 'ComputeDerivativeGroupQuadsNV' : 5288, 'FragmentDensityEXT' : 5291, @@ -974,6 +993,7 @@ spv = { 'FragmentShaderShadingRateInterlockEXT' : 5372, 'ShaderSMBuiltinsNV' : 5373, 'FragmentShaderPixelInterlockEXT' : 5378, + 'DemoteToHelperInvocation' : 5379, 'DemoteToHelperInvocationEXT' : 5379, 'BindlessTextureNV' : 5390, 'SubgroupShuffleINTEL' : 5568, @@ -1008,23 +1028,32 @@ spv = { 'FPGAMemoryAccessesINTEL' : 5898, 'FPGAClusterAttributesINTEL' : 5904, 'LoopFuseINTEL' : 5906, + 'MemoryAccessAliasingINTEL' : 5910, 'FPGABufferLocationINTEL' : 5920, 'ArbitraryPrecisionFixedPointINTEL' : 5922, 'USMStorageClassesINTEL' : 5935, 'IOPipesINTEL' : 5943, 'BlockingPipesINTEL' : 5945, 'FPGARegINTEL' : 5948, + 'DotProductInputAll' : 6016, 'DotProductInputAllKHR' : 6016, + 'DotProductInput4x8Bit' : 6017, 'DotProductInput4x8BitKHR' : 6017, + 'DotProductInput4x8BitPacked' : 6018, 'DotProductInput4x8BitPackedKHR' : 6018, + 'DotProduct' : 6019, 'DotProductKHR' : 6019, + 'RayCullMaskKHR' : 6020, 'BitInstructions' : 6025, + 'GroupNonUniformRotateKHR' : 6026, 'AtomicFloat32AddEXT' : 6033, 'AtomicFloat64AddEXT' : 6034, 'LongConstantCompositeINTEL' : 6089, 'OptNoneINTEL' : 6094, 'AtomicFloat16AddEXT' : 6095, 'DebugInfoModuleINTEL' : 6114, + 'SplitBarrierINTEL' : 6141, + 'GroupUniformArithmeticKHR' : 6400, }, 'RayFlagsShift' : { @@ -1114,6 +1143,7 @@ spv = { }, 'PackedVectorFormat' : { + 'PackedVectorFormat4x8Bit' : 0, 'PackedVectorFormat4x8BitKHR' : 0, }, @@ -1468,17 +1498,24 @@ spv = { 'OpSubgroupAllKHR' : 4428, 'OpSubgroupAnyKHR' : 4429, 'OpSubgroupAllEqualKHR' : 4430, + 'OpGroupNonUniformRotateKHR' : 4431, 'OpSubgroupReadInvocationKHR' : 4432, 'OpTraceRayKHR' : 4445, 'OpExecuteCallableKHR' : 4446, 'OpConvertUToAccelerationStructureKHR' : 4447, 'OpIgnoreIntersectionKHR' : 4448, 'OpTerminateRayKHR' : 4449, + 'OpSDot' : 4450, 'OpSDotKHR' : 4450, + 'OpUDot' : 4451, 'OpUDotKHR' : 4451, + 'OpSUDot' : 4452, 'OpSUDotKHR' : 4452, + 'OpSDotAccSat' : 4453, 'OpSDotAccSatKHR' : 4453, + 'OpUDotAccSat' : 4454, 'OpUDotAccSatKHR' : 4454, + 'OpSUDotAccSat' : 4455, 'OpSUDotAccSatKHR' : 4455, 'OpTypeRayQueryKHR' : 4472, 'OpRayQueryInitializeKHR' : 4473, @@ -1518,6 +1555,7 @@ spv = { 'OpCooperativeMatrixLengthNV' : 5362, 'OpBeginInvocationInterlockEXT' : 5364, 'OpEndInvocationInterlockEXT' : 5365, + 'OpDemoteToHelperInvocation' : 5380, 'OpDemoteToHelperInvocationEXT' : 5380, 'OpIsHelperInvocationEXT' : 5381, 'OpConvertUToImageNV' : 5391, @@ -1727,6 +1765,9 @@ spv = { 'OpArbitraryFloatPowRINTEL' : 5881, 'OpArbitraryFloatPowNINTEL' : 5882, 'OpLoopControlINTEL' : 5887, + 'OpAliasDomainDeclINTEL' : 5911, + 'OpAliasScopeDeclINTEL' : 5912, + 'OpAliasScopeListDeclINTEL' : 5913, 'OpFixedSqrtINTEL' : 5923, 'OpFixedRecipINTEL' : 5924, 'OpFixedRsqrtINTEL' : 5925, @@ -1765,6 +1806,16 @@ spv = { 'OpTypeStructContinuedINTEL' : 6090, 'OpConstantCompositeContinuedINTEL' : 6091, 'OpSpecConstantCompositeContinuedINTEL' : 6092, + 'OpControlBarrierArriveINTEL' : 6142, + 'OpControlBarrierWaitINTEL' : 6143, + 'OpGroupIMulKHR' : 6401, + 'OpGroupFMulKHR' : 6402, + 'OpGroupBitwiseAndKHR' : 6403, + 'OpGroupBitwiseOrKHR' : 6404, + 'OpGroupBitwiseXorKHR' : 6405, + 'OpGroupLogicalAndKHR' : 6406, + 'OpGroupLogicalOrKHR' : 6407, + 'OpGroupLogicalXorKHR' : 6408, }, } diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spv.d b/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spv.d index afff6f4b01..db88b273f6 100644 --- a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spv.d +++ b/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spv.d @@ -31,7 +31,7 @@ /+ + Enumeration tokens for SPIR-V, in various styles: - + C, C++, C++11, JSON, Lua, Python, C#, D + + C, C++, C++11, JSON, Lua, Python, C#, D, Beef + + - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL + - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL @@ -41,6 +41,8 @@ + - C# will use enum classes in the Specification class located in the "Spv" namespace, + e.g.: Spv.Specification.SourceLanguage.GLSL + - D will have tokens under the "spv" module, e.g: spv.SourceLanguage.GLSL + + - Beef will use enum classes in the Specification class located in the "Spv" namespace, + + e.g.: Spv.Specification.SourceLanguage.GLSL + + Some tokens act like mask values, which can be OR'd together, + while others are mutually exclusive. The mask-like ones have @@ -51,8 +53,8 @@ module spv; enum uint MagicNumber = 0x07230203; -enum uint Version = 0x00010500; -enum uint Revision = 4; +enum uint Version = 0x00010600; +enum uint Revision = 1; enum uint OpCodeMask = 0xffff; enum uint WordCountShift = 16; @@ -65,6 +67,7 @@ enum SourceLanguage : uint OpenCL_CPP = 4, HLSL = 5, CPP_for_OpenCL = 6, + SYCL = 7, } enum ExecutionModel : uint @@ -179,6 +182,7 @@ enum ExecutionMode : uint NoGlobalOffsetINTEL = 5895, NumSIMDWorkitemsINTEL = 5896, SchedulerTargetFmaxMhzINTEL = 5903, + NamedBarrierCountINTEL = 6417, } enum StorageClass : uint @@ -352,6 +356,7 @@ enum ImageOperandsShift : uint VolatileTexelKHR = 11, SignExtend = 12, ZeroExtend = 13, + Nontemporal = 14, Offsets = 16, } @@ -376,6 +381,7 @@ enum ImageOperandsMask : uint VolatileTexelKHR = 0x00000800, SignExtend = 0x00001000, ZeroExtend = 0x00002000, + Nontemporal = 0x00004000, Offsets = 0x00010000, } @@ -495,6 +501,7 @@ enum Decoration : uint PerPrimitiveNV = 5271, PerViewNV = 5272, PerTaskNV = 5273, + PerVertexKHR = 5285, PerVertexNV = 5285, NonUniform = 5300, NonUniformEXT = 5300, @@ -540,11 +547,14 @@ enum Decoration : uint PrefetchINTEL = 5902, StallEnableINTEL = 5905, FuseLoopsInFunctionINTEL = 5907, + AliasScopeINTEL = 5914, + NoAliasINTEL = 5915, BufferLocationINTEL = 5921, IOPipeStorageINTEL = 5944, FunctionFloatingPointModeINTEL = 6080, SingleElementVectorINTEL = 6085, VectorComputeCallableFunctionINTEL = 6087, + MediaBlockIOINTEL = 6140, } enum BuiltIn : uint @@ -629,7 +639,9 @@ enum BuiltIn : uint LayerPerViewNV = 5279, MeshViewCountNV = 5280, MeshViewIndicesNV = 5281, + BaryCoordKHR = 5286, BaryCoordNV = 5286, + BaryCoordNoPerspKHR = 5287, BaryCoordNoPerspNV = 5287, FragSizeEXT = 5292, FragmentSizeNV = 5292, @@ -668,6 +680,7 @@ enum BuiltIn : uint SMCountNV = 5375, WarpIDNV = 5376, SMIDNV = 5377, + CullMaskKHR = 6021, } enum SelectionControlShift : uint @@ -799,6 +812,8 @@ enum MemoryAccessShift : uint MakePointerVisibleKHR = 4, NonPrivatePointer = 5, NonPrivatePointerKHR = 5, + AliasScopeINTELMask = 16, + NoAliasINTELMask = 17, } enum MemoryAccessMask : uint @@ -813,6 +828,8 @@ enum MemoryAccessMask : uint MakePointerVisibleKHR = 0x00000010, NonPrivatePointer = 0x00000020, NonPrivatePointerKHR = 0x00000020, + AliasScopeINTELMask = 0x00010000, + NoAliasINTELMask = 0x00020000, } enum Scope : uint @@ -927,6 +944,7 @@ enum Capability : uint GroupNonUniformQuad = 68, ShaderLayer = 69, ShaderViewportIndex = 70, + UniformDecoration = 71, FragmentShadingRateKHR = 4422, SubgroupBallotKHR = 4423, DrawParameters = 4427, @@ -975,6 +993,7 @@ enum Capability : uint FragmentFullyCoveredEXT = 5265, MeshShadingNV = 5266, ImageFootprintNV = 5282, + FragmentBarycentricKHR = 5284, FragmentBarycentricNV = 5284, ComputeDerivativeGroupQuadsNV = 5288, FragmentDensityEXT = 5291, @@ -1019,6 +1038,7 @@ enum Capability : uint FragmentShaderShadingRateInterlockEXT = 5372, ShaderSMBuiltinsNV = 5373, FragmentShaderPixelInterlockEXT = 5378, + DemoteToHelperInvocation = 5379, DemoteToHelperInvocationEXT = 5379, BindlessTextureNV = 5390, SubgroupShuffleINTEL = 5568, @@ -1053,23 +1073,32 @@ enum Capability : uint FPGAMemoryAccessesINTEL = 5898, FPGAClusterAttributesINTEL = 5904, LoopFuseINTEL = 5906, + MemoryAccessAliasingINTEL = 5910, FPGABufferLocationINTEL = 5920, ArbitraryPrecisionFixedPointINTEL = 5922, USMStorageClassesINTEL = 5935, IOPipesINTEL = 5943, BlockingPipesINTEL = 5945, FPGARegINTEL = 5948, + DotProductInputAll = 6016, DotProductInputAllKHR = 6016, + DotProductInput4x8Bit = 6017, DotProductInput4x8BitKHR = 6017, + DotProductInput4x8BitPacked = 6018, DotProductInput4x8BitPackedKHR = 6018, + DotProduct = 6019, DotProductKHR = 6019, + RayCullMaskKHR = 6020, BitInstructions = 6025, + GroupNonUniformRotateKHR = 6026, AtomicFloat32AddEXT = 6033, AtomicFloat64AddEXT = 6034, LongConstantCompositeINTEL = 6089, OptNoneINTEL = 6094, AtomicFloat16AddEXT = 6095, DebugInfoModuleINTEL = 6114, + SplitBarrierINTEL = 6141, + GroupUniformArithmeticKHR = 6400, } enum RayFlagsShift : uint @@ -1171,6 +1200,7 @@ enum OverflowModes : uint enum PackedVectorFormat : uint { + PackedVectorFormat4x8Bit = 0, PackedVectorFormat4x8BitKHR = 0, } @@ -1526,17 +1556,24 @@ enum Op : uint OpSubgroupAllKHR = 4428, OpSubgroupAnyKHR = 4429, OpSubgroupAllEqualKHR = 4430, + OpGroupNonUniformRotateKHR = 4431, OpSubgroupReadInvocationKHR = 4432, OpTraceRayKHR = 4445, OpExecuteCallableKHR = 4446, OpConvertUToAccelerationStructureKHR = 4447, OpIgnoreIntersectionKHR = 4448, OpTerminateRayKHR = 4449, + OpSDot = 4450, OpSDotKHR = 4450, + OpUDot = 4451, OpUDotKHR = 4451, + OpSUDot = 4452, OpSUDotKHR = 4452, + OpSDotAccSat = 4453, OpSDotAccSatKHR = 4453, + OpUDotAccSat = 4454, OpUDotAccSatKHR = 4454, + OpSUDotAccSat = 4455, OpSUDotAccSatKHR = 4455, OpTypeRayQueryKHR = 4472, OpRayQueryInitializeKHR = 4473, @@ -1576,6 +1613,7 @@ enum Op : uint OpCooperativeMatrixLengthNV = 5362, OpBeginInvocationInterlockEXT = 5364, OpEndInvocationInterlockEXT = 5365, + OpDemoteToHelperInvocation = 5380, OpDemoteToHelperInvocationEXT = 5380, OpIsHelperInvocationEXT = 5381, OpConvertUToImageNV = 5391, @@ -1785,6 +1823,9 @@ enum Op : uint OpArbitraryFloatPowRINTEL = 5881, OpArbitraryFloatPowNINTEL = 5882, OpLoopControlINTEL = 5887, + OpAliasDomainDeclINTEL = 5911, + OpAliasScopeDeclINTEL = 5912, + OpAliasScopeListDeclINTEL = 5913, OpFixedSqrtINTEL = 5923, OpFixedRecipINTEL = 5924, OpFixedRsqrtINTEL = 5925, @@ -1823,6 +1864,16 @@ enum Op : uint OpTypeStructContinuedINTEL = 6090, OpConstantCompositeContinuedINTEL = 6091, OpSpecConstantCompositeContinuedINTEL = 6092, + OpControlBarrierArriveINTEL = 6142, + OpControlBarrierWaitINTEL = 6143, + OpGroupIMulKHR = 6401, + OpGroupFMulKHR = 6402, + OpGroupBitwiseAndKHR = 6403, + OpGroupBitwiseOrKHR = 6404, + OpGroupBitwiseXorKHR = 6405, + OpGroupLogicalAndKHR = 6406, + OpGroupLogicalOrKHR = 6407, + OpGroupLogicalXorKHR = 6408, } diff --git a/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/header.cpp b/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/header.cpp index dc780ef372..f9e06fb5a8 100644 --- a/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/header.cpp +++ b/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/header.cpp @@ -69,9 +69,9 @@ namespace { TPrinter(); static const int DocMagicNumber = 0x07230203; - static const int DocVersion = 0x00010500; - static const int DocRevision = 4; - #define DocRevisionString "4" + static const int DocVersion = 0x00010600; + static const int DocRevision = 1; + #define DocRevisionString "1" static const std::string DocCopyright; static const std::string DocComment1; static const std::string DocComment2; @@ -199,7 +199,7 @@ namespace { const std::string TPrinter::DocComment2 = "Enumeration tokens for SPIR-V, in various styles:\n" - " C, C++, C++11, JSON, Lua, Python, C#, D\n" + " C, C++, C++11, JSON, Lua, Python, C#, D, Beef\n" "\n" "- C will have tokens with a \"Spv\" prefix, e.g.: SpvSourceLanguageGLSL\n" "- C++ will have tokens in the \"spv\" name space, e.g.: spv::SourceLanguageGLSL\n" @@ -209,6 +209,8 @@ namespace { "- C# will use enum classes in the Specification class located in the \"Spv\" namespace,\n" " e.g.: Spv.Specification.SourceLanguage.GLSL\n" "- D will have tokens under the \"spv\" module, e.g: spv.SourceLanguage.GLSL\n" + "- Beef will use enum classes in the Specification class located in the \"Spv\" namespace,\n" + " e.g.: Spv.Specification.SourceLanguage.GLSL\n" "\n" "Some tokens act like mask values, which can be OR'd together,\n" "while others are mutually exclusive. The mask-like ones have\n" @@ -513,6 +515,9 @@ namespace { } out << "#ifdef SPV_ENABLE_UTILITY_CODE" << std::endl; + out << "#ifndef __cplusplus" << std::endl; + out << "#include " << std::endl; + out << "#endif" << std::endl; out << "inline void " << pre() << "HasResultAndType(" << pre() << opName << " opcode, bool *hasResult, bool *hasResultType) {" << std::endl; out << " *hasResult = *hasResultType = false;" << std::endl; out << " switch (opcode) {" << std::endl; @@ -776,6 +781,43 @@ namespace { } }; + // Beef printer + class TPrinterBeef final : public TPrinter { + private: + std::string commentBOL() const override { return "// "; } + + void printPrologue(std::ostream& out) const override { + out << "namespace Spv\n{\n"; + out << indent() << "using System;\n\n"; + out << indent() << "public static class Specification\n"; + out << indent() << "{\n"; + } + + void printEpilogue(std::ostream& out) const override { + out << indent() << "}\n"; + out << "}\n"; + } + + std::string enumBeg(const std::string& s, enumStyle_t style) const override { + return indent(2) + "[AllowDuplicates, CRepr] public enum " + s + styleStr(style) + "\n" + indent(2) + "{\n"; + } + + std::string enumEnd(const std::string& s, enumStyle_t style, bool isLast) const override { + return indent(2) + "}" + +(isLast ? "\n" : "\n\n"); + } + + std::string enumFmt(const std::string& s, const valpair_t& v, + enumStyle_t style, bool isLast) const override { + return indent(3) + prependIfDigit(s, v.second) + " = " + fmtStyleVal(v.first, style) + ",\n"; + } + + std::string fmtConstInt(unsigned val, const std::string& name, + const char* fmt, bool isLast) const override { + return indent(2) + std::string("public const uint32 ") + name + + " = " + fmtNum(fmt, val) + (isLast ? ";\n\n" : ";\n"); + } + }; + } // namespace namespace spv { @@ -792,6 +834,7 @@ namespace spv { langInfo.push_back(std::make_pair(ELangPython, "spirv.py")); langInfo.push_back(std::make_pair(ELangCSharp, "spirv.cs")); langInfo.push_back(std::make_pair(ELangD, "spv.d")); + langInfo.push_back(std::make_pair(ELangBeef, "spirv.bf")); for (const auto& lang : langInfo) { std::ofstream out(lang.second, std::ios::out); @@ -819,6 +862,7 @@ namespace spv { case ELangPython: p = TPrinterPtr(new TPrinterPython); break; case ELangCSharp: p = TPrinterPtr(new TPrinterCSharp); break; case ELangD: p = TPrinterPtr(new TPrinterD); break; + case ELangBeef: p = TPrinterPtr(new TPrinterBeef); break; case ELangAll: PrintAllHeaders(); break; default: std::cerr << "Unknown language." << std::endl; diff --git a/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/header.h b/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/header.h index 9c34b21128..1dd6e67b2c 100644 --- a/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/header.h +++ b/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/header.h @@ -43,6 +43,7 @@ namespace spv { ELangPython, // Python ELangCSharp, // CSharp ELangD, // D + ELangBeef, // Beef ELangAll, // print headers in all languages to files }; diff --git a/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/main.cpp b/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/main.cpp index 7e5f7f808f..9a5971408c 100644 --- a/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/main.cpp +++ b/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/main.cpp @@ -52,6 +52,7 @@ void Usage() " Python - Python module (also accepts Py)\n" " C# - C# module (also accepts CSharp)\n" " D - D module\n" + " Beef - Beef module\n" " -H print header in all supported languages to files in current directory\n" ); } @@ -96,6 +97,8 @@ bool ProcessArguments(int argc, char* argv[]) Language = spv::ELangCSharp; } else if (language == "d") { Language = spv::ELangD; + } else if (language == "beef") { + Language = spv::ELangBeef; } else return false; diff --git a/third_party/spirv-tools/filament-specific-changes.patch b/third_party/spirv-tools/filament-specific-changes.patch index 715874e99c..a6d1fb5213 100644 --- a/third_party/spirv-tools/filament-specific-changes.patch +++ b/third_party/spirv-tools/filament-specific-changes.patch @@ -1,80 +1,69 @@ -From 468f1935352773b5f9975cae8800ed148b0c8bf3 Mon Sep 17 00:00:00 2001 -From: Benjamin Doherty -Date: Tue, 2 Nov 2021 14:48:14 -0700 -Subject: [PATCH] Filament specific changes - ---- - third_party/spirv-tools/CMakeLists.txt | 94 ++++++++++++------- - .../spirv-tools/external/CMakeLists.txt | 6 +- - .../external/spirv-headers/CMakeLists.txt | 8 +- - third_party/spirv-tools/source/CMakeLists.txt | 26 +++-- - 4 files changed, 86 insertions(+), 48 deletions(-) - +diff --git a/third_party/spirv-tools/.gitignore b/third_party/spirv-tools/.gitignore +index ec709ba79..a87496a7d 100644 +--- a/third_party/spirv-tools/.gitignore ++++ b/third_party/spirv-tools/.gitignore +@@ -5,8 +5,6 @@ compile_commands.json + /build*/ + /buildtools/ + /external/googletest +-/external/SPIRV-Headers +-/external/spirv-headers + /external/effcee + /external/re2 + /external/protobuf diff --git a/third_party/spirv-tools/CMakeLists.txt b/third_party/spirv-tools/CMakeLists.txt -index 70caf857a..3991bf660 100755 +index 76b87d8c5..53b3404d1 100755 --- a/third_party/spirv-tools/CMakeLists.txt +++ b/third_party/spirv-tools/CMakeLists.txt -@@ -24,8 +24,19 @@ if (POLICY CMP0054) +@@ -24,8 +24,14 @@ if (POLICY CMP0054) endif() set_property(GLOBAL PROPERTY USE_FOLDERS ON) -+# Filament specific changes +if (APPLE) + set(CMAKE_MACOSX_RPATH ON) +endif (APPLE) +set(SPIRV_SKIP_EXECUTABLES_OPTION ON) +set(SPIRV_SKIP_TESTS_OPTION ON) +set(SKIP_SPIRV_TOOLS_INSTALL ON) -+# End Filament specific changes + project(spirv-tools) -enable_testing() -+# Filament specific changes -+# enable_testing() -+# End Filament specific changes set(SPIRV_TOOLS "SPIRV-Tools") include(GNUInstallDirs) -@@ -71,7 +82,9 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "") +@@ -71,7 +77,6 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "") set(CMAKE_BUILD_TYPE "Debug") endif() -option(SKIP_SPIRV_TOOLS_INSTALL "Skip installation" ${SKIP_SPIRV_TOOLS_INSTALL}) -+# Filament specific changes -+# option(SKIP_SPIRV_TOOLS_INSTALL "Skip installation" ${SKIP_SPIRV_TOOLS_INSTALL}) -+# End Filament specific changes if(NOT ${SKIP_SPIRV_TOOLS_INSTALL}) set(ENABLE_SPIRV_TOOLS_INSTALL ON) endif() -@@ -88,7 +101,10 @@ set(SPIRV_LIB_FUZZING_ENGINE_LINK_OPTIONS "" CACHE STRING "Used by OSS-Fuzz to c +@@ -88,7 +93,8 @@ set(SPIRV_LIB_FUZZING_ENGINE_LINK_OPTIONS "" CACHE STRING "Used by OSS-Fuzz to c option(SPIRV_BUILD_LIBFUZZER_TARGETS "Build libFuzzer targets" OFF) -option(SPIRV_WERROR "Enable error on warning" ON) -+# Filament specific changes -+# option(SPIRV_WERROR "Enable error on warning" ON) +set(SPIRV_WERROR OFF) -+# End Filament specific changes ++ if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND (NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))) set(COMPILER_IS_LIKE_GNU TRUE) endif() -@@ -243,7 +259,13 @@ if(NOT COMMAND find_host_program) +@@ -243,7 +249,12 @@ if(NOT COMMAND find_host_program) endif() # Tests require Python3 -find_host_package(PythonInterp 3 REQUIRED) -+# Filament specific changes +if(CMAKE_VERSION VERSION_LESS "3.12" OR ${CMAKE_SYSTEM_NAME} MATCHES "Windows") + find_host_package(PythonInterp 3 REQUIRED) +else() + find_package(Python3 COMPONENTS Interpreter) + set(PYTHON_EXECUTABLE "${Python3_EXECUTABLE}") +endif() -+# End Filament specific changes # Check for symbol exports on Linux. # At the moment, this check will fail on the OSX build machines for the Android NDK. -@@ -286,11 +308,13 @@ if(ENABLE_SPIRV_TOOLS_INSTALL) +@@ -286,11 +297,13 @@ if(ENABLE_SPIRV_TOOLS_INSTALL) endif() # Defaults to OFF if the user didn't set it. @@ -83,33 +72,33 @@ index 70caf857a..3991bf660 100755 - ${SPIRV_SKIP_EXECUTABLES}) -option(SPIRV_SKIP_TESTS - "Skip building tests along with the library" ${SPIRV_SKIP_TESTS}) -+# Filament specific changes + option(SPIRV_SKIP_EXECUTABLES + "Skip building the executable and tests along with the library" + ${SPIRV_SKIP_EXECUTABLES_OPTION}) + option(SPIRV_SKIP_TESTS + "Skip building tests along with the library" ${SPIRV_SKIP_TESTS_OPTION}) -+# End Filament specific changes ++ ++ if ("${SPIRV_SKIP_EXECUTABLES}") set(SPIRV_SKIP_TESTS ON) endif() -@@ -334,8 +358,10 @@ endif() +@@ -334,9 +347,6 @@ endif() add_subdirectory(source) add_subdirectory(tools) -add_subdirectory(test) -add_subdirectory(examples) -+# Filament specific changes -+#add_subdirectory(test) -+#add_subdirectory(examples) -+# End Filament specific changes - +- if(ENABLE_SPIRV_TOOLS_INSTALL) install( -@@ -360,28 +386,30 @@ set(SPIRV_SHARED_LIBRARIES "-lSPIRV-Tools-shared") + FILES +@@ -357,38 +367,3 @@ endif() - # Build pkg-config file - # Use a first-class target so it's regenerated when relevant files are updated. + set(SPIRV_LIBRARIES "-lSPIRV-Tools-opt -lSPIRV-Tools -lSPIRV-Tools-link") + set(SPIRV_SHARED_LIBRARIES "-lSPIRV-Tools-shared") +- +-# Build pkg-config file +-# Use a first-class target so it's regenerated when relevant files are updated. -add_custom_target(spirv-tools-pkg-config ALL - COMMAND ${CMAKE_COMMAND} - -DCHANGES_FILE=${CMAKE_CURRENT_SOURCE_DIR}/CHANGES @@ -132,75 +121,51 @@ index 70caf857a..3991bf660 100755 - -DSPIRV_SHARED_LIBRARIES=${SPIRV_SHARED_LIBRARIES} - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/write_pkg_config.cmake - DEPENDS "CHANGES" "cmake/SPIRV-Tools-shared.pc.in" "cmake/write_pkg_config.cmake") -+# Filament specific changes -+# add_custom_target(spirv-tools-pkg-config ALL -+# COMMAND ${CMAKE_COMMAND} -+# -DCHANGES_FILE=${CMAKE_CURRENT_SOURCE_DIR}/CHANGES -+# -DTEMPLATE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/SPIRV-Tools.pc.in -+# -DOUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools.pc -+# -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -+# -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} -+# -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} -+# -DSPIRV_LIBRARIES=${SPIRV_LIBRARIES} -+# -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/write_pkg_config.cmake -+# DEPENDS "CHANGES" "cmake/SPIRV-Tools.pc.in" "cmake/write_pkg_config.cmake") -+# add_custom_target(spirv-tools-shared-pkg-config ALL -+# COMMAND ${CMAKE_COMMAND} -+# -DCHANGES_FILE=${CMAKE_CURRENT_SOURCE_DIR}/CHANGES -+# -DTEMPLATE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/SPIRV-Tools-shared.pc.in -+# -DOUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools-shared.pc -+# -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -+# -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} -+# -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} -+# -DSPIRV_SHARED_LIBRARIES=${SPIRV_SHARED_LIBRARIES} -+# -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/write_pkg_config.cmake -+# DEPENDS "CHANGES" "cmake/SPIRV-Tools-shared.pc.in" "cmake/write_pkg_config.cmake") -+# End Filament specific changes +- +-# Install pkg-config file +-if (ENABLE_SPIRV_TOOLS_INSTALL) +- install( +- FILES +- ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools.pc +- ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools-shared.pc +- DESTINATION +- ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +-endif() +diff --git a/third_party/spirv-tools/FILAMENT_README.md b/third_party/spirv-tools/FILAMENT_README.md +index 39e4620a0..3aa363ebf 100644 +--- a/third_party/spirv-tools/FILAMENT_README.md ++++ b/third_party/spirv-tools/FILAMENT_README.md +@@ -1,9 +1,6 @@ +-When updating spirv-tools to a new version, make sure to preserve all the changes marked with +-the following in `CMakeLists.txt` and `source/CMakeLists.txt`: +- +-`# Filament specific changes` +- +-You can easily apply these changes by running the following command at Filament's root: ++When updating spirv-tools to a new version there are several `CMakeLists.txt` files that need ++to patched with Filament specific changes. This can be done by running the following command at ++Filament's root: - # Install pkg-config file - if (ENABLE_SPIRV_TOOLS_INSTALL) + ``` + git apply third_party/spirv-tools/filament-specific-changes.patch diff --git a/third_party/spirv-tools/external/CMakeLists.txt b/third_party/spirv-tools/external/CMakeLists.txt -index 179a4012f..152cfc421 100644 +index 179a4012f..a081e119b 100644 --- a/third_party/spirv-tools/external/CMakeLists.txt +++ b/third_party/spirv-tools/external/CMakeLists.txt -@@ -45,8 +45,10 @@ if (IS_DIRECTORY ${SPIRV_HEADER_DIR}) +@@ -45,8 +45,6 @@ if (IS_DIRECTORY ${SPIRV_HEADER_DIR}) # Do this so enclosing projects can use SPIRV-Headers_SOURCE_DIR to find # headers to include. if (NOT DEFINED SPIRV-Headers_SOURCE_DIR) - set(SPIRV_HEADERS_SKIP_INSTALL ON) - set(SPIRV_HEADERS_SKIP_EXAMPLES ON) -+# Filament specific changes -+ #set(SPIRV_HEADERS_SKIP_INSTALL ON) -+ #set(SPIRV_HEADERS_SKIP_EXAMPLES ON) -+# End Filament specific changes add_subdirectory(${SPIRV_HEADER_DIR}) endif() else() -diff --git a/third_party/spirv-tools/external/spirv-headers/CMakeLists.txt b/third_party/spirv-tools/external/spirv-headers/CMakeLists.txt -index c11150008..1a1fe9548 100644 ---- a/third_party/spirv-tools/external/spirv-headers/CMakeLists.txt -+++ b/third_party/spirv-tools/external/spirv-headers/CMakeLists.txt -@@ -49,11 +49,11 @@ add_custom_target(install-headers - COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv - $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/include/spirv) - --option(SPIRV_HEADERS_SKIP_EXAMPLES "Skip building examples" -- ${SPIRV_HEADERS_SKIP_EXAMPLES}) -+# Filament specific changes -+option(SPIRV_HEADERS_SKIP_EXAMPLES "Skip building examples" ON) - --option(SPIRV_HEADERS_SKIP_INSTALL "Skip install" -- ${SPIRV_HEADERS_SKIP_INSTALL}) -+option(SPIRV_HEADERS_SKIP_INSTALL "Skip install" ON) -+# End Filament specific changes - - if(NOT ${SPIRV_HEADERS_SKIP_EXAMPLES}) - set(SPIRV_HEADERS_ENABLE_EXAMPLES ON) diff --git a/third_party/spirv-tools/source/CMakeLists.txt b/third_party/spirv-tools/source/CMakeLists.txt -index 331ff6755..ef6eb8e77 100644 +index 98559b8fe..0734d6a82 100644 --- a/third_party/spirv-tools/source/CMakeLists.txt +++ b/third_party/spirv-tools/source/CMakeLists.txt -@@ -371,13 +371,15 @@ endfunction() +@@ -374,13 +374,6 @@ endfunction() # Always build ${SPIRV_TOOLS}-shared. This is expected distro packages, and # unlike the other SPIRV_TOOLS target, defaults to hidden symbol visibility. @@ -211,38 +176,39 @@ index 331ff6755..ef6eb8e77 100644 - PRIVATE SPIRV_TOOLS_IMPLEMENTATION - PUBLIC SPIRV_TOOLS_SHAREDLIB -) -+# Filament specific changes -+# add_library(${SPIRV_TOOLS}-shared SHARED ${SPIRV_SOURCES}) -+# spirv_tools_default_target_options(${SPIRV_TOOLS}-shared) -+# set_target_properties(${SPIRV_TOOLS}-shared PROPERTIES CXX_VISIBILITY_PRESET hidden) -+# target_compile_definitions(${SPIRV_TOOLS}-shared -+# PRIVATE SPIRV_TOOLS_IMPLEMENTATION -+# PUBLIC SPIRV_TOOLS_SHAREDLIB -+# ) -+# End Filament specific changes if(SPIRV_TOOLS_BUILD_STATIC) add_library(${SPIRV_TOOLS}-static STATIC ${SPIRV_SOURCES}) -@@ -393,11 +395,17 @@ if(SPIRV_TOOLS_BUILD_STATIC) +@@ -396,11 +389,11 @@ if(SPIRV_TOOLS_BUILD_STATIC) add_library(${SPIRV_TOOLS} ALIAS ${SPIRV_TOOLS}-static) endif() - set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}-static ${SPIRV_TOOLS}-shared) -+# Filament specific changes -+ # set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}-static ${SPIRV_TOOLS}-shared) + set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}-static) -+# End Filament specific changes else() add_library(${SPIRV_TOOLS} ${SPIRV_TOOLS_LIBRARY_TYPE} ${SPIRV_SOURCES}) spirv_tools_default_target_options(${SPIRV_TOOLS}) - set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS} ${SPIRV_TOOLS}-shared) -+# Filament specific changes -+ # set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS} ${SPIRV_TOOLS}-shared) + set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}) -+# End Filament specific changes endif() if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") --- -2.33.1.1089.g2158813163f-goog +diff --git a/third_party/spirv-tools/external/spirv-headers/CMakeLists.txt b/third_party/spirv-tools/external/spirv-headers/CMakeLists.txt +index 147f7adee..d8d1d7e35 100644 +--- a/third_party/spirv-tools/external/spirv-headers/CMakeLists.txt ++++ b/third_party/spirv-tools/external/spirv-headers/CMakeLists.txt +@@ -49,11 +49,9 @@ add_custom_target(install-headers + COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv + $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/include/spirv) + +-option(SPIRV_HEADERS_SKIP_EXAMPLES "Skip building examples" +- ${SPIRV_HEADERS_SKIP_EXAMPLES}) ++option(SPIRV_HEADERS_SKIP_EXAMPLES "Skip building examples" ON) + +-option(SPIRV_HEADERS_SKIP_INSTALL "Skip install" +- ${SPIRV_HEADERS_SKIP_INSTALL}) ++option(SPIRV_HEADERS_SKIP_INSTALL "Skip install" ON) + + if(NOT ${SPIRV_HEADERS_SKIP_EXAMPLES}) + set(SPIRV_HEADERS_ENABLE_EXAMPLES ON) diff --git a/third_party/spirv-tools/include/spirv-tools/libspirv.h b/third_party/spirv-tools/include/spirv-tools/libspirv.h index 8df14f5fb4..e1b8890eb9 100644 --- a/third_party/spirv-tools/include/spirv-tools/libspirv.h +++ b/third_party/spirv-tools/include/spirv-tools/libspirv.h @@ -482,6 +482,7 @@ SPIRV_TOOLS_EXPORT const char* spvSoftwareVersionDetailsString(void); // SPV_ENV_VULKAN_1_1 -> SPIR-V 1.3 // SPV_ENV_VULKAN_1_1_SPIRV_1_4 -> SPIR-V 1.4 // SPV_ENV_VULKAN_1_2 -> SPIR-V 1.5 +// SPV_ENV_VULKAN_1_3 -> SPIR-V 1.6 // Consult the description of API entry points for specific rules. typedef enum { SPV_ENV_UNIVERSAL_1_0, // SPIR-V 1.0 latest revision, no other restrictions. @@ -516,7 +517,11 @@ typedef enum { SPV_ENV_UNIVERSAL_1_5, // SPIR-V 1.5 latest revision, no other restrictions. SPV_ENV_VULKAN_1_2, // Vulkan 1.2 latest revision. - SPV_ENV_MAX // Keep this as the last enum value. + + SPV_ENV_UNIVERSAL_1_6, // SPIR-V 1.6 latest revision, no other restrictions. + SPV_ENV_VULKAN_1_3, // Vulkan 1.3 latest revision. + + SPV_ENV_MAX // Keep this as the last enum value. } spv_target_env; // SPIR-V Validator can be parameterized with the following Universal Limits. @@ -555,7 +560,7 @@ SPIRV_TOOLS_EXPORT bool spvParseVulkanEnv(uint32_t vulkan_ver, // Creates a context object for most of the SPIRV-Tools API. // Returns null if env is invalid. // -// See specific API calls for how the target environment is interpeted +// See specific API calls for how the target environment is interpreted // (particularly assembly and validation). SPIRV_TOOLS_EXPORT spv_context spvContextCreate(spv_target_env env); @@ -607,7 +612,7 @@ SPIRV_TOOLS_EXPORT void spvValidatorOptionsSetRelaxLogicalPointer( // set that option. // 2) Pointers that are pass as parameters to function calls do not have to // match the storage class of the formal parameter. -// 3) Pointers that are actaul parameters on function calls do not have to point +// 3) Pointers that are actual parameters on function calls do not have to point // to the same type pointed as the formal parameter. The types just need to // logically match. // 4) GLSLstd450 Interpolate* instructions can have a load of an interpolant @@ -633,7 +638,7 @@ SPIRV_TOOLS_EXPORT void spvValidatorOptionsSetUniformBufferStandardLayout( // Records whether the validator should use "scalar" block layout rules. // Scalar layout rules are more permissive than relaxed block layout. // -// See Vulkan extnesion VK_EXT_scalar_block_layout. The scalar alignment is +// See Vulkan extension VK_EXT_scalar_block_layout. The scalar alignment is // defined as follows: // - scalar alignment of a scalar is the scalar size // - scalar alignment of a vector is the scalar alignment of its component diff --git a/third_party/spirv-tools/include/spirv-tools/libspirv.hpp b/third_party/spirv-tools/include/spirv-tools/libspirv.hpp index 8dfb46b774..25eb8a1dcf 100644 --- a/third_party/spirv-tools/include/spirv-tools/libspirv.hpp +++ b/third_party/spirv-tools/include/spirv-tools/libspirv.hpp @@ -36,7 +36,7 @@ class Context { public: // Constructs a context targeting the given environment |env|. // - // See specific API calls for how the target environment is interpeted + // See specific API calls for how the target environment is interpreted // (particularly assembly and validation). // // The constructed instance will have an empty message consumer, which just @@ -139,7 +139,7 @@ class ValidatorOptions { // set that option. // 2) Pointers that are pass as parameters to function calls do not have to // match the storage class of the formal parameter. - // 3) Pointers that are actaul parameters on function calls do not have to + // 3) Pointers that are actual parameters on function calls do not have to // point to the same type pointed as the formal parameter. The types just // need to logically match. // 4) GLSLstd450 Interpolate* instructions can have a load of an interpolant diff --git a/third_party/spirv-tools/include/spirv-tools/optimizer.hpp b/third_party/spirv-tools/include/spirv-tools/optimizer.hpp index 21059cbe35..949735608d 100644 --- a/third_party/spirv-tools/include/spirv-tools/optimizer.hpp +++ b/third_party/spirv-tools/include/spirv-tools/optimizer.hpp @@ -43,7 +43,7 @@ class Optimizer { // consumed by the RegisterPass() method. Tokens are one-time objects that // only support move; copying is not allowed. struct PassToken { - struct Impl; // Opaque struct for holding inernal data. + struct Impl; // Opaque struct for holding internal data. PassToken(std::unique_ptr); @@ -227,16 +227,17 @@ Optimizer::PassToken CreateNullPass(); // Creates a strip-debug-info pass. // A strip-debug-info pass removes all debug instructions (as documented in -// Section 3.32.2 of the SPIR-V spec) of the SPIR-V module to be optimized. +// Section 3.42.2 of the SPIR-V spec) of the SPIR-V module to be optimized. Optimizer::PassToken CreateStripDebugInfoPass(); -// Creates a strip-reflect-info pass. -// A strip-reflect-info pass removes all reflections instructions. -// For now, this is limited to removing decorations defined in -// SPV_GOOGLE_hlsl_functionality1. The coverage may expand in -// the future. +// [Deprecated] This will create a strip-nonsemantic-info pass. See below. Optimizer::PassToken CreateStripReflectInfoPass(); +// Creates a strip-nonsemantic-info pass. +// A strip-nonsemantic-info pass removes all reflections and explicitly +// non-semantic instructions. +Optimizer::PassToken CreateStripNonSemanticInfoPass(); + // Creates an eliminate-dead-functions pass. // An eliminate-dead-functions pass will remove all functions that are not in // the call trees rooted at entry points and exported functions. These @@ -295,11 +296,11 @@ Optimizer::PassToken CreateFreezeSpecConstantValuePass(); // and can be changed in future. A spec constant is foldable if all of its // value(s) can be determined from the module. E.g., an integer spec constant // defined with OpSpecConstantOp instruction can be folded if its value won't -// change later. This pass will replace the original OpSpecContantOp instruction -// with an OpConstant instruction. When folding composite spec constants, -// new instructions may be inserted to define the components of the composite -// constant first, then the original spec constants will be replaced by -// OpConstantComposite instructions. +// change later. This pass will replace the original OpSpecConstantOp +// instruction with an OpConstant instruction. When folding composite spec +// constants, new instructions may be inserted to define the components of the +// composite constant first, then the original spec constants will be replaced +// by OpConstantComposite instructions. // // There are some operations not supported yet: // OpSConvert, OpFConvert, OpQuantizeToF16 and @@ -325,7 +326,7 @@ Optimizer::PassToken CreateUnifyConstantPass(); // Creates a eliminate-dead-constant pass. // A eliminate-dead-constant pass removes dead constants, including normal -// contants defined by OpConstant, OpConstantComposite, OpConstantTrue, or +// constants defined by OpConstant, OpConstantComposite, OpConstantTrue, or // OpConstantFalse and spec constants defined by OpSpecConstant, // OpSpecConstantComposite, OpSpecConstantTrue, OpSpecConstantFalse or // OpSpecConstantOp. @@ -389,7 +390,7 @@ Optimizer::PassToken CreateInlineOpaquePass(); // Only modules with relaxed logical addressing (see opt/instruction.h) are // currently processed. // -// This pass is most effective if preceeded by Inlining and +// This pass is most effective if preceded by Inlining and // LocalAccessChainConvert. This pass will reduce the work needed to be done // by LocalSingleStoreElim and LocalMultiStoreElim. // @@ -407,7 +408,7 @@ Optimizer::PassToken CreateLocalSingleBlockLoadStoreElimPass(); // Note that some branches and blocks may be left to avoid creating invalid // control flow. Improving this is left to future work. // -// This pass is most effective when preceeded by passes which eliminate +// This pass is most effective when preceded by passes which eliminate // local loads and stores, effectively propagating constant values where // possible. Optimizer::PassToken CreateDeadBranchElimPass(); @@ -424,7 +425,7 @@ Optimizer::PassToken CreateDeadBranchElimPass(); // are currently processed. Currently modules with any extensions enabled are // not processed. This is left for future work. // -// This pass is most effective if preceeded by Inlining and +// This pass is most effective if preceded by Inlining and // LocalAccessChainConvert. LocalSingleStoreElim and LocalSingleBlockElim // will reduce the work that this pass has to do. Optimizer::PassToken CreateLocalMultiStoreElimPass(); @@ -519,7 +520,8 @@ Optimizer::PassToken CreateDeadInsertElimPass(); // interface are considered live and are not eliminated. This mode is needed // by GPU-Assisted validation instrumentation, where a change in the interface // is not allowed. -Optimizer::PassToken CreateAggressiveDCEPass(bool preserve_interface = false); +Optimizer::PassToken CreateAggressiveDCEPass(); +Optimizer::PassToken CreateAggressiveDCEPass(bool preserve_interface); // Creates a remove-unused-interface-variables pass. // Removes variables referenced on the |OpEntryPoint| instruction that are not @@ -628,7 +630,7 @@ Optimizer::PassToken CreateRedundancyEliminationPass(); Optimizer::PassToken CreateScalarReplacementPass(uint32_t size_limit = 100); // Create a private to local pass. -// This pass looks for variables delcared in the private storage class that are +// This pass looks for variables declared in the private storage class that are // used in only one function. Those variables are moved to the function storage // class in the function that they are used. Optimizer::PassToken CreatePrivateToLocalPass(); @@ -833,6 +835,19 @@ Optimizer::PassToken CreateFixStorageClassPass(); // inclusive. Optimizer::PassToken CreateGraphicsRobustAccessPass(); +// Create a pass to spread Volatile semantics to variables with SMIDNV, +// WarpIDNV, SubgroupSize, SubgroupLocalInvocationId, SubgroupEqMask, +// SubgroupGeMask, SubgroupGtMask, SubgroupLeMask, or SubgroupLtMask BuiltIn +// decorations or OpLoad for them when the shader model is the ray generation, +// closest hit, miss, intersection, or callable. This pass can be used for +// VUID-StandaloneSpirv-VulkanMemoryModel-04678 and +// VUID-StandaloneSpirv-VulkanMemoryModel-04679 (See "Standalone SPIR-V +// Validation" section of Vulkan spec "Appendix A: Vulkan Environment for +// SPIR-V"). When the SPIR-V version is 1.6 or above, the pass also spreads +// the Volatile semantics to a variable with HelperInvocation BuiltIn decoration +// in the fragement shader. +Optimizer::PassToken CreateSpreadVolatileSemanticsPass(); + // Create a pass to replace a descriptor access using variable index. // This pass replaces every access using a variable index to array variable // |desc| that has a DescriptorSet and Binding decorations with a constant @@ -871,6 +886,13 @@ Optimizer::PassToken CreateAmdExtToKhrPass(); // propagated into their final positions. Optimizer::PassToken CreateInterpolateFixupPass(); +// Removes unused components from composite input variables. Current +// implementation just removes trailing unused components from input arrays. +// The pass performs best after maximizing dead code removal. A subsequent dead +// code elimination pass would be beneficial in removing newly unused component +// types. +Optimizer::PassToken CreateEliminateDeadInputComponentsPass(); + // Creates a convert-to-sampled-image pass to convert images and/or // samplers with given pairs of descriptor set and binding to sampled image. // If a pair of an image and a sampler have the same pair of descriptor set and @@ -881,6 +903,20 @@ Optimizer::PassToken CreateConvertToSampledImagePass( const std::vector& descriptor_set_binding_pairs); +// Create an interface-variable-scalar-replacement pass that replaces array or +// matrix interface variables with a series of scalar or vector interface +// variables. For example, it replaces `float3 foo[2]` with `float3 foo0, foo1`. +Optimizer::PassToken CreateInterfaceVariableScalarReplacementPass(); + +// Creates a remove-dont-inline pass to remove the |DontInline| function control +// from every function in the module. This is useful if you want the inliner to +// inline these functions some reason. +Optimizer::PassToken CreateRemoveDontInlinePass(); +// Create a fix-func-call-param pass to fix non memory argument for the function +// call, as spirv-validation requires function parameters to be an memory +// object, currently the pass would remove accesschain pointer argument passed +// to the function +Optimizer::PassToken CreateFixFuncCallArgumentsPass(); } // namespace spvtools #endif // INCLUDE_SPIRV_TOOLS_OPTIMIZER_HPP_ diff --git a/third_party/spirv-tools/kokoro/macos-clang-release-bazel/build.sh b/third_party/spirv-tools/kokoro/macos-clang-release-bazel/build.sh index d2a516f5d8..c62611abdd 100644 --- a/third_party/spirv-tools/kokoro/macos-clang-release-bazel/build.sh +++ b/third_party/spirv-tools/kokoro/macos-clang-release-bazel/build.sh @@ -31,14 +31,14 @@ cd external && cd googletest && git reset --hard 1fb1bb23bb8418dc73a5a9a82bbed31 git clone --depth=1 https://github.com/google/effcee external/effcee git clone --depth=1 https://github.com/google/re2 external/re2 -# Get bazel 0.29.1. -gsutil cp gs://bazel/0.29.1/release/bazel-0.29.1-darwin-x86_64 . -chmod +x bazel-0.29.1-darwin-x86_64 +# Get bazel 5.0.0 +gsutil cp gs://bazel/5.0.0/release/bazel-5.0.0-darwin-x86_64 . +chmod +x bazel-5.0.0-darwin-x86_64 echo $(date): Build everything... -./bazel-0.29.1-darwin-x86_64 build :all +./bazel-5.0.0-darwin-x86_64 build :all echo $(date): Build completed. echo $(date): Starting bazel test... -./bazel-0.29.1-darwin-x86_64 test :all +./bazel-5.0.0-darwin-x86_64 test :all echo $(date): Bazel test completed. diff --git a/third_party/spirv-tools/kokoro/scripts/linux/build-docker.sh b/third_party/spirv-tools/kokoro/scripts/linux/build-docker.sh index 8f76803c78..80043b8a4e 100755 --- a/third_party/spirv-tools/kokoro/scripts/linux/build-docker.sh +++ b/third_party/spirv-tools/kokoro/scripts/linux/build-docker.sh @@ -195,7 +195,7 @@ elif [ $TOOL = "android-ndk-build" ]; then echo $(date): ndk-build completed. elif [ $TOOL = "bazel" ]; then - using bazel-3.1.0 + using bazel-5.0.0 echo $(date): Build everything... bazel build :all diff --git a/third_party/spirv-tools/kokoro/scripts/linux/build.sh b/third_party/spirv-tools/kokoro/scripts/linux/build.sh index 4731ebdc26..85d4b61abb 100644 --- a/third_party/spirv-tools/kokoro/scripts/linux/build.sh +++ b/third_party/spirv-tools/kokoro/scripts/linux/build.sh @@ -26,7 +26,9 @@ COMPILER=$2 TOOL=$3 BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT} +# "--privileged" is required to run ptrace in the asan builds. docker run --rm -i \ + --privileged \ --volume "${ROOT_DIR}:${ROOT_DIR}" \ --volume "${KOKORO_ARTIFACTS_DIR}:${KOKORO_ARTIFACTS_DIR}" \ --workdir "${ROOT_DIR}" \ diff --git a/third_party/spirv-tools/kokoro/scripts/windows/build.bat b/third_party/spirv-tools/kokoro/scripts/windows/build.bat index 24e29ccf08..8c9d6892c2 100644 --- a/third_party/spirv-tools/kokoro/scripts/windows/build.bat +++ b/third_party/spirv-tools/kokoro/scripts/windows/build.bat @@ -22,7 +22,7 @@ set BUILD_TYPE=%1 set VS_VERSION=%2 :: Force usage of python 3.6 -set PATH=C:\python36;"C:\Program Files\CMake\bin";%PATH% +set PATH=C:\python36;"C:\Program Files\cmake-3.23.1-windows-x86_64\bin";%PATH% cd %SRC% git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv-headers diff --git a/third_party/spirv-tools/kokoro/windows-msvc-2015-release-bazel/build.bat b/third_party/spirv-tools/kokoro/windows-msvc-2015-release-bazel/build.bat index 2f721af4c4..de20b0aa23 100644 --- a/third_party/spirv-tools/kokoro/windows-msvc-2015-release-bazel/build.bat +++ b/third_party/spirv-tools/kokoro/windows-msvc-2015-release-bazel/build.bat @@ -30,14 +30,13 @@ git clone --depth=1 https://github.com/google/effcee external/effce git clone --depth=1 https://github.com/google/re2 external/re2 :: REM Install Bazel. -wget -q https://github.com/bazelbuild/bazel/releases/download/0.29.1/bazel-0.29.1-windows-x86_64.zip -unzip -q bazel-0.29.1-windows-x86_64.zip +wget -q https://github.com/bazelbuild/bazel/releases/download/5.0.0/bazel-5.0.0-windows-x86_64.zip +unzip -q bazel-5.0.0-windows-x86_64.zip :: Set up MSVC call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 set BAZEL_VS=C:\Program Files (x86)\Microsoft Visual Studio 14.0 set BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC -set BAZEL_SH=c:\tools\msys64\usr\bin\bash.exe set BAZEL_PYTHON=c:\tools\python2\python.exe :: ######################################### diff --git a/third_party/spirv-tools/source/CMakeLists.txt b/third_party/spirv-tools/source/CMakeLists.txt index ef6eb8e770..0734d6a823 100644 --- a/third_party/spirv-tools/source/CMakeLists.txt +++ b/third_party/spirv-tools/source/CMakeLists.txt @@ -197,7 +197,7 @@ set(SPIRV_TOOLS_CHANGES_FILE add_custom_command(OUTPUT ${SPIRV_TOOLS_BUILD_VERSION_INC} COMMAND ${PYTHON_EXECUTABLE} ${SPIRV_TOOLS_BUILD_VERSION_INC_GENERATOR} - ${spirv-tools_SOURCE_DIR} ${SPIRV_TOOLS_BUILD_VERSION_INC} + ${SPIRV_TOOLS_CHANGES_FILE} ${SPIRV_TOOLS_BUILD_VERSION_INC} DEPENDS ${SPIRV_TOOLS_BUILD_VERSION_INC_GENERATOR} ${SPIRV_TOOLS_CHANGES_FILE} COMMENT "Update build-version.inc in the SPIRV-Tools build directory (if necessary).") @@ -217,15 +217,18 @@ add_subdirectory(reduce) add_subdirectory(fuzz) add_subdirectory(link) add_subdirectory(lint) +add_subdirectory(diff) set(SPIRV_SOURCES ${spirv-tools_SOURCE_DIR}/include/spirv-tools/libspirv.h ${CMAKE_CURRENT_SOURCE_DIR}/util/bitutils.h ${CMAKE_CURRENT_SOURCE_DIR}/util/bit_vector.h + ${CMAKE_CURRENT_SOURCE_DIR}/util/hash_combine.h ${CMAKE_CURRENT_SOURCE_DIR}/util/hex_float.h ${CMAKE_CURRENT_SOURCE_DIR}/util/make_unique.h ${CMAKE_CURRENT_SOURCE_DIR}/util/parse_number.h + ${CMAKE_CURRENT_SOURCE_DIR}/util/pooled_linked_list.h ${CMAKE_CURRENT_SOURCE_DIR}/util/small_vector.h ${CMAKE_CURRENT_SOURCE_DIR}/util/string_utils.h ${CMAKE_CURRENT_SOURCE_DIR}/util/timer.h @@ -371,15 +374,6 @@ endfunction() # Always build ${SPIRV_TOOLS}-shared. This is expected distro packages, and # unlike the other SPIRV_TOOLS target, defaults to hidden symbol visibility. -# Filament specific changes -# add_library(${SPIRV_TOOLS}-shared SHARED ${SPIRV_SOURCES}) -# spirv_tools_default_target_options(${SPIRV_TOOLS}-shared) -# set_target_properties(${SPIRV_TOOLS}-shared PROPERTIES CXX_VISIBILITY_PRESET hidden) -# target_compile_definitions(${SPIRV_TOOLS}-shared -# PRIVATE SPIRV_TOOLS_IMPLEMENTATION -# PUBLIC SPIRV_TOOLS_SHAREDLIB -# ) -# End Filament specific changes if(SPIRV_TOOLS_BUILD_STATIC) add_library(${SPIRV_TOOLS}-static STATIC ${SPIRV_SOURCES}) @@ -395,24 +389,18 @@ if(SPIRV_TOOLS_BUILD_STATIC) add_library(${SPIRV_TOOLS} ALIAS ${SPIRV_TOOLS}-static) endif() -# Filament specific changes - # set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}-static ${SPIRV_TOOLS}-shared) set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}-static) -# End Filament specific changes else() add_library(${SPIRV_TOOLS} ${SPIRV_TOOLS_LIBRARY_TYPE} ${SPIRV_SOURCES}) spirv_tools_default_target_options(${SPIRV_TOOLS}) -# Filament specific changes - # set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS} ${SPIRV_TOOLS}-shared) set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}) -# End Filament specific changes endif() if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") find_library(LIBRT rt) if(LIBRT) foreach(target ${SPIRV_TOOLS_TARGETS}) - target_link_libraries(${target} ${LIBRT}) + target_link_libraries(${target} rt) endforeach() endif() endif() diff --git a/third_party/spirv-tools/source/assembly_grammar.cpp b/third_party/spirv-tools/source/assembly_grammar.cpp index 79f18eee39..4f5942ab4f 100644 --- a/third_party/spirv-tools/source/assembly_grammar.cpp +++ b/third_party/spirv-tools/source/assembly_grammar.cpp @@ -62,9 +62,9 @@ spv_result_t spvTextParseMaskOperand(spv_target_env env, end = std::find(begin, text_end, separator); spv_operand_desc entry = nullptr; - if (spvOperandTableNameLookup(env, operandTable, type, begin, end - begin, - &entry)) { - return SPV_ERROR_INVALID_TEXT; + if (auto error = spvOperandTableNameLookup(env, operandTable, type, begin, + end - begin, &entry)) { + return error; } value |= entry->value; diff --git a/third_party/spirv-tools/source/binary.cpp b/third_party/spirv-tools/source/binary.cpp index 93d5da7aba..24d32f8c4a 100644 --- a/third_party/spirv-tools/source/binary.cpp +++ b/third_party/spirv-tools/source/binary.cpp @@ -33,6 +33,7 @@ #include "source/operand.h" #include "source/spirv_constant.h" #include "source/spirv_endian.h" +#include "source/util/string_utils.h" spv_result_t spvBinaryHeaderGet(const spv_const_binary binary, const spv_endianness_t endian, @@ -62,6 +63,15 @@ spv_result_t spvBinaryHeaderGet(const spv_const_binary binary, return SPV_SUCCESS; } +std::string spvDecodeLiteralStringOperand(const spv_parsed_instruction_t& inst, + const uint16_t operand_index) { + assert(operand_index < inst.num_operands); + const spv_parsed_operand_t& operand = inst.operands[operand_index]; + + return spvtools::utils::MakeString(inst.words + operand.offset, + operand.num_words); +} + namespace { // A SPIR-V binary parser. A parser instance communicates detailed parse @@ -205,7 +215,7 @@ class Parser { size_t word_index; // The current position in words. size_t instruction_count; // The count of processed instructions spv_endianness_t endian; // The endianness of the binary. - // Is the SPIR-V binary in a different endiannes from the host native + // Is the SPIR-V binary in a different endianness from the host native // endianness? bool requires_endian_conversion; @@ -290,7 +300,7 @@ spv_result_t Parser::parseInstruction() { const uint32_t first_word = peek(); // If the module's endianness is different from the host native endianness, - // then converted_words contains the the endian-translated words in the + // then converted_words contains the endian-translated words in the // instruction. _.endian_converted_words.clear(); _.endian_converted_words.push_back(first_word); @@ -577,27 +587,18 @@ spv_result_t Parser::parseOperand(size_t inst_offset, case SPV_OPERAND_TYPE_LITERAL_STRING: case SPV_OPERAND_TYPE_OPTIONAL_LITERAL_STRING: { - convert_operand_endianness = false; - const char* string = - reinterpret_cast(_.words + _.word_index); - // Compute the length of the string, but make sure we don't run off the - // end of the input. - const size_t remaining_input_bytes = - sizeof(uint32_t) * (_.num_words - _.word_index); - const size_t string_num_content_bytes = - spv_strnlen_s(string, remaining_input_bytes); - // If there was no terminating null byte, then that's an end-of-input - // error. - if (string_num_content_bytes == remaining_input_bytes) + const size_t max_words = _.num_words - _.word_index; + std::string string = + spvtools::utils::MakeString(_.words + _.word_index, max_words, false); + + if (string.length() == max_words * 4) return exhaustedInputDiagnostic(inst_offset, opcode, type); - // Account for null in the word length, so add 1 for null, then add 3 to - // make sure we round up. The following is equivalent to: - // (string_num_content_bytes + 1 + 3) / 4 - const size_t string_num_words = string_num_content_bytes / 4 + 1; + // Make sure we can record the word count without overflow. // // This error can't currently be triggered because of validity // checks elsewhere. + const size_t string_num_words = string.length() / 4 + 1; if (string_num_words > std::numeric_limits::max()) { return diagnostic() << "Literal string is longer than " << std::numeric_limits::max() @@ -611,7 +612,7 @@ spv_result_t Parser::parseOperand(size_t inst_offset, // There is only one string literal argument to OpExtInstImport, // so it's sufficient to guard this just on the opcode. const spv_ext_inst_type_t ext_inst_type = - spvExtInstImportTypeGet(string); + spvExtInstImportTypeGet(string.c_str()); if (SPV_EXT_INST_TYPE_NONE == ext_inst_type) { return diagnostic() << "Invalid extended instruction import '" << string << "'"; diff --git a/third_party/spirv-tools/source/binary.h b/third_party/spirv-tools/source/binary.h index 66d24c7e41..eb3beacac3 100644 --- a/third_party/spirv-tools/source/binary.h +++ b/third_party/spirv-tools/source/binary.h @@ -15,6 +15,8 @@ #ifndef SOURCE_BINARY_H_ #define SOURCE_BINARY_H_ +#include + #include "source/spirv_definition.h" #include "spirv-tools/libspirv.h" @@ -33,4 +35,9 @@ spv_result_t spvBinaryHeaderGet(const spv_const_binary binary, // replacement for C11's strnlen_s which might not exist in all environments. size_t spv_strnlen_s(const char* str, size_t strsz); +// Decode the string literal operand with index operand_index from instruction +// inst. +std::string spvDecodeLiteralStringOperand(const spv_parsed_instruction_t& inst, + const uint16_t operand_index); + #endif // SOURCE_BINARY_H_ diff --git a/third_party/spirv-tools/source/cfa.h b/third_party/spirv-tools/source/cfa.h index 0d09014c9a..7cadf55f07 100644 --- a/third_party/spirv-tools/source/cfa.h +++ b/third_party/spirv-tools/source/cfa.h @@ -42,7 +42,7 @@ class CFA { /// Returns true if a block with @p id is found in the @p work_list vector /// - /// @param[in] work_list Set of blocks visited in the the depth first + /// @param[in] work_list Set of blocks visited in the depth first /// traversal /// of the CFG /// @param[in] id The ID of the block being checked diff --git a/third_party/spirv-tools/source/diff/CMakeLists.txt b/third_party/spirv-tools/source/diff/CMakeLists.txt new file mode 100644 index 0000000000..1328699ab1 --- /dev/null +++ b/third_party/spirv-tools/source/diff/CMakeLists.txt @@ -0,0 +1,54 @@ +# Copyright (c) 2022 Google LLC. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +set(SPIRV_TOOLS_DIFF_SOURCES + diff.h + lcs.h + + diff.cpp +) + +add_library(SPIRV-Tools-diff ${SPIRV_TOOLS_LIBRARY_TYPE} ${SPIRV_TOOLS_DIFF_SOURCES}) + +spvtools_default_compile_options(SPIRV-Tools-diff) +target_include_directories(SPIRV-Tools-diff + PUBLIC + $ + $ + $ + PRIVATE ${spirv-tools_BINARY_DIR} +) +# We need the assembling and disassembling functionalities in the main library. +target_link_libraries(SPIRV-Tools-diff + PUBLIC ${SPIRV_TOOLS_FULL_VISIBILITY}) +# We need the internals of spirv-opt. +target_link_libraries(SPIRV-Tools-diff + PUBLIC SPIRV-Tools-opt) + +set_property(TARGET SPIRV-Tools-diff PROPERTY FOLDER "SPIRV-Tools libraries") +spvtools_check_symbol_exports(SPIRV-Tools-diff) + +if(ENABLE_SPIRV_TOOLS_INSTALL) + install(TARGETS SPIRV-Tools-diff EXPORT SPIRV-Tools-diffTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + export(EXPORT SPIRV-Tools-diffTargets FILE SPIRV-Tools-diffTargets.cmake) + + spvtools_config_package_dir(SPIRV-Tools-diff PACKAGE_DIR) + install(EXPORT SPIRV-Tools-diffTargets FILE SPIRV-Tools-diffTargets.cmake + DESTINATION ${PACKAGE_DIR}) + + spvtools_generate_config_file(SPIRV-Tools-diff) + install(FILES ${CMAKE_BINARY_DIR}/SPIRV-Tools-diffConfig.cmake DESTINATION ${PACKAGE_DIR}) +endif(ENABLE_SPIRV_TOOLS_INSTALL) diff --git a/third_party/spirv-tools/source/diff/diff.cpp b/third_party/spirv-tools/source/diff/diff.cpp new file mode 100644 index 0000000000..bca31b061c --- /dev/null +++ b/third_party/spirv-tools/source/diff/diff.cpp @@ -0,0 +1,2862 @@ +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "source/diff/diff.h" + +#include "source/diff/lcs.h" +#include "source/disassemble.h" +#include "source/ext_inst.h" +#include "source/latest_version_spirv_header.h" +#include "source/print.h" +#include "spirv-tools/libspirv.hpp" + +namespace spvtools { +namespace diff { + +namespace { + +// A map from an id to the instruction that defines it. +using IdToInstructionMap = std::vector; +// A map from an id to the instructions that decorate it, or name it, etc. +using IdToInfoMap = std::vector>; +// A map from an instruction to another, used for instructions without id. +using InstructionToInstructionMap = + std::unordered_map; +// A flat list of instructions in a function for easier iteration. +using InstructionList = std::vector; +// A map from a function to its list of instructions. +using FunctionInstMap = std::map; +// A list of ids with some similar property, for example functions with the same +// name. +using IdGroup = std::vector; +// A map of names to ids with the same name. This is an ordered map so +// different implementations produce identical results. +using IdGroupMapByName = std::map; +using IdGroupMapByTypeId = std::map; +using IdGroupMapByOp = std::map; +using IdGroupMapByStorageClass = std::map; + +// A set of potential id mappings that haven't been resolved yet. Any id in src +// may map in any id in dst. Note that ids are added in the same order as they +// appear in src and dst to facilitate matching dependent instructions. For +// example, this guarantees that when matching OpTypeVector, the basic type of +// the vector is already (potentially) matched. +struct PotentialIdMap { + std::vector src_ids; + std::vector dst_ids; +}; + +void CompactIds(std::vector& ids) { + size_t write_index = 0; + for (size_t i = 0; i < ids.size(); ++i) { + if (ids[i] != 0) { + ids[write_index++] = ids[i]; + } + } + ids.resize(write_index); +} + +// A mapping between src and dst ids. +class IdMap { + public: + IdMap(size_t id_bound) { id_map_.resize(id_bound, 0); } + + void MapIds(uint32_t from, uint32_t to) { + assert(from != 0); + assert(to != 0); + assert(from < id_map_.size()); + assert(id_map_[from] == 0); + + id_map_[from] = to; + } + + uint32_t MappedId(uint32_t from) const { + assert(from != 0); + return from < id_map_.size() ? id_map_[from] : 0; + } + const opt::Instruction* MappedInst(const opt::Instruction* from_inst) const { + assert(from_inst != nullptr); + assert(!from_inst->HasResultId()); + + auto mapped = inst_map_.find(from_inst); + if (mapped == inst_map_.end()) { + return nullptr; + } + return mapped->second; + } + + bool IsMapped(uint32_t from) const { + assert(from != 0); + return from < id_map_.size() && id_map_[from] != 0; + } + + // Map any ids in src and dst that have not been mapped to new ids in dst and + // src respectively. + void MapUnmatchedIds(IdMap& other_way); + + // Some instructions don't have result ids. Those are mapped by pointer. + void MapInsts(const opt::Instruction* from_inst, + const opt::Instruction* to_inst) { + assert(from_inst != nullptr); + assert(to_inst != nullptr); + assert(inst_map_.find(from_inst) == inst_map_.end()); + + inst_map_[from_inst] = to_inst; + } + + uint32_t IdBound() const { return static_cast(id_map_.size()); } + + private: + // Given an id, returns the corresponding id in the other module, or 0 if not + // matched yet. + std::vector id_map_; + + // Same for instructions that don't have an id. + InstructionToInstructionMap inst_map_; +}; + +// Two way mapping of ids. +class SrcDstIdMap { + public: + SrcDstIdMap(size_t src_id_bound, size_t dst_id_bound) + : src_to_dst_(src_id_bound), dst_to_src_(dst_id_bound) {} + + void MapIds(uint32_t src, uint32_t dst) { + src_to_dst_.MapIds(src, dst); + dst_to_src_.MapIds(dst, src); + } + + uint32_t MappedDstId(uint32_t src) { + uint32_t dst = src_to_dst_.MappedId(src); + assert(dst == 0 || dst_to_src_.MappedId(dst) == src); + return dst; + } + uint32_t MappedSrcId(uint32_t dst) { + uint32_t src = dst_to_src_.MappedId(dst); + assert(src == 0 || src_to_dst_.MappedId(src) == dst); + return src; + } + + bool IsSrcMapped(uint32_t src) { return src_to_dst_.IsMapped(src); } + bool IsDstMapped(uint32_t dst) { return dst_to_src_.IsMapped(dst); } + + // Map any ids in src and dst that have not been mapped to new ids in dst and + // src respectively. + void MapUnmatchedIds(); + + // Some instructions don't have result ids. Those are mapped by pointer. + void MapInsts(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst) { + assert(src_inst->HasResultId() == dst_inst->HasResultId()); + if (src_inst->HasResultId()) { + MapIds(src_inst->result_id(), dst_inst->result_id()); + } else { + src_to_dst_.MapInsts(src_inst, dst_inst); + dst_to_src_.MapInsts(dst_inst, src_inst); + } + } + + const IdMap& SrcToDstMap() const { return src_to_dst_; } + const IdMap& DstToSrcMap() const { return dst_to_src_; } + + private: + IdMap src_to_dst_; + IdMap dst_to_src_; +}; + +struct IdInstructions { + IdInstructions(const opt::Module* module) + : inst_map_(module->IdBound(), nullptr), + name_map_(module->IdBound()), + decoration_map_(module->IdBound()), + forward_pointer_map_(module->IdBound()) { + // Map ids from all sections to instructions that define them. + MapIdsToInstruction(module->ext_inst_imports()); + MapIdsToInstruction(module->types_values()); + for (const opt::Function& function : *module) { + function.ForEachInst( + [this](const opt::Instruction* inst) { + if (inst->HasResultId()) { + MapIdToInstruction(inst->result_id(), inst); + } + }, + true, true); + } + + // Gather decorations applied to ids that could be useful in matching them + // between src and dst modules. + MapIdsToInfos(module->debugs2()); + MapIdsToInfos(module->annotations()); + MapIdsToInfos(module->types_values()); + } + + void MapIdToInstruction(uint32_t id, const opt::Instruction* inst); + + void MapIdsToInstruction( + opt::IteratorRange section); + void MapIdsToInfos( + opt::IteratorRange section); + + IdToInstructionMap inst_map_; + IdToInfoMap name_map_; + IdToInfoMap decoration_map_; + IdToInstructionMap forward_pointer_map_; +}; + +class Differ { + public: + Differ(opt::IRContext* src, opt::IRContext* dst, std::ostream& out, + Options options) + : src_context_(src), + dst_context_(dst), + src_(src->module()), + dst_(dst->module()), + options_(options), + out_(out), + src_id_to_(src_), + dst_id_to_(dst_), + id_map_(src_->IdBound(), dst_->IdBound()) { + // Cache function bodies in canonicalization order. + GetFunctionBodies(src_context_, &src_funcs_, &src_func_insts_); + GetFunctionBodies(dst_context_, &dst_funcs_, &dst_func_insts_); + } + + // Match ids or instructions of different sections. + void MatchCapabilities(); + void MatchExtensions(); + void MatchExtInstImportIds(); + void MatchMemoryModel(); + void MatchEntryPointIds(); + void MatchExecutionModes(); + void MatchTypeForwardPointers(); + void MatchTypeIds(); + void MatchConstants(); + void MatchVariableIds(); + void MatchFunctions(); + + // Debug info and annotations are matched only after ids are matched. + void MatchDebugs1(); + void MatchDebugs2(); + void MatchDebugs3(); + void MatchExtInstDebugInfo(); + void MatchAnnotations(); + + // Output the diff. + spv_result_t Output(); + + void DumpIdMap() { + if (!options_.dump_id_map) { + return; + } + + out_ << " Src -> Dst\n"; + for (uint32_t src_id = 1; src_id < src_->IdBound(); ++src_id) { + uint32_t dst_id = id_map_.MappedDstId(src_id); + if (src_id_to_.inst_map_[src_id] != nullptr && dst_id != 0) + out_ << std::setw(4) << src_id << " -> " << std::setw(4) << dst_id + << " [" << spvOpcodeString(src_id_to_.inst_map_[src_id]->opcode()) + << "]\n"; + } + } + + private: + // Helper functions that match ids between src and dst + void PoolPotentialIds( + opt::IteratorRange section, + std::vector& ids, bool is_src, + std::function filter, + std::function get_id); + void MatchIds( + PotentialIdMap& potential, + std::function + match); + // Helper functions that match id-less instructions between src and dst. + void MatchPreambleInstructions( + opt::IteratorRange src_insts, + opt::IteratorRange dst_insts); + InstructionList SortPreambleInstructions( + const opt::Module* module, + opt::IteratorRange insts); + int ComparePreambleInstructions(const opt::Instruction* a, + const opt::Instruction* b, + const opt::Module* src_inst_module, + const opt::Module* dst_inst_module); + // Helper functions that match debug and annotation instructions of already + // matched ids. + void MatchDebugAndAnnotationInstructions( + opt::IteratorRange src_insts, + opt::IteratorRange dst_insts); + + // Get various properties from an id. These Helper functions are passed to + // `GroupIds` and `GroupIdsAndMatch` below (as the `get_group` argument). + uint32_t GroupIdsHelperGetTypeId(const IdInstructions& id_to, uint32_t id); + SpvStorageClass GroupIdsHelperGetTypePointerStorageClass( + const IdInstructions& id_to, uint32_t id); + SpvOp GroupIdsHelperGetTypePointerTypeOp(const IdInstructions& id_to, + uint32_t id); + + // Given a list of ids, groups them based on some value. The `get_group` + // function extracts a piece of information corresponding to each id, and the + // ids are bucketed based on that (and output in `groups`). This is useful to + // attempt to match ids between src and dst only when said property is + // identical. + template + void GroupIds(const IdGroup& ids, bool is_src, std::map* groups, + T (Differ::*get_group)(const IdInstructions&, uint32_t)); + + // Calls GroupIds to bucket ids in src and dst based on a property returned by + // `get_group`. This function then calls `match_group` for each bucket (i.e. + // "group") with identical values for said property. + // + // For example, say src and dst ids have the following properties + // correspondingly: + // + // - src ids' properties: {id0: A, id1: A, id2: B, id3: C, id4: B} + // - dst ids' properties: {id0': B, id1': C, id2': B, id3': D, id4': B} + // + // Then `match_group` is called 2 times: + // + // - Once with: ([id2, id4], [id0', id2', id4']) corresponding to B + // - Once with: ([id3], [id2']) corresponding to C + // + // Ids corresponding to A and D cannot match based on this property. + template + void GroupIdsAndMatch( + const IdGroup& src_ids, const IdGroup& dst_ids, T invalid_group_key, + T (Differ::*get_group)(const IdInstructions&, uint32_t), + std::function + match_group); + + // Helper functions that determine if two instructions match + bool DoIdsMatch(uint32_t src_id, uint32_t dst_id); + bool DoesOperandMatch(const opt::Operand& src_operand, + const opt::Operand& dst_operand); + bool DoOperandsMatch(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst, + uint32_t in_operand_index_start, + uint32_t in_operand_count); + bool DoInstructionsMatch(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst); + bool DoIdsMatchFuzzy(uint32_t src_id, uint32_t dst_id); + bool DoesOperandMatchFuzzy(const opt::Operand& src_operand, + const opt::Operand& dst_operand); + bool DoInstructionsMatchFuzzy(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst); + bool AreIdenticalUintConstants(uint32_t src_id, uint32_t dst_id); + bool DoDebugAndAnnotationInstructionsMatch(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst); + bool AreVariablesMatchable(uint32_t src_id, uint32_t dst_id, + uint32_t flexibility); + bool MatchOpTypeStruct(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst, + uint32_t flexibility); + bool MatchOpConstant(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst, uint32_t flexibility); + bool MatchOpSpecConstant(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst); + bool MatchOpVariable(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst, uint32_t flexibility); + bool MatchPerVertexType(uint32_t src_type_id, uint32_t dst_type_id); + bool MatchPerVertexVariable(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst); + + // Helper functions for matching OpTypeForwardPointer + void MatchTypeForwardPointersByName(const IdGroup& src, const IdGroup& dst); + void MatchTypeForwardPointersByTypeOp(const IdGroup& src, const IdGroup& dst); + + // Helper functions for function matching. + using FunctionMap = std::map; + + InstructionList GetFunctionBody(opt::IRContext* context, + opt::Function& function); + InstructionList GetFunctionHeader(const opt::Function& function); + void GetFunctionBodies(opt::IRContext* context, FunctionMap* functions, + FunctionInstMap* function_insts); + void GetFunctionHeaderInstructions(const opt::Module* module, + FunctionInstMap* function_insts); + void BestEffortMatchFunctions(const IdGroup& src_func_ids, + const IdGroup& dst_func_ids, + const FunctionInstMap& src_func_insts, + const FunctionInstMap& dst_func_insts); + + // Calculates the diff of two function bodies. Note that the matched + // instructions themselves may not be identical; output of exact matches + // should produce the exact instruction while inexact matches should produce a + // diff as well. + // + // Returns the similarity of the two bodies = 2*N_match / (N_src + N_dst) + void MatchFunctionParamIds(const opt::Function* src_func, + const opt::Function* dst_func); + float MatchFunctionBodies(const InstructionList& src_body, + const InstructionList& dst_body, + DiffMatch* src_match_result, + DiffMatch* dst_match_result); + void MatchIdsInFunctionBodies(const InstructionList& src_body, + const InstructionList& dst_body, + const DiffMatch& src_match_result, + const DiffMatch& dst_match_result, + uint32_t flexibility); + void MatchVariablesUsedByMatchedInstructions(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst, + uint32_t flexibility); + + // Helper functions to retrieve information pertaining to an id + const opt::Instruction* GetInst(const IdInstructions& id_to, uint32_t id); + uint32_t GetConstantUint(const IdInstructions& id_to, uint32_t constant_id); + SpvExecutionModel GetExecutionModel(const opt::Module* module, + uint32_t entry_point_id); + bool HasName(const IdInstructions& id_to, uint32_t id); + // Get the OpName associated with an id + std::string GetName(const IdInstructions& id_to, uint32_t id, bool* has_name); + // Get the OpName associated with an id, with argument types stripped for + // functions. Some tools don't encode function argument types in the OpName + // string, and this improves diff between SPIR-V from those tools and others. + std::string GetSanitizedName(const IdInstructions& id_to, uint32_t id); + uint32_t GetVarTypeId(const IdInstructions& id_to, uint32_t var_id, + SpvStorageClass* storage_class); + bool GetDecorationValue(const IdInstructions& id_to, uint32_t id, + SpvDecoration decoration, uint32_t* decoration_value); + const opt::Instruction* GetForwardPointerInst(const IdInstructions& id_to, + uint32_t id); + bool IsIntType(const IdInstructions& id_to, uint32_t type_id); + bool IsFloatType(const IdInstructions& id_to, uint32_t type_id); + bool IsConstantUint(const IdInstructions& id_to, uint32_t id); + bool IsVariable(const IdInstructions& id_to, uint32_t pointer_id); + bool IsOp(const IdInstructions& id_to, uint32_t id, SpvOp opcode); + bool IsPerVertexType(const IdInstructions& id_to, uint32_t type_id); + bool IsPerVertexVariable(const IdInstructions& id_to, uint32_t type_id); + SpvStorageClass GetPerVertexStorageClass(const opt::Module* module, + uint32_t type_id); + spv_ext_inst_type_t GetExtInstType(const IdInstructions& id_to, + uint32_t set_id); + spv_number_kind_t GetNumberKind(const IdInstructions& id_to, + const opt::Instruction& inst, + uint32_t operand_index, + uint32_t* number_bit_width); + spv_number_kind_t GetTypeNumberKind(const IdInstructions& id_to, uint32_t id, + uint32_t* number_bit_width); + + // Helper functions to output a diff line + const opt::Instruction* MappedDstInst(const opt::Instruction* src_inst); + const opt::Instruction* MappedSrcInst(const opt::Instruction* dst_inst); + const opt::Instruction* MappedInstImpl(const opt::Instruction* inst, + const IdMap& to_other, + const IdInstructions& other_id_to); + void OutputLine(std::function are_lines_identical, + std::function output_src_line, + std::function output_dst_line); + template + void OutputSection( + const InstList& src_insts, const InstList& dst_insts, + std::function + write_inst); + void ToParsedInstruction(const opt::Instruction& inst, + const IdInstructions& id_to, + const opt::Instruction& original_inst, + spv_parsed_instruction_t* parsed_inst, + std::vector& parsed_operands, + std::vector& inst_binary); + opt::Instruction ToMappedSrcIds(const opt::Instruction& dst_inst); + + void OutputRed() { + if (options_.color_output) out_ << spvtools::clr::red{true}; + } + void OutputGreen() { + if (options_.color_output) out_ << spvtools::clr::green{true}; + } + void OutputResetColor() { + if (options_.color_output) out_ << spvtools::clr::reset{true}; + } + + opt::IRContext* src_context_; + opt::IRContext* dst_context_; + const opt::Module* src_; + const opt::Module* dst_; + Options options_; + std::ostream& out_; + + // Helpers to look up instructions based on id. + IdInstructions src_id_to_; + IdInstructions dst_id_to_; + + // The ids that have been matched between src and dst so far. + SrcDstIdMap id_map_; + + // List of instructions in function bodies after canonicalization. Cached + // here to avoid duplicate work. More importantly, some maps use + // opt::Instruction pointers so they need to be unique. + FunctionInstMap src_func_insts_; + FunctionInstMap dst_func_insts_; + FunctionMap src_funcs_; + FunctionMap dst_funcs_; +}; + +void IdMap::MapUnmatchedIds(IdMap& other_way) { + const uint32_t src_id_bound = static_cast(id_map_.size()); + const uint32_t dst_id_bound = static_cast(other_way.id_map_.size()); + + uint32_t next_src_id = src_id_bound; + uint32_t next_dst_id = dst_id_bound; + + for (uint32_t src_id = 1; src_id < src_id_bound; ++src_id) { + if (!IsMapped(src_id)) { + MapIds(src_id, next_dst_id); + + other_way.id_map_.push_back(0); + other_way.MapIds(next_dst_id++, src_id); + } + } + + for (uint32_t dst_id = 1; dst_id < dst_id_bound; ++dst_id) { + if (!other_way.IsMapped(dst_id)) { + id_map_.push_back(0); + MapIds(next_src_id, dst_id); + + other_way.MapIds(dst_id, next_src_id++); + } + } +} + +void SrcDstIdMap::MapUnmatchedIds() { + src_to_dst_.MapUnmatchedIds(dst_to_src_); +} + +void IdInstructions::MapIdToInstruction(uint32_t id, + const opt::Instruction* inst) { + assert(id != 0); + assert(id < inst_map_.size()); + assert(inst_map_[id] == nullptr); + + inst_map_[id] = inst; +} + +void IdInstructions::MapIdsToInstruction( + opt::IteratorRange section) { + for (const opt::Instruction& inst : section) { + uint32_t result_id = inst.result_id(); + if (result_id == 0) { + continue; + } + + MapIdToInstruction(result_id, &inst); + } +} + +void IdInstructions::MapIdsToInfos( + opt::IteratorRange section) { + for (const opt::Instruction& inst : section) { + IdToInfoMap* info_map = nullptr; + uint32_t id_operand = 0; + + switch (inst.opcode()) { + case SpvOpName: + info_map = &name_map_; + break; + case SpvOpMemberName: + info_map = &name_map_; + break; + case SpvOpDecorate: + info_map = &decoration_map_; + break; + case SpvOpMemberDecorate: + info_map = &decoration_map_; + break; + case SpvOpTypeForwardPointer: { + uint32_t id = inst.GetSingleWordOperand(0); + assert(id != 0); + + assert(id < forward_pointer_map_.size()); + forward_pointer_map_[id] = &inst; + continue; + } + default: + // Currently unsupported instruction, don't attempt to use it for + // matching. + break; + } + + if (info_map == nullptr) { + continue; + } + + uint32_t id = inst.GetOperand(id_operand).AsId(); + assert(id != 0); + + assert(id < info_map->size()); + assert(std::find((*info_map)[id].begin(), (*info_map)[id].end(), &inst) == + (*info_map)[id].end()); + + (*info_map)[id].push_back(&inst); + } +} + +void Differ::PoolPotentialIds( + opt::IteratorRange section, + std::vector& ids, bool is_src, + std::function filter, + std::function get_id) { + for (const opt::Instruction& inst : section) { + if (!filter(inst)) { + continue; + } + + uint32_t result_id = get_id(inst); + assert(result_id != 0); + + assert(std::find(ids.begin(), ids.end(), result_id) == ids.end()); + + // Don't include ids that are already matched, for example through + // OpTypeForwardPointer. + const bool is_matched = is_src ? id_map_.IsSrcMapped(result_id) + : id_map_.IsDstMapped(result_id); + if (is_matched) { + continue; + } + + ids.push_back(result_id); + } +} + +void Differ::MatchIds( + PotentialIdMap& potential, + std::function + match) { + for (size_t src_index = 0; src_index < potential.src_ids.size(); + ++src_index) { + for (size_t dst_index = 0; dst_index < potential.dst_ids.size(); + ++dst_index) { + const uint32_t src_id = potential.src_ids[src_index]; + const uint32_t dst_id = potential.dst_ids[dst_index]; + + if (dst_id == 0) { + // Already matched. + continue; + } + + const opt::Instruction* src_inst = src_id_to_.inst_map_[src_id]; + const opt::Instruction* dst_inst = dst_id_to_.inst_map_[dst_id]; + + if (match(src_inst, dst_inst)) { + id_map_.MapIds(src_id, dst_id); + + // Remove the ids from the potential list. + potential.src_ids[src_index] = 0; + potential.dst_ids[dst_index] = 0; + + // Find a match for the next src id. + break; + } + } + } + + // Remove matched ids to make the next iteration faster. + CompactIds(potential.src_ids); + CompactIds(potential.dst_ids); +} + +void Differ::MatchPreambleInstructions( + opt::IteratorRange src_insts, + opt::IteratorRange dst_insts) { + // First, pool all instructions from each section and sort them. + InstructionList sorted_src_insts = SortPreambleInstructions(src_, src_insts); + InstructionList sorted_dst_insts = SortPreambleInstructions(dst_, dst_insts); + + // Then walk and match them. + size_t src_cur = 0; + size_t dst_cur = 0; + + while (src_cur < sorted_src_insts.size() && + dst_cur < sorted_dst_insts.size()) { + const opt::Instruction* src_inst = sorted_src_insts[src_cur]; + const opt::Instruction* dst_inst = sorted_dst_insts[dst_cur]; + + int compare = ComparePreambleInstructions(src_inst, dst_inst, src_, dst_); + if (compare == 0) { + id_map_.MapInsts(src_inst, dst_inst); + } + if (compare <= 0) { + ++src_cur; + } + if (compare >= 0) { + ++dst_cur; + } + } +} + +InstructionList Differ::SortPreambleInstructions( + const opt::Module* module, + opt::IteratorRange insts) { + InstructionList sorted; + for (const opt::Instruction& inst : insts) { + sorted.push_back(&inst); + } + std::sort( + sorted.begin(), sorted.end(), + [this, module](const opt::Instruction* a, const opt::Instruction* b) { + return ComparePreambleInstructions(a, b, module, module) < 0; + }); + return sorted; +} + +int Differ::ComparePreambleInstructions(const opt::Instruction* a, + const opt::Instruction* b, + const opt::Module* src_inst_module, + const opt::Module* dst_inst_module) { + assert(a->opcode() == b->opcode()); + assert(!a->HasResultId()); + assert(!a->HasResultType()); + + const uint32_t a_operand_count = a->NumOperands(); + const uint32_t b_operand_count = b->NumOperands(); + + if (a_operand_count < b_operand_count) { + return -1; + } + if (a_operand_count > b_operand_count) { + return 1; + } + + // Instead of comparing OpExecutionMode entry point ids as ids, compare them + // through their corresponding execution model. This simplifies traversing + // the sorted list of instructions between src and dst modules. + if (a->opcode() == SpvOpExecutionMode) { + const SpvExecutionModel src_model = + GetExecutionModel(src_inst_module, a->GetSingleWordOperand(0)); + const SpvExecutionModel dst_model = + GetExecutionModel(dst_inst_module, b->GetSingleWordOperand(0)); + + if (src_model < dst_model) { + return -1; + } + if (src_model > dst_model) { + return 1; + } + } + + // Match every operand of the instruction. + for (uint32_t operand_index = 0; operand_index < a_operand_count; + ++operand_index) { + const opt::Operand& a_operand = a->GetOperand(operand_index); + const opt::Operand& b_operand = b->GetOperand(operand_index); + + if (a_operand.type < b_operand.type) { + return -1; + } + if (a_operand.type > b_operand.type) { + return 1; + } + + assert(a_operand.words.size() == 1); + assert(b_operand.words.size() == 1); + + switch (a_operand.type) { + case SPV_OPERAND_TYPE_ID: + // Don't compare ids, there can't be multiple instances of the + // OpExecutionMode with different ids of the same execution model. + break; + case SPV_OPERAND_TYPE_TYPE_ID: + case SPV_OPERAND_TYPE_MEMORY_SEMANTICS_ID: + case SPV_OPERAND_TYPE_SCOPE_ID: + assert(false && "Unreachable"); + break; + case SPV_OPERAND_TYPE_LITERAL_STRING: { + int str_compare = + strcmp(a_operand.AsString().c_str(), b_operand.AsString().c_str()); + if (str_compare != 0) { + return str_compare; + } + break; + } + default: + // Expect literal values to match. + if (a_operand.words[0] < b_operand.words[0]) { + return -1; + } + if (a_operand.words[0] > b_operand.words[0]) { + return 1; + } + break; + } + } + + return 0; +} + +void Differ::MatchDebugAndAnnotationInstructions( + opt::IteratorRange src_insts, + opt::IteratorRange dst_insts) { + for (const opt::Instruction& src_inst : src_insts) { + for (const opt::Instruction& dst_inst : dst_insts) { + if (MappedSrcInst(&dst_inst) != nullptr) { + continue; + } + + // Map instructions as soon as they match. Debug and annotation + // instructions are matched such that there can't be multiple matches. + if (DoDebugAndAnnotationInstructionsMatch(&src_inst, &dst_inst)) { + id_map_.MapInsts(&src_inst, &dst_inst); + break; + } + } + } +} + +uint32_t Differ::GroupIdsHelperGetTypeId(const IdInstructions& id_to, + uint32_t id) { + return GetInst(id_to, id)->type_id(); +} + +SpvStorageClass Differ::GroupIdsHelperGetTypePointerStorageClass( + const IdInstructions& id_to, uint32_t id) { + const opt::Instruction* inst = GetInst(id_to, id); + assert(inst && inst->opcode() == SpvOpTypePointer); + return SpvStorageClass(inst->GetSingleWordInOperand(0)); +} + +SpvOp Differ::GroupIdsHelperGetTypePointerTypeOp(const IdInstructions& id_to, + uint32_t id) { + const opt::Instruction* inst = GetInst(id_to, id); + assert(inst && inst->opcode() == SpvOpTypePointer); + + const uint32_t type_id = inst->GetSingleWordInOperand(1); + const opt::Instruction* type_inst = GetInst(id_to, type_id); + assert(type_inst); + + return type_inst->opcode(); +} + +template +void Differ::GroupIds(const IdGroup& ids, bool is_src, + std::map* groups, + T (Differ::*get_group)(const IdInstructions&, uint32_t)) { + assert(groups->empty()); + + const IdInstructions& id_to = is_src ? src_id_to_ : dst_id_to_; + + for (const uint32_t id : ids) { + // Don't include ids that are already matched, for example through + // OpEntryPoint. + const bool is_matched = + is_src ? id_map_.IsSrcMapped(id) : id_map_.IsDstMapped(id); + if (is_matched) { + continue; + } + + T group = (this->*get_group)(id_to, id); + (*groups)[group].push_back(id); + } +} + +template +void Differ::GroupIdsAndMatch( + const IdGroup& src_ids, const IdGroup& dst_ids, T invalid_group_key, + T (Differ::*get_group)(const IdInstructions&, uint32_t), + std::function + match_group) { + // Group the ids based on a key (get_group) + std::map src_groups; + std::map dst_groups; + + GroupIds(src_ids, true, &src_groups, get_group); + GroupIds(dst_ids, false, &dst_groups, get_group); + + // Iterate over the groups, and match those with identical keys + for (const auto& iter : src_groups) { + const T& key = iter.first; + const IdGroup& src_group = iter.second; + + if (key == invalid_group_key) { + continue; + } + + const IdGroup& dst_group = dst_groups[key]; + + // Let the caller match the groups as appropriate. + match_group(src_group, dst_group); + } +} + +bool Differ::DoIdsMatch(uint32_t src_id, uint32_t dst_id) { + assert(dst_id != 0); + return id_map_.MappedDstId(src_id) == dst_id; +} + +bool Differ::DoesOperandMatch(const opt::Operand& src_operand, + const opt::Operand& dst_operand) { + assert(src_operand.type == dst_operand.type); + + switch (src_operand.type) { + case SPV_OPERAND_TYPE_ID: + case SPV_OPERAND_TYPE_TYPE_ID: + case SPV_OPERAND_TYPE_RESULT_ID: + case SPV_OPERAND_TYPE_MEMORY_SEMANTICS_ID: + case SPV_OPERAND_TYPE_SCOPE_ID: + // Match ids only if they are already matched in the id map. + return DoIdsMatch(src_operand.AsId(), dst_operand.AsId()); + case SPV_OPERAND_TYPE_LITERAL_STRING: + return src_operand.AsString() == dst_operand.AsString(); + default: + // Otherwise expect them to match exactly. + assert(src_operand.type != SPV_OPERAND_TYPE_LITERAL_STRING); + if (src_operand.words.size() != dst_operand.words.size()) { + return false; + } + for (size_t i = 0; i < src_operand.words.size(); ++i) { + if (src_operand.words[i] != dst_operand.words[i]) { + return false; + } + } + return true; + } +} + +bool Differ::DoOperandsMatch(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst, + uint32_t in_operand_index_start, + uint32_t in_operand_count) { + // Caller should have returned early for instructions with different opcode. + assert(src_inst->opcode() == dst_inst->opcode()); + + bool match = true; + for (uint32_t i = 0; i < in_operand_count; ++i) { + const uint32_t in_operand_index = in_operand_index_start + i; + + const opt::Operand& src_operand = src_inst->GetInOperand(in_operand_index); + const opt::Operand& dst_operand = dst_inst->GetInOperand(in_operand_index); + + match = match && DoesOperandMatch(src_operand, dst_operand); + } + + return match; +} + +bool Differ::DoInstructionsMatch(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst) { + // Check whether the two instructions are identical, that is the instructions + // themselves are matched, every id is matched, and every other value is + // identical. + if (MappedDstInst(src_inst) != dst_inst) { + return false; + } + + assert(src_inst->opcode() == dst_inst->opcode()); + if (src_inst->NumOperands() != dst_inst->NumOperands()) { + return false; + } + + for (uint32_t operand_index = 0; operand_index < src_inst->NumOperands(); + ++operand_index) { + const opt::Operand& src_operand = src_inst->GetOperand(operand_index); + const opt::Operand& dst_operand = dst_inst->GetOperand(operand_index); + + if (!DoesOperandMatch(src_operand, dst_operand)) { + return false; + } + } + + return true; +} + +bool Differ::DoIdsMatchFuzzy(uint32_t src_id, uint32_t dst_id) { + assert(dst_id != 0); + const uint32_t mapped_dst_id = id_map_.MappedDstId(src_id); + + // Consider unmatched ids as a match. In function bodies, no result id is + // matched yet and thus they are excluded from instruction matching when used + // as parameters in subsequent instructions. + if (mapped_dst_id == 0 || mapped_dst_id == dst_id) { + return true; + } + + // Int and Uint constants are interchangeable, match them in that case. + if (AreIdenticalUintConstants(src_id, dst_id)) { + return true; + } + + return false; +} + +bool Differ::DoesOperandMatchFuzzy(const opt::Operand& src_operand, + const opt::Operand& dst_operand) { + if (src_operand.type != dst_operand.type) { + return false; + } + + assert(src_operand.type != SPV_OPERAND_TYPE_RESULT_ID); + assert(dst_operand.type != SPV_OPERAND_TYPE_RESULT_ID); + + switch (src_operand.type) { + case SPV_OPERAND_TYPE_ID: + case SPV_OPERAND_TYPE_TYPE_ID: + case SPV_OPERAND_TYPE_MEMORY_SEMANTICS_ID: + case SPV_OPERAND_TYPE_SCOPE_ID: + // Match id operands only if they are already matched in the id map. + return DoIdsMatchFuzzy(src_operand.AsId(), dst_operand.AsId()); + default: + // Otherwise allow everything to match. + return true; + } +} + +bool Differ::DoInstructionsMatchFuzzy(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst) { + // Similar to DoOperandsMatch, but only checks that ids that have already been + // matched are identical. Ids that are unknown are allowed to match, as well + // as any non-id operand. + if (src_inst->opcode() != dst_inst->opcode()) { + return false; + } + // For external instructions, make sure the set and opcode of the external + // instruction matches too. + if (src_inst->opcode() == SpvOpExtInst) { + if (!DoOperandsMatch(src_inst, dst_inst, 0, 2)) { + return false; + } + } + + assert(src_inst->HasResultType() == dst_inst->HasResultType()); + if (src_inst->HasResultType() && + !DoIdsMatchFuzzy(src_inst->type_id(), dst_inst->type_id())) { + return false; + } + + // TODO: allow some instructions to match with different instruction lengths, + // for example OpImage* with additional operands. + if (src_inst->NumInOperandWords() != dst_inst->NumInOperandWords()) { + return false; + } + + bool match = true; + for (uint32_t in_operand_index = 0; + in_operand_index < src_inst->NumInOperandWords(); ++in_operand_index) { + const opt::Operand& src_operand = src_inst->GetInOperand(in_operand_index); + const opt::Operand& dst_operand = dst_inst->GetInOperand(in_operand_index); + + match = match && DoesOperandMatchFuzzy(src_operand, dst_operand); + } + + return match; +} + +bool Differ::AreIdenticalUintConstants(uint32_t src_id, uint32_t dst_id) { + return IsConstantUint(src_id_to_, src_id) && + IsConstantUint(dst_id_to_, dst_id) && + GetConstantUint(src_id_to_, src_id) == + GetConstantUint(dst_id_to_, dst_id); +} + +bool Differ::DoDebugAndAnnotationInstructionsMatch( + const opt::Instruction* src_inst, const opt::Instruction* dst_inst) { + if (src_inst->opcode() != dst_inst->opcode()) { + return false; + } + + switch (src_inst->opcode()) { + case SpvOpString: + case SpvOpSourceExtension: + case SpvOpModuleProcessed: + return DoesOperandMatch(src_inst->GetOperand(0), dst_inst->GetOperand(0)); + case SpvOpSource: + return DoOperandsMatch(src_inst, dst_inst, 0, 2); + case SpvOpSourceContinued: + return true; + case SpvOpName: + return DoOperandsMatch(src_inst, dst_inst, 0, 1); + case SpvOpMemberName: + return DoOperandsMatch(src_inst, dst_inst, 0, 2); + case SpvOpDecorate: + return DoOperandsMatch(src_inst, dst_inst, 0, 2); + case SpvOpMemberDecorate: + return DoOperandsMatch(src_inst, dst_inst, 0, 3); + case SpvOpExtInst: + case SpvOpDecorationGroup: + case SpvOpGroupDecorate: + case SpvOpGroupMemberDecorate: + return false; + default: + return false; + } +} + +bool Differ::AreVariablesMatchable(uint32_t src_id, uint32_t dst_id, + uint32_t flexibility) { + // Variables must match by their built-in decorations. + uint32_t src_built_in_decoration = 0, dst_built_in_decoration = 0; + const bool src_is_built_in = GetDecorationValue( + src_id_to_, src_id, SpvDecorationBuiltIn, &src_built_in_decoration); + const bool dst_is_built_in = GetDecorationValue( + dst_id_to_, dst_id, SpvDecorationBuiltIn, &dst_built_in_decoration); + + if (src_is_built_in != dst_is_built_in) { + return false; + } + if (src_is_built_in && src_built_in_decoration != dst_built_in_decoration) { + return false; + } + + // Check their types and storage classes. + SpvStorageClass src_storage_class, dst_storage_class; + const uint32_t src_type_id = + GetVarTypeId(src_id_to_, src_id, &src_storage_class); + const uint32_t dst_type_id = + GetVarTypeId(dst_id_to_, dst_id, &dst_storage_class); + + if (!DoIdsMatch(src_type_id, dst_type_id)) { + return false; + } + switch (flexibility) { + case 0: + if (src_storage_class != dst_storage_class) { + return false; + } + break; + case 1: + if (src_storage_class != dst_storage_class) { + // Allow one of the two to be Private while the other is Input or + // Output, this allows matching in/out variables that have been turned + // global as part of linking two stages (as done in ANGLE). + const bool src_is_io = src_storage_class == SpvStorageClassInput || + src_storage_class == SpvStorageClassOutput; + const bool dst_is_io = dst_storage_class == SpvStorageClassInput || + dst_storage_class == SpvStorageClassOutput; + const bool src_is_private = src_storage_class == SpvStorageClassPrivate; + const bool dst_is_private = dst_storage_class == SpvStorageClassPrivate; + + if (!((src_is_io && dst_is_private) || (src_is_private && dst_is_io))) { + return false; + } + } + break; + default: + assert(false && "Unreachable"); + return false; + } + + // TODO: Is there any other way to check compatiblity of the variables? It's + // easy to tell when the variables definitely don't match, but there's little + // information that can be used for a definite match. + return true; +} + +bool Differ::MatchOpTypeStruct(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst, + uint32_t flexibility) { + const uint32_t src_type_id = src_inst->result_id(); + const uint32_t dst_type_id = dst_inst->result_id(); + + bool src_has_name = false, dst_has_name = false; + std::string src_name = GetName(src_id_to_, src_type_id, &src_has_name); + std::string dst_name = GetName(dst_id_to_, dst_type_id, &dst_has_name); + + // If debug info is present, always match the structs by name. + if (src_has_name && dst_has_name) { + if (src_name != dst_name) { + return false; + } + + // For gl_PerVertex, find the type pointer of this type (array) and make + // sure the storage classes of src and dst match; geometry and tessellation + // shaders have two instances of gl_PerVertex. + if (src_name == "gl_PerVertex") { + return MatchPerVertexType(src_type_id, dst_type_id); + } + + return true; + } + + // If debug info is not present, match the structs by their type. + + // For gl_PerVertex, find the type pointer of this type (array) and match by + // storage class. The gl_PerVertex struct is itself found by the BuiltIn + // decorations applied to its members. + const bool src_is_per_vertex = IsPerVertexType(src_id_to_, src_type_id); + const bool dst_is_per_vertex = IsPerVertexType(dst_id_to_, dst_type_id); + if (src_is_per_vertex != dst_is_per_vertex) { + return false; + } + + if (src_is_per_vertex) { + return MatchPerVertexType(src_type_id, dst_type_id); + } + + switch (flexibility) { + case 0: + if (src_inst->NumInOperandWords() != dst_inst->NumInOperandWords()) { + return false; + } + return DoOperandsMatch(src_inst, dst_inst, 0, + src_inst->NumInOperandWords()); + case 1: + // TODO: match by taking a diff of the fields, and see if there's a >75% + // match. Need to then make sure OpMemberName, OpMemberDecorate, + // OpAccessChain etc are aware of the struct field matching. + return false; + default: + assert(false && "Unreachable"); + return false; + } +} + +bool Differ::MatchOpConstant(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst, + uint32_t flexibility) { + // The constants' type must match. In flexibility == 1, match constants of + // int and uint, as they are generally interchangeable. + switch (flexibility) { + case 0: + if (!DoesOperandMatch(src_inst->GetOperand(0), dst_inst->GetOperand(0))) { + return false; + } + break; + case 1: + if (!IsIntType(src_id_to_, src_inst->type_id()) || + !IsIntType(dst_id_to_, dst_inst->type_id())) { + return false; + } + break; + default: + assert(false && "Unreachable"); + return false; + } + + const opt::Operand& src_value_operand = src_inst->GetOperand(2); + const opt::Operand& dst_value_operand = dst_inst->GetOperand(2); + + const uint64_t src_value = src_value_operand.AsLiteralUint64(); + const uint64_t dst_value = dst_value_operand.AsLiteralUint64(); + + // If values are identical, it's a match. + if (src_value == dst_value) { + return true; + } + + // Otherwise, only allow flexibility for float types. + if (IsFloatType(src_id_to_, src_inst->type_id()) && flexibility == 1) { + // Tolerance is: + // + // - For float: allow 4 bits of mantissa as error + // - For double: allow 6 bits of mantissa as error + // + // TODO: the above values are arbitrary and a placeholder; investigate the + // amount of error resulting from using `printf("%f", f)` and `printf("%lf", + // d)` and having glslang parse them. + const uint64_t tolerance = src_value_operand.words.size() == 1 ? 16 : 64; + return src_value - dst_value < tolerance || + dst_value - src_value < tolerance; + } + + return false; +} + +bool Differ::MatchOpSpecConstant(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst) { + const uint32_t src_id = src_inst->result_id(); + const uint32_t dst_id = dst_inst->result_id(); + + bool src_has_name = false, dst_has_name = false; + std::string src_name = GetName(src_id_to_, src_id, &src_has_name); + std::string dst_name = GetName(dst_id_to_, dst_id, &dst_has_name); + + // If debug info is present, always match the spec consts by name. + if (src_has_name && dst_has_name) { + return src_name == dst_name; + } + + // Otherwise, match them by SpecId. + uint32_t src_spec_id, dst_spec_id; + + if (GetDecorationValue(src_id_to_, src_id, SpvDecorationSpecId, + &src_spec_id) && + GetDecorationValue(dst_id_to_, dst_id, SpvDecorationSpecId, + &dst_spec_id)) { + return src_spec_id == dst_spec_id; + } + + // There is no spec id, this is not valid. + assert(false && "Unreachable"); + return false; +} + +bool Differ::MatchOpVariable(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst, + uint32_t flexibility) { + const uint32_t src_id = src_inst->result_id(); + const uint32_t dst_id = dst_inst->result_id(); + + const bool src_is_pervertex = IsPerVertexVariable(src_id_to_, src_id); + const bool dst_is_pervertex = IsPerVertexVariable(dst_id_to_, dst_id); + + // For gl_PerVertex, make sure the input and output instances are matched + // correctly. + if (src_is_pervertex != dst_is_pervertex) { + return false; + } + if (src_is_pervertex) { + return MatchPerVertexVariable(src_inst, dst_inst); + } + + bool src_has_name = false, dst_has_name = false; + std::string src_name = GetName(src_id_to_, src_id, &src_has_name); + std::string dst_name = GetName(dst_id_to_, dst_id, &dst_has_name); + + // If debug info is present, always match the variables by name. + if (src_has_name && dst_has_name) { + return src_name == dst_name; + } + + // If debug info is not present, see if the variables can be matched by their + // built-in decorations. + uint32_t src_built_in_decoration; + const bool src_is_built_in = GetDecorationValue( + src_id_to_, src_id, SpvDecorationBuiltIn, &src_built_in_decoration); + + if (src_is_built_in && AreVariablesMatchable(src_id, dst_id, flexibility)) { + return true; + } + + SpvStorageClass src_storage_class, dst_storage_class; + GetVarTypeId(src_id_to_, src_id, &src_storage_class); + GetVarTypeId(dst_id_to_, dst_id, &dst_storage_class); + + if (src_storage_class != dst_storage_class) { + return false; + } + + // If variables are decorated with set/binding, match by the value of those + // decorations. + if (!options_.ignore_set_binding) { + uint32_t src_set = 0, dst_set = 0; + uint32_t src_binding = 0, dst_binding = 0; + + const bool src_has_set = GetDecorationValue( + src_id_to_, src_id, SpvDecorationDescriptorSet, &src_set); + const bool dst_has_set = GetDecorationValue( + dst_id_to_, dst_id, SpvDecorationDescriptorSet, &dst_set); + const bool src_has_binding = + GetDecorationValue(src_id_to_, src_id, SpvDecorationBinding, &src_set); + const bool dst_has_binding = + GetDecorationValue(dst_id_to_, dst_id, SpvDecorationBinding, &dst_set); + + if (src_has_set && dst_has_set && src_has_binding && dst_has_binding) { + return src_set == dst_set && src_binding == dst_binding; + } + } + + // If variables are decorated with location, match by the value of that + // decoration. + if (!options_.ignore_location) { + uint32_t src_location, dst_location; + + const bool src_has_location = GetDecorationValue( + src_id_to_, src_id, SpvDecorationLocation, &src_location); + const bool dst_has_location = GetDecorationValue( + dst_id_to_, dst_id, SpvDecorationLocation, &dst_location); + + if (src_has_location && dst_has_location) { + return src_location == dst_location; + } + } + + // Currently, there's no other way to match variables. + return false; +} + +bool Differ::MatchPerVertexType(uint32_t src_type_id, uint32_t dst_type_id) { + // For gl_PerVertex, find the type pointer of this type (array) and make sure + // the storage classes of src and dst match; geometry and tessellation shaders + // have two instances of gl_PerVertex. + SpvStorageClass src_storage_class = + GetPerVertexStorageClass(src_, src_type_id); + SpvStorageClass dst_storage_class = + GetPerVertexStorageClass(dst_, dst_type_id); + + assert(src_storage_class == SpvStorageClassInput || + src_storage_class == SpvStorageClassOutput); + assert(dst_storage_class == SpvStorageClassInput || + dst_storage_class == SpvStorageClassOutput); + + return src_storage_class == dst_storage_class; +} + +bool Differ::MatchPerVertexVariable(const opt::Instruction* src_inst, + const opt::Instruction* dst_inst) { + SpvStorageClass src_storage_class = + SpvStorageClass(src_inst->GetSingleWordInOperand(0)); + SpvStorageClass dst_storage_class = + SpvStorageClass(dst_inst->GetSingleWordInOperand(0)); + + return src_storage_class == dst_storage_class; +} + +void Differ::MatchTypeForwardPointersByName(const IdGroup& src, + const IdGroup& dst) { + // Given two sets of compatible groups of OpTypeForwardPointer instructions, + // attempts to match them by name. + + // Group them by debug info and loop over them. + GroupIdsAndMatch( + src, dst, "", &Differ::GetSanitizedName, + [this](const IdGroup& src_group, const IdGroup& dst_group) { + + // Match only if there's a unique forward declaration with this debug + // name. + if (src_group.size() == 1 && dst_group.size() == 1) { + id_map_.MapIds(src_group[0], dst_group[0]); + } + }); +} + +void Differ::MatchTypeForwardPointersByTypeOp(const IdGroup& src, + const IdGroup& dst) { + // Given two sets of compatible groups of OpTypeForwardPointer instructions, + // attempts to match them by type op. Must be called after + // MatchTypeForwardPointersByName to match as many as possible by debug info. + + // Remove ids that are matched with debug info in + // MatchTypeForwardPointersByName. + IdGroup src_unmatched_ids; + IdGroup dst_unmatched_ids; + + std::copy_if(src.begin(), src.end(), std::back_inserter(src_unmatched_ids), + [this](uint32_t id) { return !id_map_.IsSrcMapped(id); }); + std::copy_if(dst.begin(), dst.end(), std::back_inserter(dst_unmatched_ids), + [this](uint32_t id) { return !id_map_.IsDstMapped(id); }); + + // Match only if there's a unique forward declaration with this + // storage class and type opcode. If both have debug info, they + // must not have been matchable. + if (src_unmatched_ids.size() == 1 && dst_unmatched_ids.size() == 1) { + uint32_t src_id = src_unmatched_ids[0]; + uint32_t dst_id = dst_unmatched_ids[0]; + if (!HasName(src_id_to_, src_id) || !HasName(dst_id_to_, dst_id)) { + id_map_.MapIds(src_id, dst_id); + } + } +} + +InstructionList Differ::GetFunctionBody(opt::IRContext* context, + opt::Function& function) { + // Canonicalize the blocks of the function to produce better diff, for example + // to not produce any diff if the src and dst have the same switch/case blocks + // but with the cases simply reordered. + std::list order; + context->cfg()->ComputeStructuredOrder(&function, &*function.begin(), &order); + + // Go over the instructions of the function and add the instructions to a flat + // list to simplify future iterations. + InstructionList body; + for (opt::BasicBlock* block : order) { + block->ForEachInst( + [&body](const opt::Instruction* inst) { body.push_back(inst); }, true); + } + body.push_back(function.EndInst()); + + return body; +} + +InstructionList Differ::GetFunctionHeader(const opt::Function& function) { + // Go over the instructions of the function and add the header instructions to + // a flat list to simplify diff generation. + InstructionList body; + function.WhileEachInst( + [&body](const opt::Instruction* inst) { + if (inst->opcode() == SpvOpLabel) { + return false; + } + body.push_back(inst); + return true; + }, + true, true); + + return body; +} + +void Differ::GetFunctionBodies(opt::IRContext* context, FunctionMap* functions, + FunctionInstMap* function_insts) { + for (opt::Function& function : *context->module()) { + uint32_t id = function.result_id(); + assert(functions->find(id) == functions->end()); + assert(function_insts->find(id) == function_insts->end()); + + (*functions)[id] = &function; + + InstructionList body = GetFunctionBody(context, function); + (*function_insts)[id] = std::move(body); + } +} + +void Differ::GetFunctionHeaderInstructions(const opt::Module* module, + FunctionInstMap* function_insts) { + for (opt::Function& function : *module) { + InstructionList body = GetFunctionHeader(function); + (*function_insts)[function.result_id()] = std::move(body); + } +} + +void Differ::BestEffortMatchFunctions(const IdGroup& src_func_ids, + const IdGroup& dst_func_ids, + const FunctionInstMap& src_func_insts, + const FunctionInstMap& dst_func_insts) { + struct MatchResult { + uint32_t src_id; + uint32_t dst_id; + DiffMatch src_match; + DiffMatch dst_match; + float match_rate; + bool operator<(const MatchResult& other) const { + return match_rate > other.match_rate; + } + }; + std::vector all_match_results; + + for (const uint32_t src_func_id : src_func_ids) { + if (id_map_.IsSrcMapped(src_func_id)) { + continue; + } + const std::string src_name = GetSanitizedName(src_id_to_, src_func_id); + + for (const uint32_t dst_func_id : dst_func_ids) { + if (id_map_.IsDstMapped(dst_func_id)) { + continue; + } + + // Don't match functions that are named, but the names are different. + const std::string dst_name = GetSanitizedName(dst_id_to_, dst_func_id); + if (src_name != "" && dst_name != "" && src_name != dst_name) { + continue; + } + + DiffMatch src_match_result, dst_match_result; + float match_rate = MatchFunctionBodies( + src_func_insts.at(src_func_id), dst_func_insts.at(dst_func_id), + &src_match_result, &dst_match_result); + + // Only consider the functions a match if there's at least 60% match. + // This is an arbitrary limit that should be tuned. + constexpr float pass_match_rate = 0.6f; + if (match_rate >= pass_match_rate) { + all_match_results.emplace_back( + MatchResult{src_func_id, dst_func_id, std::move(src_match_result), + std::move(dst_match_result), match_rate}); + } + } + } + + std::sort(all_match_results.begin(), all_match_results.end()); + + for (const MatchResult& match_result : all_match_results) { + if (id_map_.IsSrcMapped(match_result.src_id) || + id_map_.IsDstMapped(match_result.dst_id)) { + continue; + } + + id_map_.MapIds(match_result.src_id, match_result.dst_id); + + MatchIdsInFunctionBodies(src_func_insts.at(match_result.src_id), + dst_func_insts.at(match_result.dst_id), + match_result.src_match, match_result.dst_match, 0); + } +} + +void Differ::MatchFunctionParamIds(const opt::Function* src_func, + const opt::Function* dst_func) { + IdGroup src_params; + IdGroup dst_params; + src_func->ForEachParam( + [&src_params](const opt::Instruction* param) { + src_params.push_back(param->result_id()); + }, + false); + dst_func->ForEachParam( + [&dst_params](const opt::Instruction* param) { + dst_params.push_back(param->result_id()); + }, + false); + + GroupIdsAndMatch( + src_params, dst_params, "", &Differ::GetSanitizedName, + [this](const IdGroup& src_group, const IdGroup& dst_group) { + + // There shouldn't be two parameters with the same name, so the ids + // should match. There is nothing restricting the SPIR-V however to have + // two parameters with the same name, so be resilient against that. + if (src_group.size() == 1 && dst_group.size() == 1) { + id_map_.MapIds(src_group[0], dst_group[0]); + } + }); + + // Then match the parameters by their type. If there are multiple of them, + // match them by their order. + GroupIdsAndMatch( + src_params, dst_params, 0, &Differ::GroupIdsHelperGetTypeId, + [this](const IdGroup& src_group_by_type_id, + const IdGroup& dst_group_by_type_id) { + + const size_t shared_param_count = + std::min(src_group_by_type_id.size(), dst_group_by_type_id.size()); + + for (size_t param_index = 0; param_index < shared_param_count; + ++param_index) { + id_map_.MapIds(src_group_by_type_id[0], dst_group_by_type_id[0]); + } + }); +} + +float Differ::MatchFunctionBodies(const InstructionList& src_body, + const InstructionList& dst_body, + DiffMatch* src_match_result, + DiffMatch* dst_match_result) { + LongestCommonSubsequence> lcs(src_body, + dst_body); + + uint32_t best_match_length = lcs.Get( + [this](const opt::Instruction* src_inst, + const opt::Instruction* dst_inst) { + return DoInstructionsMatchFuzzy(src_inst, dst_inst); + }, + src_match_result, dst_match_result); + + // TODO: take the gaps in between matches and match those again with a relaxed + // instruction-and-type-only comparison. This can produce a better diff for + // example if an array index is changed, causing the OpAccessChain id to not + // match and subsequently every operation that's derived from that id. + // Usually this mismatch cascades until the next OpStore which doesn't produce + // an id. + + return static_cast(best_match_length) * 2.0f / + static_cast(src_body.size() + dst_body.size()); +} + +void Differ::MatchIdsInFunctionBodies(const InstructionList& src_body, + const InstructionList& dst_body, + const DiffMatch& src_match_result, + const DiffMatch& dst_match_result, + uint32_t flexibility) { + size_t src_cur = 0; + size_t dst_cur = 0; + + while (src_cur < src_body.size() && dst_cur < dst_body.size()) { + if (src_match_result[src_cur] && dst_match_result[dst_cur]) { + // Match instructions the src and dst instructions. + // + // TODO: count the matchings between variables discovered this way and + // choose the "best match" after all functions have been diffed and all + // instructions analyzed. + const opt::Instruction* src_inst = src_body[src_cur++]; + const opt::Instruction* dst_inst = dst_body[dst_cur++]; + + // Record the matching between the instructions. This is done only once + // (hence flexibility == 0). Calls with non-zero flexibility values will + // only deal with matching other ids based on the operands. + if (flexibility == 0) { + id_map_.MapInsts(src_inst, dst_inst); + } + + // Match any unmatched variables referenced by the instructions. + MatchVariablesUsedByMatchedInstructions(src_inst, dst_inst, flexibility); + continue; + } + if (!src_match_result[src_cur]) { + ++src_cur; + } + if (!dst_match_result[dst_cur]) { + ++dst_cur; + } + } +} + +void Differ::MatchVariablesUsedByMatchedInstructions( + const opt::Instruction* src_inst, const opt::Instruction* dst_inst, + uint32_t flexibility) { + // For OpAccessChain, OpLoad and OpStore instructions that reference unmatched + // variables, match them as a best effort. + assert(src_inst->opcode() == dst_inst->opcode()); + switch (src_inst->opcode()) { + default: + // TODO: match functions based on OpFunctionCall? + break; + case SpvOpAccessChain: + case SpvOpInBoundsAccessChain: + case SpvOpPtrAccessChain: + case SpvOpInBoundsPtrAccessChain: + case SpvOpLoad: + case SpvOpStore: + const uint32_t src_pointer_id = src_inst->GetSingleWordInOperand(0); + const uint32_t dst_pointer_id = dst_inst->GetSingleWordInOperand(0); + if (IsVariable(src_id_to_, src_pointer_id) && + IsVariable(dst_id_to_, dst_pointer_id) && + !id_map_.IsSrcMapped(src_pointer_id) && + !id_map_.IsDstMapped(dst_pointer_id) && + AreVariablesMatchable(src_pointer_id, dst_pointer_id, flexibility)) { + id_map_.MapIds(src_pointer_id, dst_pointer_id); + } + break; + } +} + +const opt::Instruction* Differ::GetInst(const IdInstructions& id_to, + uint32_t id) { + assert(id != 0); + assert(id < id_to.inst_map_.size()); + + const opt::Instruction* inst = id_to.inst_map_[id]; + assert(inst != nullptr); + + return inst; +} + +uint32_t Differ::GetConstantUint(const IdInstructions& id_to, + uint32_t constant_id) { + const opt::Instruction* constant_inst = GetInst(id_to, constant_id); + assert(constant_inst->opcode() == SpvOpConstant); + assert(GetInst(id_to, constant_inst->type_id())->opcode() == SpvOpTypeInt); + + return constant_inst->GetSingleWordInOperand(0); +} + +SpvExecutionModel Differ::GetExecutionModel(const opt::Module* module, + uint32_t entry_point_id) { + for (const opt::Instruction& inst : module->entry_points()) { + assert(inst.opcode() == SpvOpEntryPoint); + if (inst.GetSingleWordOperand(1) == entry_point_id) { + return SpvExecutionModel(inst.GetSingleWordOperand(0)); + } + } + + assert(false && "Unreachable"); + return SpvExecutionModel(0xFFF); +} + +bool Differ::HasName(const IdInstructions& id_to, uint32_t id) { + assert(id != 0); + assert(id < id_to.name_map_.size()); + + for (const opt::Instruction* inst : id_to.name_map_[id]) { + if (inst->opcode() == SpvOpName) { + return true; + } + } + + return false; +} + +std::string Differ::GetName(const IdInstructions& id_to, uint32_t id, + bool* has_name) { + assert(id != 0); + assert(id < id_to.name_map_.size()); + + for (const opt::Instruction* inst : id_to.name_map_[id]) { + if (inst->opcode() == SpvOpName) { + *has_name = true; + return inst->GetOperand(1).AsString(); + } + } + + *has_name = false; + return ""; +} + +std::string Differ::GetSanitizedName(const IdInstructions& id_to, uint32_t id) { + bool has_name = false; + std::string name = GetName(id_to, id, &has_name); + + if (!has_name) { + return ""; + } + + // Remove args from the name, in case this is a function name + return name.substr(0, name.find('(')); +} + +uint32_t Differ::GetVarTypeId(const IdInstructions& id_to, uint32_t var_id, + SpvStorageClass* storage_class) { + const opt::Instruction* var_inst = GetInst(id_to, var_id); + assert(var_inst->opcode() == SpvOpVariable); + + *storage_class = SpvStorageClass(var_inst->GetSingleWordInOperand(0)); + + // Get the type pointer from the variable. + const uint32_t type_pointer_id = var_inst->type_id(); + const opt::Instruction* type_pointer_inst = GetInst(id_to, type_pointer_id); + + // Get the type from the type pointer. + return type_pointer_inst->GetSingleWordInOperand(1); +} + +bool Differ::GetDecorationValue(const IdInstructions& id_to, uint32_t id, + SpvDecoration decoration, + uint32_t* decoration_value) { + assert(id != 0); + assert(id < id_to.decoration_map_.size()); + + for (const opt::Instruction* inst : id_to.decoration_map_[id]) { + if (inst->opcode() == SpvOpDecorate && + inst->GetSingleWordOperand(0) == id && + inst->GetSingleWordOperand(1) == decoration) { + *decoration_value = inst->GetSingleWordOperand(2); + return true; + } + } + + return false; +} + +const opt::Instruction* Differ::GetForwardPointerInst( + const IdInstructions& id_to, uint32_t id) { + assert(id != 0); + assert(id < id_to.forward_pointer_map_.size()); + return id_to.forward_pointer_map_[id]; +} + +bool Differ::IsIntType(const IdInstructions& id_to, uint32_t type_id) { + return IsOp(id_to, type_id, SpvOpTypeInt); +} + +bool Differ::IsFloatType(const IdInstructions& id_to, uint32_t type_id) { + return IsOp(id_to, type_id, SpvOpTypeFloat); +} + +bool Differ::IsConstantUint(const IdInstructions& id_to, uint32_t id) { + const opt::Instruction* constant_inst = GetInst(id_to, id); + if (constant_inst->opcode() != SpvOpConstant) { + return false; + } + + const opt::Instruction* type_inst = GetInst(id_to, constant_inst->type_id()); + return type_inst->opcode() == SpvOpTypeInt; +} + +bool Differ::IsVariable(const IdInstructions& id_to, uint32_t pointer_id) { + return IsOp(id_to, pointer_id, SpvOpVariable); +} + +bool Differ::IsOp(const IdInstructions& id_to, uint32_t id, SpvOp op) { + return GetInst(id_to, id)->opcode() == op; +} + +bool Differ::IsPerVertexType(const IdInstructions& id_to, uint32_t type_id) { + assert(type_id != 0); + assert(type_id < id_to.decoration_map_.size()); + + for (const opt::Instruction* inst : id_to.decoration_map_[type_id]) { + if (inst->opcode() == SpvOpMemberDecorate && + inst->GetSingleWordOperand(0) == type_id && + inst->GetSingleWordOperand(2) == SpvDecorationBuiltIn) { + SpvBuiltIn built_in = SpvBuiltIn(inst->GetSingleWordOperand(3)); + + // Only gl_PerVertex can have, and it can only have, the following + // built-in decorations. + return built_in == SpvBuiltInPosition || + built_in == SpvBuiltInPointSize || + built_in == SpvBuiltInClipDistance || + built_in == SpvBuiltInCullDistance; + } + } + + return false; +} + +bool Differ::IsPerVertexVariable(const IdInstructions& id_to, uint32_t var_id) { + // Get the type from the type pointer. + SpvStorageClass storage_class; + uint32_t type_id = GetVarTypeId(id_to, var_id, &storage_class); + const opt::Instruction* type_inst = GetInst(id_to, type_id); + + // If array, get the element type. + if (type_inst->opcode() == SpvOpTypeArray) { + type_id = type_inst->GetSingleWordInOperand(0); + } + + // Now check if the type is gl_PerVertex. + return IsPerVertexType(id_to, type_id); +} + +SpvStorageClass Differ::GetPerVertexStorageClass(const opt::Module* module, + uint32_t type_id) { + for (const opt::Instruction& inst : module->types_values()) { + switch (inst.opcode()) { + case SpvOpTypeArray: + // The gl_PerVertex instance could be an array, look for a variable of + // the array type instead. + if (inst.GetSingleWordInOperand(0) == type_id) { + type_id = inst.result_id(); + } + break; + case SpvOpTypePointer: + // Find the storage class of the pointer to this type. + if (inst.GetSingleWordInOperand(1) == type_id) { + return SpvStorageClass(inst.GetSingleWordInOperand(0)); + } + break; + default: + break; + } + } + + // gl_PerVertex is declared, but is unused. Return either of Input or Output + // classes just so it matches one in the other module. This should be highly + // unlikely, perhaps except for ancient GS-used-to-emulate-CS scenarios. + return SpvStorageClassOutput; +} + +spv_ext_inst_type_t Differ::GetExtInstType(const IdInstructions& id_to, + uint32_t set_id) { + const opt::Instruction* set_inst = GetInst(id_to, set_id); + return spvExtInstImportTypeGet(set_inst->GetInOperand(0).AsString().c_str()); +} + +spv_number_kind_t Differ::GetNumberKind(const IdInstructions& id_to, + const opt::Instruction& inst, + uint32_t operand_index, + uint32_t* number_bit_width) { + const opt::Operand& operand = inst.GetOperand(operand_index); + *number_bit_width = 0; + + // A very limited version of Parser::parseOperand. + switch (operand.type) { + case SPV_OPERAND_TYPE_LITERAL_INTEGER: + case SPV_OPERAND_TYPE_OPTIONAL_LITERAL_INTEGER: + // Always unsigned integers. + *number_bit_width = 32; + return SPV_NUMBER_UNSIGNED_INT; + case SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER: + case SPV_OPERAND_TYPE_OPTIONAL_TYPED_LITERAL_INTEGER: + switch (inst.opcode()) { + case SpvOpSwitch: + case SpvOpConstant: + case SpvOpSpecConstant: + // Same kind of number as the selector (OpSwitch) or the type + // (Op*Constant). + return GetTypeNumberKind(id_to, inst.GetSingleWordOperand(0), + number_bit_width); + default: + assert(false && "Unreachable"); + break; + } + break; + default: + break; + } + + return SPV_NUMBER_NONE; +} + +spv_number_kind_t Differ::GetTypeNumberKind(const IdInstructions& id_to, + uint32_t id, + uint32_t* number_bit_width) { + const opt::Instruction* type_inst = GetInst(id_to, id); + if (!spvOpcodeIsScalarType(type_inst->opcode())) { + type_inst = GetInst(id_to, type_inst->type_id()); + } + + switch (type_inst->opcode()) { + case SpvOpTypeInt: + *number_bit_width = type_inst->GetSingleWordOperand(1); + return type_inst->GetSingleWordOperand(2) == 0 ? SPV_NUMBER_UNSIGNED_INT + : SPV_NUMBER_SIGNED_INT; + break; + case SpvOpTypeFloat: + *number_bit_width = type_inst->GetSingleWordOperand(1); + return SPV_NUMBER_FLOATING; + default: + assert(false && "Unreachable"); + return SPV_NUMBER_NONE; + } +} + +void Differ::MatchCapabilities() { + MatchPreambleInstructions(src_->capabilities(), dst_->capabilities()); +} + +void Differ::MatchExtensions() { + MatchPreambleInstructions(src_->extensions(), dst_->extensions()); +} + +void Differ::MatchExtInstImportIds() { + // Bunch all of this section's ids as potential matches. + PotentialIdMap potential_id_map; + auto get_result_id = [](const opt::Instruction& inst) { + return inst.result_id(); + }; + auto accept_all = [](const opt::Instruction&) { return true; }; + + PoolPotentialIds(src_->ext_inst_imports(), potential_id_map.src_ids, true, + accept_all, get_result_id); + PoolPotentialIds(dst_->ext_inst_imports(), potential_id_map.dst_ids, false, + accept_all, get_result_id); + + // Then match the ids. + MatchIds(potential_id_map, [](const opt::Instruction* src_inst, + const opt::Instruction* dst_inst) { + // Match OpExtInstImport by exact name, which is operand 1 + const opt::Operand& src_name = src_inst->GetOperand(1); + const opt::Operand& dst_name = dst_inst->GetOperand(1); + + return src_name.AsString() == dst_name.AsString(); + }); +} +void Differ::MatchMemoryModel() { + // Always match the memory model instructions, there is always a single one of + // it. + id_map_.MapInsts(src_->GetMemoryModel(), dst_->GetMemoryModel()); +} + +void Differ::MatchEntryPointIds() { + // Match OpEntryPoint ids (at index 1) by ExecutionModel (at index 0) and + // possibly name (at index 2). OpEntryPoint doesn't produce a result id, so + // this function doesn't use the helpers the other functions use. + + // Map from execution model to OpEntryPoint instructions of that model. + using ExecutionModelMap = + std::unordered_map>; + ExecutionModelMap src_entry_points_map; + ExecutionModelMap dst_entry_points_map; + std::set all_execution_models; + + for (const opt::Instruction& src_inst : src_->entry_points()) { + uint32_t execution_model = src_inst.GetSingleWordOperand(0); + src_entry_points_map[execution_model].push_back(&src_inst); + all_execution_models.insert(execution_model); + } + for (const opt::Instruction& dst_inst : dst_->entry_points()) { + uint32_t execution_model = dst_inst.GetSingleWordOperand(0); + dst_entry_points_map[execution_model].push_back(&dst_inst); + all_execution_models.insert(execution_model); + } + + // Go through each model and match the ids. + for (const uint32_t execution_model : all_execution_models) { + auto& src_insts = src_entry_points_map[execution_model]; + auto& dst_insts = dst_entry_points_map[execution_model]; + + // If there is only one entry point in src and dst with that model, match + // them unconditionally. + if (src_insts.size() == 1 && dst_insts.size() == 1) { + uint32_t src_id = src_insts[0]->GetSingleWordOperand(1); + uint32_t dst_id = dst_insts[0]->GetSingleWordOperand(1); + id_map_.MapIds(src_id, dst_id); + id_map_.MapInsts(src_insts[0], dst_insts[0]); + continue; + } + + // Otherwise match them by name. + bool matched = false; + for (const opt::Instruction* src_inst : src_insts) { + for (const opt::Instruction* dst_inst : dst_insts) { + const opt::Operand& src_name = src_inst->GetOperand(2); + const opt::Operand& dst_name = dst_inst->GetOperand(2); + + if (src_name.AsString() == dst_name.AsString()) { + uint32_t src_id = src_inst->GetSingleWordOperand(1); + uint32_t dst_id = dst_inst->GetSingleWordOperand(1); + id_map_.MapIds(src_id, dst_id); + id_map_.MapInsts(src_inst, dst_inst); + matched = true; + break; + } + } + if (matched) { + break; + } + } + } +} + +void Differ::MatchExecutionModes() { + MatchPreambleInstructions(src_->execution_modes(), dst_->execution_modes()); +} + +void Differ::MatchTypeForwardPointers() { + // Bunch all of type forward pointers as potential matches. + PotentialIdMap potential_id_map; + auto get_pointer_type_id = [](const opt::Instruction& inst) { + return inst.GetSingleWordOperand(0); + }; + auto accept_type_forward_pointer_ops = [](const opt::Instruction& inst) { + return inst.opcode() == SpvOpTypeForwardPointer; + }; + + PoolPotentialIds(src_->types_values(), potential_id_map.src_ids, true, + accept_type_forward_pointer_ops, get_pointer_type_id); + PoolPotentialIds(dst_->types_values(), potential_id_map.dst_ids, false, + accept_type_forward_pointer_ops, get_pointer_type_id); + + // Matching types with cyclical references (i.e. in the style of linked lists) + // can get very complex. Currently, the diff tool matches types bottom up, so + // on every instruction it expects to know if its operands are already matched + // or not. With cyclical references, it cannot know that. Type matching may + // need significant modifications to be able to support this use case. + // + // Currently, forwarded types are only matched by storage class and debug + // info, with minimal matching of the type being forwarded: + // + // - Group by class + // - Group by OpType being pointed to + // - Group by debug info + // - If same name and unique, match + // - If leftover is unique, match + + // Group forwarded pointers by storage class first and loop over them. + GroupIdsAndMatch( + potential_id_map.src_ids, potential_id_map.dst_ids, SpvStorageClassMax, + &Differ::GroupIdsHelperGetTypePointerStorageClass, + [this](const IdGroup& src_group_by_storage_class, + const IdGroup& dst_group_by_storage_class) { + + // Group them further by the type they are pointing to and loop over + // them. + GroupIdsAndMatch( + src_group_by_storage_class, dst_group_by_storage_class, SpvOpMax, + &Differ::GroupIdsHelperGetTypePointerTypeOp, + [this](const IdGroup& src_group_by_type_op, + const IdGroup& dst_group_by_type_op) { + + // Group them even further by debug info, if possible and match by + // debug name. + MatchTypeForwardPointersByName(src_group_by_type_op, + dst_group_by_type_op); + + // Match the leftovers only if they lack debug info and there is + // only one instance of them. + MatchTypeForwardPointersByTypeOp(src_group_by_type_op, + dst_group_by_type_op); + }); + }); + + // Match the instructions that forward declare the same type themselves + for (uint32_t src_id : potential_id_map.src_ids) { + uint32_t dst_id = id_map_.MappedDstId(src_id); + if (dst_id == 0) continue; + + const opt::Instruction* src_forward_inst = + GetForwardPointerInst(src_id_to_, src_id); + const opt::Instruction* dst_forward_inst = + GetForwardPointerInst(dst_id_to_, dst_id); + + assert(src_forward_inst); + assert(dst_forward_inst); + + id_map_.MapInsts(src_forward_inst, dst_forward_inst); + } +} + +void Differ::MatchTypeIds() { + // Bunch all of type ids as potential matches. + PotentialIdMap potential_id_map; + auto get_result_id = [](const opt::Instruction& inst) { + return inst.result_id(); + }; + auto accept_type_ops = [](const opt::Instruction& inst) { + return spvOpcodeGeneratesType(inst.opcode()); + }; + + PoolPotentialIds(src_->types_values(), potential_id_map.src_ids, true, + accept_type_ops, get_result_id); + PoolPotentialIds(dst_->types_values(), potential_id_map.dst_ids, false, + accept_type_ops, get_result_id); + + // Then match the ids. Start with exact matches, then match the leftover with + // gradually loosening degrees of strictness. For example, in the absence of + // debug info, two block types will be matched if they differ only in a few of + // the fields. + for (uint32_t flexibility = 0; flexibility < 2; ++flexibility) { + MatchIds(potential_id_map, [this, flexibility]( + const opt::Instruction* src_inst, + const opt::Instruction* dst_inst) { + const SpvOp src_op = src_inst->opcode(); + const SpvOp dst_op = dst_inst->opcode(); + + // Don't match if the opcode is not the same. + if (src_op != dst_op) { + return false; + } + + switch (src_op) { + case SpvOpTypeVoid: + case SpvOpTypeBool: + case SpvOpTypeSampler: + // void, bool and sampler are unique, match them. + return true; + case SpvOpTypeInt: + case SpvOpTypeFloat: + case SpvOpTypeVector: + case SpvOpTypeMatrix: + case SpvOpTypeSampledImage: + case SpvOpTypeRuntimeArray: + case SpvOpTypePointer: + // Match these instructions when all operands match. + assert(src_inst->NumInOperandWords() == + dst_inst->NumInOperandWords()); + return DoOperandsMatch(src_inst, dst_inst, 0, + src_inst->NumInOperandWords()); + + case SpvOpTypeFunction: + case SpvOpTypeImage: + // Match function types only if they have the same number of operands, + // and they all match. + // Match image types similarly, expecting the optional final parameter + // to match (if provided in both) + if (src_inst->NumInOperandWords() != dst_inst->NumInOperandWords()) { + return false; + } + return DoOperandsMatch(src_inst, dst_inst, 0, + src_inst->NumInOperandWords()); + + case SpvOpTypeArray: + // Match arrays only if the element type and length match. The length + // is an id of a constant, so the actual constant it's defining is + // compared instead. + if (!DoOperandsMatch(src_inst, dst_inst, 0, 1)) { + return false; + } + + if (AreIdenticalUintConstants(src_inst->GetSingleWordInOperand(1), + dst_inst->GetSingleWordInOperand(1))) { + return true; + } + + // If size is not OpConstant, expect the ids to match exactly (for + // example if a spec contant is used). + return DoOperandsMatch(src_inst, dst_inst, 1, 1); + + case SpvOpTypeStruct: + return MatchOpTypeStruct(src_inst, dst_inst, flexibility); + + default: + return false; + } + }); + } +} + +void Differ::MatchConstants() { + // Bunch all of constant ids as potential matches. + PotentialIdMap potential_id_map; + auto get_result_id = [](const opt::Instruction& inst) { + return inst.result_id(); + }; + auto accept_type_ops = [](const opt::Instruction& inst) { + return spvOpcodeIsConstant(inst.opcode()); + }; + + PoolPotentialIds(src_->types_values(), potential_id_map.src_ids, true, + accept_type_ops, get_result_id); + PoolPotentialIds(dst_->types_values(), potential_id_map.dst_ids, false, + accept_type_ops, get_result_id); + + // Then match the ids. Constants are matched exactly, except for float types + // that are first matched exactly, then leftovers are matched with a small + // error. + for (uint32_t flexibility = 0; flexibility < 2; ++flexibility) { + MatchIds(potential_id_map, [this, flexibility]( + const opt::Instruction* src_inst, + const opt::Instruction* dst_inst) { + const SpvOp src_op = src_inst->opcode(); + const SpvOp dst_op = dst_inst->opcode(); + + // Don't match if the opcode is not the same. + if (src_op != dst_op) { + return false; + } + + switch (src_op) { + case SpvOpConstantTrue: + case SpvOpConstantFalse: + // true and false are unique, match them. + return true; + case SpvOpConstant: + return MatchOpConstant(src_inst, dst_inst, flexibility); + case SpvOpConstantComposite: + case SpvOpSpecConstantComposite: + // Composite constants must match in type and value. + // + // TODO: match OpConstantNull with OpConstantComposite with all zeros + // at flexibility == 1 + // TODO: match constants from structs that have been flexibly-matched. + if (src_inst->NumInOperandWords() != dst_inst->NumInOperandWords()) { + return false; + } + return DoesOperandMatch(src_inst->GetOperand(0), + dst_inst->GetOperand(0)) && + DoOperandsMatch(src_inst, dst_inst, 0, + src_inst->NumInOperandWords()); + case SpvOpConstantSampler: + // Match sampler constants exactly. + // TODO: Allow flexibility in parameters to better diff shaders where + // the sampler param has changed. + assert(src_inst->NumInOperandWords() == + dst_inst->NumInOperandWords()); + return DoOperandsMatch(src_inst, dst_inst, 0, + src_inst->NumInOperandWords()); + case SpvOpConstantNull: + // Match null constants as long as the type matches. + return DoesOperandMatch(src_inst->GetOperand(0), + dst_inst->GetOperand(0)); + + case SpvOpSpecConstantTrue: + case SpvOpSpecConstantFalse: + case SpvOpSpecConstant: + case SpvOpSpecConstantOp: + // Match spec constants by name if available, then by the SpecId + // decoration. + return MatchOpSpecConstant(src_inst, dst_inst); + + default: + return false; + } + }); + } +} + +void Differ::MatchVariableIds() { + // Bunch all of variable ids as potential matches. + PotentialIdMap potential_id_map; + auto get_result_id = [](const opt::Instruction& inst) { + return inst.result_id(); + }; + auto accept_type_ops = [](const opt::Instruction& inst) { + return inst.opcode() == SpvOpVariable; + }; + + PoolPotentialIds(src_->types_values(), potential_id_map.src_ids, true, + accept_type_ops, get_result_id); + PoolPotentialIds(dst_->types_values(), potential_id_map.dst_ids, false, + accept_type_ops, get_result_id); + + // Then match the ids. Start with exact matches, then match the leftover with + // gradually loosening degrees of strictness. For example, in the absence of + // debug info, two otherwise identical variables will be matched if one of + // them has a Private storage class and the other doesn't. + for (uint32_t flexibility = 0; flexibility < 2; ++flexibility) { + MatchIds(potential_id_map, + [this, flexibility](const opt::Instruction* src_inst, + const opt::Instruction* dst_inst) { + assert(src_inst->opcode() == SpvOpVariable); + assert(dst_inst->opcode() == SpvOpVariable); + + return MatchOpVariable(src_inst, dst_inst, flexibility); + }); + } +} + +void Differ::MatchFunctions() { + IdGroup src_func_ids; + IdGroup dst_func_ids; + + for (const auto& func : src_funcs_) { + src_func_ids.push_back(func.first); + } + for (const auto& func : dst_funcs_) { + dst_func_ids.push_back(func.first); + } + + // Base the matching of functions on debug info when available. + GroupIdsAndMatch( + src_func_ids, dst_func_ids, "", &Differ::GetSanitizedName, + [this](const IdGroup& src_group, const IdGroup& dst_group) { + + // If there is a single function with this name in src and dst, it's a + // definite match. + if (src_group.size() == 1 && dst_group.size() == 1) { + id_map_.MapIds(src_group[0], dst_group[0]); + return; + } + + // If there are multiple functions with the same name, group them by + // type, and match only if the types match (and are unique). + GroupIdsAndMatch(src_group, dst_group, 0, + &Differ::GroupIdsHelperGetTypeId, + [this](const IdGroup& src_group_by_type_id, + const IdGroup& dst_group_by_type_id) { + + if (src_group_by_type_id.size() == 1 && + dst_group_by_type_id.size() == 1) { + id_map_.MapIds(src_group_by_type_id[0], + dst_group_by_type_id[0]); + } + }); + }); + + // Any functions that are left are pooled together and matched as if unnamed, + // with the only exception that two functions with mismatching names are not + // matched. + // + // Before that however, the diff of the functions that are matched are taken + // and processed, so that more of the global variables can be matched before + // attempting to match the rest of the functions. They can contribute to the + // precision of the diff of those functions. + for (const uint32_t src_func_id : src_func_ids) { + const uint32_t dst_func_id = id_map_.MappedDstId(src_func_id); + if (dst_func_id == 0) { + continue; + } + + // Since these functions are definite matches, match their parameters for a + // better diff. + MatchFunctionParamIds(src_funcs_[src_func_id], dst_funcs_[dst_func_id]); + + // Take the diff of the two functions. + DiffMatch src_match_result, dst_match_result; + MatchFunctionBodies(src_func_insts_[src_func_id], + dst_func_insts_[dst_func_id], &src_match_result, + &dst_match_result); + + // Match ids between the two function bodies; which can also result in + // global variables getting matched. + MatchIdsInFunctionBodies(src_func_insts_[src_func_id], + dst_func_insts_[dst_func_id], src_match_result, + dst_match_result, 0); + } + + // Best effort match functions with matching type. + GroupIdsAndMatch( + src_func_ids, dst_func_ids, 0, &Differ::GroupIdsHelperGetTypeId, + [this](const IdGroup& src_group_by_type_id, + const IdGroup& dst_group_by_type_id) { + + BestEffortMatchFunctions(src_group_by_type_id, dst_group_by_type_id, + src_func_insts_, dst_func_insts_); + }); + + // Any function that's left, best effort match them. + BestEffortMatchFunctions(src_func_ids, dst_func_ids, src_func_insts_, + dst_func_insts_); +} + +void Differ::MatchDebugs1() { + // This section in cludes: OpString, OpSourceExtension, OpSource, + // OpSourceContinued + MatchDebugAndAnnotationInstructions(src_->debugs1(), dst_->debugs1()); +} + +void Differ::MatchDebugs2() { + // This section includes: OpName, OpMemberName + MatchDebugAndAnnotationInstructions(src_->debugs2(), dst_->debugs2()); +} + +void Differ::MatchDebugs3() { + // This section includes: OpModuleProcessed + MatchDebugAndAnnotationInstructions(src_->debugs3(), dst_->debugs3()); +} + +void Differ::MatchExtInstDebugInfo() { + // This section includes OpExtInst for DebugInfo extension + MatchDebugAndAnnotationInstructions(src_->ext_inst_debuginfo(), + dst_->ext_inst_debuginfo()); +} + +void Differ::MatchAnnotations() { + // This section includes OpDecorate and family. + MatchDebugAndAnnotationInstructions(src_->annotations(), dst_->annotations()); +} + +const opt::Instruction* Differ::MappedDstInst( + const opt::Instruction* src_inst) { + return MappedInstImpl(src_inst, id_map_.SrcToDstMap(), dst_id_to_); +} + +const opt::Instruction* Differ::MappedSrcInst( + const opt::Instruction* dst_inst) { + return MappedInstImpl(dst_inst, id_map_.DstToSrcMap(), src_id_to_); +} + +const opt::Instruction* Differ::MappedInstImpl( + const opt::Instruction* inst, const IdMap& to_other, + const IdInstructions& other_id_to) { + if (inst->HasResultId()) { + if (to_other.IsMapped(inst->result_id())) { + const uint32_t other_result_id = to_other.MappedId(inst->result_id()); + + assert(other_result_id < other_id_to.inst_map_.size()); + return other_id_to.inst_map_[other_result_id]; + } + + return nullptr; + } + + return to_other.MappedInst(inst); +} + +void Differ::OutputLine(std::function are_lines_identical, + std::function output_src_line, + std::function output_dst_line) { + if (are_lines_identical()) { + out_ << " "; + output_src_line(); + } else { + OutputRed(); + out_ << "-"; + output_src_line(); + + OutputGreen(); + out_ << "+"; + output_dst_line(); + + OutputResetColor(); + } +} + +const opt::Instruction* IterInst(opt::Module::const_inst_iterator& iter) { + return &*iter; +} + +const opt::Instruction* IterInst(InstructionList::const_iterator& iter) { + return *iter; +} + +template +void Differ::OutputSection( + const InstList& src_insts, const InstList& dst_insts, + std::function + write_inst) { + auto src_iter = src_insts.begin(); + auto dst_iter = dst_insts.begin(); + + // - While src_inst doesn't have a match, output it with - + // - While dst_inst doesn't have a match, output it with + + // - Now src_inst and dst_inst both have matches; might not match each other! + // * If section is unordered, just process src_inst and its match (dst_inst + // or not), + // dst_inst will eventually be processed when its match is seen. + // * If section is ordered, also just process src_inst and its match. Its + // match must + // necessarily be dst_inst. + while (src_iter != src_insts.end() || dst_iter != dst_insts.end()) { + OutputRed(); + while (src_iter != src_insts.end() && + MappedDstInst(IterInst(src_iter)) == nullptr) { + out_ << "-"; + write_inst(*IterInst(src_iter), src_id_to_, *IterInst(src_iter)); + ++src_iter; + } + OutputGreen(); + while (dst_iter != dst_insts.end() && + MappedSrcInst(IterInst(dst_iter)) == nullptr) { + out_ << "+"; + write_inst(ToMappedSrcIds(*IterInst(dst_iter)), dst_id_to_, + *IterInst(dst_iter)); + ++dst_iter; + } + OutputResetColor(); + + if (src_iter != src_insts.end() && dst_iter != dst_insts.end()) { + const opt::Instruction* src_inst = IterInst(src_iter); + const opt::Instruction* matched_dst_inst = MappedDstInst(src_inst); + + assert(matched_dst_inst != nullptr); + assert(MappedSrcInst(IterInst(dst_iter)) != nullptr); + + OutputLine( + [this, src_inst, matched_dst_inst]() { + return DoInstructionsMatch(src_inst, matched_dst_inst); + }, + [this, src_inst, &write_inst]() { + write_inst(*src_inst, src_id_to_, *src_inst); + }, + [this, matched_dst_inst, &write_inst]() { + write_inst(ToMappedSrcIds(*matched_dst_inst), dst_id_to_, + *matched_dst_inst); + }); + + ++src_iter; + ++dst_iter; + } + } +} + +void Differ::ToParsedInstruction( + const opt::Instruction& inst, const IdInstructions& id_to, + const opt::Instruction& original_inst, + spv_parsed_instruction_t* parsed_inst, + std::vector& parsed_operands, + std::vector& inst_binary) { + inst.ToBinaryWithoutAttachedDebugInsts(&inst_binary); + parsed_operands.resize(inst.NumOperands()); + + parsed_inst->words = inst_binary.data(); + parsed_inst->num_words = static_cast(inst_binary.size()); + parsed_inst->opcode = static_cast(inst.opcode()); + parsed_inst->ext_inst_type = + inst.opcode() == SpvOpExtInst + ? GetExtInstType(id_to, original_inst.GetSingleWordInOperand(0)) + : SPV_EXT_INST_TYPE_NONE; + parsed_inst->type_id = + inst.HasResultType() ? inst.GetSingleWordOperand(0) : 0; + parsed_inst->result_id = inst.HasResultId() ? inst.result_id() : 0; + parsed_inst->operands = parsed_operands.data(); + parsed_inst->num_operands = static_cast(parsed_operands.size()); + + // Word 0 is always op and num_words, so operands start at offset 1. + uint32_t offset = 1; + for (uint16_t operand_index = 0; operand_index < parsed_inst->num_operands; + ++operand_index) { + const opt::Operand& operand = inst.GetOperand(operand_index); + spv_parsed_operand_t& parsed_operand = parsed_operands[operand_index]; + + parsed_operand.offset = static_cast(offset); + parsed_operand.num_words = static_cast(operand.words.size()); + parsed_operand.type = operand.type; + parsed_operand.number_kind = GetNumberKind( + id_to, original_inst, operand_index, &parsed_operand.number_bit_width); + + offset += parsed_operand.num_words; + } +} + +opt::Instruction Differ::ToMappedSrcIds(const opt::Instruction& dst_inst) { + // Create an identical instruction to dst_inst, except ids are changed to the + // mapped one. + opt::Instruction mapped_inst = dst_inst; + + for (uint32_t operand_index = 0; operand_index < mapped_inst.NumOperands(); + ++operand_index) { + opt::Operand& operand = mapped_inst.GetOperand(operand_index); + + if (spvIsIdType(operand.type)) { + assert(id_map_.IsDstMapped(operand.AsId())); + operand.words[0] = id_map_.MappedSrcId(operand.AsId()); + } + } + + return mapped_inst; +} + +spv_result_t Differ::Output() { + id_map_.MapUnmatchedIds(); + src_id_to_.inst_map_.resize(id_map_.SrcToDstMap().IdBound(), nullptr); + dst_id_to_.inst_map_.resize(id_map_.DstToSrcMap().IdBound(), nullptr); + + const spv_target_env target_env = SPV_ENV_UNIVERSAL_1_6; + spv_opcode_table opcode_table; + spv_operand_table operand_table; + spv_ext_inst_table ext_inst_table; + spv_result_t result; + + result = spvOpcodeTableGet(&opcode_table, target_env); + if (result != SPV_SUCCESS) return result; + + result = spvOperandTableGet(&operand_table, target_env); + if (result != SPV_SUCCESS) return result; + + result = spvExtInstTableGet(&ext_inst_table, target_env); + if (result != SPV_SUCCESS) return result; + + spv_context_t context{ + target_env, + opcode_table, + operand_table, + ext_inst_table, + }; + + const AssemblyGrammar grammar(&context); + if (!grammar.isValid()) return SPV_ERROR_INVALID_TABLE; + + uint32_t disassembly_options = SPV_BINARY_TO_TEXT_OPTION_PRINT; + if (options_.indent) { + disassembly_options |= SPV_BINARY_TO_TEXT_OPTION_INDENT; + } + + NameMapper name_mapper = GetTrivialNameMapper(); + disassemble::InstructionDisassembler dis(grammar, out_, disassembly_options, + name_mapper); + + if (!options_.no_header) { + // Output the header + // TODO: when using diff with text, the assembler overrides the version and + // generator, so these aren't reflected correctly in the output. Could + // potentially extract this info from the header comment. + OutputLine([]() { return true; }, [&dis]() { dis.EmitHeaderSpirv(); }, + []() { assert(false && "Unreachable"); }); + OutputLine([this]() { return src_->version() == dst_->version(); }, + [this, &dis]() { dis.EmitHeaderVersion(src_->version()); }, + [this, &dis]() { dis.EmitHeaderVersion(dst_->version()); }); + OutputLine([this]() { return src_->generator() == dst_->generator(); }, + [this, &dis]() { dis.EmitHeaderGenerator(src_->generator()); }, + [this, &dis]() { dis.EmitHeaderGenerator(dst_->generator()); }); + OutputLine( + [this]() { return src_->IdBound() == id_map_.SrcToDstMap().IdBound(); }, + [this, &dis]() { dis.EmitHeaderIdBound(src_->IdBound()); }, + [this, &dis]() { + dis.EmitHeaderIdBound(id_map_.SrcToDstMap().IdBound()); + }); + OutputLine([this]() { return src_->schema() == dst_->schema(); }, + [this, &dis]() { dis.EmitHeaderSchema(src_->schema()); }, + [this, &dis]() { dis.EmitHeaderSchema(dst_->schema()); }); + } + + // For each section, iterate both modules and output the disassembly. + auto write_inst = [this, &dis](const opt::Instruction& inst, + const IdInstructions& id_to, + const opt::Instruction& original_inst) { + spv_parsed_instruction_t parsed_inst; + std::vector parsed_operands; + std::vector inst_binary; + + ToParsedInstruction(inst, id_to, original_inst, &parsed_inst, + parsed_operands, inst_binary); + + dis.EmitInstruction(parsed_inst, 0); + }; + + OutputSection(src_->capabilities(), dst_->capabilities(), write_inst); + OutputSection(src_->extensions(), dst_->extensions(), write_inst); + OutputSection(src_->ext_inst_imports(), dst_->ext_inst_imports(), write_inst); + + // There is only one memory model. + OutputLine( + [this]() { + return DoInstructionsMatch(src_->GetMemoryModel(), + dst_->GetMemoryModel()); + }, + [this, &write_inst]() { + write_inst(*src_->GetMemoryModel(), src_id_to_, + *src_->GetMemoryModel()); + }, + [this, &write_inst]() { + write_inst(*dst_->GetMemoryModel(), dst_id_to_, + *dst_->GetMemoryModel()); + }); + + OutputSection(src_->entry_points(), dst_->entry_points(), write_inst); + OutputSection(src_->execution_modes(), dst_->execution_modes(), write_inst); + OutputSection(src_->debugs1(), dst_->debugs1(), write_inst); + OutputSection(src_->debugs2(), dst_->debugs2(), write_inst); + OutputSection(src_->debugs3(), dst_->debugs3(), write_inst); + OutputSection(src_->ext_inst_debuginfo(), dst_->ext_inst_debuginfo(), + write_inst); + OutputSection(src_->annotations(), dst_->annotations(), write_inst); + OutputSection(src_->types_values(), dst_->types_values(), write_inst); + + // Get the body of all the functions. + FunctionInstMap src_func_header_insts; + FunctionInstMap dst_func_header_insts; + + GetFunctionHeaderInstructions(src_, &src_func_header_insts); + GetFunctionHeaderInstructions(dst_, &dst_func_header_insts); + + for (const auto& src_func : src_func_insts_) { + const uint32_t src_func_id = src_func.first; + const InstructionList& src_insts = src_func.second; + const InstructionList& src_header_insts = + src_func_header_insts[src_func_id]; + + const uint32_t dst_func_id = id_map_.MappedDstId(src_func_id); + if (dst_func_insts_.find(dst_func_id) == dst_func_insts_.end()) { + OutputSection(src_header_insts, InstructionList(), write_inst); + OutputSection(src_insts, InstructionList(), write_inst); + continue; + } + + const InstructionList& dst_insts = dst_func_insts_[dst_func_id]; + const InstructionList& dst_header_insts = + dst_func_header_insts[dst_func_id]; + OutputSection(src_header_insts, dst_header_insts, write_inst); + OutputSection(src_insts, dst_insts, write_inst); + } + + for (const auto& dst_func : dst_func_insts_) { + const uint32_t dst_func_id = dst_func.first; + const InstructionList& dst_insts = dst_func.second; + const InstructionList& dst_header_insts = + dst_func_header_insts[dst_func_id]; + + const uint32_t src_func_id = id_map_.MappedSrcId(dst_func_id); + if (src_func_insts_.find(src_func_id) == src_func_insts_.end()) { + OutputSection(InstructionList(), dst_header_insts, write_inst); + OutputSection(InstructionList(), dst_insts, write_inst); + } + } + + out_ << std::flush; + + return SPV_SUCCESS; +} + +} // anonymous namespace + +spv_result_t Diff(opt::IRContext* src, opt::IRContext* dst, std::ostream& out, + Options options) { + // High level algorithm: + // + // - Some sections of SPIR-V don't deal with ids; instructions in those + // sections are matched identically. For example OpCapability instructions. + // - Some sections produce ids, and they can be trivially matched by their + // parameters. For example OpExtInstImport instructions. + // - Some sections annotate ids. These are matched at the end, after the ids + // themselves are matched. For example OpName or OpDecorate instructions. + // - Some sections produce ids that depend on other ids and they can be + // recursively matched. For example OpType* instructions. + // - Some sections produce ids that are not trivially matched. For these ids, + // the debug info is used when possible, or a best guess (such as through + // decorations) is used. For example OpVariable instructions. + // - Matching functions is done with multiple attempts: + // * Functions with identical debug names are matched if there are no + // overloads. + // * Otherwise, functions with identical debug names and types are matched. + // * The rest of the functions are best-effort matched, first in groups of + // identical type, then any with any. + // * The best-effort matching takes the diff of every pair of functions in + // a group and selects the top matches that also meet a similarity + // index. + // * Once a pair of functions are matched, the fuzzy diff of the + // instructions is used to match the instructions in the function body. + // The fuzzy diff makes sure that sufficiently similar instructions are + // matched and that yet-to-be-matched result ids don't result in a larger + // diff. + // + // Once the instructions are matched between the src and dst SPIR-V, the src + // is traversed and its disassembly is output. In the process, any unmatched + // instruction is prefixed with -, and any unmatched instruction in dst in the + // same section is output prefixed with +. To avoid confusion, the + // instructions in dst are output with matching ids in src so the output + // assembly is consistent. + + Differ differ(src, dst, out, options); + + // First, match instructions between the different non-annotation sections of + // the SPIR-V. + differ.MatchCapabilities(); + differ.MatchExtensions(); + differ.MatchExtInstImportIds(); + differ.MatchMemoryModel(); + differ.MatchEntryPointIds(); + differ.MatchExecutionModes(); + differ.MatchTypeForwardPointers(); + differ.MatchTypeIds(); + differ.MatchConstants(); + differ.MatchVariableIds(); + differ.MatchFunctions(); + + // Match instructions that annotate previously-matched ids. + differ.MatchDebugs1(); + differ.MatchDebugs2(); + differ.MatchDebugs3(); + differ.MatchExtInstDebugInfo(); + differ.MatchAnnotations(); + + // Show the disassembly with the diff. + // + // TODO: Based on an option, output either based on src or dst, i.e. the diff + // can show the ids and instruction/function order either from src or dst. + spv_result_t result = differ.Output(); + + differ.DumpIdMap(); + + return result; +} + +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/source/diff/diff.h b/third_party/spirv-tools/source/diff/diff.h new file mode 100644 index 0000000000..932de9eedb --- /dev/null +++ b/third_party/spirv-tools/source/diff/diff.h @@ -0,0 +1,48 @@ +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef SOURCE_DIFF_DIFF_H_ +#define SOURCE_DIFF_DIFF_H_ + +#include "source/opt/ir_context.h" + +namespace spvtools { +namespace diff { + +struct Options { + bool ignore_set_binding = false; + bool ignore_location = false; + bool indent = false; + bool no_header = false; + bool color_output = false; + bool dump_id_map = false; +}; + +// Given two SPIR-V modules, this function outputs the textual diff of their +// assembly in `out`. The diff is *semantic*, so that the ordering of certain +// instructions wouldn't matter. +// +// The output is a disassembly of src, with diff(1)-style + and - lines that +// show how the src is changed into dst. To make this disassembly +// self-consistent, the ids that are output are all in the space of the src +// module; e.g. any + lines (showing instructions from the dst module) have +// their ids mapped to the matched instruction in the src module (or a new id +// allocated in the src module if unmatched). +spv_result_t Diff(opt::IRContext* src, opt::IRContext* dst, std::ostream& out, + Options options); + +} // namespace diff +} // namespace spvtools + +#endif // SOURCE_DIFF_DIFF_H_ diff --git a/third_party/spirv-tools/source/diff/lcs.h b/third_party/spirv-tools/source/diff/lcs.h new file mode 100644 index 0000000000..6c00e86499 --- /dev/null +++ b/third_party/spirv-tools/source/diff/lcs.h @@ -0,0 +1,224 @@ +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef SOURCE_DIFF_LCS_H_ +#define SOURCE_DIFF_LCS_H_ + +#include +#include +#include +#include +#include +#include +#include + +namespace spvtools { +namespace diff { + +// The result of a diff. +using DiffMatch = std::vector; + +// Helper class to find the longest common subsequence between two function +// bodies. +template +class LongestCommonSubsequence { + public: + LongestCommonSubsequence(const Sequence& src, const Sequence& dst) + : src_(src), + dst_(dst), + table_(src.size(), std::vector(dst.size())) {} + + // Given two sequences, it creates a matching between them. The elements are + // simply marked as matched in src and dst, with any unmatched element in src + // implying a removal and any unmatched element in dst implying an addition. + // + // Returns the length of the longest common subsequence. + template + uint32_t Get(std::function match, + DiffMatch* src_match_result, DiffMatch* dst_match_result); + + private: + struct DiffMatchIndex { + uint32_t src_offset; + uint32_t dst_offset; + }; + + template + void CalculateLCS(std::function match); + void RetrieveMatch(DiffMatch* src_match_result, DiffMatch* dst_match_result); + bool IsInBound(DiffMatchIndex index) { + return index.src_offset < src_.size() && index.dst_offset < dst_.size(); + } + bool IsCalculated(DiffMatchIndex index) { + assert(IsInBound(index)); + return table_[index.src_offset][index.dst_offset].valid; + } + bool IsCalculatedOrOutOfBound(DiffMatchIndex index) { + return !IsInBound(index) || IsCalculated(index); + } + uint32_t GetMemoizedLength(DiffMatchIndex index) { + if (!IsInBound(index)) { + return 0; + } + assert(IsCalculated(index)); + return table_[index.src_offset][index.dst_offset].best_match_length; + } + bool IsMatched(DiffMatchIndex index) { + assert(IsCalculated(index)); + return table_[index.src_offset][index.dst_offset].matched; + } + void MarkMatched(DiffMatchIndex index, uint32_t best_match_length, + bool matched) { + assert(IsInBound(index)); + DiffMatchEntry& entry = table_[index.src_offset][index.dst_offset]; + assert(!entry.valid); + + entry.best_match_length = best_match_length & 0x3FFFFFFF; + assert(entry.best_match_length == best_match_length); + entry.matched = matched; + entry.valid = true; + } + + const Sequence& src_; + const Sequence& dst_; + + struct DiffMatchEntry { + DiffMatchEntry() : best_match_length(0), matched(false), valid(false) {} + + uint32_t best_match_length : 30; + // Whether src[i] and dst[j] matched. This is an optimization to avoid + // calling the `match` function again when walking the LCS table. + uint32_t matched : 1; + // Use for the recursive algorithm to know if the contents of this entry are + // valid. + uint32_t valid : 1; + }; + + std::vector> table_; +}; + +template +template +uint32_t LongestCommonSubsequence::Get( + std::function match, + DiffMatch* src_match_result, DiffMatch* dst_match_result) { + CalculateLCS(match); + RetrieveMatch(src_match_result, dst_match_result); + return GetMemoizedLength({0, 0}); +} + +template +template +void LongestCommonSubsequence::CalculateLCS( + std::function match) { + // The LCS algorithm is simple. Given sequences s and d, with a:b depicting a + // range in python syntax: + // + // lcs(s[i:], d[j:]) = + // lcs(s[i+1:], d[j+1:]) + 1 if s[i] == d[j] + // max(lcs(s[i+1:], d[j:]), lcs(s[i:], d[j+1:])) o.w. + // + // Once the LCS table is filled according to the above, it can be walked and + // the best match retrieved. + // + // This is a recursive function with memoization, which avoids filling table + // entries where unnecessary. This makes the best case O(N) instead of + // O(N^2). The implemention uses a std::stack to avoid stack overflow on long + // sequences. + + if (src_.empty() || dst_.empty()) { + return; + } + + std::stack to_calculate; + to_calculate.push({0, 0}); + + while (!to_calculate.empty()) { + DiffMatchIndex current = to_calculate.top(); + to_calculate.pop(); + assert(IsInBound(current)); + + // If already calculated through another path, ignore it. + if (IsCalculated(current)) { + continue; + } + + if (match(src_[current.src_offset], dst_[current.dst_offset])) { + // If the current elements match, advance both indices and calculate the + // LCS if not already. Visit `current` again afterwards, so its + // corresponding entry will be updated. + DiffMatchIndex next = {current.src_offset + 1, current.dst_offset + 1}; + if (IsCalculatedOrOutOfBound(next)) { + MarkMatched(current, GetMemoizedLength(next) + 1, true); + } else { + to_calculate.push(current); + to_calculate.push(next); + } + continue; + } + + // We've reached a pair of elements that don't match. Calculate the LCS for + // both cases of either being left unmatched and take the max. Visit + // `current` again afterwards, so its corresponding entry will be updated. + DiffMatchIndex next_src = {current.src_offset + 1, current.dst_offset}; + DiffMatchIndex next_dst = {current.src_offset, current.dst_offset + 1}; + + if (IsCalculatedOrOutOfBound(next_src) && + IsCalculatedOrOutOfBound(next_dst)) { + uint32_t best_match_length = + std::max(GetMemoizedLength(next_src), GetMemoizedLength(next_dst)); + MarkMatched(current, best_match_length, false); + continue; + } + + to_calculate.push(current); + if (!IsCalculatedOrOutOfBound(next_src)) { + to_calculate.push(next_src); + } + if (!IsCalculatedOrOutOfBound(next_dst)) { + to_calculate.push(next_dst); + } + } +} + +template +void LongestCommonSubsequence::RetrieveMatch( + DiffMatch* src_match_result, DiffMatch* dst_match_result) { + src_match_result->clear(); + dst_match_result->clear(); + + src_match_result->resize(src_.size(), false); + dst_match_result->resize(dst_.size(), false); + + DiffMatchIndex current = {0, 0}; + while (IsInBound(current)) { + if (IsMatched(current)) { + (*src_match_result)[current.src_offset++] = true; + (*dst_match_result)[current.dst_offset++] = true; + continue; + } + + if (GetMemoizedLength({current.src_offset + 1, current.dst_offset}) >= + GetMemoizedLength({current.src_offset, current.dst_offset + 1})) { + ++current.src_offset; + } else { + ++current.dst_offset; + } + } +} + +} // namespace diff +} // namespace spvtools + +#endif // SOURCE_DIFF_LCS_H_ diff --git a/third_party/spirv-tools/source/disassemble.cpp b/third_party/spirv-tools/source/disassemble.cpp index c553988f38..1d61b9f9ea 100644 --- a/third_party/spirv-tools/source/disassemble.cpp +++ b/third_party/spirv-tools/source/disassemble.cpp @@ -17,6 +17,8 @@ // This file contains a disassembler: It converts a SPIR-V binary // to text. +#include "source/disassemble.h" + #include #include #include @@ -28,9 +30,7 @@ #include "source/assembly_grammar.h" #include "source/binary.h" #include "source/diagnostic.h" -#include "source/disassemble.h" #include "source/ext_inst.h" -#include "source/name_mapper.h" #include "source/opcode.h" #include "source/parsed_operand.h" #include "source/print.h" @@ -40,29 +40,21 @@ #include "source/util/make_unique.h" #include "spirv-tools/libspirv.h" +namespace spvtools { namespace { // A Disassembler instance converts a SPIR-V binary to its assembly // representation. class Disassembler { public: - Disassembler(const spvtools::AssemblyGrammar& grammar, uint32_t options, - spvtools::NameMapper name_mapper) - : grammar_(grammar), - print_(spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_PRINT, options)), - color_(spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_COLOR, options)), - indent_(spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_INDENT, options) - ? kStandardIndent - : 0), - comment_(spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_COMMENT, options)), + Disassembler(const AssemblyGrammar& grammar, uint32_t options, + NameMapper name_mapper) + : print_(spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_PRINT, options)), text_(), out_(print_ ? out_stream() : out_stream(text_)), - stream_(out_.get()), + instruction_disassembler_(grammar, out_.get(), options, name_mapper), header_(!spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER, options)), - show_byte_offset_(spvIsInBitfield( - SPV_BINARY_TO_TEXT_OPTION_SHOW_BYTE_OFFSET, options)), - byte_offset_(0), - name_mapper_(std::move(name_mapper)) {} + byte_offset_(0) {} // Emits the assembly header for the module, and sets up internal state // so subsequent callbacks can handle the cases where the entire module @@ -78,56 +70,13 @@ class Disassembler { spv_result_t SaveTextResult(spv_text* text_result) const; private: - enum { kStandardIndent = 15 }; - - using out_stream = spvtools::out_stream; - - // Emits an operand for the given instruction, where the instruction - // is at offset words from the start of the binary. - void EmitOperand(const spv_parsed_instruction_t& inst, - const uint16_t operand_index); - - // Emits a mask expression for the given mask word of the specified type. - void EmitMaskOperand(const spv_operand_type_t type, const uint32_t word); - - // Resets the output color, if color is turned on. - void ResetColor() { - if (color_) out_.get() << spvtools::clr::reset{print_}; - } - // Sets the output to grey, if color is turned on. - void SetGrey() { - if (color_) out_.get() << spvtools::clr::grey{print_}; - } - // Sets the output to blue, if color is turned on. - void SetBlue() { - if (color_) out_.get() << spvtools::clr::blue{print_}; - } - // Sets the output to yellow, if color is turned on. - void SetYellow() { - if (color_) out_.get() << spvtools::clr::yellow{print_}; - } - // Sets the output to red, if color is turned on. - void SetRed() { - if (color_) out_.get() << spvtools::clr::red{print_}; - } - // Sets the output to green, if color is turned on. - void SetGreen() { - if (color_) out_.get() << spvtools::clr::green{print_}; - } - - const spvtools::AssemblyGrammar& grammar_; const bool print_; // Should we also print to the standard output stream? - const bool color_; // Should we print in colour? - const int indent_; // How much to indent. 0 means don't indent - const int comment_; // Should we comment the source spv_endianness_t endian_; // The detected endianness of the binary. std::stringstream text_; // Captures the text, if not printing. out_stream out_; // The Output stream. Either to text_ or standard output. - std::ostream& stream_; // The output std::stream. - const bool header_; // Should we output header as the leading comment? - const bool show_byte_offset_; // Should we print byte offset, in hex? - size_t byte_offset_; // The number of bytes processed so far. - spvtools::NameMapper name_mapper_; + disassemble::InstructionDisassembler instruction_disassembler_; + const bool header_; // Should we output header as the leading comment? + size_t byte_offset_; // The number of bytes processed so far. bool inserted_decoration_space_ = false; bool inserted_debug_space_ = false; bool inserted_type_space_ = false; @@ -139,21 +88,11 @@ spv_result_t Disassembler::HandleHeader(spv_endianness_t endian, endian_ = endian; if (header_) { - const char* generator_tool = - spvGeneratorStr(SPV_GENERATOR_TOOL_PART(generator)); - stream_ << "; SPIR-V\n" - << "; Version: " << SPV_SPIRV_VERSION_MAJOR_PART(version) << "." - << SPV_SPIRV_VERSION_MINOR_PART(version) << "\n" - << "; Generator: " << generator_tool; - // For unknown tools, print the numeric tool value. - if (0 == strcmp("Unknown", generator_tool)) { - stream_ << "(" << SPV_GENERATOR_TOOL_PART(generator) << ")"; - } - // Print the miscellaneous part of the generator word on the same - // line as the tool name. - stream_ << "; " << SPV_GENERATOR_MISC_PART(generator) << "\n" - << "; Bound: " << id_bound << "\n" - << "; Schema: " << schema << "\n"; + instruction_disassembler_.EmitHeaderSpirv(); + instruction_disassembler_.EmitHeaderVersion(version); + instruction_disassembler_.EmitHeaderGenerator(generator); + instruction_disassembler_.EmitHeaderIdBound(id_bound); + instruction_disassembler_.EmitHeaderSchema(schema); } byte_offset_ = SPV_INDEX_INSTRUCTION * sizeof(uint32_t); @@ -163,232 +102,17 @@ spv_result_t Disassembler::HandleHeader(spv_endianness_t endian, spv_result_t Disassembler::HandleInstruction( const spv_parsed_instruction_t& inst) { - auto opcode = static_cast(inst.opcode); - if (comment_ && opcode == SpvOpFunction) { - stream_ << std::endl; - stream_ << std::string(indent_, ' '); - stream_ << "; Function " << name_mapper_(inst.result_id) << std::endl; - } - if (comment_ && !inserted_decoration_space_ && - spvOpcodeIsDecoration(opcode)) { - inserted_decoration_space_ = true; - stream_ << std::endl; - stream_ << std::string(indent_, ' '); - stream_ << "; Annotations" << std::endl; - } - if (comment_ && !inserted_debug_space_ && spvOpcodeIsDebug(opcode)) { - inserted_debug_space_ = true; - stream_ << std::endl; - stream_ << std::string(indent_, ' '); - stream_ << "; Debug Information" << std::endl; - } - if (comment_ && !inserted_type_space_ && spvOpcodeGeneratesType(opcode)) { - inserted_type_space_ = true; - stream_ << std::endl; - stream_ << std::string(indent_, ' '); - stream_ << "; Types, variables and constants" << std::endl; - } + instruction_disassembler_.EmitSectionComment(inst, inserted_decoration_space_, + inserted_debug_space_, + inserted_type_space_); - if (inst.result_id) { - SetBlue(); - const std::string id_name = name_mapper_(inst.result_id); - if (indent_) - stream_ << std::setw(std::max(0, indent_ - 3 - int(id_name.size()))); - stream_ << "%" << id_name; - ResetColor(); - stream_ << " = "; - } else { - stream_ << std::string(indent_, ' '); - } - - stream_ << "Op" << spvOpcodeString(opcode); - - for (uint16_t i = 0; i < inst.num_operands; i++) { - const spv_operand_type_t type = inst.operands[i].type; - assert(type != SPV_OPERAND_TYPE_NONE); - if (type == SPV_OPERAND_TYPE_RESULT_ID) continue; - stream_ << " "; - EmitOperand(inst, i); - } - - if (comment_ && opcode == SpvOpName) { - const spv_parsed_operand_t& operand = inst.operands[0]; - const uint32_t word = inst.words[operand.offset]; - stream_ << " ; id %" << word; - } - - if (show_byte_offset_) { - SetGrey(); - auto saved_flags = stream_.flags(); - auto saved_fill = stream_.fill(); - stream_ << " ; 0x" << std::setw(8) << std::hex << std::setfill('0') - << byte_offset_; - stream_.flags(saved_flags); - stream_.fill(saved_fill); - ResetColor(); - } + instruction_disassembler_.EmitInstruction(inst, byte_offset_); byte_offset_ += inst.num_words * sizeof(uint32_t); - stream_ << "\n"; return SPV_SUCCESS; } -void Disassembler::EmitOperand(const spv_parsed_instruction_t& inst, - const uint16_t operand_index) { - assert(operand_index < inst.num_operands); - const spv_parsed_operand_t& operand = inst.operands[operand_index]; - const uint32_t word = inst.words[operand.offset]; - switch (operand.type) { - case SPV_OPERAND_TYPE_RESULT_ID: - assert(false && " is not supposed to be handled here"); - SetBlue(); - stream_ << "%" << name_mapper_(word); - break; - case SPV_OPERAND_TYPE_ID: - case SPV_OPERAND_TYPE_TYPE_ID: - case SPV_OPERAND_TYPE_SCOPE_ID: - case SPV_OPERAND_TYPE_MEMORY_SEMANTICS_ID: - SetYellow(); - stream_ << "%" << name_mapper_(word); - break; - case SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER: { - spv_ext_inst_desc ext_inst; - SetRed(); - if (grammar_.lookupExtInst(inst.ext_inst_type, word, &ext_inst) == - SPV_SUCCESS) { - stream_ << ext_inst->name; - } else { - if (!spvExtInstIsNonSemantic(inst.ext_inst_type)) { - assert(false && "should have caught this earlier"); - } else { - // for non-semantic instruction sets we can just print the number - stream_ << word; - } - } - } break; - case SPV_OPERAND_TYPE_SPEC_CONSTANT_OP_NUMBER: { - spv_opcode_desc opcode_desc; - if (grammar_.lookupOpcode(SpvOp(word), &opcode_desc)) - assert(false && "should have caught this earlier"); - SetRed(); - stream_ << opcode_desc->name; - } break; - case SPV_OPERAND_TYPE_LITERAL_INTEGER: - case SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER: { - SetRed(); - spvtools::EmitNumericLiteral(&stream_, inst, operand); - ResetColor(); - } break; - case SPV_OPERAND_TYPE_LITERAL_STRING: { - stream_ << "\""; - SetGreen(); - // Strings are always little-endian, and null-terminated. - // Write out the characters, escaping as needed, and without copying - // the entire string. - auto c_str = reinterpret_cast(inst.words + operand.offset); - for (auto p = c_str; *p; ++p) { - if (*p == '"' || *p == '\\') stream_ << '\\'; - stream_ << *p; - } - ResetColor(); - stream_ << '"'; - } break; - case SPV_OPERAND_TYPE_CAPABILITY: - case SPV_OPERAND_TYPE_SOURCE_LANGUAGE: - case SPV_OPERAND_TYPE_EXECUTION_MODEL: - case SPV_OPERAND_TYPE_ADDRESSING_MODEL: - case SPV_OPERAND_TYPE_MEMORY_MODEL: - case SPV_OPERAND_TYPE_EXECUTION_MODE: - case SPV_OPERAND_TYPE_STORAGE_CLASS: - case SPV_OPERAND_TYPE_DIMENSIONALITY: - case SPV_OPERAND_TYPE_SAMPLER_ADDRESSING_MODE: - case SPV_OPERAND_TYPE_SAMPLER_FILTER_MODE: - case SPV_OPERAND_TYPE_SAMPLER_IMAGE_FORMAT: - case SPV_OPERAND_TYPE_FP_ROUNDING_MODE: - case SPV_OPERAND_TYPE_LINKAGE_TYPE: - case SPV_OPERAND_TYPE_ACCESS_QUALIFIER: - case SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE: - case SPV_OPERAND_TYPE_DECORATION: - case SPV_OPERAND_TYPE_BUILT_IN: - case SPV_OPERAND_TYPE_GROUP_OPERATION: - case SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS: - case SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO: - case SPV_OPERAND_TYPE_RAY_FLAGS: - case SPV_OPERAND_TYPE_RAY_QUERY_INTERSECTION: - case SPV_OPERAND_TYPE_RAY_QUERY_COMMITTED_INTERSECTION_TYPE: - case SPV_OPERAND_TYPE_RAY_QUERY_CANDIDATE_INTERSECTION_TYPE: - case SPV_OPERAND_TYPE_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING: - case SPV_OPERAND_TYPE_DEBUG_COMPOSITE_TYPE: - case SPV_OPERAND_TYPE_DEBUG_TYPE_QUALIFIER: - case SPV_OPERAND_TYPE_DEBUG_OPERATION: - case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING: - case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_COMPOSITE_TYPE: - case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_TYPE_QUALIFIER: - case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_OPERATION: - case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_IMPORTED_ENTITY: - case SPV_OPERAND_TYPE_FPDENORM_MODE: - case SPV_OPERAND_TYPE_FPOPERATION_MODE: - case SPV_OPERAND_TYPE_QUANTIZATION_MODES: - case SPV_OPERAND_TYPE_OVERFLOW_MODES: { - spv_operand_desc entry; - if (grammar_.lookupOperand(operand.type, word, &entry)) - assert(false && "should have caught this earlier"); - stream_ << entry->name; - } break; - case SPV_OPERAND_TYPE_FP_FAST_MATH_MODE: - case SPV_OPERAND_TYPE_FUNCTION_CONTROL: - case SPV_OPERAND_TYPE_LOOP_CONTROL: - case SPV_OPERAND_TYPE_IMAGE: - case SPV_OPERAND_TYPE_MEMORY_ACCESS: - case SPV_OPERAND_TYPE_SELECTION_CONTROL: - case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS: - case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS: - EmitMaskOperand(operand.type, word); - break; - default: - if (spvOperandIsConcreteMask(operand.type)) { - EmitMaskOperand(operand.type, word); - } else if (spvOperandIsConcrete(operand.type)) { - spv_operand_desc entry; - if (grammar_.lookupOperand(operand.type, word, &entry)) - assert(false && "should have caught this earlier"); - stream_ << entry->name; - } else { - assert(false && "unhandled or invalid case"); - } - break; - } - ResetColor(); -} - -void Disassembler::EmitMaskOperand(const spv_operand_type_t type, - const uint32_t word) { - // Scan the mask from least significant bit to most significant bit. For each - // set bit, emit the name of that bit. Separate multiple names with '|'. - uint32_t remaining_word = word; - uint32_t mask; - int num_emitted = 0; - for (mask = 1; remaining_word; mask <<= 1) { - if (remaining_word & mask) { - remaining_word ^= mask; - spv_operand_desc entry; - if (grammar_.lookupOperand(type, mask, &entry)) - assert(false && "should have caught this earlier"); - if (num_emitted) stream_ << "|"; - stream_ << entry->name; - num_emitted++; - } - } - if (!num_emitted) { - // An operand value of 0 was provided, so represent it by the name - // of the 0 value. In many cases, that's "None". - spv_operand_desc entry; - if (SPV_SUCCESS == grammar_.lookupOperand(type, 0, &entry)) - stream_ << entry->name; - } -} - spv_result_t Disassembler::SaveTextResult(spv_text* text_result) const { if (!print_) { size_t length = text_.str().size(); @@ -470,8 +194,342 @@ spv_result_t DisassembleTargetInstruction( return SPV_SUCCESS; } +constexpr int kStandardIndent = 15; } // namespace +namespace disassemble { +InstructionDisassembler::InstructionDisassembler(const AssemblyGrammar& grammar, + std::ostream& stream, + uint32_t options, + NameMapper name_mapper) + : grammar_(grammar), + stream_(stream), + print_(spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_PRINT, options)), + color_(spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_COLOR, options)), + indent_(spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_INDENT, options) + ? kStandardIndent + : 0), + comment_(spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_COMMENT, options)), + show_byte_offset_( + spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_SHOW_BYTE_OFFSET, options)), + name_mapper_(std::move(name_mapper)) {} + +void InstructionDisassembler::EmitHeaderSpirv() { stream_ << "; SPIR-V\n"; } + +void InstructionDisassembler::EmitHeaderVersion(uint32_t version) { + stream_ << "; Version: " << SPV_SPIRV_VERSION_MAJOR_PART(version) << "." + << SPV_SPIRV_VERSION_MINOR_PART(version) << "\n"; +} + +void InstructionDisassembler::EmitHeaderGenerator(uint32_t generator) { + const char* generator_tool = + spvGeneratorStr(SPV_GENERATOR_TOOL_PART(generator)); + stream_ << "; Generator: " << generator_tool; + // For unknown tools, print the numeric tool value. + if (0 == strcmp("Unknown", generator_tool)) { + stream_ << "(" << SPV_GENERATOR_TOOL_PART(generator) << ")"; + } + // Print the miscellaneous part of the generator word on the same + // line as the tool name. + stream_ << "; " << SPV_GENERATOR_MISC_PART(generator) << "\n"; +} + +void InstructionDisassembler::EmitHeaderIdBound(uint32_t id_bound) { + stream_ << "; Bound: " << id_bound << "\n"; +} + +void InstructionDisassembler::EmitHeaderSchema(uint32_t schema) { + stream_ << "; Schema: " << schema << "\n"; +} + +void InstructionDisassembler::EmitInstruction( + const spv_parsed_instruction_t& inst, size_t inst_byte_offset) { + auto opcode = static_cast(inst.opcode); + + if (inst.result_id) { + SetBlue(); + const std::string id_name = name_mapper_(inst.result_id); + if (indent_) + stream_ << std::setw(std::max(0, indent_ - 3 - int(id_name.size()))); + stream_ << "%" << id_name; + ResetColor(); + stream_ << " = "; + } else { + stream_ << std::string(indent_, ' '); + } + + stream_ << "Op" << spvOpcodeString(opcode); + + for (uint16_t i = 0; i < inst.num_operands; i++) { + const spv_operand_type_t type = inst.operands[i].type; + assert(type != SPV_OPERAND_TYPE_NONE); + if (type == SPV_OPERAND_TYPE_RESULT_ID) continue; + stream_ << " "; + EmitOperand(inst, i); + } + + if (comment_ && opcode == SpvOpName) { + const spv_parsed_operand_t& operand = inst.operands[0]; + const uint32_t word = inst.words[operand.offset]; + stream_ << " ; id %" << word; + } + + if (show_byte_offset_) { + SetGrey(); + auto saved_flags = stream_.flags(); + auto saved_fill = stream_.fill(); + stream_ << " ; 0x" << std::setw(8) << std::hex << std::setfill('0') + << inst_byte_offset; + stream_.flags(saved_flags); + stream_.fill(saved_fill); + ResetColor(); + } + stream_ << "\n"; +} + +void InstructionDisassembler::EmitSectionComment( + const spv_parsed_instruction_t& inst, bool& inserted_decoration_space, + bool& inserted_debug_space, bool& inserted_type_space) { + auto opcode = static_cast(inst.opcode); + if (comment_ && opcode == SpvOpFunction) { + stream_ << std::endl; + stream_ << std::string(indent_, ' '); + stream_ << "; Function " << name_mapper_(inst.result_id) << std::endl; + } + if (comment_ && !inserted_decoration_space && spvOpcodeIsDecoration(opcode)) { + inserted_decoration_space = true; + stream_ << std::endl; + stream_ << std::string(indent_, ' '); + stream_ << "; Annotations" << std::endl; + } + if (comment_ && !inserted_debug_space && spvOpcodeIsDebug(opcode)) { + inserted_debug_space = true; + stream_ << std::endl; + stream_ << std::string(indent_, ' '); + stream_ << "; Debug Information" << std::endl; + } + if (comment_ && !inserted_type_space && spvOpcodeGeneratesType(opcode)) { + inserted_type_space = true; + stream_ << std::endl; + stream_ << std::string(indent_, ' '); + stream_ << "; Types, variables and constants" << std::endl; + } +} + +void InstructionDisassembler::EmitOperand(const spv_parsed_instruction_t& inst, + const uint16_t operand_index) { + assert(operand_index < inst.num_operands); + const spv_parsed_operand_t& operand = inst.operands[operand_index]; + const uint32_t word = inst.words[operand.offset]; + switch (operand.type) { + case SPV_OPERAND_TYPE_RESULT_ID: + assert(false && " is not supposed to be handled here"); + SetBlue(); + stream_ << "%" << name_mapper_(word); + break; + case SPV_OPERAND_TYPE_ID: + case SPV_OPERAND_TYPE_TYPE_ID: + case SPV_OPERAND_TYPE_SCOPE_ID: + case SPV_OPERAND_TYPE_MEMORY_SEMANTICS_ID: + SetYellow(); + stream_ << "%" << name_mapper_(word); + break; + case SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER: { + spv_ext_inst_desc ext_inst; + SetRed(); + if (grammar_.lookupExtInst(inst.ext_inst_type, word, &ext_inst) == + SPV_SUCCESS) { + stream_ << ext_inst->name; + } else { + if (!spvExtInstIsNonSemantic(inst.ext_inst_type)) { + assert(false && "should have caught this earlier"); + } else { + // for non-semantic instruction sets we can just print the number + stream_ << word; + } + } + } break; + case SPV_OPERAND_TYPE_SPEC_CONSTANT_OP_NUMBER: { + spv_opcode_desc opcode_desc; + if (grammar_.lookupOpcode(SpvOp(word), &opcode_desc)) + assert(false && "should have caught this earlier"); + SetRed(); + stream_ << opcode_desc->name; + } break; + case SPV_OPERAND_TYPE_LITERAL_INTEGER: + case SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER: { + SetRed(); + EmitNumericLiteral(&stream_, inst, operand); + ResetColor(); + } break; + case SPV_OPERAND_TYPE_LITERAL_STRING: { + stream_ << "\""; + SetGreen(); + + std::string str = spvDecodeLiteralStringOperand(inst, operand_index); + for (char const& c : str) { + if (c == '"' || c == '\\') stream_ << '\\'; + stream_ << c; + } + ResetColor(); + stream_ << '"'; + } break; + case SPV_OPERAND_TYPE_CAPABILITY: + case SPV_OPERAND_TYPE_SOURCE_LANGUAGE: + case SPV_OPERAND_TYPE_EXECUTION_MODEL: + case SPV_OPERAND_TYPE_ADDRESSING_MODEL: + case SPV_OPERAND_TYPE_MEMORY_MODEL: + case SPV_OPERAND_TYPE_EXECUTION_MODE: + case SPV_OPERAND_TYPE_STORAGE_CLASS: + case SPV_OPERAND_TYPE_DIMENSIONALITY: + case SPV_OPERAND_TYPE_SAMPLER_ADDRESSING_MODE: + case SPV_OPERAND_TYPE_SAMPLER_FILTER_MODE: + case SPV_OPERAND_TYPE_SAMPLER_IMAGE_FORMAT: + case SPV_OPERAND_TYPE_FP_ROUNDING_MODE: + case SPV_OPERAND_TYPE_LINKAGE_TYPE: + case SPV_OPERAND_TYPE_ACCESS_QUALIFIER: + case SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE: + case SPV_OPERAND_TYPE_DECORATION: + case SPV_OPERAND_TYPE_BUILT_IN: + case SPV_OPERAND_TYPE_GROUP_OPERATION: + case SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS: + case SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO: + case SPV_OPERAND_TYPE_RAY_FLAGS: + case SPV_OPERAND_TYPE_RAY_QUERY_INTERSECTION: + case SPV_OPERAND_TYPE_RAY_QUERY_COMMITTED_INTERSECTION_TYPE: + case SPV_OPERAND_TYPE_RAY_QUERY_CANDIDATE_INTERSECTION_TYPE: + case SPV_OPERAND_TYPE_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING: + case SPV_OPERAND_TYPE_DEBUG_COMPOSITE_TYPE: + case SPV_OPERAND_TYPE_DEBUG_TYPE_QUALIFIER: + case SPV_OPERAND_TYPE_DEBUG_OPERATION: + case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING: + case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_COMPOSITE_TYPE: + case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_TYPE_QUALIFIER: + case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_OPERATION: + case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_IMPORTED_ENTITY: + case SPV_OPERAND_TYPE_FPDENORM_MODE: + case SPV_OPERAND_TYPE_FPOPERATION_MODE: + case SPV_OPERAND_TYPE_QUANTIZATION_MODES: + case SPV_OPERAND_TYPE_OVERFLOW_MODES: { + spv_operand_desc entry; + if (grammar_.lookupOperand(operand.type, word, &entry)) + assert(false && "should have caught this earlier"); + stream_ << entry->name; + } break; + case SPV_OPERAND_TYPE_FP_FAST_MATH_MODE: + case SPV_OPERAND_TYPE_FUNCTION_CONTROL: + case SPV_OPERAND_TYPE_LOOP_CONTROL: + case SPV_OPERAND_TYPE_IMAGE: + case SPV_OPERAND_TYPE_MEMORY_ACCESS: + case SPV_OPERAND_TYPE_SELECTION_CONTROL: + case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS: + case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS: + EmitMaskOperand(operand.type, word); + break; + default: + if (spvOperandIsConcreteMask(operand.type)) { + EmitMaskOperand(operand.type, word); + } else if (spvOperandIsConcrete(operand.type)) { + spv_operand_desc entry; + if (grammar_.lookupOperand(operand.type, word, &entry)) + assert(false && "should have caught this earlier"); + stream_ << entry->name; + } else { + assert(false && "unhandled or invalid case"); + } + break; + } + ResetColor(); +} + +void InstructionDisassembler::EmitMaskOperand(const spv_operand_type_t type, + const uint32_t word) { + // Scan the mask from least significant bit to most significant bit. For each + // set bit, emit the name of that bit. Separate multiple names with '|'. + uint32_t remaining_word = word; + uint32_t mask; + int num_emitted = 0; + for (mask = 1; remaining_word; mask <<= 1) { + if (remaining_word & mask) { + remaining_word ^= mask; + spv_operand_desc entry; + if (grammar_.lookupOperand(type, mask, &entry)) + assert(false && "should have caught this earlier"); + if (num_emitted) stream_ << "|"; + stream_ << entry->name; + num_emitted++; + } + } + if (!num_emitted) { + // An operand value of 0 was provided, so represent it by the name + // of the 0 value. In many cases, that's "None". + spv_operand_desc entry; + if (SPV_SUCCESS == grammar_.lookupOperand(type, 0, &entry)) + stream_ << entry->name; + } +} + +void InstructionDisassembler::ResetColor() { + if (color_) stream_ << spvtools::clr::reset{print_}; +} +void InstructionDisassembler::SetGrey() { + if (color_) stream_ << spvtools::clr::grey{print_}; +} +void InstructionDisassembler::SetBlue() { + if (color_) stream_ << spvtools::clr::blue{print_}; +} +void InstructionDisassembler::SetYellow() { + if (color_) stream_ << spvtools::clr::yellow{print_}; +} +void InstructionDisassembler::SetRed() { + if (color_) stream_ << spvtools::clr::red{print_}; +} +void InstructionDisassembler::SetGreen() { + if (color_) stream_ << spvtools::clr::green{print_}; +} +} // namespace disassemble + +std::string spvInstructionBinaryToText(const spv_target_env env, + const uint32_t* instCode, + const size_t instWordCount, + const uint32_t* code, + const size_t wordCount, + const uint32_t options) { + spv_context context = spvContextCreate(env); + const AssemblyGrammar grammar(context); + if (!grammar.isValid()) { + spvContextDestroy(context); + return ""; + } + + // Generate friendly names for Ids if requested. + std::unique_ptr friendly_mapper; + NameMapper name_mapper = GetTrivialNameMapper(); + if (options & SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES) { + friendly_mapper = MakeUnique(context, code, wordCount); + name_mapper = friendly_mapper->GetNameMapper(); + } + + // Now disassemble! + Disassembler disassembler(grammar, options, name_mapper); + WrappedDisassembler wrapped(&disassembler, instCode, instWordCount); + spvBinaryParse(context, &wrapped, code, wordCount, DisassembleTargetHeader, + DisassembleTargetInstruction, nullptr); + + spv_text text = nullptr; + std::string output; + if (disassembler.SaveTextResult(&text) == SPV_SUCCESS) { + output.assign(text->str, text->str + text->length); + // Drop trailing newline characters. + while (!output.empty() && output.back() == '\n') output.pop_back(); + } + spvTextDestroy(text); + spvContextDestroy(context); + + return output; +} +} // namespace spvtools + spv_result_t spvBinaryToText(const spv_const_context context, const uint32_t* code, const size_t wordCount, const uint32_t options, spv_text* pText, @@ -495,53 +553,13 @@ spv_result_t spvBinaryToText(const spv_const_context context, } // Now disassemble! - Disassembler disassembler(grammar, options, name_mapper); - if (auto error = spvBinaryParse(&hijack_context, &disassembler, code, - wordCount, DisassembleHeader, - DisassembleInstruction, pDiagnostic)) { + spvtools::Disassembler disassembler(grammar, options, name_mapper); + if (auto error = + spvBinaryParse(&hijack_context, &disassembler, code, wordCount, + spvtools::DisassembleHeader, + spvtools::DisassembleInstruction, pDiagnostic)) { return error; } return disassembler.SaveTextResult(pText); } - -std::string spvtools::spvInstructionBinaryToText(const spv_target_env env, - const uint32_t* instCode, - const size_t instWordCount, - const uint32_t* code, - const size_t wordCount, - const uint32_t options) { - spv_context context = spvContextCreate(env); - const spvtools::AssemblyGrammar grammar(context); - if (!grammar.isValid()) { - spvContextDestroy(context); - return ""; - } - - // Generate friendly names for Ids if requested. - std::unique_ptr friendly_mapper; - spvtools::NameMapper name_mapper = spvtools::GetTrivialNameMapper(); - if (options & SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES) { - friendly_mapper = spvtools::MakeUnique( - context, code, wordCount); - name_mapper = friendly_mapper->GetNameMapper(); - } - - // Now disassemble! - Disassembler disassembler(grammar, options, name_mapper); - WrappedDisassembler wrapped(&disassembler, instCode, instWordCount); - spvBinaryParse(context, &wrapped, code, wordCount, DisassembleTargetHeader, - DisassembleTargetInstruction, nullptr); - - spv_text text = nullptr; - std::string output; - if (disassembler.SaveTextResult(&text) == SPV_SUCCESS) { - output.assign(text->str, text->str + text->length); - // Drop trailing newline characters. - while (!output.empty() && output.back() == '\n') output.pop_back(); - } - spvTextDestroy(text); - spvContextDestroy(context); - - return output; -} diff --git a/third_party/spirv-tools/source/disassemble.h b/third_party/spirv-tools/source/disassemble.h index ac3574272a..8eacb10066 100644 --- a/third_party/spirv-tools/source/disassemble.h +++ b/third_party/spirv-tools/source/disassemble.h @@ -15,8 +15,10 @@ #ifndef SOURCE_DISASSEMBLE_H_ #define SOURCE_DISASSEMBLE_H_ +#include #include +#include "source/name_mapper.h" #include "spirv-tools/libspirv.h" namespace spvtools { @@ -33,6 +35,63 @@ std::string spvInstructionBinaryToText(const spv_target_env env, const size_t word_count, const uint32_t options); +class AssemblyGrammar; +namespace disassemble { + +// Shared code with other tools (than the disassembler) that might need to +// output disassembly. An InstructionDisassembler instance converts SPIR-V +// binary for an instruction to its assembly representation. +class InstructionDisassembler { + public: + InstructionDisassembler(const AssemblyGrammar& grammar, std::ostream& stream, + uint32_t options, NameMapper name_mapper); + + // Emits the assembly header for the module. + void EmitHeaderSpirv(); + void EmitHeaderVersion(uint32_t version); + void EmitHeaderGenerator(uint32_t generator); + void EmitHeaderIdBound(uint32_t id_bound); + void EmitHeaderSchema(uint32_t schema); + + // Emits the assembly text for the given instruction. + void EmitInstruction(const spv_parsed_instruction_t& inst, + size_t inst_byte_offset); + + // Emits a comment between different sections of the module. + void EmitSectionComment(const spv_parsed_instruction_t& inst, + bool& inserted_decoration_space, + bool& inserted_debug_space, + bool& inserted_type_space); + + // Resets the output color, if color is turned on. + void ResetColor(); + // Set the output color, if color is turned on. + void SetGrey(); + void SetBlue(); + void SetYellow(); + void SetRed(); + void SetGreen(); + + private: + // Emits an operand for the given instruction, where the instruction + // is at offset words from the start of the binary. + void EmitOperand(const spv_parsed_instruction_t& inst, + const uint16_t operand_index); + + // Emits a mask expression for the given mask word of the specified type. + void EmitMaskOperand(const spv_operand_type_t type, const uint32_t word); + + const spvtools::AssemblyGrammar& grammar_; + std::ostream& stream_; + const bool print_; // Should we also print to the standard output stream? + const bool color_; // Should we print in colour? + const int indent_; // How much to indent. 0 means don't indent + const int comment_; // Should we comment the source + const bool show_byte_offset_; // Should we print byte offset, in hex? + spvtools::NameMapper name_mapper_; +}; + +} // namespace disassemble } // namespace spvtools #endif // SOURCE_DISASSEMBLE_H_ diff --git a/third_party/spirv-tools/source/ext_inst.cpp b/third_party/spirv-tools/source/ext_inst.cpp index 812053ec0a..4e2795453f 100644 --- a/third_party/spirv-tools/source/ext_inst.cpp +++ b/third_party/spirv-tools/source/ext_inst.cpp @@ -96,6 +96,8 @@ spv_result_t spvExtInstTableGet(spv_ext_inst_table* pExtInstTable, case SPV_ENV_UNIVERSAL_1_4: case SPV_ENV_UNIVERSAL_1_5: case SPV_ENV_VULKAN_1_2: + case SPV_ENV_UNIVERSAL_1_6: + case SPV_ENV_VULKAN_1_3: *pExtInstTable = &kTable_1_0; return SPV_SUCCESS; default: diff --git a/third_party/spirv-tools/source/ext_inst.h b/third_party/spirv-tools/source/ext_inst.h index aff6e308c7..4027f4c3c8 100644 --- a/third_party/spirv-tools/source/ext_inst.h +++ b/third_party/spirv-tools/source/ext_inst.h @@ -27,7 +27,7 @@ bool spvExtInstIsNonSemantic(const spv_ext_inst_type_t type); // Returns true if the extended instruction set is debug info bool spvExtInstIsDebugInfo(const spv_ext_inst_type_t type); -// Finds the named extented instruction of the given type in the given extended +// Finds the named extended instruction of the given type in the given extended // instruction table. On success, returns SPV_SUCCESS and writes a handle of // the instruction entry into *entry. spv_result_t spvExtInstTableNameLookup(const spv_ext_inst_table table, @@ -35,7 +35,7 @@ spv_result_t spvExtInstTableNameLookup(const spv_ext_inst_table table, const char* name, spv_ext_inst_desc* entry); -// Finds the extented instruction of the given type in the given extended +// Finds the extended instruction of the given type in the given extended // instruction table by value. On success, returns SPV_SUCCESS and writes a // handle of the instruction entry into *entry. spv_result_t spvExtInstTableValueLookup(const spv_ext_inst_table table, diff --git a/third_party/spirv-tools/source/extensions.cpp b/third_party/spirv-tools/source/extensions.cpp index a94db273e7..049a3ad10a 100644 --- a/third_party/spirv-tools/source/extensions.cpp +++ b/third_party/spirv-tools/source/extensions.cpp @@ -18,6 +18,7 @@ #include #include +#include "source/binary.h" #include "source/enum_string_mapping.h" namespace spvtools { @@ -30,8 +31,9 @@ std::string GetExtensionString(const spv_parsed_instruction_t* inst) { const auto& operand = inst->operands[0]; assert(operand.type == SPV_OPERAND_TYPE_LITERAL_STRING); assert(inst->num_words > operand.offset); + (void)operand; /* No unused variables in release builds. */ - return reinterpret_cast(inst->words + operand.offset); + return spvDecodeLiteralStringOperand(*inst, 0); } std::string ExtensionSetToString(const ExtensionSet& extensions) { diff --git a/third_party/spirv-tools/source/fuzz/fact_manager/fact_manager.h b/third_party/spirv-tools/source/fuzz/fact_manager/fact_manager.h index 5cf5b18bce..ce28ae4c92 100644 --- a/third_party/spirv-tools/source/fuzz/fact_manager/fact_manager.h +++ b/third_party/spirv-tools/source/fuzz/fact_manager/fact_manager.h @@ -163,7 +163,7 @@ class FactManager { std::vector GetSynonymsForDataDescriptor( const protobufs::DataDescriptor& data_descriptor) const; - // Returns true if and ony if |data_descriptor1| and |data_descriptor2| are + // Returns true if and only if |data_descriptor1| and |data_descriptor2| are // known to be synonymous. bool IsSynonymous(const protobufs::DataDescriptor& data_descriptor1, const protobufs::DataDescriptor& data_descriptor2) const; @@ -174,7 +174,7 @@ class FactManager { //============================== // Querying facts about dead blocks - // Returns true if and ony if |block_id| is the id of a block known to be + // Returns true if and only if |block_id| is the id of a block known to be // dynamically unreachable. bool BlockIsDead(uint32_t block_id) const; @@ -184,7 +184,7 @@ class FactManager { //============================== // Querying facts about livesafe function - // Returns true if and ony if |function_id| is the id of a function known + // Returns true if and only if |function_id| is the id of a function known // to be livesafe. bool FunctionIsLivesafe(uint32_t function_id) const; @@ -194,7 +194,7 @@ class FactManager { //============================== // Querying facts about irrelevant values - // Returns true if and ony if the value of the pointee associated with + // Returns true if and only if the value of the pointee associated with // |pointer_id| is irrelevant. bool PointeeValueIsIrrelevant(uint32_t pointer_id) const; diff --git a/third_party/spirv-tools/source/fuzz/fuzzer_context.cpp b/third_party/spirv-tools/source/fuzz/fuzzer_context.cpp index c2175425b2..7e34cc33ce 100644 --- a/third_party/spirv-tools/source/fuzz/fuzzer_context.cpp +++ b/third_party/spirv-tools/source/fuzz/fuzzer_context.cpp @@ -21,7 +21,7 @@ namespace fuzz { namespace { -// An offset between the the module's id bound and the minimum fresh id. +// An offset between the module's id bound and the minimum fresh id. // // TODO(https://github.com/KhronosGroup/SPIRV-Tools/issues/2541): consider // the case where the maximum id bound is reached. diff --git a/third_party/spirv-tools/source/fuzz/fuzzer_pass.cpp b/third_party/spirv-tools/source/fuzz/fuzzer_pass.cpp index d91482cc7e..6a879851d0 100644 --- a/third_party/spirv-tools/source/fuzz/fuzzer_pass.cpp +++ b/third_party/spirv-tools/source/fuzz/fuzzer_pass.cpp @@ -261,7 +261,7 @@ uint32_t FuzzerPass::FindOrCreateFloatType(uint32_t width) { uint32_t FuzzerPass::FindOrCreateFunctionType( uint32_t return_type_id, const std::vector& argument_id) { - // FindFunctionType has a sigle argument for OpTypeFunction operands + // FindFunctionType has a single argument for OpTypeFunction operands // so we will have to copy them all in this vector std::vector type_ids(argument_id.size() + 1); type_ids[0] = return_type_id; diff --git a/third_party/spirv-tools/source/fuzz/fuzzer_pass_donate_modules.cpp b/third_party/spirv-tools/source/fuzz/fuzzer_pass_donate_modules.cpp index 5bdf6973eb..29ede58b5b 100644 --- a/third_party/spirv-tools/source/fuzz/fuzzer_pass_donate_modules.cpp +++ b/third_party/spirv-tools/source/fuzz/fuzzer_pass_donate_modules.cpp @@ -479,7 +479,7 @@ void FuzzerPassDonateModules::HandleTypeOrValue( "should have been donated."); // It is OK to have duplicate constant composite definitions, so add - // this to the module using remapped versions of all consituent ids and + // this to the module using remapped versions of all constituent ids and // the result type. new_result_id = GetFuzzerContext()->GetFreshId(); std::vector constituent_ids; diff --git a/third_party/spirv-tools/source/fuzz/protobufs/spvtoolsfuzz.proto b/third_party/spirv-tools/source/fuzz/protobufs/spvtoolsfuzz.proto index cba9397b54..e71b6a3f6a 100644 --- a/third_party/spirv-tools/source/fuzz/protobufs/spvtoolsfuzz.proto +++ b/third_party/spirv-tools/source/fuzz/protobufs/spvtoolsfuzz.proto @@ -1961,10 +1961,10 @@ message TransformationReplaceBooleanConstantWithConstantBinary { // A descriptor for the boolean constant id we would like to replace IdUseDescriptor id_use_descriptor = 1; - // Id for the constant to be used on the LHS of the comparision + // Id for the constant to be used on the LHS of the comparison uint32 lhs_id = 2; - // Id for the constant to be used on the RHS of the comparision + // Id for the constant to be used on the RHS of the comparison uint32 rhs_id = 3; // Opcode for binary operator @@ -2403,7 +2403,7 @@ message TransformationWrapVectorSynonym { // va = vector(..., a, ...) // vb = vector(..., b, ...) // - // where a and b are in the same position i in each of their correponding vector + // where a and b are in the same position i in each of their corresponding vector // and a is synonymous with va[i] and b is synonymous with vb[i]. // // The transformation then add an instruction vc = va op vb where c is synonymous diff --git a/third_party/spirv-tools/source/fuzz/transformation_add_constant_composite.cpp b/third_party/spirv-tools/source/fuzz/transformation_add_constant_composite.cpp index e6cd5a96e3..89007ab655 100644 --- a/third_party/spirv-tools/source/fuzz/transformation_add_constant_composite.cpp +++ b/third_party/spirv-tools/source/fuzz/transformation_add_constant_composite.cpp @@ -75,7 +75,7 @@ bool TransformationAddConstantComposite::IsApplicable( // We do not create constants of structs decorated with Block nor // BufferBlock. The SPIR-V spec does not explicitly disallow this, but it // seems like a strange thing to do, so we disallow it to avoid triggering - // low priorty edge case issues related to it. + // low priority edge case issues related to it. if (fuzzerutil::HasBlockOrBufferBlockDecoration( ir_context, composite_type_instruction->result_id())) { return false; diff --git a/third_party/spirv-tools/source/fuzz/transformation_duplicate_region_with_selection.cpp b/third_party/spirv-tools/source/fuzz/transformation_duplicate_region_with_selection.cpp index a80becd97b..db88610f10 100644 --- a/third_party/spirv-tools/source/fuzz/transformation_duplicate_region_with_selection.cpp +++ b/third_party/spirv-tools/source/fuzz/transformation_duplicate_region_with_selection.cpp @@ -325,7 +325,7 @@ void TransformationDuplicateRegionWithSelection::Apply( std::map original_id_to_phi_id = fuzzerutil::RepeatedUInt32PairToMap(message_.original_id_to_phi_id()); - // Use oveflow ids to fill in any required ids that are missing from these + // Use overflow ids to fill in any required ids that are missing from these // maps. for (auto block : region_blocks) { if (original_label_to_duplicate_label.count(block->id()) == 0) { diff --git a/third_party/spirv-tools/source/fuzz/transformation_replace_id_with_synonym.h b/third_party/spirv-tools/source/fuzz/transformation_replace_id_with_synonym.h index 4570fcefec..66f8e439a2 100644 --- a/third_party/spirv-tools/source/fuzz/transformation_replace_id_with_synonym.h +++ b/third_party/spirv-tools/source/fuzz/transformation_replace_id_with_synonym.h @@ -32,7 +32,7 @@ class TransformationReplaceIdWithSynonym : public Transformation { protobufs::IdUseDescriptor id_use_descriptor, uint32_t synonymous_id); // - The fact manager must know that the id identified by - // |message_.id_use_descriptor| is synonomous with |message_.synonymous_id|. + // |message_.id_use_descriptor| is synonymous with |message_.synonymous_id|. // - Replacing the id in |message_.id_use_descriptor| by // |message_.synonymous_id| must respect SPIR-V's rules about uses being // dominated by their definitions. diff --git a/third_party/spirv-tools/source/link/CMakeLists.txt b/third_party/spirv-tools/source/link/CMakeLists.txt index c8dd2f7153..a452a107df 100644 --- a/third_party/spirv-tools/source/link/CMakeLists.txt +++ b/third_party/spirv-tools/source/link/CMakeLists.txt @@ -23,7 +23,7 @@ target_include_directories(SPIRV-Tools-link $ PRIVATE ${spirv-tools_BINARY_DIR} ) -# We need the IR functionnalities from the optimizer +# We need the IR functionalities from the optimizer target_link_libraries(SPIRV-Tools-link PUBLIC SPIRV-Tools-opt) diff --git a/third_party/spirv-tools/source/link/linker.cpp b/third_party/spirv-tools/source/link/linker.cpp index c5ca5625d6..3b388cc6ea 100644 --- a/third_party/spirv-tools/source/link/linker.cpp +++ b/third_party/spirv-tools/source/link/linker.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -33,10 +34,12 @@ #include "source/opt/ir_loader.h" #include "source/opt/pass_manager.h" #include "source/opt/remove_duplicates_pass.h" +#include "source/opt/remove_unused_interface_variables_pass.h" #include "source/opt/type_manager.h" #include "source/spirv_constant.h" #include "source/spirv_target_env.h" #include "source/util/make_unique.h" +#include "source/util/string_utils.h" #include "spirv-tools/libspirv.hpp" namespace spvtools { @@ -86,10 +89,6 @@ spv_result_t ShiftIdsInModules(const MessageConsumer& consumer, // // |header| should not be null, |modules| should not be empty and pointers // should be non-null. |max_id_bound| should be strictly greater than 0. -// -// TODO(pierremoreau): What to do when binaries use different versions of -// SPIR-V? For now, use the max of all versions found in -// the input modules. spv_result_t GenerateHeader(const MessageConsumer& consumer, const std::vector& modules, uint32_t max_id_bound, opt::ModuleHeader* header); @@ -130,7 +129,7 @@ spv_result_t CheckImportExportCompatibility(const MessageConsumer& consumer, // Remove linkage specific instructions, such as prototypes of imported // functions, declarations of imported variables, import (and export if -// necessary) linkage attribtes. +// necessary) linkage attributes. // // |linked_context| and |decoration_manager| should not be null, and the // 'RemoveDuplicatePass' should be run first. @@ -148,6 +147,15 @@ spv_result_t RemoveLinkageSpecificInstructions( spv_result_t VerifyIds(const MessageConsumer& consumer, opt::IRContext* linked_context); +// Verify that the universal limits are not crossed, and warn the user +// otherwise. +// +// TODO(pierremoreau): +// - Verify against the limits of the environment (e.g. Vulkan limits if +// consuming vulkan1.x) +spv_result_t VerifyLimits(const MessageConsumer& consumer, + const opt::IRContext& linked_context); + spv_result_t ShiftIdsInModules(const MessageConsumer& consumer, std::vector* modules, uint32_t* max_id_bound) { @@ -163,29 +171,31 @@ spv_result_t ShiftIdsInModules(const MessageConsumer& consumer, return DiagnosticStream(position, consumer, "", SPV_ERROR_INVALID_DATA) << "|max_id_bound| of ShiftIdsInModules should not be null."; - uint32_t id_bound = modules->front()->IdBound() - 1u; + const size_t id_bound = + std::accumulate(modules->begin(), modules->end(), static_cast(1), + [](const size_t& accumulation, opt::Module* module) { + return accumulation + module->IdBound() - 1u; + }); + if (id_bound > std::numeric_limits::max()) + return DiagnosticStream(position, consumer, "", SPV_ERROR_INVALID_DATA) + << "Too many IDs (" << id_bound + << "): combining all modules would overflow the 32-bit word of the " + "SPIR-V header."; + + *max_id_bound = static_cast(id_bound); + + uint32_t id_offset = modules->front()->IdBound() - 1u; for (auto module_iter = modules->begin() + 1; module_iter != modules->end(); ++module_iter) { Module* module = *module_iter; - module->ForEachInst([&id_bound](Instruction* insn) { - insn->ForEachId([&id_bound](uint32_t* id) { *id += id_bound; }); + module->ForEachInst([&id_offset](Instruction* insn) { + insn->ForEachId([&id_offset](uint32_t* id) { *id += id_offset; }); }); - id_bound += module->IdBound() - 1u; - if (id_bound > 0x3FFFFF) - return DiagnosticStream(position, consumer, "", SPV_ERROR_INVALID_ID) - << "The limit of IDs, 4194303, was exceeded:" - << " " << id_bound << " is the current ID bound."; + id_offset += module->IdBound() - 1u; // Invalidate the DefUseManager module->context()->InvalidateAnalyses(opt::IRContext::kAnalysisDefUse); } - ++id_bound; - if (id_bound > 0x3FFFFF) - return DiagnosticStream(position, consumer, "", SPV_ERROR_INVALID_ID) - << "The limit of IDs, 4194303, was exceeded:" - << " " << id_bound << " is the current ID bound."; - - *max_id_bound = id_bound; return SPV_SUCCESS; } @@ -202,15 +212,25 @@ spv_result_t GenerateHeader(const MessageConsumer& consumer, return DiagnosticStream(position, consumer, "", SPV_ERROR_INVALID_DATA) << "|max_id_bound| of GenerateHeader should not be null."; - uint32_t version = 0u; - for (const auto& module : modules) - version = std::max(version, module->version()); + const uint32_t linked_version = modules.front()->version(); + for (std::size_t i = 1; i < modules.size(); ++i) { + const uint32_t module_version = modules[i]->version(); + if (module_version != linked_version) + return DiagnosticStream({0, 0, 1}, consumer, "", SPV_ERROR_INTERNAL) + << "Conflicting SPIR-V versions: " + << SPV_SPIRV_VERSION_MAJOR_PART(linked_version) << "." + << SPV_SPIRV_VERSION_MINOR_PART(linked_version) + << " (input modules 1 through " << i << ") vs " + << SPV_SPIRV_VERSION_MAJOR_PART(module_version) << "." + << SPV_SPIRV_VERSION_MINOR_PART(module_version) + << " (input module " << (i + 1) << ")."; + } header->magic_number = SpvMagicNumber; - header->version = version; + header->version = linked_version; header->generator = SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS_LINKER, 0); header->bound = max_id_bound; - header->reserved = 0u; + header->schema = 0u; return SPV_SUCCESS; } @@ -243,55 +263,65 @@ spv_result_t MergeModules(const MessageConsumer& consumer, linked_module->AddExtInstImport( std::unique_ptr(inst.Clone(linked_context))); - do { - const Instruction* memory_model_inst = input_modules[0]->GetMemoryModel(); - if (memory_model_inst == nullptr) break; + const Instruction* linked_memory_model_inst = + input_modules.front()->GetMemoryModel(); + if (linked_memory_model_inst == nullptr) { + return DiagnosticStream(position, consumer, "", SPV_ERROR_INVALID_BINARY) + << "Input module 1 is lacking an OpMemoryModel instruction."; + } + const uint32_t linked_addressing_model = + linked_memory_model_inst->GetSingleWordOperand(0u); + const uint32_t linked_memory_model = + linked_memory_model_inst->GetSingleWordOperand(1u); - uint32_t addressing_model = memory_model_inst->GetSingleWordOperand(0u); - uint32_t memory_model = memory_model_inst->GetSingleWordOperand(1u); - for (const auto& module : input_modules) { - memory_model_inst = module->GetMemoryModel(); - if (memory_model_inst == nullptr) continue; + for (std::size_t i = 1; i < input_modules.size(); ++i) { + const Module* module = input_modules[i]; + const Instruction* memory_model_inst = module->GetMemoryModel(); + if (memory_model_inst == nullptr) + return DiagnosticStream(position, consumer, "", SPV_ERROR_INVALID_BINARY) + << "Input module " << (i + 1) + << " is lacking an OpMemoryModel instruction."; - if (addressing_model != memory_model_inst->GetSingleWordOperand(0u)) { - spv_operand_desc initial_desc = nullptr, current_desc = nullptr; - grammar.lookupOperand(SPV_OPERAND_TYPE_ADDRESSING_MODEL, - addressing_model, &initial_desc); - grammar.lookupOperand(SPV_OPERAND_TYPE_ADDRESSING_MODEL, - memory_model_inst->GetSingleWordOperand(0u), - ¤t_desc); - return DiagnosticStream(position, consumer, "", SPV_ERROR_INTERNAL) - << "Conflicting addressing models: " << initial_desc->name - << " vs " << current_desc->name << "."; - } - if (memory_model != memory_model_inst->GetSingleWordOperand(1u)) { - spv_operand_desc initial_desc = nullptr, current_desc = nullptr; - grammar.lookupOperand(SPV_OPERAND_TYPE_MEMORY_MODEL, memory_model, - &initial_desc); - grammar.lookupOperand(SPV_OPERAND_TYPE_MEMORY_MODEL, - memory_model_inst->GetSingleWordOperand(1u), - ¤t_desc); - return DiagnosticStream(position, consumer, "", SPV_ERROR_INTERNAL) - << "Conflicting memory models: " << initial_desc->name << " vs " - << current_desc->name << "."; - } + const uint32_t module_addressing_model = + memory_model_inst->GetSingleWordOperand(0u); + if (module_addressing_model != linked_addressing_model) { + spv_operand_desc linked_desc = nullptr, module_desc = nullptr; + grammar.lookupOperand(SPV_OPERAND_TYPE_ADDRESSING_MODEL, + linked_addressing_model, &linked_desc); + grammar.lookupOperand(SPV_OPERAND_TYPE_ADDRESSING_MODEL, + module_addressing_model, &module_desc); + return DiagnosticStream(position, consumer, "", SPV_ERROR_INTERNAL) + << "Conflicting addressing models: " << linked_desc->name + << " (input modules 1 through " << i << ") vs " + << module_desc->name << " (input module " << (i + 1) << ")."; } - if (memory_model_inst != nullptr) - linked_module->SetMemoryModel(std::unique_ptr( - memory_model_inst->Clone(linked_context))); - } while (false); + const uint32_t module_memory_model = + memory_model_inst->GetSingleWordOperand(1u); + if (module_memory_model != linked_memory_model) { + spv_operand_desc linked_desc = nullptr, module_desc = nullptr; + grammar.lookupOperand(SPV_OPERAND_TYPE_MEMORY_MODEL, linked_memory_model, + &linked_desc); + grammar.lookupOperand(SPV_OPERAND_TYPE_MEMORY_MODEL, module_memory_model, + &module_desc); + return DiagnosticStream(position, consumer, "", SPV_ERROR_INTERNAL) + << "Conflicting memory models: " << linked_desc->name + << " (input modules 1 through " << i << ") vs " + << module_desc->name << " (input module " << (i + 1) << ")."; + } + } + linked_module->SetMemoryModel(std::unique_ptr( + linked_memory_model_inst->Clone(linked_context))); - std::vector> entry_points; + std::vector> entry_points; for (const auto& module : input_modules) for (const auto& inst : module->entry_points()) { const uint32_t model = inst.GetSingleWordInOperand(0); - const char* const name = - reinterpret_cast(inst.GetInOperand(2).words.data()); + const std::string name = inst.GetInOperand(2).AsString(); const auto i = std::find_if( entry_points.begin(), entry_points.end(), - [model, name](const std::pair& v) { - return v.first == model && strcmp(name, v.second) == 0; + [model, name](const std::pair& v) { + return v.first == model && v.second == name; }); if (i != entry_points.end()) { spv_operand_desc desc = nullptr; @@ -332,13 +362,10 @@ spv_result_t MergeModules(const MessageConsumer& consumer, // If the generated module uses SPIR-V 1.1 or higher, add an // OpModuleProcessed instruction about the linking step. - if (linked_module->version() >= 0x10100) { + if (linked_module->version() >= SPV_SPIRV_VERSION_WORD(1, 1)) { const std::string processed_string("Linked by SPIR-V Tools Linker"); - const auto num_chars = processed_string.size(); - // Compute num words, accommodate the terminating null character. - const auto num_words = (num_chars + 1 + 3) / 4; - std::vector processed_words(num_words, 0u); - std::memcpy(processed_words.data(), processed_string.data(), num_chars); + std::vector processed_words = + spvtools::utils::MakeVector(processed_string); linked_module->AddDebug3Inst(std::unique_ptr( new Instruction(linked_context, SpvOpModuleProcessed, 0u, 0u, {{SPV_OPERAND_TYPE_LITERAL_STRING, processed_words}}))); @@ -352,18 +379,12 @@ spv_result_t MergeModules(const MessageConsumer& consumer, // TODO(pierremoreau): Since the modules have not been validate, should we // expect SpvStorageClassFunction variables outside // functions? - uint32_t num_global_values = 0u; for (const auto& module : input_modules) { for (const auto& inst : module->types_values()) { linked_module->AddType( std::unique_ptr(inst.Clone(linked_context))); - num_global_values += inst.opcode() == SpvOpVariable; } } - if (num_global_values > 0xFFFF) - return DiagnosticStream(position, consumer, "", SPV_ERROR_INTERNAL) - << "The limit of global values, 65535, was exceeded;" - << " " << num_global_values << " global values were found."; // Process functions and their basic blocks for (const auto& module : input_modules) { @@ -414,8 +435,7 @@ spv_result_t GetImportExportPairs(const MessageConsumer& consumer, const uint32_t type = decoration.GetSingleWordInOperand(3u); LinkageSymbolInfo symbol_info; - symbol_info.name = - reinterpret_cast(decoration.GetInOperand(2u).words.data()); + symbol_info.name = decoration.GetInOperand(2u).AsString(); symbol_info.id = id; symbol_info.type_id = 0u; @@ -636,6 +656,34 @@ spv_result_t VerifyIds(const MessageConsumer& consumer, return SPV_SUCCESS; } +spv_result_t VerifyLimits(const MessageConsumer& consumer, + const opt::IRContext& linked_context) { + spv_position_t position = {}; + + const uint32_t max_id_bound = linked_context.module()->id_bound(); + if (max_id_bound >= SPV_LIMIT_RESULT_ID_BOUND) + DiagnosticStream({0u, 0u, 4u}, consumer, "", SPV_WARNING) + << "The minimum limit of IDs, " << (SPV_LIMIT_RESULT_ID_BOUND - 1) + << ", was exceeded:" + << " " << max_id_bound << " is the current ID bound.\n" + << "The resulting module might not be supported by all " + "implementations."; + + size_t num_global_values = 0u; + for (const auto& inst : linked_context.module()->types_values()) { + num_global_values += inst.opcode() == SpvOpVariable; + } + if (num_global_values >= SPV_LIMIT_GLOBAL_VARIABLES_MAX) + DiagnosticStream(position, consumer, "", SPV_WARNING) + << "The minimum limit of global values, " + << (SPV_LIMIT_GLOBAL_VARIABLES_MAX - 1) << ", was exceeded;" + << " " << num_global_values << " global values were found.\n" + << "The resulting module might not be supported by all " + "implementations."; + + return SPV_SUCCESS; +} + } // namespace spv_result_t Link(const Context& context, @@ -760,7 +808,16 @@ spv_result_t Link(const Context& context, const uint32_t* const* binaries, pass_res = manager.Run(&linked_context); if (pass_res == opt::Pass::Status::Failure) return SPV_ERROR_INVALID_DATA; - // Phase 11: Output the module + // Phase 11: Recompute EntryPoint variables + manager.AddPass(); + pass_res = manager.Run(&linked_context); + if (pass_res == opt::Pass::Status::Failure) return SPV_ERROR_INVALID_DATA; + + // Phase 12: Warn if SPIR-V limits were exceeded + res = VerifyLimits(consumer, linked_context); + if (res != SPV_SUCCESS) return res; + + // Phase 13: Output the module linked_context.module()->ToBinary(linked_binary, true); return SPV_SUCCESS; diff --git a/third_party/spirv-tools/source/name_mapper.cpp b/third_party/spirv-tools/source/name_mapper.cpp index eb08f8fed3..3b31d33a81 100644 --- a/third_party/spirv-tools/source/name_mapper.cpp +++ b/third_party/spirv-tools/source/name_mapper.cpp @@ -22,10 +22,10 @@ #include #include -#include "spirv-tools/libspirv.h" - +#include "source/binary.h" #include "source/latest_version_spirv_header.h" #include "source/parsed_operand.h" +#include "spirv-tools/libspirv.h" namespace spvtools { namespace { @@ -172,7 +172,7 @@ spv_result_t FriendlyNameMapper::ParseInstruction( const auto result_id = inst.result_id; switch (inst.opcode) { case SpvOpName: - SaveName(inst.words[1], reinterpret_cast(inst.words + 2)); + SaveName(inst.words[1], spvDecodeLiteralStringOperand(inst, 1)); break; case SpvOpDecorate: // Decorations come after OpName. So OpName will take precedence over @@ -274,9 +274,8 @@ spv_result_t FriendlyNameMapper::ParseInstruction( SaveName(result_id, "Queue"); break; case SpvOpTypeOpaque: - SaveName(result_id, - std::string("Opaque_") + - Sanitize(reinterpret_cast(inst.words + 2))); + SaveName(result_id, std::string("Opaque_") + + Sanitize(spvDecodeLiteralStringOperand(inst, 1))); break; case SpvOpTypePipeStorage: SaveName(result_id, "PipeStorage"); diff --git a/third_party/spirv-tools/source/opcode.cpp b/third_party/spirv-tools/source/opcode.cpp index c96cde8d69..2584d51eb1 100644 --- a/third_party/spirv-tools/source/opcode.cpp +++ b/third_party/spirv-tools/source/opcode.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2020 The Khronos Group Inc. +// Copyright (c) 2015-2022 The Khronos Group Inc. // Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights // reserved. // @@ -40,12 +40,12 @@ struct OpcodeDescPtrLen { static const spv_opcode_table_t kOpcodeTable = {ARRAY_SIZE(kOpcodeTableEntries), kOpcodeTableEntries}; -// Represents a vendor tool entry in the SPIR-V XML Regsitry. +// Represents a vendor tool entry in the SPIR-V XML Registry. struct VendorTool { uint32_t value; const char* vendor; const char* tool; // Might be empty string. - const char* vendor_tool; // Combiantion of vendor and tool. + const char* vendor_tool; // Combination of vendor and tool. }; const VendorTool vendor_tools[] = { @@ -528,6 +528,7 @@ bool spvOpcodeIsNonUniformGroupOperation(SpvOp opcode) { case SpvOpGroupNonUniformLogicalXor: case SpvOpGroupNonUniformQuadBroadcast: case SpvOpGroupNonUniformQuadSwap: + case SpvOpGroupNonUniformRotateKHR: return true; default: return false; @@ -631,6 +632,7 @@ bool spvOpcodeIsDebug(SpvOp opcode) { case SpvOpString: case SpvOpLine: case SpvOpNoLine: + case SpvOpModuleProcessed: return true; default: return false; diff --git a/third_party/spirv-tools/source/operand.cpp b/third_party/spirv-tools/source/operand.cpp index 6d83e81e2f..0c255a352d 100644 --- a/third_party/spirv-tools/source/operand.cpp +++ b/third_party/spirv-tools/source/operand.cpp @@ -72,12 +72,16 @@ spv_result_t spvOperandTableNameLookup(spv_target_env env, // Note that the second rule assumes the extension enabling this operand // is indeed requested in the SPIR-V code; checking that should be // validator's work. - if (((version >= entry.minVersion && version <= entry.lastVersion) || - entry.numExtensions > 0u || entry.numCapabilities > 0u) && - nameLength == strlen(entry.name) && + if (nameLength == strlen(entry.name) && !strncmp(entry.name, name, nameLength)) { - *pEntry = &entry; - return SPV_SUCCESS; + if ((version >= entry.minVersion && version <= entry.lastVersion) || + entry.numExtensions > 0u || entry.numCapabilities > 0u) { + *pEntry = &entry; + return SPV_SUCCESS; + } else { + // if there is no extension/capability then the version is wrong + return SPV_ERROR_WRONG_VERSION; + } } } } diff --git a/third_party/spirv-tools/source/opt/CMakeLists.txt b/third_party/spirv-tools/source/opt/CMakeLists.txt index 7d522fb5e6..75fe4c0fdc 100644 --- a/third_party/spirv-tools/source/opt/CMakeLists.txt +++ b/third_party/spirv-tools/source/opt/CMakeLists.txt @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. set(SPIRV_TOOLS_OPT_SOURCES + fix_func_call_arguments.h aggressive_dead_code_elim_pass.h amd_ext_to_khr.h basic_block.h @@ -45,6 +46,7 @@ set(SPIRV_TOOLS_OPT_SOURCES eliminate_dead_constant_pass.h eliminate_dead_functions_pass.h eliminate_dead_functions_util.h + eliminate_dead_input_components_pass.h eliminate_dead_members_pass.h empty_pass.h feature_manager.h @@ -66,6 +68,7 @@ set(SPIRV_TOOLS_OPT_SOURCES instruction.h instruction_list.h instrument_pass.h + interface_var_sroa.h interp_fixup_pass.h ir_builder.h ir_context.h @@ -99,6 +102,7 @@ set(SPIRV_TOOLS_OPT_SOURCES reflect.h register_pressure.h relax_float_ops_pass.h + remove_dontinline_pass.h remove_duplicates_pass.h remove_unused_interface_variables_pass.h replace_desc_array_access_using_var_index.h @@ -108,10 +112,11 @@ set(SPIRV_TOOLS_OPT_SOURCES scalar_replacement_pass.h set_spec_constant_default_value_pass.h simplification_pass.h + spread_volatile_semantics.h ssa_rewrite_pass.h strength_reduction_pass.h strip_debug_info_pass.h - strip_reflect_info_pass.h + strip_nonsemantic_info_pass.h struct_cfg_analysis.h tree_iterator.h type_manager.h @@ -123,6 +128,7 @@ set(SPIRV_TOOLS_OPT_SOURCES workaround1209.h wrap_opkill.h + fix_func_call_arguments.cpp aggressive_dead_code_elim_pass.cpp amd_ext_to_khr.cpp basic_block.cpp @@ -156,6 +162,7 @@ set(SPIRV_TOOLS_OPT_SOURCES eliminate_dead_constant_pass.cpp eliminate_dead_functions_pass.cpp eliminate_dead_functions_util.cpp + eliminate_dead_input_components_pass.cpp eliminate_dead_members_pass.cpp feature_manager.cpp fix_storage_class.cpp @@ -176,6 +183,7 @@ set(SPIRV_TOOLS_OPT_SOURCES instruction.cpp instruction_list.cpp instrument_pass.cpp + interface_var_sroa.cpp interp_fixup_pass.cpp ir_context.cpp ir_loader.cpp @@ -206,6 +214,7 @@ set(SPIRV_TOOLS_OPT_SOURCES redundancy_elimination.cpp register_pressure.cpp relax_float_ops_pass.cpp + remove_dontinline_pass.cpp remove_duplicates_pass.cpp remove_unused_interface_variables_pass.cpp replace_desc_array_access_using_var_index.cpp @@ -215,10 +224,11 @@ set(SPIRV_TOOLS_OPT_SOURCES scalar_replacement_pass.cpp set_spec_constant_default_value_pass.cpp simplification_pass.cpp + spread_volatile_semantics.cpp ssa_rewrite_pass.cpp strength_reduction_pass.cpp strip_debug_info_pass.cpp - strip_reflect_info_pass.cpp + strip_nonsemantic_info_pass.cpp struct_cfg_analysis.cpp type_manager.cpp types.cpp diff --git a/third_party/spirv-tools/source/opt/aggressive_dead_code_elim_pass.cpp b/third_party/spirv-tools/source/opt/aggressive_dead_code_elim_pass.cpp index 0b54d5e85a..2486242a7b 100644 --- a/third_party/spirv-tools/source/opt/aggressive_dead_code_elim_pass.cpp +++ b/third_party/spirv-tools/source/opt/aggressive_dead_code_elim_pass.cpp @@ -27,6 +27,7 @@ #include "source/opt/iterator.h" #include "source/opt/reflect.h" #include "source/spirv_constant.h" +#include "source/util/string_utils.h" namespace spvtools { namespace opt { @@ -146,8 +147,7 @@ void AggressiveDCEPass::AddStores(Function* func, uint32_t ptrId) { bool AggressiveDCEPass::AllExtensionsSupported() const { // If any extension not in allowlist, return false for (auto& ei : get_module()->extensions()) { - const char* extName = - reinterpret_cast(&ei.GetInOperand(0).words[0]); + const std::string extName = ei.GetInOperand(0).AsString(); if (extensions_allowlist_.find(extName) == extensions_allowlist_.end()) return false; } @@ -156,11 +156,9 @@ bool AggressiveDCEPass::AllExtensionsSupported() const { for (auto& inst : context()->module()->ext_inst_imports()) { assert(inst.opcode() == SpvOpExtInstImport && "Expecting an import of an extension's instruction set."); - const char* extension_name = - reinterpret_cast(&inst.GetInOperand(0).words[0]); - if (0 == std::strncmp(extension_name, "NonSemantic.", 12) && - 0 != std::strncmp(extension_name, "NonSemantic.Shader.DebugInfo.100", - 32)) { + const std::string extension_name = inst.GetInOperand(0).AsString(); + if (spvtools::utils::starts_with(extension_name, "NonSemantic.") && + extension_name != "NonSemantic.Shader.DebugInfo.100") { return false; } } @@ -569,12 +567,7 @@ void AggressiveDCEPass::InitializeModuleScopeLiveInstructions() { } // Keep all entry points. for (auto& entry : get_module()->entry_points()) { - if (get_module()->version() >= SPV_SPIRV_VERSION_WORD(1, 4) && - !preserve_interface_) { - // In SPIR-V 1.4 and later, entry points must list all global variables - // used. DCE can still remove non-input/output variables and update the - // interface list. Mark the entry point as live and inputs and outputs as - // live, but defer decisions all other interfaces. + if (!preserve_interface_) { live_insts_.Set(entry.unique_id()); // The actual function is live always. AddToWorklist( @@ -582,8 +575,9 @@ void AggressiveDCEPass::InitializeModuleScopeLiveInstructions() { for (uint32_t i = 3; i < entry.NumInOperands(); ++i) { auto* var = get_def_use_mgr()->GetDef(entry.GetSingleWordInOperand(i)); auto storage_class = var->GetSingleWordInOperand(0u); - if (storage_class == SpvStorageClassInput || - storage_class == SpvStorageClassOutput) { + // Vulkan support outputs without an associated input, but not inputs + // without an associated output. + if (storage_class == SpvStorageClassOutput) { AddToWorklist(var); } } @@ -885,8 +879,7 @@ bool AggressiveDCEPass::ProcessGlobalValues() { } } - if (get_module()->version() >= SPV_SPIRV_VERSION_WORD(1, 4) && - !preserve_interface_) { + if (!preserve_interface_) { // Remove the dead interface variables from the entry point interface list. for (auto& entry : get_module()->entry_points()) { std::vector new_operands; @@ -974,6 +967,8 @@ void AggressiveDCEPass::InitExtensions() { "SPV_KHR_integer_dot_product", "SPV_EXT_shader_image_int64", "SPV_KHR_non_semantic_info", + "SPV_KHR_uniform_group_instructions", + "SPV_KHR_fragment_shader_barycentric", }); } diff --git a/third_party/spirv-tools/source/opt/amd_ext_to_khr.cpp b/third_party/spirv-tools/source/opt/amd_ext_to_khr.cpp index ccedc0bc5c..dd9bafda32 100644 --- a/third_party/spirv-tools/source/opt/amd_ext_to_khr.cpp +++ b/third_party/spirv-tools/source/opt/amd_ext_to_khr.cpp @@ -584,9 +584,9 @@ bool ReplaceCubeFaceCoord(IRContext* ctx, Instruction* inst, } // Get the constants that will be used. - uint32_t f0_const_id = const_mgr->GetFloatConst(0.0); - uint32_t f2_const_id = const_mgr->GetFloatConst(2.0); - uint32_t f0_5_const_id = const_mgr->GetFloatConst(0.5); + uint32_t f0_const_id = const_mgr->GetFloatConstId(0.0); + uint32_t f2_const_id = const_mgr->GetFloatConstId(2.0); + uint32_t f0_5_const_id = const_mgr->GetFloatConstId(0.5); const analysis::Constant* vec_const = const_mgr->GetConstant(v2_float_type, {f0_5_const_id, f0_5_const_id}); uint32_t vec_const_id = @@ -731,12 +731,12 @@ bool ReplaceCubeFaceIndex(IRContext* ctx, Instruction* inst, } // Get the constants that will be used. - uint32_t f0_const_id = const_mgr->GetFloatConst(0.0); - uint32_t f1_const_id = const_mgr->GetFloatConst(1.0); - uint32_t f2_const_id = const_mgr->GetFloatConst(2.0); - uint32_t f3_const_id = const_mgr->GetFloatConst(3.0); - uint32_t f4_const_id = const_mgr->GetFloatConst(4.0); - uint32_t f5_const_id = const_mgr->GetFloatConst(5.0); + uint32_t f0_const_id = const_mgr->GetFloatConstId(0.0); + uint32_t f1_const_id = const_mgr->GetFloatConstId(1.0); + uint32_t f2_const_id = const_mgr->GetFloatConstId(2.0); + uint32_t f3_const_id = const_mgr->GetFloatConstId(3.0); + uint32_t f4_const_id = const_mgr->GetFloatConstId(4.0); + uint32_t f5_const_id = const_mgr->GetFloatConstId(5.0); // Extract the input values. Instruction* x = ir_builder.AddCompositeExtract(float_type_id, input_id, {0}); @@ -935,8 +935,7 @@ Pass::Status AmdExtensionToKhrPass::Process() { std::vector to_be_killed; for (Instruction& inst : context()->module()->extensions()) { if (inst.opcode() == SpvOpExtension) { - if (ext_to_remove.count(reinterpret_cast( - &(inst.GetInOperand(0).words[0]))) != 0) { + if (ext_to_remove.count(inst.GetInOperand(0).AsString()) != 0) { to_be_killed.push_back(&inst); } } @@ -944,8 +943,7 @@ Pass::Status AmdExtensionToKhrPass::Process() { for (Instruction& inst : context()->ext_inst_imports()) { if (inst.opcode() == SpvOpExtInstImport) { - if (ext_to_remove.count(reinterpret_cast( - &(inst.GetInOperand(0).words[0]))) != 0) { + if (ext_to_remove.count(inst.GetInOperand(0).AsString()) != 0) { to_be_killed.push_back(&inst); } } diff --git a/third_party/spirv-tools/source/opt/amd_ext_to_khr.h b/third_party/spirv-tools/source/opt/amd_ext_to_khr.h index fd3dab4e7d..6a39d953a1 100644 --- a/third_party/spirv-tools/source/opt/amd_ext_to_khr.h +++ b/third_party/spirv-tools/source/opt/amd_ext_to_khr.h @@ -23,7 +23,7 @@ namespace spvtools { namespace opt { // Replaces the extensions VK_AMD_shader_ballot, VK_AMD_gcn_shader, and -// VK_AMD_shader_trinary_minmax with equivalant code using core instructions and +// VK_AMD_shader_trinary_minmax with equivalent code using core instructions and // capabilities. class AmdExtensionToKhrPass : public Pass { public: diff --git a/third_party/spirv-tools/source/opt/basic_block.h b/third_party/spirv-tools/source/opt/basic_block.h index 6741a50f26..dd3b2e2871 100644 --- a/third_party/spirv-tools/source/opt/basic_block.h +++ b/third_party/spirv-tools/source/opt/basic_block.h @@ -83,7 +83,7 @@ class BasicBlock { const Instruction* GetMergeInst() const; Instruction* GetMergeInst(); - // Returns the OpLoopMerge instruciton in this basic block, if it exists. + // Returns the OpLoopMerge instruction in this basic block, if it exists. // Otherwise return null. May be used whenever tail() can be used. const Instruction* GetLoopMergeInst() const; Instruction* GetLoopMergeInst(); diff --git a/third_party/spirv-tools/source/opt/ccp_pass.cpp b/third_party/spirv-tools/source/opt/ccp_pass.cpp index 8b896d504b..5f85502760 100644 --- a/third_party/spirv-tools/source/opt/ccp_pass.cpp +++ b/third_party/spirv-tools/source/opt/ccp_pass.cpp @@ -102,6 +102,34 @@ SSAPropagator::PropStatus CCPPass::VisitPhi(Instruction* phi) { return SSAPropagator::kInteresting; } +uint32_t CCPPass::ComputeLatticeMeet(Instruction* instr, uint32_t val2) { + // Given two values val1 and val2, the meet operation in the constant + // lattice uses the following rules: + // + // meet(val1, UNDEFINED) = val1 + // meet(val1, VARYING) = VARYING + // meet(val1, val2) = val1 if val1 == val2 + // meet(val1, val2) = VARYING if val1 != val2 + // + // When two different values meet, the result is always varying because CCP + // does not allow lateral transitions in the lattice. This prevents + // infinite cycles during propagation. + auto val1_it = values_.find(instr->result_id()); + if (val1_it == values_.end()) { + return val2; + } + + uint32_t val1 = val1_it->second; + if (IsVaryingValue(val1)) { + return val1; + } else if (IsVaryingValue(val2)) { + return val2; + } else if (val1 != val2) { + return kVaryingSSAId; + } + return val2; +} + SSAPropagator::PropStatus CCPPass::VisitAssignment(Instruction* instr) { assert(instr->result_id() != 0 && "Expecting an instruction that produces a result"); @@ -115,8 +143,10 @@ SSAPropagator::PropStatus CCPPass::VisitAssignment(Instruction* instr) { if (IsVaryingValue(it->second)) { return MarkInstructionVarying(instr); } else { - values_[instr->result_id()] = it->second; - return SSAPropagator::kInteresting; + uint32_t new_val = ComputeLatticeMeet(instr, it->second); + values_[instr->result_id()] = new_val; + return IsVaryingValue(new_val) ? SSAPropagator::kVarying + : SSAPropagator::kInteresting; } } return SSAPropagator::kNotInteresting; @@ -142,9 +172,13 @@ SSAPropagator::PropStatus CCPPass::VisitAssignment(Instruction* instr) { if (folded_inst != nullptr) { // We do not want to change the body of the function by adding new // instructions. When folding we can only generate new constants. - assert(folded_inst->IsConstant() && "CCP is only interested in constant."); - values_[instr->result_id()] = folded_inst->result_id(); - return SSAPropagator::kInteresting; + assert((folded_inst->IsConstant() || + IsSpecConstantInst(folded_inst->opcode())) && + "CCP is only interested in constant values."); + uint32_t new_val = ComputeLatticeMeet(instr, folded_inst->result_id()); + values_[instr->result_id()] = new_val; + return IsVaryingValue(new_val) ? SSAPropagator::kVarying + : SSAPropagator::kInteresting; } // Conservatively mark this instruction as varying if any input id is varying. diff --git a/third_party/spirv-tools/source/opt/ccp_pass.h b/third_party/spirv-tools/source/opt/ccp_pass.h index fb20c78089..77ea9f80da 100644 --- a/third_party/spirv-tools/source/opt/ccp_pass.h +++ b/third_party/spirv-tools/source/opt/ccp_pass.h @@ -92,6 +92,22 @@ class CCPPass : public MemPass { // generated during propagation. analysis::ConstantManager* const_mgr_; + // Returns a new value for |instr| by computing the meet operation between + // its existing value and |val2|. + // + // Given two values val1 and val2, the meet operation in the constant + // lattice uses the following rules: + // + // meet(val1, UNDEFINED) = val1 + // meet(val1, VARYING) = VARYING + // meet(val1, val2) = val1 if val1 == val2 + // meet(val1, val2) = VARYING if val1 != val2 + // + // When two different values meet, the result is always varying because CCP + // does not allow lateral transitions in the lattice. This prevents + // infinite cycles during propagation. + uint32_t ComputeLatticeMeet(Instruction* instr, uint32_t val2); + // Constant value table. Each entry in this map // represents the compile-time constant value for |id| as declared by // |const_decl_id|. Each |const_decl_id| in this table is an OpConstant diff --git a/third_party/spirv-tools/source/opt/cfg.h b/third_party/spirv-tools/source/opt/cfg.h index f280682295..33412f180f 100644 --- a/third_party/spirv-tools/source/opt/cfg.h +++ b/third_party/spirv-tools/source/opt/cfg.h @@ -30,7 +30,7 @@ class CFG { public: explicit CFG(Module* module); - // Return the list of predecesors for basic block with label |blkid|. + // Return the list of predecessors for basic block with label |blkid|. // TODO(dnovillo): Move this to BasicBlock. const std::vector& preds(uint32_t blk_id) const { assert(label2preds_.count(blk_id)); diff --git a/third_party/spirv-tools/source/opt/compact_ids_pass.cpp b/third_party/spirv-tools/source/opt/compact_ids_pass.cpp index 8815b8c658..70848d79b2 100644 --- a/third_party/spirv-tools/source/opt/compact_ids_pass.cpp +++ b/third_party/spirv-tools/source/opt/compact_ids_pass.cpp @@ -86,7 +86,8 @@ Pass::Status CompactIdsPass::Process() { }, true); - if (modified) { + if (context()->module()->id_bound() != result_id_mapping.size() + 1) { + modified = true; context()->module()->SetIdBound( static_cast(result_id_mapping.size() + 1)); // There are ids in the feature manager that could now be invalid diff --git a/third_party/spirv-tools/source/opt/const_folding_rules.cpp b/third_party/spirv-tools/source/opt/const_folding_rules.cpp index 515a3ed5df..249e11e563 100644 --- a/third_party/spirv-tools/source/opt/const_folding_rules.cpp +++ b/third_party/spirv-tools/source/opt/const_folding_rules.cpp @@ -22,6 +22,45 @@ namespace { const uint32_t kExtractCompositeIdInIdx = 0; +// Returns a constants with the value NaN of the given type. Only works for +// 32-bit and 64-bit float point types. Returns |nullptr| if an error occurs. +const analysis::Constant* GetNan(const analysis::Type* type, + analysis::ConstantManager* const_mgr) { + const analysis::Float* float_type = type->AsFloat(); + if (float_type == nullptr) { + return nullptr; + } + + switch (float_type->width()) { + case 32: + return const_mgr->GetFloatConst(std::numeric_limits::quiet_NaN()); + case 64: + return const_mgr->GetDoubleConst( + std::numeric_limits::quiet_NaN()); + default: + return nullptr; + } +} + +// Returns a constants with the value INF of the given type. Only works for +// 32-bit and 64-bit float point types. Returns |nullptr| if an error occurs. +const analysis::Constant* GetInf(const analysis::Type* type, + analysis::ConstantManager* const_mgr) { + const analysis::Float* float_type = type->AsFloat(); + if (float_type == nullptr) { + return nullptr; + } + + switch (float_type->width()) { + case 32: + return const_mgr->GetFloatConst(std::numeric_limits::infinity()); + case 64: + return const_mgr->GetDoubleConst(std::numeric_limits::infinity()); + default: + return nullptr; + } +} + // Returns true if |type| is Float or a vector of Float. bool HasFloatingPoint(const analysis::Type* type) { if (type->AsFloat()) { @@ -33,6 +72,23 @@ bool HasFloatingPoint(const analysis::Type* type) { return false; } +// Returns a constants with the value |-val| of the given type. Only works for +// 32-bit and 64-bit float point types. Returns |nullptr| if an error occurs. +const analysis::Constant* negateFPConst(const analysis::Type* result_type, + const analysis::Constant* val, + analysis::ConstantManager* const_mgr) { + const analysis::Float* float_type = result_type->AsFloat(); + assert(float_type != nullptr); + if (float_type->width() == 32) { + float fa = val->GetFloat(); + return const_mgr->GetFloatConst(-fa); + } else if (float_type->width() == 64) { + double da = val->GetDouble(); + return const_mgr->GetDoubleConst(-da); + } + return nullptr; +} + // Folds an OpcompositeExtract where input is a composite constant. ConstantFoldingRule FoldExtractWithConstants() { return [](IRContext* context, Instruction* inst, @@ -492,7 +548,60 @@ ConstantFoldingRule FoldQuantizeToF16() { ConstantFoldingRule FoldFSub() { return FoldFPBinaryOp(FOLD_FPARITH_OP(-)); } ConstantFoldingRule FoldFAdd() { return FoldFPBinaryOp(FOLD_FPARITH_OP(+)); } ConstantFoldingRule FoldFMul() { return FoldFPBinaryOp(FOLD_FPARITH_OP(*)); } -ConstantFoldingRule FoldFDiv() { return FoldFPBinaryOp(FOLD_FPARITH_OP(/)); } + +// Returns the constant that results from evaluating |numerator| / 0.0. Returns +// |nullptr| if the result could not be evaluated. +const analysis::Constant* FoldFPScalarDivideByZero( + const analysis::Type* result_type, const analysis::Constant* numerator, + analysis::ConstantManager* const_mgr) { + if (numerator == nullptr) { + return nullptr; + } + + if (numerator->IsZero()) { + return GetNan(result_type, const_mgr); + } + + const analysis::Constant* result = GetInf(result_type, const_mgr); + if (result == nullptr) { + return nullptr; + } + + if (numerator->AsFloatConstant()->GetValueAsDouble() < 0.0) { + result = negateFPConst(result_type, result, const_mgr); + } + return result; +} + +// Returns the result of folding |numerator| / |denominator|. Returns |nullptr| +// if it cannot be folded. +const analysis::Constant* FoldScalarFPDivide( + const analysis::Type* result_type, const analysis::Constant* numerator, + const analysis::Constant* denominator, + analysis::ConstantManager* const_mgr) { + if (denominator == nullptr) { + return nullptr; + } + + if (denominator->IsZero()) { + return FoldFPScalarDivideByZero(result_type, numerator, const_mgr); + } + + const analysis::FloatConstant* denominator_float = + denominator->AsFloatConstant(); + if (denominator_float && denominator->GetValueAsDouble() == -0.0) { + const analysis::Constant* result = + FoldFPScalarDivideByZero(result_type, numerator, const_mgr); + if (result != nullptr) + result = negateFPConst(result_type, result, const_mgr); + return result; + } else { + return FOLD_FPARITH_OP(/)(result_type, numerator, denominator, const_mgr); + } +} + +// Returns the constant folding rule to fold |OpFDiv| with two constants. +ConstantFoldingRule FoldFDiv() { return FoldFPBinaryOp(FoldScalarFPDivide); } bool CompareFloatingPoint(bool op_result, bool op_unordered, bool need_ordered) { @@ -655,20 +764,7 @@ UnaryScalarFoldingRule FoldFNegateOp() { analysis::ConstantManager* const_mgr) -> const analysis::Constant* { assert(result_type != nullptr && a != nullptr); assert(result_type == a->type()); - const analysis::Float* float_type = result_type->AsFloat(); - assert(float_type != nullptr); - if (float_type->width() == 32) { - float fa = a->GetFloat(); - utils::FloatProxy result(-fa); - std::vector words = result.GetWords(); - return const_mgr->GetConstant(result_type, words); - } else if (float_type->width() == 64) { - double da = a->GetDouble(); - utils::FloatProxy result(-da); - std::vector words = result.GetWords(); - return const_mgr->GetConstant(result_type, words); - } - return nullptr; + return negateFPConst(result_type, a, const_mgr); }; } @@ -1250,7 +1346,7 @@ void ConstantFoldingRules::AddFoldingRules() { FoldFPUnaryOp(FoldFTranscendentalUnary(std::log))); #ifdef __ANDROID__ - // Android NDK r15c tageting ABI 15 doesn't have full support for C++11 + // Android NDK r15c targeting ABI 15 doesn't have full support for C++11 // (no std::exp2/log2). ::exp2 is available from C99 but ::log2 isn't // available up until ABI 18 so we use a shim auto log2_shim = [](double v) -> double { return log(v) / log(2.0); }; diff --git a/third_party/spirv-tools/source/opt/constants.cpp b/third_party/spirv-tools/source/opt/constants.cpp index 020e248b29..bcff08c135 100644 --- a/third_party/spirv-tools/source/opt/constants.cpp +++ b/third_party/spirv-tools/source/opt/constants.cpp @@ -158,6 +158,7 @@ Type* ConstantManager::GetType(const Instruction* inst) const { std::vector ConstantManager::GetOperandConstants( const Instruction* inst) const { std::vector constants; + constants.reserve(inst->NumInOperands()); for (uint32_t i = 0; i < inst->NumInOperands(); i++) { const Operand* operand = &inst->GetInOperand(i); if (operand->type != SPV_OPERAND_TYPE_ID) { @@ -420,13 +421,30 @@ const Constant* ConstantManager::GetNumericVectorConstantWithWords( return GetConstant(type, element_ids); } -uint32_t ConstantManager::GetFloatConst(float val) { +uint32_t ConstantManager::GetFloatConstId(float val) { + const Constant* c = GetFloatConst(val); + return GetDefiningInstruction(c)->result_id(); +} + +const Constant* ConstantManager::GetFloatConst(float val) { Type* float_type = context()->get_type_mgr()->GetFloatType(); utils::FloatProxy v(val); const Constant* c = GetConstant(float_type, v.GetWords()); + return c; +} + +uint32_t ConstantManager::GetDoubleConstId(double val) { + const Constant* c = GetDoubleConst(val); return GetDefiningInstruction(c)->result_id(); } +const Constant* ConstantManager::GetDoubleConst(double val) { + Type* float_type = context()->get_type_mgr()->GetDoubleType(); + utils::FloatProxy v(val); + const Constant* c = GetConstant(float_type, v.GetWords()); + return c; +} + uint32_t ConstantManager::GetSIntConst(int32_t val) { Type* sint_type = context()->get_type_mgr()->GetSIntType(); const Constant* c = GetConstant(sint_type, {static_cast(val)}); diff --git a/third_party/spirv-tools/source/opt/constants.h b/third_party/spirv-tools/source/opt/constants.h index 52bd809ab3..c039ae087f 100644 --- a/third_party/spirv-tools/source/opt/constants.h +++ b/third_party/spirv-tools/source/opt/constants.h @@ -541,7 +541,7 @@ class ConstantManager { // instruction at the end of the current module's types section. // // |type_id| is an optional argument for disambiguating equivalent types. If - // |type_id| is specified, the contant returned will have that type id. + // |type_id| is specified, the constant returned will have that type id. Instruction* GetDefiningInstruction(const Constant* c, uint32_t type_id = 0, Module::inst_iterator* pos = nullptr); @@ -637,7 +637,16 @@ class ConstantManager { } // Returns the id of a 32-bit floating point constant with value |val|. - uint32_t GetFloatConst(float val); + uint32_t GetFloatConstId(float val); + + // Returns a 32-bit float constant with the given value. + const Constant* GetFloatConst(float val); + + // Returns the id of a 64-bit floating point constant with value |val|. + uint32_t GetDoubleConstId(double val); + + // Returns a 64-bit float constant with the given value. + const Constant* GetDoubleConst(double val); // Returns the id of a 32-bit signed integer constant with value |val|. uint32_t GetSIntConst(int32_t val); diff --git a/third_party/spirv-tools/source/opt/convert_to_half_pass.cpp b/third_party/spirv-tools/source/opt/convert_to_half_pass.cpp index b127eabe96..4086e31ac1 100644 --- a/third_party/spirv-tools/source/opt/convert_to_half_pass.cpp +++ b/third_party/spirv-tools/source/opt/convert_to_half_pass.cpp @@ -181,7 +181,7 @@ bool ConvertToHalfPass::ProcessPhi(Instruction* inst, uint32_t from_width, uint32_t to_width) { // Add converts of any float operands to to_width if they are of from_width. // If converting to 16, change type of phi to float16 equivalent and remember - // result id. Converts need to be added to preceeding blocks. + // result id. Converts need to be added to preceding blocks. uint32_t ocnt = 0; uint32_t* prev_idp; bool modified = false; diff --git a/third_party/spirv-tools/source/opt/copy_prop_arrays.cpp b/third_party/spirv-tools/source/opt/copy_prop_arrays.cpp index 62ed5e77ab..321d496923 100644 --- a/third_party/spirv-tools/source/opt/copy_prop_arrays.cpp +++ b/third_party/spirv-tools/source/opt/copy_prop_arrays.cpp @@ -745,11 +745,11 @@ void CopyPropagateArrays::UpdateUses(Instruction* original_ptr_inst, context()->AnalyzeUses(use); } break; + case SpvOpDecorate: + // We treat an OpImageTexelPointer as a load. The result type should + // always have the Image storage class, and should not need to be + // updated. case SpvOpImageTexelPointer: - // We treat an OpImageTexelPointer as a load. The result type should - // always have the Image storage class, and should not need to be - // updated. - // Replace the actual use. context()->ForgetUses(use); use->SetOperand(index, {new_ptr_inst->result_id()}); diff --git a/third_party/spirv-tools/source/opt/copy_prop_arrays.h b/third_party/spirv-tools/source/opt/copy_prop_arrays.h index f4314a74b7..46a508cfad 100644 --- a/third_party/spirv-tools/source/opt/copy_prop_arrays.h +++ b/third_party/spirv-tools/source/opt/copy_prop_arrays.h @@ -35,7 +35,7 @@ namespace opt { // // The hard part is keeping all of the types correct. We do not want to // have to do too large a search to update everything, which may not be -// possible, do we give up if we see any instruction that might be hard to +// possible, so we give up if we see any instruction that might be hard to // update. class CopyPropagateArrays : public MemPass { diff --git a/third_party/spirv-tools/source/opt/dead_branch_elim_pass.cpp b/third_party/spirv-tools/source/opt/dead_branch_elim_pass.cpp index 356dbcb34a..cc616ca6e1 100644 --- a/third_party/spirv-tools/source/opt/dead_branch_elim_pass.cpp +++ b/third_party/spirv-tools/source/opt/dead_branch_elim_pass.cpp @@ -207,7 +207,7 @@ bool DeadBranchElimPass::SimplifyBranch(BasicBlock* block, Instruction::OperandList new_operands; new_operands.push_back(terminator->GetInOperand(0)); new_operands.push_back({SPV_OPERAND_TYPE_ID, {live_lab_id}}); - terminator->SetInOperands(move(new_operands)); + terminator->SetInOperands(std::move(new_operands)); context()->UpdateDefUse(terminator); } else { // Check if the merge instruction is still needed because of a diff --git a/third_party/spirv-tools/source/opt/dead_branch_elim_pass.h b/third_party/spirv-tools/source/opt/dead_branch_elim_pass.h index 7841bc4705..198bad2dcb 100644 --- a/third_party/spirv-tools/source/opt/dead_branch_elim_pass.h +++ b/third_party/spirv-tools/source/opt/dead_branch_elim_pass.h @@ -98,7 +98,7 @@ class DeadBranchElimPass : public MemPass { // Fix phis in reachable blocks so that only live (or unremovable) incoming // edges are present. If the block now only has a single live incoming edge, // remove the phi and replace its uses with its data input. If the single - // remaining incoming edge is from the phi itself, the the phi is in an + // remaining incoming edge is from the phi itself, the phi is in an // unreachable single block loop. Either the block is dead and will be // removed, or it's reachable from an unreachable continue target. In the // latter case that continue target block will be collapsed into a block that @@ -158,7 +158,7 @@ class DeadBranchElimPass : public MemPass { uint32_t cont_id, uint32_t header_id, uint32_t merge_id, std::unordered_set* blocks_with_back_edges); - // Returns true if there is a brach to the merge node of the selection + // Returns true if there is a branch to the merge node of the selection // construct |switch_header_id| that is inside a nested selection construct or // in the header of the nested selection construct. bool SwitchHasNestedBreak(uint32_t switch_header_id); diff --git a/third_party/spirv-tools/source/opt/debug_info_manager.cpp b/third_party/spirv-tools/source/opt/debug_info_manager.cpp index 060e0d9312..c1df6258b0 100644 --- a/third_party/spirv-tools/source/opt/debug_info_manager.cpp +++ b/third_party/spirv-tools/source/opt/debug_info_manager.cpp @@ -149,7 +149,7 @@ void DebugInfoManager::RegisterDbgDeclare(uint32_t var_id, // Create new constant directly into global value area, bypassing the // Constant manager. This is used when the DefUse or Constant managers // are invalid and cannot be regenerated due to the module being in an -// inconsistant state e.g. in the middle of significant modification +// inconsistent state e.g. in the middle of significant modification // such as inlining. Invalidate Constant and DefUse managers if used. uint32_t AddNewConstInGlobals(IRContext* context, uint32_t const_value) { uint32_t id = context->TakeNextId(); diff --git a/third_party/spirv-tools/source/opt/def_use_manager.cpp b/third_party/spirv-tools/source/opt/def_use_manager.cpp index 394b9fa174..e1e441e0e4 100644 --- a/third_party/spirv-tools/source/opt/def_use_manager.cpp +++ b/third_party/spirv-tools/source/opt/def_use_manager.cpp @@ -13,16 +13,23 @@ // limitations under the License. #include "source/opt/def_use_manager.h" - -#include - -#include "source/opt/log.h" -#include "source/opt/reflect.h" +#include "source/util/make_unique.h" namespace spvtools { namespace opt { namespace analysis { +// Don't compact before we have a reasonable number of ids allocated (~32kb). +static const size_t kCompactThresholdMinTotalIds = (8 * 1024); +// Compact when fewer than this fraction of the storage is used (should be 2^n +// for performance). +static const size_t kCompactThresholdFractionFreeIds = 8; + +DefUseManager::DefUseManager() { + use_pool_ = MakeUnique(); + used_id_pool_ = MakeUnique(); +} + void DefUseManager::AnalyzeInstDef(Instruction* inst) { const uint32_t def_id = inst->result_id(); if (def_id != 0) { @@ -39,15 +46,15 @@ void DefUseManager::AnalyzeInstDef(Instruction* inst) { } void DefUseManager::AnalyzeInstUse(Instruction* inst) { + // It might have existed before. + EraseUseRecordsOfOperandIds(inst); + // Create entry for the given instruction. Note that the instruction may // not have any in-operands. In such cases, we still need a entry for those // instructions so this manager knows it has seen the instruction later. - auto* used_ids = &inst_to_used_ids_[inst]; - if (used_ids->size()) { - EraseUseRecordsOfOperandIds(inst); - used_ids = &inst_to_used_ids_[inst]; - } - used_ids->clear(); // It might have existed before. + UsedIdList& used_ids = + inst_to_used_id_.insert({inst, UsedIdList(used_id_pool_.get())}) + .first->second; for (uint32_t i = 0; i < inst->NumOperands(); ++i) { switch (inst->GetOperand(i).type) { @@ -58,9 +65,18 @@ void DefUseManager::AnalyzeInstUse(Instruction* inst) { case SPV_OPERAND_TYPE_SCOPE_ID: { uint32_t use_id = inst->GetSingleWordOperand(i); Instruction* def = GetDef(use_id); - if (!def) assert(false && "Definition is not registered."); - id_to_users_.insert(UserEntry(def, inst)); - used_ids->push_back(use_id); + assert(def && "Definition is not registered."); + + // Add to inst's use records + used_ids.push_back(use_id); + + // Add to the users, taking care to avoid adding duplicates. We know + // the duplicate for this instruction will always be at the tail. + UseList& list = inst_to_users_.insert({def, UseList(use_pool_.get())}) + .first->second; + if (list.empty() || list.back() != inst) { + list.push_back(inst); + } } break; default: break; @@ -99,23 +115,6 @@ const Instruction* DefUseManager::GetDef(uint32_t id) const { return iter->second; } -DefUseManager::IdToUsersMap::const_iterator DefUseManager::UsersBegin( - const Instruction* def) const { - return id_to_users_.lower_bound( - UserEntry(const_cast(def), nullptr)); -} - -bool DefUseManager::UsersNotEnd(const IdToUsersMap::const_iterator& iter, - const IdToUsersMap::const_iterator& cached_end, - const Instruction* inst) const { - return (iter != cached_end && iter->first == inst); -} - -bool DefUseManager::UsersNotEnd(const IdToUsersMap::const_iterator& iter, - const Instruction* inst) const { - return UsersNotEnd(iter, id_to_users_.end(), inst); -} - bool DefUseManager::WhileEachUser( const Instruction* def, const std::function& f) const { // Ensure that |def| has been registered. @@ -123,9 +122,11 @@ bool DefUseManager::WhileEachUser( "Definition is not registered."); if (!def->HasResultId()) return true; - auto end = id_to_users_.end(); - for (auto iter = UsersBegin(def); UsersNotEnd(iter, end, def); ++iter) { - if (!f(iter->second)) return false; + auto iter = inst_to_users_.find(def); + if (iter != inst_to_users_.end()) { + for (Instruction* user : iter->second) { + if (!f(user)) return false; + } } return true; } @@ -156,14 +157,15 @@ bool DefUseManager::WhileEachUse( "Definition is not registered."); if (!def->HasResultId()) return true; - auto end = id_to_users_.end(); - for (auto iter = UsersBegin(def); UsersNotEnd(iter, end, def); ++iter) { - Instruction* user = iter->second; - for (uint32_t idx = 0; idx != user->NumOperands(); ++idx) { - const Operand& op = user->GetOperand(idx); - if (op.type != SPV_OPERAND_TYPE_RESULT_ID && spvIsIdType(op.type)) { - if (def->result_id() == op.words[0]) { - if (!f(user, idx)) return false; + auto iter = inst_to_users_.find(def); + if (iter != inst_to_users_.end()) { + for (Instruction* user : iter->second) { + for (uint32_t idx = 0; idx != user->NumOperands(); ++idx) { + const Operand& op = user->GetOperand(idx); + if (op.type != SPV_OPERAND_TYPE_RESULT_ID && spvIsIdType(op.type)) { + if (def->result_id() == op.words[0]) { + if (!f(user, idx)) return false; + } } } } @@ -235,17 +237,18 @@ void DefUseManager::AnalyzeDefUse(Module* module) { } void DefUseManager::ClearInst(Instruction* inst) { - auto iter = inst_to_used_ids_.find(inst); - if (iter != inst_to_used_ids_.end()) { + if (inst_to_used_id_.find(inst) != inst_to_used_id_.end()) { EraseUseRecordsOfOperandIds(inst); - if (inst->result_id() != 0) { - // Remove all uses of this inst. - auto users_begin = UsersBegin(inst); - auto end = id_to_users_.end(); - auto new_end = users_begin; - for (; UsersNotEnd(new_end, end, inst); ++new_end) { + uint32_t const result_id = inst->result_id(); + if (result_id != 0) { + // For each using instruction, remove result_id from their used ids. + auto iter = inst_to_users_.find(inst); + if (iter != inst_to_users_.end()) { + for (Instruction* use : iter->second) { + inst_to_used_id_.at(use).remove_first(result_id); + } + inst_to_users_.erase(iter); } - id_to_users_.erase(users_begin, new_end); id_to_def_.erase(inst->result_id()); } } @@ -254,59 +257,113 @@ void DefUseManager::ClearInst(Instruction* inst) { void DefUseManager::EraseUseRecordsOfOperandIds(const Instruction* inst) { // Go through all ids used by this instruction, remove this instruction's // uses of them. - auto iter = inst_to_used_ids_.find(inst); - if (iter != inst_to_used_ids_.end()) { - for (auto use_id : iter->second) { - id_to_users_.erase( - UserEntry(GetDef(use_id), const_cast(inst))); + auto iter = inst_to_used_id_.find(inst); + if (iter != inst_to_used_id_.end()) { + const UsedIdList& used_ids = iter->second; + for (uint32_t def_id : used_ids) { + auto def_iter = inst_to_users_.find(GetDef(def_id)); + if (def_iter != inst_to_users_.end()) { + def_iter->second.remove_first(const_cast(inst)); + } + } + inst_to_used_id_.erase(inst); + + // If we're using only a fraction of the space in used_ids_, compact storage + // to prevent memory usage from being unbounded. + if (used_id_pool_->total_nodes() > kCompactThresholdMinTotalIds && + used_id_pool_->used_nodes() < + used_id_pool_->total_nodes() / kCompactThresholdFractionFreeIds) { + CompactStorage(); } - inst_to_used_ids_.erase(inst); } } -bool operator==(const DefUseManager& lhs, const DefUseManager& rhs) { +void DefUseManager::CompactStorage() { + CompactUseRecords(); + CompactUsedIds(); +} + +void DefUseManager::CompactUseRecords() { + std::unique_ptr new_pool = MakeUnique(); + for (auto& iter : inst_to_users_) { + iter.second.move_nodes(new_pool.get()); + } + use_pool_ = std::move(new_pool); +} + +void DefUseManager::CompactUsedIds() { + std::unique_ptr new_pool = MakeUnique(); + for (auto& iter : inst_to_used_id_) { + iter.second.move_nodes(new_pool.get()); + } + used_id_pool_ = std::move(new_pool); +} + +bool CompareAndPrintDifferences(const DefUseManager& lhs, + const DefUseManager& rhs) { + bool same = true; + if (lhs.id_to_def_ != rhs.id_to_def_) { for (auto p : lhs.id_to_def_) { if (rhs.id_to_def_.find(p.first) == rhs.id_to_def_.end()) { - return false; + printf("Diff in id_to_def: missing value in rhs\n"); } } for (auto p : rhs.id_to_def_) { if (lhs.id_to_def_.find(p.first) == lhs.id_to_def_.end()) { - return false; + printf("Diff in id_to_def: missing value in lhs\n"); } } - return false; + same = false; } - if (lhs.id_to_users_ != rhs.id_to_users_) { - for (auto p : lhs.id_to_users_) { - if (rhs.id_to_users_.count(p) == 0) { - return false; - } + for (const auto& l : lhs.inst_to_used_id_) { + std::set ul, ur; + lhs.ForEachUse(l.first, + [&ul](Instruction*, uint32_t id) { ul.insert(id); }); + rhs.ForEachUse(l.first, + [&ur](Instruction*, uint32_t id) { ur.insert(id); }); + if (ul.size() != ur.size()) { + printf( + "Diff in inst_to_used_id_: different number of used ids (%zu != %zu)", + ul.size(), ur.size()); + same = false; + } else if (ul != ur) { + printf("Diff in inst_to_used_id_: different used ids\n"); + same = false; } - for (auto p : rhs.id_to_users_) { - if (lhs.id_to_users_.count(p) == 0) { - return false; - } + } + for (const auto& r : rhs.inst_to_used_id_) { + auto iter_l = lhs.inst_to_used_id_.find(r.first); + if (r.second.empty() && + !(iter_l == lhs.inst_to_used_id_.end() || iter_l->second.empty())) { + printf("Diff in inst_to_used_id_: unexpected instr in rhs\n"); + same = false; } - return false; } - if (lhs.inst_to_used_ids_ != rhs.inst_to_used_ids_) { - for (auto p : lhs.inst_to_used_ids_) { - if (rhs.inst_to_used_ids_.count(p.first) == 0) { - return false; - } + for (const auto& l : lhs.inst_to_users_) { + std::set ul, ur; + lhs.ForEachUser(l.first, [&ul](Instruction* use) { ul.insert(use); }); + rhs.ForEachUser(l.first, [&ur](Instruction* use) { ur.insert(use); }); + if (ul.size() != ur.size()) { + printf("Diff in inst_to_users_: different number of users (%zu != %zu)", + ul.size(), ur.size()); + same = false; + } else if (ul != ur) { + printf("Diff in inst_to_users_: different users\n"); + same = false; } - for (auto p : rhs.inst_to_used_ids_) { - if (lhs.inst_to_used_ids_.count(p.first) == 0) { - return false; - } - } - return false; } - return true; + for (const auto& r : rhs.inst_to_users_) { + auto iter_l = lhs.inst_to_users_.find(r.first); + if (r.second.empty() && + !(iter_l == lhs.inst_to_users_.end() || iter_l->second.empty())) { + printf("Diff in inst_to_users_: unexpected instr in rhs\n"); + same = false; + } + } + return same; } } // namespace analysis diff --git a/third_party/spirv-tools/source/opt/def_use_manager.h b/third_party/spirv-tools/source/opt/def_use_manager.h index 0499e82b54..cf6cbdf516 100644 --- a/third_party/spirv-tools/source/opt/def_use_manager.h +++ b/third_party/spirv-tools/source/opt/def_use_manager.h @@ -15,14 +15,13 @@ #ifndef SOURCE_OPT_DEF_USE_MANAGER_H_ #define SOURCE_OPT_DEF_USE_MANAGER_H_ -#include #include #include -#include #include #include "source/opt/instruction.h" #include "source/opt/module.h" +#include "source/util/pooled_linked_list.h" #include "spirv-tools/libspirv.hpp" namespace spvtools { @@ -51,59 +50,16 @@ inline bool operator<(const Use& lhs, const Use& rhs) { return lhs.operand_index < rhs.operand_index; } -// Definition and user pair. -// -// The first element of the pair is the definition. -// The second element of the pair is the user. -// -// Definition should never be null. User can be null, however, such an entry -// should be used only for searching (e.g. all users of a particular definition) -// and never stored in a container. -using UserEntry = std::pair; - -// Orders UserEntry for use in associative containers (i.e. less than ordering). -// -// The definition of an UserEntry is treated as the major key and the users as -// the minor key so that all the users of a particular definition are -// consecutive in a container. -// -// A null user always compares less than a real user. This is done to provide -// easy values to search for the beginning of the users of a particular -// definition (i.e. using {def, nullptr}). -struct UserEntryLess { - bool operator()(const UserEntry& lhs, const UserEntry& rhs) const { - // If lhs.first and rhs.first are both null, fall through to checking the - // second entries. - if (!lhs.first && rhs.first) return true; - if (lhs.first && !rhs.first) return false; - - // If neither definition is null, then compare unique ids. - if (lhs.first && rhs.first) { - if (lhs.first->unique_id() < rhs.first->unique_id()) return true; - if (rhs.first->unique_id() < lhs.first->unique_id()) return false; - } - - // Return false on equality. - if (!lhs.second && !rhs.second) return false; - if (!lhs.second) return true; - if (!rhs.second) return false; - - // If neither user is null then compare unique ids. - return lhs.second->unique_id() < rhs.second->unique_id(); - } -}; - // A class for analyzing and managing defs and uses in an Module. class DefUseManager { public: using IdToDefMap = std::unordered_map; - using IdToUsersMap = std::set; // Constructs a def-use manager from the given |module|. All internal messages // will be communicated to the outside via the given message |consumer|. This // instance only keeps a reference to the |consumer|, so the |consumer| should // outlive this instance. - DefUseManager(Module* module) { AnalyzeDefUse(module); } + DefUseManager(Module* module) : DefUseManager() { AnalyzeDefUse(module); } DefUseManager(const DefUseManager&) = delete; DefUseManager(DefUseManager&&) = delete; @@ -191,14 +147,12 @@ class DefUseManager { // Returns the annotation instrunctions which are a direct use of the given // |id|. This means when the decorations are applied through decoration // group(s), this function will just return the OpGroupDecorate - // instrcution(s) which refer to the given id as an operand. The OpDecorate + // instruction(s) which refer to the given id as an operand. The OpDecorate // instructions which decorate the decoration group will not be returned. std::vector GetAnnotations(uint32_t id) const; // Returns the map from ids to their def instructions. const IdToDefMap& id_to_defs() const { return id_to_def_; } - // Returns the map from instructions to their users. - const IdToUsersMap& id_to_users() const { return id_to_users_; } // Clear the internal def-use record of the given instruction |inst|. This // method will update the use information of the operand ids of |inst|. The @@ -210,43 +164,43 @@ class DefUseManager { // Erases the records that a given instruction uses its operand ids. void EraseUseRecordsOfOperandIds(const Instruction* inst); - friend bool operator==(const DefUseManager&, const DefUseManager&); - friend bool operator!=(const DefUseManager& lhs, const DefUseManager& rhs) { - return !(lhs == rhs); - } + friend bool CompareAndPrintDifferences(const DefUseManager&, + const DefUseManager&); - // If |inst| has not already been analysed, then analyses its defintion and + // If |inst| has not already been analysed, then analyses its definition and // uses. void UpdateDefUse(Instruction* inst); + // Compacts any internal storage to save memory. + void CompactStorage(); + private: - using InstToUsedIdsMap = - std::unordered_map>; + using UseList = spvtools::utils::PooledLinkedList; + using UseListPool = spvtools::utils::PooledLinkedListNodes; + // Stores linked lists of Instructions using a def. + using InstToUsersMap = std::unordered_map; - // Returns the first location that {|def|, nullptr} could be inserted into the - // users map without violating ordering. - IdToUsersMap::const_iterator UsersBegin(const Instruction* def) const; + using UsedIdList = spvtools::utils::PooledLinkedList; + using UsedIdListPool = spvtools::utils::PooledLinkedListNodes; + // Stores mapping from instruction to their UsedIdRange. + using InstToUsedIdMap = std::unordered_map; - // Returns true if |iter| has not reached the end of |def|'s users. - // - // In the first version |iter| is compared against the end of the map for - // validity before other checks. In the second version, |iter| is compared - // against |cached_end| for validity before other checks. This allows caching - // the map's end which is a performance improvement on some platforms. - bool UsersNotEnd(const IdToUsersMap::const_iterator& iter, - const Instruction* def) const; - bool UsersNotEnd(const IdToUsersMap::const_iterator& iter, - const IdToUsersMap::const_iterator& cached_end, - const Instruction* def) const; + DefUseManager(); // Analyzes the defs and uses in the given |module| and populates data // structures in this class. Does nothing if |module| is nullptr. void AnalyzeDefUse(Module* module); - IdToDefMap id_to_def_; // Mapping from ids to their definitions - IdToUsersMap id_to_users_; // Mapping from ids to their users - // Mapping from instructions to the ids used in the instruction. - InstToUsedIdsMap inst_to_used_ids_; + // Removes unused entries in used_records_ and used_ids_. + void CompactUseRecords(); + void CompactUsedIds(); + + IdToDefMap id_to_def_; // Mapping from ids to their definitions + InstToUsersMap inst_to_users_; // Map from def to uses. + std::unique_ptr use_pool_; + + std::unique_ptr used_id_pool_; + InstToUsedIdMap inst_to_used_id_; // Map from instruction to used ids. }; } // namespace analysis diff --git a/third_party/spirv-tools/source/opt/desc_sroa.cpp b/third_party/spirv-tools/source/opt/desc_sroa.cpp index bcbdde94ca..b130ca806c 100644 --- a/third_party/spirv-tools/source/opt/desc_sroa.cpp +++ b/third_party/spirv-tools/source/opt/desc_sroa.cpp @@ -118,7 +118,7 @@ bool DescriptorScalarReplacement::ReplaceAccessChain(Instruction* var, if (use->NumInOperands() == 2) { // We are not indexing into the replacement variable. We can replaces the - // access chain with the replacement varibale itself. + // access chain with the replacement variable itself. context()->ReplaceAllUsesWith(use->result_id(), replacement_var); context()->KillInst(use); return true; @@ -135,8 +135,8 @@ bool DescriptorScalarReplacement::ReplaceAccessChain(Instruction* var, // Use the replacement variable as the base address. new_operands.push_back({SPV_OPERAND_TYPE_ID, {replacement_var}}); - // Drop the first index because it is consumed by the replacment, and copy the - // rest. + // Drop the first index because it is consumed by the replacement, and copy + // the rest. for (uint32_t i = 4; i < use->NumOperands(); i++) { new_operands.emplace_back(use->GetOperand(i)); } @@ -169,7 +169,7 @@ void DescriptorScalarReplacement::CopyDecorationsForNewVariable( Instruction* old_var, uint32_t index, uint32_t new_var_id, uint32_t new_var_ptr_type_id, const bool is_old_var_array, const bool is_old_var_struct, Instruction* old_var_type) { - // Handle OpDecorate instructions. + // Handle OpDecorate and OpDecorateString instructions. for (auto old_decoration : get_decoration_mgr()->GetDecorationsFor(old_var->result_id(), true)) { uint32_t new_binding = 0; @@ -212,7 +212,8 @@ uint32_t DescriptorScalarReplacement::GetNewBindingForElement( void DescriptorScalarReplacement::CreateNewDecorationForNewVariable( Instruction* old_decoration, uint32_t new_var_id, uint32_t new_binding) { - assert(old_decoration->opcode() == SpvOpDecorate); + assert(old_decoration->opcode() == SpvOpDecorate || + old_decoration->opcode() == SpvOpDecorateString); std::unique_ptr new_decoration(old_decoration->Clone(context())); new_decoration->SetInOperand(0, {new_var_id}); diff --git a/third_party/spirv-tools/source/opt/desc_sroa.h b/third_party/spirv-tools/source/opt/desc_sroa.h index fea062559c..6a24fd8714 100644 --- a/third_party/spirv-tools/source/opt/desc_sroa.h +++ b/third_party/spirv-tools/source/opt/desc_sroa.h @@ -115,10 +115,11 @@ class DescriptorScalarReplacement : public Pass { const bool is_old_var_struct, Instruction* old_var_type); - // Create a new OpDecorate instruction by cloning |old_decoration|. The new - // OpDecorate instruction will be used for a variable whose id is - // |new_var_ptr_type_id|. If |old_decoration| is a decoration for a binding, - // the new OpDecorate instruction will have |new_binding| as its binding. + // Create a new OpDecorate(String) instruction by cloning |old_decoration|. + // The new OpDecorate(String) instruction will be used for a variable whose id + // is |new_var_ptr_type_id|. If |old_decoration| is a decoration for a + // binding, the new OpDecorate(String) instruction will have |new_binding| as + // its binding. void CreateNewDecorationForNewVariable(Instruction* old_decoration, uint32_t new_var_id, uint32_t new_binding); @@ -131,7 +132,7 @@ class DescriptorScalarReplacement : public Pass { // A map from an OpVariable instruction to the set of variables that will be // used to replace it. The entry |replacement_variables_[var][i]| is the id of - // a variable that will be used in the place of the the ith element of the + // a variable that will be used in the place of the ith element of the // array |var|. If the entry is |0|, then the variable has not been // created yet. std::map> replacement_variables_; diff --git a/third_party/spirv-tools/source/opt/dominator_tree.cpp b/third_party/spirv-tools/source/opt/dominator_tree.cpp index 55287f4441..d86de151ed 100644 --- a/third_party/spirv-tools/source/opt/dominator_tree.cpp +++ b/third_party/spirv-tools/source/opt/dominator_tree.cpp @@ -48,7 +48,7 @@ namespace { // BBType - BasicBlock type. Will either be BasicBlock or DominatorTreeNode // SuccessorLambda - Lamdba matching the signature of 'const // std::vector*(const BBType *A)'. Will return a vector of the nodes -// succeding BasicBlock A. +// succeeding BasicBlock A. // PostLambda - Lamdba matching the signature of 'void (const BBType*)' will be // called on each node traversed AFTER their children. // PreLambda - Lamdba matching the signature of 'void (const BBType*)' will be @@ -69,7 +69,7 @@ static void DepthFirstSearch(const BBType* bb, SuccessorLambda successors, // BBType - BasicBlock type. Will either be BasicBlock or DominatorTreeNode // SuccessorLambda - Lamdba matching the signature of 'const // std::vector*(const BBType *A)'. Will return a vector of the nodes -// succeding BasicBlock A. +// succeeding BasicBlock A. // PostLambda - Lamdba matching the signature of 'void (const BBType*)' will be // called on each node traversed after their children. template diff --git a/third_party/spirv-tools/source/opt/dominator_tree.h b/third_party/spirv-tools/source/opt/dominator_tree.h index 0024bc508a..1674b228fd 100644 --- a/third_party/spirv-tools/source/opt/dominator_tree.h +++ b/third_party/spirv-tools/source/opt/dominator_tree.h @@ -278,7 +278,7 @@ class DominatorTree { private: // Wrapper function which gets the list of pairs of each BasicBlocks to its - // immediately dominating BasicBlock and stores the result in the the edges + // immediately dominating BasicBlock and stores the result in the edges // parameter. // // The |edges| vector will contain the dominator tree as pairs of nodes. diff --git a/third_party/spirv-tools/source/opt/eliminate_dead_input_components_pass.cpp b/third_party/spirv-tools/source/opt/eliminate_dead_input_components_pass.cpp new file mode 100644 index 0000000000..f383136d55 --- /dev/null +++ b/third_party/spirv-tools/source/opt/eliminate_dead_input_components_pass.cpp @@ -0,0 +1,146 @@ +// Copyright (c) 2022 The Khronos Group Inc. +// Copyright (c) 2022 LunarG Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "source/opt/eliminate_dead_input_components_pass.h" + +#include +#include + +#include "source/opt/instruction.h" +#include "source/opt/ir_builder.h" +#include "source/opt/ir_context.h" +#include "source/util/bit_vector.h" + +namespace { + +const uint32_t kAccessChainBaseInIdx = 0; +const uint32_t kAccessChainIndex0InIdx = 1; +const uint32_t kConstantValueInIdx = 0; +const uint32_t kVariableStorageClassInIdx = 0; + +} // namespace + +namespace spvtools { +namespace opt { + +Pass::Status EliminateDeadInputComponentsPass::Process() { + // Current functionality assumes shader capability + if (!context()->get_feature_mgr()->HasCapability(SpvCapabilityShader)) + return Status::SuccessWithoutChange; + analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr(); + analysis::TypeManager* type_mgr = context()->get_type_mgr(); + bool modified = false; + std::vector> arrays_to_change; + for (auto& var : context()->types_values()) { + if (var.opcode() != SpvOpVariable) { + continue; + } + analysis::Type* var_type = type_mgr->GetType(var.type_id()); + analysis::Pointer* ptr_type = var_type->AsPointer(); + if (ptr_type == nullptr) { + continue; + } + if (ptr_type->storage_class() != SpvStorageClassInput) { + continue; + } + const analysis::Array* arr_type = ptr_type->pointee_type()->AsArray(); + if (arr_type == nullptr) { + continue; + } + unsigned arr_len_id = arr_type->LengthId(); + Instruction* arr_len_inst = def_use_mgr->GetDef(arr_len_id); + if (arr_len_inst->opcode() != SpvOpConstant) { + continue; + } + // SPIR-V requires array size is >= 1, so this works for signed or + // unsigned size + unsigned original_max = + arr_len_inst->GetSingleWordInOperand(kConstantValueInIdx) - 1; + unsigned max_idx = FindMaxIndex(var, original_max); + if (max_idx != original_max) { + ChangeArrayLength(var, max_idx + 1); + modified = true; + } + } + + return modified ? Status::SuccessWithChange : Status::SuccessWithoutChange; +} + +unsigned EliminateDeadInputComponentsPass::FindMaxIndex(Instruction& var, + unsigned original_max) { + unsigned max = 0; + bool seen_non_const_ac = false; + assert(var.opcode() == SpvOpVariable && "must be variable"); + context()->get_def_use_mgr()->WhileEachUser( + var.result_id(), [&max, &seen_non_const_ac, var, this](Instruction* use) { + auto use_opcode = use->opcode(); + if (use_opcode == SpvOpLoad || use_opcode == SpvOpCopyMemory || + use_opcode == SpvOpCopyMemorySized || + use_opcode == SpvOpCopyObject) { + seen_non_const_ac = true; + return false; + } + if (use->opcode() != SpvOpAccessChain && + use->opcode() != SpvOpInBoundsAccessChain) { + return true; + } + // OpAccessChain with no indices currently not optimized + if (use->NumInOperands() == 1) { + seen_non_const_ac = true; + return false; + } + unsigned base_id = use->GetSingleWordInOperand(kAccessChainBaseInIdx); + USE_ASSERT(base_id == var.result_id() && "unexpected base"); + unsigned idx_id = use->GetSingleWordInOperand(kAccessChainIndex0InIdx); + Instruction* idx_inst = context()->get_def_use_mgr()->GetDef(idx_id); + if (idx_inst->opcode() != SpvOpConstant) { + seen_non_const_ac = true; + return false; + } + unsigned value = idx_inst->GetSingleWordInOperand(kConstantValueInIdx); + if (value > max) max = value; + return true; + }); + return seen_non_const_ac ? original_max : max; +} + +void EliminateDeadInputComponentsPass::ChangeArrayLength(Instruction& arr, + unsigned length) { + analysis::TypeManager* type_mgr = context()->get_type_mgr(); + analysis::ConstantManager* const_mgr = context()->get_constant_mgr(); + analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr(); + analysis::Pointer* ptr_type = type_mgr->GetType(arr.type_id())->AsPointer(); + const analysis::Array* arr_ty = ptr_type->pointee_type()->AsArray(); + assert(arr_ty && "expecting array type"); + uint32_t length_id = const_mgr->GetUIntConst(length); + analysis::Array new_arr_ty(arr_ty->element_type(), + arr_ty->GetConstantLengthInfo(length_id, length)); + analysis::Type* reg_new_arr_ty = type_mgr->GetRegisteredType(&new_arr_ty); + analysis::Pointer new_ptr_ty(reg_new_arr_ty, SpvStorageClassInput); + analysis::Type* reg_new_ptr_ty = type_mgr->GetRegisteredType(&new_ptr_ty); + uint32_t new_ptr_ty_id = type_mgr->GetTypeInstruction(reg_new_ptr_ty); + arr.SetResultType(new_ptr_ty_id); + def_use_mgr->AnalyzeInstUse(&arr); + // Move array OpVariable instruction after its new type to preserve order + USE_ASSERT(arr.GetSingleWordInOperand(kVariableStorageClassInIdx) != + SpvStorageClassFunction && + "cannot move Function variable"); + Instruction* new_ptr_ty_inst = def_use_mgr->GetDef(new_ptr_ty_id); + arr.RemoveFromList(); + arr.InsertAfter(new_ptr_ty_inst); +} + +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/eliminate_dead_input_components_pass.h b/third_party/spirv-tools/source/opt/eliminate_dead_input_components_pass.h new file mode 100644 index 0000000000..b77857f4e9 --- /dev/null +++ b/third_party/spirv-tools/source/opt/eliminate_dead_input_components_pass.h @@ -0,0 +1,59 @@ +// Copyright (c) 2022 The Khronos Group Inc. +// Copyright (c) 2022 LunarG Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef SOURCE_OPT_ELIMINATE_DEAD_INPUT_COMPONENTS_H_ +#define SOURCE_OPT_ELIMINATE_DEAD_INPUT_COMPONENTS_H_ + +#include + +#include "source/opt/ir_context.h" +#include "source/opt/module.h" +#include "source/opt/pass.h" + +namespace spvtools { +namespace opt { + +// See optimizer.hpp for documentation. +class EliminateDeadInputComponentsPass : public Pass { + public: + explicit EliminateDeadInputComponentsPass() {} + + const char* name() const override { return "reduce-load-size"; } + Status Process() override; + + // Return the mask of preserved Analyses. + IRContext::Analysis GetPreservedAnalyses() override { + return IRContext::kAnalysisDefUse | + IRContext::kAnalysisInstrToBlockMapping | + IRContext::kAnalysisCombinators | IRContext::kAnalysisCFG | + IRContext::kAnalysisDominatorAnalysis | + IRContext::kAnalysisLoopAnalysis | IRContext::kAnalysisNameMap | + IRContext::kAnalysisConstants | IRContext::kAnalysisTypes; + } + + private: + // Find the max constant used to index the variable declared by |var| + // through OpAccessChain or OpInBoundsAccessChain. If any non-constant + // indices or non-Op*AccessChain use of |var|, return |original_max|. + unsigned FindMaxIndex(Instruction& var, unsigned original_max); + + // Change the length of the array |inst| to |length| + void ChangeArrayLength(Instruction& inst, unsigned length); +}; + +} // namespace opt +} // namespace spvtools + +#endif // SOURCE_OPT_ELIMINATE_DEAD_INPUT_COMPONENTS_H_ diff --git a/third_party/spirv-tools/source/opt/eliminate_dead_members_pass.cpp b/third_party/spirv-tools/source/opt/eliminate_dead_members_pass.cpp index a24ba8f41c..52aca5254d 100644 --- a/third_party/spirv-tools/source/opt/eliminate_dead_members_pass.cpp +++ b/third_party/spirv-tools/source/opt/eliminate_dead_members_pass.cpp @@ -38,7 +38,7 @@ Pass::Status EliminateDeadMembersPass::Process() { } void EliminateDeadMembersPass::FindLiveMembers() { - // Until we have implemented the rewritting of OpSpecConsantOp instructions, + // Until we have implemented the rewriting of OpSpecConsantOp instructions, // we have to mark them as fully used just to be safe. for (auto& inst : get_module()->types_values()) { if (inst.opcode() == SpvOpSpecConstantOp) { @@ -570,7 +570,7 @@ bool EliminateDeadMembersPass::UpdateCompsiteExtract(Instruction* inst) { Instruction* type_inst = get_def_use_mgr()->GetDef(type_id); switch (type_inst->opcode()) { case SpvOpTypeStruct: - // The type will have already been rewriten, so use the new member + // The type will have already been rewritten, so use the new member // index. type_id = type_inst->GetSingleWordInOperand(new_member_idx); break; diff --git a/third_party/spirv-tools/source/opt/feature_manager.cpp b/third_party/spirv-tools/source/opt/feature_manager.cpp index 39a4a3486e..a590271679 100644 --- a/third_party/spirv-tools/source/opt/feature_manager.cpp +++ b/third_party/spirv-tools/source/opt/feature_manager.cpp @@ -39,8 +39,7 @@ void FeatureManager::AddExtension(Instruction* ext) { assert(ext->opcode() == SpvOpExtension && "Expecting an extension instruction."); - const std::string name = - reinterpret_cast(ext->GetInOperand(0u).words.data()); + const std::string name = ext->GetInOperand(0u).AsString(); Extension extension; if (GetExtensionFromString(name.c_str(), &extension)) { extensions_.Add(extension); diff --git a/third_party/spirv-tools/source/opt/fix_func_call_arguments.cpp b/third_party/spirv-tools/source/opt/fix_func_call_arguments.cpp new file mode 100644 index 0000000000..d140fb4b0e --- /dev/null +++ b/third_party/spirv-tools/source/opt/fix_func_call_arguments.cpp @@ -0,0 +1,90 @@ +// Copyright (c) 2022 Advanced Micro Devices, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "fix_func_call_arguments.h" + +#include "ir_builder.h" + +using namespace spvtools; +using namespace opt; + +bool FixFuncCallArgumentsPass::ModuleHasASingleFunction() { + auto funcsNum = get_module()->end() - get_module()->begin(); + return funcsNum == 1; +} + +Pass::Status FixFuncCallArgumentsPass::Process() { + bool modified = false; + if (ModuleHasASingleFunction()) return Status::SuccessWithoutChange; + for (auto& func : *get_module()) { + func.ForEachInst([this, &modified](Instruction* inst) { + if (inst->opcode() == SpvOpFunctionCall) { + modified |= FixFuncCallArguments(inst); + } + }); + } + return modified ? Status::SuccessWithChange : Status::SuccessWithoutChange; +} + +bool FixFuncCallArgumentsPass::FixFuncCallArguments( + Instruction* func_call_inst) { + bool modified = false; + for (uint32_t i = 0; i < func_call_inst->NumInOperands(); ++i) { + Operand& op = func_call_inst->GetInOperand(i); + if (op.type != SPV_OPERAND_TYPE_ID) continue; + Instruction* operand_inst = get_def_use_mgr()->GetDef(op.AsId()); + if (operand_inst->opcode() == SpvOpAccessChain) { + uint32_t var_id = + ReplaceAccessChainFuncCallArguments(func_call_inst, operand_inst); + func_call_inst->SetInOperand(i, {var_id}); + modified = true; + } + } + if (modified) { + context()->UpdateDefUse(func_call_inst); + } + return modified; +} + +uint32_t FixFuncCallArgumentsPass::ReplaceAccessChainFuncCallArguments( + Instruction* func_call_inst, Instruction* operand_inst) { + InstructionBuilder builder( + context(), func_call_inst, + IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping); + + Instruction* next_insert_point = func_call_inst->NextNode(); + // Get Variable insertion point + Function* func = context()->get_instr_block(func_call_inst)->GetParent(); + Instruction* variable_insertion_point = &*(func->begin()->begin()); + Instruction* op_ptr_type = get_def_use_mgr()->GetDef(operand_inst->type_id()); + Instruction* op_type = + get_def_use_mgr()->GetDef(op_ptr_type->GetSingleWordInOperand(1)); + uint32_t varType = context()->get_type_mgr()->FindPointerToType( + op_type->result_id(), SpvStorageClassFunction); + // Create new variable + builder.SetInsertPoint(variable_insertion_point); + Instruction* var = builder.AddVariable(varType, SpvStorageClassFunction); + // Load access chain to the new variable before function call + builder.SetInsertPoint(func_call_inst); + + uint32_t operand_id = operand_inst->result_id(); + Instruction* load = builder.AddLoad(op_type->result_id(), operand_id); + builder.AddStore(var->result_id(), load->result_id()); + // Load return value to the acesschain after function call + builder.SetInsertPoint(next_insert_point); + load = builder.AddLoad(op_type->result_id(), var->result_id()); + builder.AddStore(operand_id, load->result_id()); + + return var->result_id(); +} diff --git a/third_party/spirv-tools/source/opt/fix_func_call_arguments.h b/third_party/spirv-tools/source/opt/fix_func_call_arguments.h new file mode 100644 index 0000000000..15781b8c6b --- /dev/null +++ b/third_party/spirv-tools/source/opt/fix_func_call_arguments.h @@ -0,0 +1,47 @@ +// Copyright (c) 2022 Advanced Micro Devices, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef _VAR_FUNC_CALL_PASS_H +#define _VAR_FUNC_CALL_PASS_H + +#include "source/opt/pass.h" + +namespace spvtools { +namespace opt { +class FixFuncCallArgumentsPass : public Pass { + public: + FixFuncCallArgumentsPass() {} + const char* name() const override { return "fix-for-funcall-param"; } + Status Process() override; + // Returns true if the module has one one function. + bool ModuleHasASingleFunction(); + // Copies from the memory pointed to by |operand_inst| to a new function scope + // variable created before |func_call_inst|, and + // copies the value of the new variable back to the memory pointed to by + // |operand_inst| after |funct_call_inst| Returns the id of + // the new variable. + uint32_t ReplaceAccessChainFuncCallArguments(Instruction* func_call_inst, + Instruction* operand_inst); + + // Fix function call |func_call_inst| non memory object arguments + bool FixFuncCallArguments(Instruction* func_call_inst); + + IRContext::Analysis GetPreservedAnalyses() override { + return IRContext::kAnalysisTypes; + } +}; +} // namespace opt +} // namespace spvtools + +#endif // _VAR_FUNC_CALL_PASS_H \ No newline at end of file diff --git a/third_party/spirv-tools/source/opt/fold.cpp b/third_party/spirv-tools/source/opt/fold.cpp index 6550fb4fdb..b903da6a2d 100644 --- a/third_party/spirv-tools/source/opt/fold.cpp +++ b/third_party/spirv-tools/source/opt/fold.cpp @@ -540,7 +540,7 @@ std::vector InstructionFolder::FoldVectors( // in 32-bit words here. The reason of not using FoldScalars() here // is that we do not create temporary null constants as components // when the vector operand is a NullConstant because Constant creation - // may need extra checks for the validity and that is not manageed in + // may need extra checks for the validity and that is not managed in // here. if (const analysis::ScalarConstant* scalar_component = vector_operand->GetComponents().at(d)->AsScalarConstant()) { diff --git a/third_party/spirv-tools/source/opt/fold_spec_constant_op_and_composite_pass.cpp b/third_party/spirv-tools/source/opt/fold_spec_constant_op_and_composite_pass.cpp index 8ab717ea8a..85f11fdea0 100644 --- a/third_party/spirv-tools/source/opt/fold_spec_constant_op_and_composite_pass.cpp +++ b/third_party/spirv-tools/source/opt/fold_spec_constant_op_and_composite_pass.cpp @@ -115,7 +115,7 @@ bool FoldSpecConstantOpAndCompositePass::ProcessOpSpecConstantOp( Instruction* folded_inst = nullptr; assert(inst->GetInOperand(0).type == SPV_OPERAND_TYPE_SPEC_CONSTANT_OP_NUMBER && - "The first in-operand of OpSpecContantOp instruction must be of " + "The first in-operand of OpSpecConstantOp instruction must be of " "SPV_OPERAND_TYPE_SPEC_CONSTANT_OP_NUMBER type"); switch (static_cast(inst->GetSingleWordInOperand(0))) { diff --git a/third_party/spirv-tools/source/opt/folding_rules.cpp b/third_party/spirv-tools/source/opt/folding_rules.cpp index 4904f1862e..ab7a20ef91 100644 --- a/third_party/spirv-tools/source/opt/folding_rules.cpp +++ b/third_party/spirv-tools/source/opt/folding_rules.cpp @@ -1430,6 +1430,64 @@ FoldingRule FactorAddMuls() { }; } +// Replaces |inst| inplace with an FMA instruction |(x*y)+a|. +void ReplaceWithFma(Instruction* inst, uint32_t x, uint32_t y, uint32_t a) { + uint32_t ext = + inst->context()->get_feature_mgr()->GetExtInstImportId_GLSLstd450(); + + if (ext == 0) { + inst->context()->AddExtInstImport("GLSL.std.450"); + ext = inst->context()->get_feature_mgr()->GetExtInstImportId_GLSLstd450(); + assert(ext != 0 && + "Could not add the GLSL.std.450 extended instruction set"); + } + + std::vector operands; + operands.push_back({SPV_OPERAND_TYPE_ID, {ext}}); + operands.push_back({SPV_OPERAND_TYPE_LITERAL_INTEGER, {GLSLstd450Fma}}); + operands.push_back({SPV_OPERAND_TYPE_ID, {x}}); + operands.push_back({SPV_OPERAND_TYPE_ID, {y}}); + operands.push_back({SPV_OPERAND_TYPE_ID, {a}}); + + inst->SetOpcode(SpvOpExtInst); + inst->SetInOperands(std::move(operands)); +} + +// Folds a multiple and add into an Fma. +// +// Cases: +// (x * y) + a = Fma x y a +// a + (x * y) = Fma x y a +bool MergeMulAddArithmetic(IRContext* context, Instruction* inst, + const std::vector&) { + assert(inst->opcode() == SpvOpFAdd); + + if (!inst->IsFloatingPointFoldingAllowed()) { + return false; + } + + analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); + for (int i = 0; i < 2; i++) { + uint32_t op_id = inst->GetSingleWordInOperand(i); + Instruction* op_inst = def_use_mgr->GetDef(op_id); + + if (op_inst->opcode() != SpvOpFMul) { + continue; + } + + if (!op_inst->IsFloatingPointFoldingAllowed()) { + continue; + } + + uint32_t x = op_inst->GetSingleWordInOperand(0); + uint32_t y = op_inst->GetSingleWordInOperand(1); + uint32_t a = inst->GetSingleWordInOperand((i + 1) % 2); + ReplaceWithFma(inst, x, y, a); + return true; + } + return false; +} + FoldingRule IntMultipleBy1() { return [](IRContext*, Instruction* inst, const std::vector& constants) { @@ -1573,6 +1631,57 @@ bool CompositeConstructFeedingExtract( return true; } +// Walks the indexes chain from |start| to |end| of an OpCompositeInsert or +// OpCompositeExtract instruction, and returns the type of the final element +// being accessed. +const analysis::Type* GetElementType(uint32_t type_id, + Instruction::iterator start, + Instruction::iterator end, + const analysis::TypeManager* type_mgr) { + const analysis::Type* type = type_mgr->GetType(type_id); + for (auto index : make_range(std::move(start), std::move(end))) { + assert(index.type == SPV_OPERAND_TYPE_LITERAL_INTEGER && + index.words.size() == 1); + if (auto* array_type = type->AsArray()) { + type = array_type->element_type(); + } else if (auto* matrix_type = type->AsMatrix()) { + type = matrix_type->element_type(); + } else if (auto* struct_type = type->AsStruct()) { + type = struct_type->element_types()[index.words[0]]; + } else { + type = nullptr; + } + } + return type; +} + +// Returns true of |inst_1| and |inst_2| have the same indexes that will be used +// to index into a composite object, excluding the last index. The two +// instructions must have the same opcode, and be either OpCompositeExtract or +// OpCompositeInsert instructions. +bool HaveSameIndexesExceptForLast(Instruction* inst_1, Instruction* inst_2) { + assert(inst_1->opcode() == inst_2->opcode() && + "Expecting the opcodes to be the same."); + assert((inst_1->opcode() == SpvOpCompositeInsert || + inst_1->opcode() == SpvOpCompositeExtract) && + "Instructions must be OpCompositeInsert or OpCompositeExtract."); + + if (inst_1->NumInOperands() != inst_2->NumInOperands()) { + return false; + } + + uint32_t first_index_position = + (inst_1->opcode() == SpvOpCompositeInsert ? 2 : 1); + for (uint32_t i = first_index_position; i < inst_1->NumInOperands() - 1; + i++) { + if (inst_1->GetSingleWordInOperand(i) != + inst_2->GetSingleWordInOperand(i)) { + return false; + } + } + return true; +} + // If the OpCompositeConstruct is simply putting back together elements that // where extracted from the same source, we can simply reuse the source. // @@ -1595,19 +1704,24 @@ bool CompositeExtractFeedingConstruct( // - extractions // - extracting the same position they are inserting // - all extract from the same id. + Instruction* first_element_inst = nullptr; for (uint32_t i = 0; i < inst->NumInOperands(); ++i) { const uint32_t element_id = inst->GetSingleWordInOperand(i); Instruction* element_inst = def_use_mgr->GetDef(element_id); + if (first_element_inst == nullptr) { + first_element_inst = element_inst; + } if (element_inst->opcode() != SpvOpCompositeExtract) { return false; } - if (element_inst->NumInOperands() != 2) { + if (!HaveSameIndexesExceptForLast(element_inst, first_element_inst)) { return false; } - if (element_inst->GetSingleWordInOperand(1) != i) { + if (element_inst->GetSingleWordInOperand(element_inst->NumInOperands() - + 1) != i) { return false; } @@ -1623,13 +1737,31 @@ bool CompositeExtractFeedingConstruct( // The last check it to see that the object being extracted from is the // correct type. Instruction* original_inst = def_use_mgr->GetDef(original_id); - if (original_inst->type_id() != inst->type_id()) { + analysis::TypeManager* type_mgr = context->get_type_mgr(); + const analysis::Type* original_type = + GetElementType(original_inst->type_id(), first_element_inst->begin() + 3, + first_element_inst->end() - 1, type_mgr); + + if (original_type == nullptr) { return false; } - // Simplify by using the original object. - inst->SetOpcode(SpvOpCopyObject); - inst->SetInOperands({{SPV_OPERAND_TYPE_ID, {original_id}}}); + if (inst->type_id() != type_mgr->GetId(original_type)) { + return false; + } + + if (first_element_inst->NumInOperands() == 2) { + // Simplify by using the original object. + inst->SetOpcode(SpvOpCopyObject); + inst->SetInOperands({{SPV_OPERAND_TYPE_ID, {original_id}}}); + return true; + } + + // Copies the original id and all indexes except for the last to the new + // extract instruction. + inst->SetOpcode(SpvOpCompositeExtract); + inst->SetInOperands(std::vector(first_element_inst->begin() + 2, + first_element_inst->end() - 1)); return true; } @@ -1833,6 +1965,139 @@ FoldingRule FMixFeedingExtract() { }; } +// Returns the number of elements in the composite type |type|. Returns 0 if +// |type| is a scalar value. +uint32_t GetNumberOfElements(const analysis::Type* type) { + if (auto* vector_type = type->AsVector()) { + return vector_type->element_count(); + } + if (auto* matrix_type = type->AsMatrix()) { + return matrix_type->element_count(); + } + if (auto* struct_type = type->AsStruct()) { + return static_cast(struct_type->element_types().size()); + } + if (auto* array_type = type->AsArray()) { + return array_type->length_info().words[0]; + } + return 0; +} + +// Returns a map with the set of values that were inserted into an object by +// the chain of OpCompositeInsertInstruction starting with |inst|. +// The map will map the index to the value inserted at that index. +std::map GetInsertedValues(Instruction* inst) { + analysis::DefUseManager* def_use_mgr = inst->context()->get_def_use_mgr(); + std::map values_inserted; + Instruction* current_inst = inst; + while (current_inst->opcode() == SpvOpCompositeInsert) { + if (current_inst->NumInOperands() > inst->NumInOperands()) { + // This is the catch the case + // %2 = OpCompositeInsert %m2x2int %v2int_1_0 %m2x2int_undef 0 + // %3 = OpCompositeInsert %m2x2int %int_4 %2 0 0 + // %4 = OpCompositeInsert %m2x2int %v2int_2_3 %3 1 + // In this case we cannot do a single construct to get the matrix. + uint32_t partially_inserted_element_index = + current_inst->GetSingleWordInOperand(inst->NumInOperands() - 1); + if (values_inserted.count(partially_inserted_element_index) == 0) + return {}; + } + if (HaveSameIndexesExceptForLast(inst, current_inst)) { + values_inserted.insert( + {current_inst->GetSingleWordInOperand(current_inst->NumInOperands() - + 1), + current_inst->GetSingleWordInOperand(kInsertObjectIdInIdx)}); + } + current_inst = def_use_mgr->GetDef( + current_inst->GetSingleWordInOperand(kInsertCompositeIdInIdx)); + } + return values_inserted; +} + +// Returns true of there is an entry in |values_inserted| for every element of +// |Type|. +bool DoInsertedValuesCoverEntireObject( + const analysis::Type* type, std::map& values_inserted) { + uint32_t container_size = GetNumberOfElements(type); + if (container_size != values_inserted.size()) { + return false; + } + + if (values_inserted.rbegin()->first >= container_size) { + return false; + } + return true; +} + +// Returns the type of the element that immediately contains the element being +// inserted by the OpCompositeInsert instruction |inst|. +const analysis::Type* GetContainerType(Instruction* inst) { + assert(inst->opcode() == SpvOpCompositeInsert); + analysis::TypeManager* type_mgr = inst->context()->get_type_mgr(); + return GetElementType(inst->type_id(), inst->begin() + 4, inst->end() - 1, + type_mgr); +} + +// Returns an OpCompositeConstruct instruction that build an object with +// |type_id| out of the values in |values_inserted|. Each value will be +// placed at the index corresponding to the value. The new instruction will +// be placed before |insert_before|. +Instruction* BuildCompositeConstruct( + uint32_t type_id, const std::map& values_inserted, + Instruction* insert_before) { + InstructionBuilder ir_builder( + insert_before->context(), insert_before, + IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping); + + std::vector ids_in_order; + for (auto it : values_inserted) { + ids_in_order.push_back(it.second); + } + Instruction* construct = + ir_builder.AddCompositeConstruct(type_id, ids_in_order); + return construct; +} + +// Replaces the OpCompositeInsert |inst| that inserts |construct| into the same +// object as |inst| with final index removed. If the resulting +// OpCompositeInsert instruction would have no remaining indexes, the +// instruction is replaced with an OpCopyObject instead. +void InsertConstructedObject(Instruction* inst, const Instruction* construct) { + if (inst->NumInOperands() == 3) { + inst->SetOpcode(SpvOpCopyObject); + inst->SetInOperands({{SPV_OPERAND_TYPE_ID, {construct->result_id()}}}); + } else { + inst->SetInOperand(kInsertObjectIdInIdx, {construct->result_id()}); + inst->RemoveOperand(inst->NumOperands() - 1); + } +} + +// Replaces a series of |OpCompositeInsert| instruction that cover the entire +// object with an |OpCompositeConstruct|. +bool CompositeInsertToCompositeConstruct( + IRContext* context, Instruction* inst, + const std::vector&) { + assert(inst->opcode() == SpvOpCompositeInsert && + "Wrong opcode. Should be OpCompositeInsert."); + if (inst->NumInOperands() < 3) return false; + + std::map values_inserted = GetInsertedValues(inst); + const analysis::Type* container_type = GetContainerType(inst); + if (container_type == nullptr) { + return false; + } + + if (!DoInsertedValuesCoverEntireObject(container_type, values_inserted)) { + return false; + } + + analysis::TypeManager* type_mgr = context->get_type_mgr(); + Instruction* construct = BuildCompositeConstruct( + type_mgr->GetId(container_type), values_inserted, inst); + InsertConstructedObject(inst, construct); + return true; +} + FoldingRule RedundantPhi() { // An OpPhi instruction where all values are the same or the result of the phi // itself, can be replaced by the value itself. @@ -2368,7 +2633,7 @@ FoldingRule VectorShuffleFeedingShuffle() { // fold. return false; } - } else { + } else if (component_index != undef_literal) { if (new_feeder_id == 0) { // First time through, save the id of the operand the element comes // from. @@ -2382,7 +2647,7 @@ FoldingRule VectorShuffleFeedingShuffle() { component_index -= feeder_op0_length; } - if (!feeder_is_op0) { + if (!feeder_is_op0 && component_index != undef_literal) { component_index += op0_length; } } @@ -2533,6 +2798,8 @@ void FoldingRules::AddFoldingRules() { rules_[SpvOpCompositeExtract].push_back(VectorShuffleFeedingExtract()); rules_[SpvOpCompositeExtract].push_back(FMixFeedingExtract()); + rules_[SpvOpCompositeInsert].push_back(CompositeInsertToCompositeConstruct); + rules_[SpvOpDot].push_back(DotProductDoingExtract()); rules_[SpvOpEntryPoint].push_back(RemoveRedundantOperands()); @@ -2543,6 +2810,7 @@ void FoldingRules::AddFoldingRules() { rules_[SpvOpFAdd].push_back(MergeAddSubArithmetic()); rules_[SpvOpFAdd].push_back(MergeGenericAddSubArithmetic()); rules_[SpvOpFAdd].push_back(FactorAddMuls()); + rules_[SpvOpFAdd].push_back(MergeMulAddArithmetic); rules_[SpvOpFDiv].push_back(RedundantFDiv()); rules_[SpvOpFDiv].push_back(ReciprocalFDiv()); diff --git a/third_party/spirv-tools/source/opt/graphics_robust_access_pass.cpp b/third_party/spirv-tools/source/opt/graphics_robust_access_pass.cpp index 1b28f9b529..4652d72d5c 100644 --- a/third_party/spirv-tools/source/opt/graphics_robust_access_pass.cpp +++ b/third_party/spirv-tools/source/opt/graphics_robust_access_pass.cpp @@ -13,7 +13,7 @@ // limitations under the License. // This pass injects code in a graphics shader to implement guarantees -// satisfying Vulkan's robustBufferAcces rules. Robust access rules permit +// satisfying Vulkan's robustBufferAccess rules. Robust access rules permit // an out-of-bounds access to be redirected to an access of the same type // (load, store, etc.) but within the same root object. // @@ -74,7 +74,7 @@ // Pointers are always (correctly) typed and so the address and number of // consecutive locations are fully determined by the pointer. // -// - A pointer value orginates as one of few cases: +// - A pointer value originates as one of few cases: // // - OpVariable for an interface object or an array of them: image, // buffer (UBO or SSBO), sampler, sampled-image, push-constant, input @@ -559,21 +559,17 @@ uint32_t GraphicsRobustAccessPass::GetGlslInsts() { if (module_status_.glsl_insts_id == 0) { // This string serves double-duty as raw data for a string and for a vector // of 32-bit words - const char glsl[] = "GLSL.std.450\0\0\0\0"; - const size_t glsl_str_byte_len = 16; + const char glsl[] = "GLSL.std.450"; // Use an existing import if we can. for (auto& inst : context()->module()->ext_inst_imports()) { - const auto& name_words = inst.GetInOperand(0).words; - if (0 == std::strncmp(reinterpret_cast(name_words.data()), - glsl, glsl_str_byte_len)) { + if (inst.GetInOperand(0).AsString() == glsl) { module_status_.glsl_insts_id = inst.result_id(); } } if (module_status_.glsl_insts_id == 0) { // Make a new import instruction. module_status_.glsl_insts_id = TakeNextId(); - std::vector words(glsl_str_byte_len / sizeof(uint32_t)); - std::memcpy(words.data(), glsl, glsl_str_byte_len); + std::vector words = spvtools::utils::MakeVector(glsl); auto import_inst = MakeUnique( context(), SpvOpExtInstImport, 0, module_status_.glsl_insts_id, std::initializer_list{ @@ -962,7 +958,7 @@ spv_result_t GraphicsRobustAccessPass::ClampCoordinateForImageTexelPointer( constant_mgr->GetDefiningInstruction(component_0)->result_id(); // If the image is a cube array, then the last component of the queried - // size is the layer count. In the query, we have to accomodate folding + // size is the layer count. In the query, we have to accommodate folding // in the face index ranging from 0 through 5. The inclusive upper bound // on the third coordinate therefore is multiplied by 6. auto* query_size_including_faces = query_size; diff --git a/third_party/spirv-tools/source/opt/graphics_robust_access_pass.h b/third_party/spirv-tools/source/opt/graphics_robust_access_pass.h index 6fc692c133..8f4c9dc7db 100644 --- a/third_party/spirv-tools/source/opt/graphics_robust_access_pass.h +++ b/third_party/spirv-tools/source/opt/graphics_robust_access_pass.h @@ -111,7 +111,7 @@ class GraphicsRobustAccessPass : public Pass { Instruction* max, Instruction* where); // Returns a new instruction which evaluates to the length the runtime array - // referenced by the access chain at the specfied index. The instruction is + // referenced by the access chain at the specified index. The instruction is // inserted before the access chain instruction. Returns a null pointer in // some cases if assumptions are violated (rather than asserting out). opt::Instruction* MakeRuntimeArrayLengthInst(Instruction* access_chain, diff --git a/third_party/spirv-tools/source/opt/if_conversion.cpp b/third_party/spirv-tools/source/opt/if_conversion.cpp index 492066177f..d1debd055f 100644 --- a/third_party/spirv-tools/source/opt/if_conversion.cpp +++ b/third_party/spirv-tools/source/opt/if_conversion.cpp @@ -169,6 +169,8 @@ bool IfConversion::CheckBlock(BasicBlock* block, DominatorAnalysis* dominators, if (branch->opcode() != SpvOpBranchConditional) return false; auto merge = (*common)->GetMergeInst(); if (!merge || merge->opcode() != SpvOpSelectionMerge) return false; + if (merge->GetSingleWordInOperand(1) == SpvSelectionControlDontFlattenMask) + return false; if ((*common)->MergeBlockIdIfAny() != block->id()) return false; return true; diff --git a/third_party/spirv-tools/source/opt/inst_bindless_check_pass.cpp b/third_party/spirv-tools/source/opt/inst_bindless_check_pass.cpp index 5607239aaf..c2c5d6cb44 100644 --- a/third_party/spirv-tools/source/opt/inst_bindless_check_pass.cpp +++ b/third_party/spirv-tools/source/opt/inst_bindless_check_pass.cpp @@ -39,13 +39,6 @@ static const int kSpvTypeImageMS = 4; static const int kSpvTypeImageSampled = 5; } // anonymous namespace -// Avoid unused variable warning/error on Linux -#ifndef NDEBUG -#define USE_ASSERT(x) assert(x) -#else -#define USE_ASSERT(x) ((void)(x)) -#endif - namespace spvtools { namespace opt { diff --git a/third_party/spirv-tools/source/opt/inst_bindless_check_pass.h b/third_party/spirv-tools/source/opt/inst_bindless_check_pass.h index cd9618059f..e6e6ef4f98 100644 --- a/third_party/spirv-tools/source/opt/inst_bindless_check_pass.h +++ b/third_party/spirv-tools/source/opt/inst_bindless_check_pass.h @@ -147,11 +147,11 @@ class InstBindlessCheckPass : public InstrumentPass { uint32_t GenLastByteIdx(RefAnalysis* ref, InstructionBuilder* builder); // Clone original image computation starting at |image_id| into |builder|. - // This may generate more than one instruction if neccessary. + // This may generate more than one instruction if necessary. uint32_t CloneOriginalImage(uint32_t image_id, InstructionBuilder* builder); // Clone original original reference encapsulated by |ref| into |builder|. - // This may generate more than one instruction if neccessary. + // This may generate more than one instruction if necessary. uint32_t CloneOriginalReference(RefAnalysis* ref, InstructionBuilder* builder); diff --git a/third_party/spirv-tools/source/opt/inst_debug_printf_pass.cpp b/third_party/spirv-tools/source/opt/inst_debug_printf_pass.cpp index c0e6bc3f04..4218138f97 100644 --- a/third_party/spirv-tools/source/opt/inst_debug_printf_pass.cpp +++ b/third_party/spirv-tools/source/opt/inst_debug_printf_pass.cpp @@ -16,6 +16,7 @@ #include "inst_debug_printf_pass.h" +#include "source/util/string_utils.h" #include "spirv/unified1/NonSemanticDebugPrintf.h" namespace spvtools { @@ -231,10 +232,8 @@ Pass::Status InstDebugPrintfPass::ProcessImpl() { bool non_sem_set_seen = false; for (auto c_itr = context()->module()->ext_inst_import_begin(); c_itr != context()->module()->ext_inst_import_end(); ++c_itr) { - const char* set_name = - reinterpret_cast(&c_itr->GetInOperand(0).words[0]); - const char* non_sem_str = "NonSemantic."; - if (!strncmp(set_name, non_sem_str, strlen(non_sem_str))) { + const std::string set_name = c_itr->GetInOperand(0).AsString(); + if (spvtools::utils::starts_with(set_name, "NonSemantic.")) { non_sem_set_seen = true; break; } @@ -242,9 +241,8 @@ Pass::Status InstDebugPrintfPass::ProcessImpl() { if (!non_sem_set_seen) { for (auto c_itr = context()->module()->extension_begin(); c_itr != context()->module()->extension_end(); ++c_itr) { - const char* ext_name = - reinterpret_cast(&c_itr->GetInOperand(0).words[0]); - if (!strcmp(ext_name, "SPV_KHR_non_semantic_info")) { + const std::string ext_name = c_itr->GetInOperand(0).AsString(); + if (ext_name == "SPV_KHR_non_semantic_info") { context()->KillInst(&*c_itr); break; } diff --git a/third_party/spirv-tools/source/opt/instruction.cpp b/third_party/spirv-tools/source/opt/instruction.cpp index 2461e41e96..418f1213ab 100644 --- a/third_party/spirv-tools/source/opt/instruction.cpp +++ b/third_party/spirv-tools/source/opt/instruction.cpp @@ -76,10 +76,9 @@ Instruction::Instruction(IRContext* c, const spv_parsed_instruction_t& inst, dbg_scope_(kNoDebugScope, kNoInlinedAt) { for (uint32_t i = 0; i < inst.num_operands; ++i) { const auto& current_payload = inst.operands[i]; - std::vector words( - inst.words + current_payload.offset, + operands_.emplace_back( + current_payload.type, inst.words + current_payload.offset, inst.words + current_payload.offset + current_payload.num_words); - operands_.emplace_back(current_payload.type, std::move(words)); } assert((!IsLineInst() || dbg_line.empty()) && "Op(No)Line attaching to Op(No)Line found"); @@ -96,10 +95,9 @@ Instruction::Instruction(IRContext* c, const spv_parsed_instruction_t& inst, dbg_scope_(dbg_scope) { for (uint32_t i = 0; i < inst.num_operands; ++i) { const auto& current_payload = inst.operands[i]; - std::vector words( - inst.words + current_payload.offset, + operands_.emplace_back( + current_payload.type, inst.words + current_payload.offset, inst.words + current_payload.offset + current_payload.num_words); - operands_.emplace_back(current_payload.type, std::move(words)); } } diff --git a/third_party/spirv-tools/source/opt/instruction.h b/third_party/spirv-tools/source/opt/instruction.h index ce568f6626..2163d99b33 100644 --- a/third_party/spirv-tools/source/opt/instruction.h +++ b/third_party/spirv-tools/source/opt/instruction.h @@ -24,6 +24,7 @@ #include "NonSemanticShaderDebugInfo100.h" #include "OpenCLDebugInfo100.h" +#include "source/binary.h" #include "source/common_debug_info.h" #include "source/latest_version_glsl_std_450_header.h" #include "source/latest_version_spirv_header.h" @@ -32,6 +33,7 @@ #include "source/opt/reflect.h" #include "source/util/ilist_node.h" #include "source/util/small_vector.h" +#include "source/util/string_utils.h" #include "spirv-tools/libspirv.h" const uint32_t kNoDebugScope = 0; @@ -82,21 +84,32 @@ struct Operand { Operand(spv_operand_type_t t, const OperandData& w) : type(t), words(w) {} + template + Operand(spv_operand_type_t t, InputIt firstOperandData, + InputIt lastOperandData) + : type(t), words(firstOperandData, lastOperandData) {} + spv_operand_type_t type; // Type of this logical operand. OperandData words; // Binary segments of this logical operand. - // Returns a string operand as a C-style string. - const char* AsCString() const { - assert(type == SPV_OPERAND_TYPE_LITERAL_STRING); - return reinterpret_cast(words.data()); + uint32_t AsId() const { + assert(spvIsIdType(type)); + assert(words.size() == 1); + return words[0]; } // Returns a string operand as a std::string. - std::string AsString() const { return AsCString(); } + std::string AsString() const { + assert(type == SPV_OPERAND_TYPE_LITERAL_STRING); + return spvtools::utils::MakeString(words); + } // Returns a literal integer operand as a uint64_t uint64_t AsLiteralUint64() const { - assert(type == SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER); + assert(type == SPV_OPERAND_TYPE_LITERAL_INTEGER || + type == SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER || + type == SPV_OPERAND_TYPE_OPTIONAL_LITERAL_INTEGER || + type == SPV_OPERAND_TYPE_OPTIONAL_TYPED_LITERAL_INTEGER); assert(1 <= words.size()); assert(words.size() <= 2); uint64_t result = 0; @@ -123,7 +136,7 @@ inline bool operator!=(const Operand& o1, const Operand& o2) { } // This structure is used to represent a DebugScope instruction from -// the OpenCL.100.DebugInfo extened instruction set. Note that we can +// the OpenCL.100.DebugInfo extended instruction set. Note that we can // ignore the result id of DebugScope instruction because it is not // used for anything. We do not keep it to reduce the size of // structure. @@ -295,6 +308,7 @@ class Instruction : public utils::IntrusiveNodeBase { inline void SetInOperands(OperandList&& new_operands); // Sets the result type id. inline void SetResultType(uint32_t ty_id); + inline bool HasResultType() const { return has_type_id_; } // Sets the result id inline void SetResultId(uint32_t res_id); inline bool HasResultId() const { return has_result_id_; } diff --git a/third_party/spirv-tools/source/opt/instrument_pass.h b/third_party/spirv-tools/source/opt/instrument_pass.h index 12b939d4dc..90c1dd47ea 100644 --- a/third_party/spirv-tools/source/opt/instrument_pass.h +++ b/third_party/spirv-tools/source/opt/instrument_pass.h @@ -50,7 +50,7 @@ // A validation pass may read or write multiple buffers. All such buffers // are located in a single debug descriptor set whose index is passed at the // creation of the instrumentation pass. The bindings of the buffers used by -// a validation pass are permanantly assigned and fixed and documented by +// a validation pass are permanently assigned and fixed and documented by // the kDebugOutput* static consts. namespace spvtools { @@ -179,8 +179,8 @@ class InstrumentPass : public Pass { // the error. Every stage will write a fixed number of words. Vertex shaders // will write the Vertex and Instance ID. Fragment shaders will write // FragCoord.xy. Compute shaders will write the GlobalInvocation ID. - // The tesselation eval shader will write the Primitive ID and TessCoords.uv. - // The tesselation control shader and geometry shader will write the + // The tessellation eval shader will write the Primitive ID and TessCoords.uv. + // The tessellation control shader and geometry shader will write the // Primitive ID and Invocation ID. // // The Validation Error Code specifies the exact error which has occurred. diff --git a/third_party/spirv-tools/source/opt/interface_var_sroa.cpp b/third_party/spirv-tools/source/opt/interface_var_sroa.cpp new file mode 100644 index 0000000000..58ed897c16 --- /dev/null +++ b/third_party/spirv-tools/source/opt/interface_var_sroa.cpp @@ -0,0 +1,964 @@ +// Copyright (c) 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "source/opt/interface_var_sroa.h" + +#include + +#include "source/opt/decoration_manager.h" +#include "source/opt/def_use_manager.h" +#include "source/opt/function.h" +#include "source/opt/log.h" +#include "source/opt/type_manager.h" +#include "source/util/make_unique.h" + +const static uint32_t kOpDecorateDecorationInOperandIndex = 1; +const static uint32_t kOpDecorateLiteralInOperandIndex = 2; +const static uint32_t kOpEntryPointInOperandInterface = 3; +const static uint32_t kOpVariableStorageClassInOperandIndex = 0; +const static uint32_t kOpTypeArrayElemTypeInOperandIndex = 0; +const static uint32_t kOpTypeArrayLengthInOperandIndex = 1; +const static uint32_t kOpTypeMatrixColCountInOperandIndex = 1; +const static uint32_t kOpTypeMatrixColTypeInOperandIndex = 0; +const static uint32_t kOpTypePtrTypeInOperandIndex = 1; +const static uint32_t kOpConstantValueInOperandIndex = 0; + +namespace spvtools { +namespace opt { +namespace { + +// Get the length of the OpTypeArray |array_type|. +uint32_t GetArrayLength(analysis::DefUseManager* def_use_mgr, + Instruction* array_type) { + assert(array_type->opcode() == SpvOpTypeArray); + uint32_t const_int_id = + array_type->GetSingleWordInOperand(kOpTypeArrayLengthInOperandIndex); + Instruction* array_length_inst = def_use_mgr->GetDef(const_int_id); + assert(array_length_inst->opcode() == SpvOpConstant); + return array_length_inst->GetSingleWordInOperand( + kOpConstantValueInOperandIndex); +} + +// Get the element type instruction of the OpTypeArray |array_type|. +Instruction* GetArrayElementType(analysis::DefUseManager* def_use_mgr, + Instruction* array_type) { + assert(array_type->opcode() == SpvOpTypeArray); + uint32_t elem_type_id = + array_type->GetSingleWordInOperand(kOpTypeArrayElemTypeInOperandIndex); + return def_use_mgr->GetDef(elem_type_id); +} + +// Get the column type instruction of the OpTypeMatrix |matrix_type|. +Instruction* GetMatrixColumnType(analysis::DefUseManager* def_use_mgr, + Instruction* matrix_type) { + assert(matrix_type->opcode() == SpvOpTypeMatrix); + uint32_t column_type_id = + matrix_type->GetSingleWordInOperand(kOpTypeMatrixColTypeInOperandIndex); + return def_use_mgr->GetDef(column_type_id); +} + +// Traverses the component type of OpTypeArray or OpTypeMatrix. Repeats it +// |depth_to_component| times recursively and returns the component type. +// |type_id| is the result id of the OpTypeArray or OpTypeMatrix instruction. +uint32_t GetComponentTypeOfArrayMatrix(analysis::DefUseManager* def_use_mgr, + uint32_t type_id, + uint32_t depth_to_component) { + if (depth_to_component == 0) return type_id; + + Instruction* type_inst = def_use_mgr->GetDef(type_id); + if (type_inst->opcode() == SpvOpTypeArray) { + uint32_t elem_type_id = + type_inst->GetSingleWordInOperand(kOpTypeArrayElemTypeInOperandIndex); + return GetComponentTypeOfArrayMatrix(def_use_mgr, elem_type_id, + depth_to_component - 1); + } + + assert(type_inst->opcode() == SpvOpTypeMatrix); + uint32_t column_type_id = + type_inst->GetSingleWordInOperand(kOpTypeMatrixColTypeInOperandIndex); + return GetComponentTypeOfArrayMatrix(def_use_mgr, column_type_id, + depth_to_component - 1); +} + +// Creates an OpDecorate instruction whose Target is |var_id| and Decoration is +// |decoration|. Adds |literal| as an extra operand of the instruction. +void CreateDecoration(analysis::DecorationManager* decoration_mgr, + uint32_t var_id, SpvDecoration decoration, + uint32_t literal) { + std::vector operands({ + {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {var_id}}, + {spv_operand_type_t::SPV_OPERAND_TYPE_DECORATION, + {static_cast(decoration)}}, + {spv_operand_type_t::SPV_OPERAND_TYPE_LITERAL_INTEGER, {literal}}, + }); + decoration_mgr->AddDecoration(SpvOpDecorate, std::move(operands)); +} + +// Replaces load instructions with composite construct instructions in all the +// users of the loads. |loads_to_composites| is the mapping from each load to +// its corresponding OpCompositeConstruct. +void ReplaceLoadWithCompositeConstruct( + IRContext* context, + const std::unordered_map& loads_to_composites) { + for (const auto& load_and_composite : loads_to_composites) { + Instruction* load = load_and_composite.first; + Instruction* composite_construct = load_and_composite.second; + + std::vector users; + context->get_def_use_mgr()->ForEachUse( + load, [&users, composite_construct](Instruction* user, uint32_t index) { + user->GetOperand(index).words[0] = composite_construct->result_id(); + users.push_back(user); + }); + + for (Instruction* user : users) + context->get_def_use_mgr()->AnalyzeInstUse(user); + } +} + +// Returns the storage class of the instruction |var|. +SpvStorageClass GetStorageClass(Instruction* var) { + return static_cast( + var->GetSingleWordInOperand(kOpVariableStorageClassInOperandIndex)); +} + +} // namespace + +bool InterfaceVariableScalarReplacement::HasExtraArrayness( + Instruction& entry_point, Instruction* var) { + SpvExecutionModel execution_model = + static_cast(entry_point.GetSingleWordInOperand(0)); + if (execution_model != SpvExecutionModelTessellationEvaluation && + execution_model != SpvExecutionModelTessellationControl) { + return false; + } + if (!context()->get_decoration_mgr()->HasDecoration(var->result_id(), + SpvDecorationPatch)) { + if (execution_model == SpvExecutionModelTessellationControl) return true; + return GetStorageClass(var) != SpvStorageClassOutput; + } + return false; +} + +bool InterfaceVariableScalarReplacement:: + CheckExtraArraynessConflictBetweenEntries(Instruction* interface_var, + bool has_extra_arrayness) { + if (has_extra_arrayness) { + return !ReportErrorIfHasNoExtraArraynessForOtherEntry(interface_var); + } + return !ReportErrorIfHasExtraArraynessForOtherEntry(interface_var); +} + +bool InterfaceVariableScalarReplacement::GetVariableLocation( + Instruction* var, uint32_t* location) { + return !context()->get_decoration_mgr()->WhileEachDecoration( + var->result_id(), SpvDecorationLocation, + [location](const Instruction& inst) { + *location = + inst.GetSingleWordInOperand(kOpDecorateLiteralInOperandIndex); + return false; + }); +} + +bool InterfaceVariableScalarReplacement::GetVariableComponent( + Instruction* var, uint32_t* component) { + return !context()->get_decoration_mgr()->WhileEachDecoration( + var->result_id(), SpvDecorationComponent, + [component](const Instruction& inst) { + *component = + inst.GetSingleWordInOperand(kOpDecorateLiteralInOperandIndex); + return false; + }); +} + +std::vector +InterfaceVariableScalarReplacement::CollectInterfaceVariables( + Instruction& entry_point) { + std::vector interface_vars; + for (uint32_t i = kOpEntryPointInOperandInterface; + i < entry_point.NumInOperands(); ++i) { + Instruction* interface_var = context()->get_def_use_mgr()->GetDef( + entry_point.GetSingleWordInOperand(i)); + assert(interface_var->opcode() == SpvOpVariable); + + SpvStorageClass storage_class = GetStorageClass(interface_var); + if (storage_class != SpvStorageClassInput && + storage_class != SpvStorageClassOutput) { + continue; + } + + interface_vars.push_back(interface_var); + } + return interface_vars; +} + +void InterfaceVariableScalarReplacement::KillInstructionAndUsers( + Instruction* inst) { + if (inst->opcode() == SpvOpEntryPoint) { + return; + } + if (inst->opcode() != SpvOpAccessChain) { + context()->KillInst(inst); + return; + } + context()->get_def_use_mgr()->ForEachUser( + inst, [this](Instruction* user) { KillInstructionAndUsers(user); }); + context()->KillInst(inst); +} + +void InterfaceVariableScalarReplacement::KillInstructionsAndUsers( + const std::vector& insts) { + for (Instruction* inst : insts) { + KillInstructionAndUsers(inst); + } +} + +void InterfaceVariableScalarReplacement::KillLocationAndComponentDecorations( + uint32_t var_id) { + context()->get_decoration_mgr()->RemoveDecorationsFrom( + var_id, [](const Instruction& inst) { + uint32_t decoration = + inst.GetSingleWordInOperand(kOpDecorateDecorationInOperandIndex); + return decoration == SpvDecorationLocation || + decoration == SpvDecorationComponent; + }); +} + +bool InterfaceVariableScalarReplacement::ReplaceInterfaceVariableWithScalars( + Instruction* interface_var, Instruction* interface_var_type, + uint32_t location, uint32_t component, uint32_t extra_array_length) { + NestedCompositeComponents scalar_interface_vars = + CreateScalarInterfaceVarsForReplacement(interface_var_type, + GetStorageClass(interface_var), + extra_array_length); + + AddLocationAndComponentDecorations(scalar_interface_vars, &location, + component); + KillLocationAndComponentDecorations(interface_var->result_id()); + + if (!ReplaceInterfaceVarWith(interface_var, extra_array_length, + scalar_interface_vars)) { + return false; + } + + context()->KillInst(interface_var); + return true; +} + +bool InterfaceVariableScalarReplacement::ReplaceInterfaceVarWith( + Instruction* interface_var, uint32_t extra_array_length, + const NestedCompositeComponents& scalar_interface_vars) { + std::vector users; + context()->get_def_use_mgr()->ForEachUser( + interface_var, [&users](Instruction* user) { users.push_back(user); }); + + std::vector interface_var_component_indices; + std::unordered_map loads_to_composites; + std::unordered_map + loads_for_access_chain_to_composites; + if (extra_array_length != 0) { + // Note that the extra arrayness is the first dimension of the array + // interface variable. + for (uint32_t index = 0; index < extra_array_length; ++index) { + std::unordered_map loads_to_component_values; + if (!ReplaceComponentsOfInterfaceVarWith( + interface_var, users, scalar_interface_vars, + interface_var_component_indices, &index, + &loads_to_component_values, + &loads_for_access_chain_to_composites)) { + return false; + } + AddComponentsToCompositesForLoads(loads_to_component_values, + &loads_to_composites, 0); + } + } else if (!ReplaceComponentsOfInterfaceVarWith( + interface_var, users, scalar_interface_vars, + interface_var_component_indices, nullptr, &loads_to_composites, + &loads_for_access_chain_to_composites)) { + return false; + } + + ReplaceLoadWithCompositeConstruct(context(), loads_to_composites); + ReplaceLoadWithCompositeConstruct(context(), + loads_for_access_chain_to_composites); + + KillInstructionsAndUsers(users); + return true; +} + +void InterfaceVariableScalarReplacement::AddLocationAndComponentDecorations( + const NestedCompositeComponents& vars, uint32_t* location, + uint32_t component) { + if (!vars.HasMultipleComponents()) { + uint32_t var_id = vars.GetComponentVariable()->result_id(); + CreateDecoration(context()->get_decoration_mgr(), var_id, + SpvDecorationLocation, *location); + CreateDecoration(context()->get_decoration_mgr(), var_id, + SpvDecorationComponent, component); + ++(*location); + return; + } + for (const auto& var : vars.GetComponents()) { + AddLocationAndComponentDecorations(var, location, component); + } +} + +bool InterfaceVariableScalarReplacement::ReplaceComponentsOfInterfaceVarWith( + Instruction* interface_var, + const std::vector& interface_var_users, + const NestedCompositeComponents& scalar_interface_vars, + std::vector& interface_var_component_indices, + const uint32_t* extra_array_index, + std::unordered_map* loads_to_composites, + std::unordered_map* + loads_for_access_chain_to_composites) { + if (!scalar_interface_vars.HasMultipleComponents()) { + for (Instruction* interface_var_user : interface_var_users) { + if (!ReplaceComponentOfInterfaceVarWith( + interface_var, interface_var_user, + scalar_interface_vars.GetComponentVariable(), + interface_var_component_indices, extra_array_index, + loads_to_composites, loads_for_access_chain_to_composites)) { + return false; + } + } + return true; + } + return ReplaceMultipleComponentsOfInterfaceVarWith( + interface_var, interface_var_users, scalar_interface_vars.GetComponents(), + interface_var_component_indices, extra_array_index, loads_to_composites, + loads_for_access_chain_to_composites); +} + +bool InterfaceVariableScalarReplacement:: + ReplaceMultipleComponentsOfInterfaceVarWith( + Instruction* interface_var, + const std::vector& interface_var_users, + const std::vector& components, + std::vector& interface_var_component_indices, + const uint32_t* extra_array_index, + std::unordered_map* loads_to_composites, + std::unordered_map* + loads_for_access_chain_to_composites) { + for (uint32_t i = 0; i < components.size(); ++i) { + interface_var_component_indices.push_back(i); + std::unordered_map loads_to_component_values; + std::unordered_map + loads_for_access_chain_to_component_values; + if (!ReplaceComponentsOfInterfaceVarWith( + interface_var, interface_var_users, components[i], + interface_var_component_indices, extra_array_index, + &loads_to_component_values, + &loads_for_access_chain_to_component_values)) { + return false; + } + interface_var_component_indices.pop_back(); + + uint32_t depth_to_component = + static_cast(interface_var_component_indices.size()); + AddComponentsToCompositesForLoads( + loads_for_access_chain_to_component_values, + loads_for_access_chain_to_composites, depth_to_component); + if (extra_array_index) ++depth_to_component; + AddComponentsToCompositesForLoads(loads_to_component_values, + loads_to_composites, depth_to_component); + } + return true; +} + +bool InterfaceVariableScalarReplacement::ReplaceComponentOfInterfaceVarWith( + Instruction* interface_var, Instruction* interface_var_user, + Instruction* scalar_var, + const std::vector& interface_var_component_indices, + const uint32_t* extra_array_index, + std::unordered_map* loads_to_component_values, + std::unordered_map* + loads_for_access_chain_to_component_values) { + SpvOp opcode = interface_var_user->opcode(); + if (opcode == SpvOpStore) { + uint32_t value_id = interface_var_user->GetSingleWordInOperand(1); + StoreComponentOfValueToScalarVar(value_id, interface_var_component_indices, + scalar_var, extra_array_index, + interface_var_user); + return true; + } + if (opcode == SpvOpLoad) { + Instruction* scalar_load = + LoadScalarVar(scalar_var, extra_array_index, interface_var_user); + loads_to_component_values->insert({interface_var_user, scalar_load}); + return true; + } + + // Copy OpName and annotation instructions only once. Therefore, we create + // them only for the first element of the extra array. + if (extra_array_index && *extra_array_index != 0) return true; + + if (opcode == SpvOpDecorateId || opcode == SpvOpDecorateString || + opcode == SpvOpDecorate) { + CloneAnnotationForVariable(interface_var_user, scalar_var->result_id()); + return true; + } + + if (opcode == SpvOpName) { + std::unique_ptr new_inst(interface_var_user->Clone(context())); + new_inst->SetInOperand(0, {scalar_var->result_id()}); + context()->AddDebug2Inst(std::move(new_inst)); + return true; + } + + if (opcode == SpvOpEntryPoint) { + return ReplaceInterfaceVarInEntryPoint(interface_var, interface_var_user, + scalar_var->result_id()); + } + + if (opcode == SpvOpAccessChain) { + ReplaceAccessChainWith(interface_var_user, interface_var_component_indices, + scalar_var, + loads_for_access_chain_to_component_values); + return true; + } + + std::string message("Unhandled instruction"); + message += "\n " + interface_var_user->PrettyPrint( + SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES); + message += + "\nfor interface variable scalar replacement\n " + + interface_var->PrettyPrint(SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES); + context()->consumer()(SPV_MSG_ERROR, "", {0, 0, 0}, message.c_str()); + return false; +} + +void InterfaceVariableScalarReplacement::UseBaseAccessChainForAccessChain( + Instruction* access_chain, Instruction* base_access_chain) { + assert(base_access_chain->opcode() == SpvOpAccessChain && + access_chain->opcode() == SpvOpAccessChain && + access_chain->GetSingleWordInOperand(0) == + base_access_chain->result_id()); + Instruction::OperandList new_operands; + for (uint32_t i = 0; i < base_access_chain->NumInOperands(); ++i) { + new_operands.emplace_back(base_access_chain->GetInOperand(i)); + } + for (uint32_t i = 1; i < access_chain->NumInOperands(); ++i) { + new_operands.emplace_back(access_chain->GetInOperand(i)); + } + access_chain->SetInOperands(std::move(new_operands)); +} + +Instruction* InterfaceVariableScalarReplacement::CreateAccessChainToVar( + uint32_t var_type_id, Instruction* var, + const std::vector& index_ids, Instruction* insert_before, + uint32_t* component_type_id) { + analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr(); + *component_type_id = GetComponentTypeOfArrayMatrix( + def_use_mgr, var_type_id, static_cast(index_ids.size())); + + uint32_t ptr_type_id = + GetPointerType(*component_type_id, GetStorageClass(var)); + + std::unique_ptr new_access_chain( + new Instruction(context(), SpvOpAccessChain, ptr_type_id, TakeNextId(), + std::initializer_list{ + {SPV_OPERAND_TYPE_ID, {var->result_id()}}})); + for (uint32_t index_id : index_ids) { + new_access_chain->AddOperand({SPV_OPERAND_TYPE_ID, {index_id}}); + } + + Instruction* inst = new_access_chain.get(); + def_use_mgr->AnalyzeInstDefUse(inst); + insert_before->InsertBefore(std::move(new_access_chain)); + return inst; +} + +Instruction* InterfaceVariableScalarReplacement::CreateAccessChainWithIndex( + uint32_t component_type_id, Instruction* var, uint32_t index, + Instruction* insert_before) { + uint32_t ptr_type_id = + GetPointerType(component_type_id, GetStorageClass(var)); + uint32_t index_id = context()->get_constant_mgr()->GetUIntConst(index); + std::unique_ptr new_access_chain( + new Instruction(context(), SpvOpAccessChain, ptr_type_id, TakeNextId(), + std::initializer_list{ + {SPV_OPERAND_TYPE_ID, {var->result_id()}}, + {SPV_OPERAND_TYPE_ID, {index_id}}, + })); + Instruction* inst = new_access_chain.get(); + context()->get_def_use_mgr()->AnalyzeInstDefUse(inst); + insert_before->InsertBefore(std::move(new_access_chain)); + return inst; +} + +void InterfaceVariableScalarReplacement::ReplaceAccessChainWith( + Instruction* access_chain, + const std::vector& interface_var_component_indices, + Instruction* scalar_var, + std::unordered_map* loads_to_component_values) { + std::vector indexes; + for (uint32_t i = 1; i < access_chain->NumInOperands(); ++i) { + indexes.push_back(access_chain->GetSingleWordInOperand(i)); + } + + // Note that we have a strong assumption that |access_chain| has only a single + // index that is for the extra arrayness. + context()->get_def_use_mgr()->ForEachUser( + access_chain, + [this, access_chain, &indexes, &interface_var_component_indices, + scalar_var, loads_to_component_values](Instruction* user) { + switch (user->opcode()) { + case SpvOpAccessChain: { + UseBaseAccessChainForAccessChain(user, access_chain); + ReplaceAccessChainWith(user, interface_var_component_indices, + scalar_var, loads_to_component_values); + return; + } + case SpvOpStore: { + uint32_t value_id = user->GetSingleWordInOperand(1); + StoreComponentOfValueToAccessChainToScalarVar( + value_id, interface_var_component_indices, scalar_var, indexes, + user); + return; + } + case SpvOpLoad: { + Instruction* value = + LoadAccessChainToVar(scalar_var, indexes, user); + loads_to_component_values->insert({user, value}); + return; + } + default: + break; + } + }); +} + +void InterfaceVariableScalarReplacement::CloneAnnotationForVariable( + Instruction* annotation_inst, uint32_t var_id) { + assert(annotation_inst->opcode() == SpvOpDecorate || + annotation_inst->opcode() == SpvOpDecorateId || + annotation_inst->opcode() == SpvOpDecorateString); + std::unique_ptr new_inst(annotation_inst->Clone(context())); + new_inst->SetInOperand(0, {var_id}); + context()->AddAnnotationInst(std::move(new_inst)); +} + +bool InterfaceVariableScalarReplacement::ReplaceInterfaceVarInEntryPoint( + Instruction* interface_var, Instruction* entry_point, + uint32_t scalar_var_id) { + analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr(); + uint32_t interface_var_id = interface_var->result_id(); + if (interface_vars_removed_from_entry_point_operands_.find( + interface_var_id) != + interface_vars_removed_from_entry_point_operands_.end()) { + entry_point->AddOperand({SPV_OPERAND_TYPE_ID, {scalar_var_id}}); + def_use_mgr->AnalyzeInstUse(entry_point); + return true; + } + + bool success = !entry_point->WhileEachInId( + [&interface_var_id, &scalar_var_id](uint32_t* id) { + if (*id == interface_var_id) { + *id = scalar_var_id; + return false; + } + return true; + }); + if (!success) { + std::string message( + "interface variable is not an operand of the entry point"); + message += "\n " + interface_var->PrettyPrint( + SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES); + message += "\n " + entry_point->PrettyPrint( + SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES); + context()->consumer()(SPV_MSG_ERROR, "", {0, 0, 0}, message.c_str()); + return false; + } + + def_use_mgr->AnalyzeInstUse(entry_point); + interface_vars_removed_from_entry_point_operands_.insert(interface_var_id); + return true; +} + +uint32_t InterfaceVariableScalarReplacement::GetPointeeTypeIdOfVar( + Instruction* var) { + assert(var->opcode() == SpvOpVariable); + + uint32_t ptr_type_id = var->type_id(); + analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr(); + Instruction* ptr_type_inst = def_use_mgr->GetDef(ptr_type_id); + + assert(ptr_type_inst->opcode() == SpvOpTypePointer && + "Variable must have a pointer type."); + return ptr_type_inst->GetSingleWordInOperand(kOpTypePtrTypeInOperandIndex); +} + +void InterfaceVariableScalarReplacement::StoreComponentOfValueToScalarVar( + uint32_t value_id, const std::vector& component_indices, + Instruction* scalar_var, const uint32_t* extra_array_index, + Instruction* insert_before) { + uint32_t component_type_id = GetPointeeTypeIdOfVar(scalar_var); + Instruction* ptr = scalar_var; + if (extra_array_index) { + auto* ty_mgr = context()->get_type_mgr(); + analysis::Array* array_type = ty_mgr->GetType(component_type_id)->AsArray(); + assert(array_type != nullptr); + component_type_id = ty_mgr->GetTypeInstruction(array_type->element_type()); + ptr = CreateAccessChainWithIndex(component_type_id, scalar_var, + *extra_array_index, insert_before); + } + + StoreComponentOfValueTo(component_type_id, value_id, component_indices, ptr, + extra_array_index, insert_before); +} + +Instruction* InterfaceVariableScalarReplacement::LoadScalarVar( + Instruction* scalar_var, const uint32_t* extra_array_index, + Instruction* insert_before) { + uint32_t component_type_id = GetPointeeTypeIdOfVar(scalar_var); + Instruction* ptr = scalar_var; + if (extra_array_index) { + auto* ty_mgr = context()->get_type_mgr(); + analysis::Array* array_type = ty_mgr->GetType(component_type_id)->AsArray(); + assert(array_type != nullptr); + component_type_id = ty_mgr->GetTypeInstruction(array_type->element_type()); + ptr = CreateAccessChainWithIndex(component_type_id, scalar_var, + *extra_array_index, insert_before); + } + + return CreateLoad(component_type_id, ptr, insert_before); +} + +Instruction* InterfaceVariableScalarReplacement::CreateLoad( + uint32_t type_id, Instruction* ptr, Instruction* insert_before) { + std::unique_ptr load( + new Instruction(context(), SpvOpLoad, type_id, TakeNextId(), + std::initializer_list{ + {SPV_OPERAND_TYPE_ID, {ptr->result_id()}}})); + Instruction* load_inst = load.get(); + context()->get_def_use_mgr()->AnalyzeInstDefUse(load_inst); + insert_before->InsertBefore(std::move(load)); + return load_inst; +} + +void InterfaceVariableScalarReplacement::StoreComponentOfValueTo( + uint32_t component_type_id, uint32_t value_id, + const std::vector& component_indices, Instruction* ptr, + const uint32_t* extra_array_index, Instruction* insert_before) { + std::unique_ptr composite_extract(CreateCompositeExtract( + component_type_id, value_id, component_indices, extra_array_index)); + + std::unique_ptr new_store( + new Instruction(context(), SpvOpStore)); + new_store->AddOperand({SPV_OPERAND_TYPE_ID, {ptr->result_id()}}); + new_store->AddOperand( + {SPV_OPERAND_TYPE_ID, {composite_extract->result_id()}}); + + analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr(); + def_use_mgr->AnalyzeInstDefUse(composite_extract.get()); + def_use_mgr->AnalyzeInstDefUse(new_store.get()); + + insert_before->InsertBefore(std::move(composite_extract)); + insert_before->InsertBefore(std::move(new_store)); +} + +Instruction* InterfaceVariableScalarReplacement::CreateCompositeExtract( + uint32_t type_id, uint32_t composite_id, + const std::vector& indexes, const uint32_t* extra_first_index) { + uint32_t component_id = TakeNextId(); + Instruction* composite_extract = new Instruction( + context(), SpvOpCompositeExtract, type_id, component_id, + std::initializer_list{{SPV_OPERAND_TYPE_ID, {composite_id}}}); + if (extra_first_index) { + composite_extract->AddOperand( + {SPV_OPERAND_TYPE_LITERAL_INTEGER, {*extra_first_index}}); + } + for (uint32_t index : indexes) { + composite_extract->AddOperand({SPV_OPERAND_TYPE_LITERAL_INTEGER, {index}}); + } + return composite_extract; +} + +void InterfaceVariableScalarReplacement:: + StoreComponentOfValueToAccessChainToScalarVar( + uint32_t value_id, const std::vector& component_indices, + Instruction* scalar_var, + const std::vector& access_chain_indices, + Instruction* insert_before) { + uint32_t component_type_id = GetPointeeTypeIdOfVar(scalar_var); + Instruction* ptr = scalar_var; + if (!access_chain_indices.empty()) { + ptr = CreateAccessChainToVar(component_type_id, scalar_var, + access_chain_indices, insert_before, + &component_type_id); + } + + StoreComponentOfValueTo(component_type_id, value_id, component_indices, ptr, + nullptr, insert_before); +} + +Instruction* InterfaceVariableScalarReplacement::LoadAccessChainToVar( + Instruction* var, const std::vector& indexes, + Instruction* insert_before) { + uint32_t component_type_id = GetPointeeTypeIdOfVar(var); + Instruction* ptr = var; + if (!indexes.empty()) { + ptr = CreateAccessChainToVar(component_type_id, var, indexes, insert_before, + &component_type_id); + } + + return CreateLoad(component_type_id, ptr, insert_before); +} + +Instruction* +InterfaceVariableScalarReplacement::CreateCompositeConstructForComponentOfLoad( + Instruction* load, uint32_t depth_to_component) { + analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr(); + uint32_t type_id = load->type_id(); + if (depth_to_component != 0) { + type_id = GetComponentTypeOfArrayMatrix(def_use_mgr, load->type_id(), + depth_to_component); + } + uint32_t new_id = context()->TakeNextId(); + std::unique_ptr new_composite_construct( + new Instruction(context(), SpvOpCompositeConstruct, type_id, new_id, {})); + Instruction* composite_construct = new_composite_construct.get(); + def_use_mgr->AnalyzeInstDefUse(composite_construct); + + // Insert |new_composite_construct| after |load|. When there are multiple + // recursive composite construct instructions for a load, we have to place the + // composite construct with a lower depth later because it constructs the + // composite that contains other composites with lower depths. + auto* insert_before = load->NextNode(); + while (true) { + auto itr = + composite_ids_to_component_depths.find(insert_before->result_id()); + if (itr == composite_ids_to_component_depths.end()) break; + if (itr->second <= depth_to_component) break; + insert_before = insert_before->NextNode(); + } + insert_before->InsertBefore(std::move(new_composite_construct)); + composite_ids_to_component_depths.insert({new_id, depth_to_component}); + return composite_construct; +} + +void InterfaceVariableScalarReplacement::AddComponentsToCompositesForLoads( + const std::unordered_map& + loads_to_component_values, + std::unordered_map* loads_to_composites, + uint32_t depth_to_component) { + analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr(); + for (auto& load_and_component_vale : loads_to_component_values) { + Instruction* load = load_and_component_vale.first; + Instruction* component_value = load_and_component_vale.second; + Instruction* composite_construct = nullptr; + auto itr = loads_to_composites->find(load); + if (itr == loads_to_composites->end()) { + composite_construct = + CreateCompositeConstructForComponentOfLoad(load, depth_to_component); + loads_to_composites->insert({load, composite_construct}); + } else { + composite_construct = itr->second; + } + composite_construct->AddOperand( + {SPV_OPERAND_TYPE_ID, {component_value->result_id()}}); + def_use_mgr->AnalyzeInstDefUse(composite_construct); + } +} + +uint32_t InterfaceVariableScalarReplacement::GetArrayType( + uint32_t elem_type_id, uint32_t array_length) { + analysis::Type* elem_type = context()->get_type_mgr()->GetType(elem_type_id); + uint32_t array_length_id = + context()->get_constant_mgr()->GetUIntConst(array_length); + analysis::Array array_type( + elem_type, + analysis::Array::LengthInfo{array_length_id, {0, array_length}}); + return context()->get_type_mgr()->GetTypeInstruction(&array_type); +} + +uint32_t InterfaceVariableScalarReplacement::GetPointerType( + uint32_t type_id, SpvStorageClass storage_class) { + analysis::Type* type = context()->get_type_mgr()->GetType(type_id); + analysis::Pointer ptr_type(type, storage_class); + return context()->get_type_mgr()->GetTypeInstruction(&ptr_type); +} + +InterfaceVariableScalarReplacement::NestedCompositeComponents +InterfaceVariableScalarReplacement::CreateScalarInterfaceVarsForArray( + Instruction* interface_var_type, SpvStorageClass storage_class, + uint32_t extra_array_length) { + assert(interface_var_type->opcode() == SpvOpTypeArray); + + analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr(); + uint32_t array_length = GetArrayLength(def_use_mgr, interface_var_type); + Instruction* elem_type = GetArrayElementType(def_use_mgr, interface_var_type); + + NestedCompositeComponents scalar_vars; + while (array_length > 0) { + NestedCompositeComponents scalar_vars_for_element = + CreateScalarInterfaceVarsForReplacement(elem_type, storage_class, + extra_array_length); + scalar_vars.AddComponent(scalar_vars_for_element); + --array_length; + } + return scalar_vars; +} + +InterfaceVariableScalarReplacement::NestedCompositeComponents +InterfaceVariableScalarReplacement::CreateScalarInterfaceVarsForMatrix( + Instruction* interface_var_type, SpvStorageClass storage_class, + uint32_t extra_array_length) { + assert(interface_var_type->opcode() == SpvOpTypeMatrix); + + analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr(); + uint32_t column_count = interface_var_type->GetSingleWordInOperand( + kOpTypeMatrixColCountInOperandIndex); + Instruction* column_type = + GetMatrixColumnType(def_use_mgr, interface_var_type); + + NestedCompositeComponents scalar_vars; + while (column_count > 0) { + NestedCompositeComponents scalar_vars_for_column = + CreateScalarInterfaceVarsForReplacement(column_type, storage_class, + extra_array_length); + scalar_vars.AddComponent(scalar_vars_for_column); + --column_count; + } + return scalar_vars; +} + +InterfaceVariableScalarReplacement::NestedCompositeComponents +InterfaceVariableScalarReplacement::CreateScalarInterfaceVarsForReplacement( + Instruction* interface_var_type, SpvStorageClass storage_class, + uint32_t extra_array_length) { + // Handle array case. + if (interface_var_type->opcode() == SpvOpTypeArray) { + return CreateScalarInterfaceVarsForArray(interface_var_type, storage_class, + extra_array_length); + } + + // Handle matrix case. + if (interface_var_type->opcode() == SpvOpTypeMatrix) { + return CreateScalarInterfaceVarsForMatrix(interface_var_type, storage_class, + extra_array_length); + } + + // Handle scalar or vector case. + NestedCompositeComponents scalar_var; + uint32_t type_id = interface_var_type->result_id(); + if (extra_array_length != 0) { + type_id = GetArrayType(type_id, extra_array_length); + } + uint32_t ptr_type_id = + context()->get_type_mgr()->FindPointerToType(type_id, storage_class); + uint32_t id = TakeNextId(); + std::unique_ptr variable( + new Instruction(context(), SpvOpVariable, ptr_type_id, id, + std::initializer_list{ + {SPV_OPERAND_TYPE_STORAGE_CLASS, + {static_cast(storage_class)}}})); + scalar_var.SetSingleComponentVariable(variable.get()); + context()->AddGlobalValue(std::move(variable)); + return scalar_var; +} + +Instruction* InterfaceVariableScalarReplacement::GetTypeOfVariable( + Instruction* var) { + uint32_t pointee_type_id = GetPointeeTypeIdOfVar(var); + analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr(); + return def_use_mgr->GetDef(pointee_type_id); +} + +Pass::Status InterfaceVariableScalarReplacement::Process() { + Pass::Status status = Status::SuccessWithoutChange; + for (Instruction& entry_point : get_module()->entry_points()) { + status = + CombineStatus(status, ReplaceInterfaceVarsWithScalars(entry_point)); + } + return status; +} + +bool InterfaceVariableScalarReplacement:: + ReportErrorIfHasExtraArraynessForOtherEntry(Instruction* var) { + if (vars_with_extra_arrayness.find(var) == vars_with_extra_arrayness.end()) + return false; + + std::string message( + "A variable is arrayed for an entry point but it is not " + "arrayed for another entry point"); + message += + "\n " + var->PrettyPrint(SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES); + context()->consumer()(SPV_MSG_ERROR, "", {0, 0, 0}, message.c_str()); + return true; +} + +bool InterfaceVariableScalarReplacement:: + ReportErrorIfHasNoExtraArraynessForOtherEntry(Instruction* var) { + if (vars_without_extra_arrayness.find(var) == + vars_without_extra_arrayness.end()) + return false; + + std::string message( + "A variable is not arrayed for an entry point but it is " + "arrayed for another entry point"); + message += + "\n " + var->PrettyPrint(SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES); + context()->consumer()(SPV_MSG_ERROR, "", {0, 0, 0}, message.c_str()); + return true; +} + +Pass::Status +InterfaceVariableScalarReplacement::ReplaceInterfaceVarsWithScalars( + Instruction& entry_point) { + std::vector interface_vars = + CollectInterfaceVariables(entry_point); + + Pass::Status status = Status::SuccessWithoutChange; + for (Instruction* interface_var : interface_vars) { + uint32_t location, component; + if (!GetVariableLocation(interface_var, &location)) continue; + if (!GetVariableComponent(interface_var, &component)) component = 0; + + Instruction* interface_var_type = GetTypeOfVariable(interface_var); + uint32_t extra_array_length = 0; + if (HasExtraArrayness(entry_point, interface_var)) { + extra_array_length = + GetArrayLength(context()->get_def_use_mgr(), interface_var_type); + interface_var_type = + GetArrayElementType(context()->get_def_use_mgr(), interface_var_type); + vars_with_extra_arrayness.insert(interface_var); + } else { + vars_without_extra_arrayness.insert(interface_var); + } + + if (!CheckExtraArraynessConflictBetweenEntries(interface_var, + extra_array_length != 0)) { + return Pass::Status::Failure; + } + + if (interface_var_type->opcode() != SpvOpTypeArray && + interface_var_type->opcode() != SpvOpTypeMatrix) { + continue; + } + + if (!ReplaceInterfaceVariableWithScalars(interface_var, interface_var_type, + location, component, + extra_array_length)) { + return Pass::Status::Failure; + } + status = Pass::Status::SuccessWithChange; + } + + return status; +} + +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/interface_var_sroa.h b/third_party/spirv-tools/source/opt/interface_var_sroa.h new file mode 100644 index 0000000000..23baad0ad3 --- /dev/null +++ b/third_party/spirv-tools/source/opt/interface_var_sroa.h @@ -0,0 +1,401 @@ +// Copyright (c) 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef SOURCE_OPT_INTERFACE_VAR_SROA_H_ +#define SOURCE_OPT_INTERFACE_VAR_SROA_H_ + +#include + +#include "source/opt/pass.h" + +namespace spvtools { +namespace opt { + +// See optimizer.hpp for documentation. +// +// Note that the current implementation of this pass covers only store, load, +// access chain instructions for the interface variables. Supporting other types +// of instructions is a future work. +class InterfaceVariableScalarReplacement : public Pass { + public: + InterfaceVariableScalarReplacement() {} + + const char* name() const override { + return "interface-variable-scalar-replacement"; + } + Status Process() override; + + IRContext::Analysis GetPreservedAnalyses() override { + return IRContext::kAnalysisDecorations | IRContext::kAnalysisDefUse | + IRContext::kAnalysisConstants | IRContext::kAnalysisTypes; + } + + private: + // A struct containing components of a composite variable. If the composite + // consists of multiple or recursive components, |component_variable| is + // nullptr and |nested_composite_components| keeps the components. If it has a + // single component, |nested_composite_components| is empty and + // |component_variable| is the component. Note that each element of + // |nested_composite_components| has the NestedCompositeComponents struct as + // its type that can recursively keep the components. + struct NestedCompositeComponents { + NestedCompositeComponents() : component_variable(nullptr) {} + + bool HasMultipleComponents() const { + return !nested_composite_components.empty(); + } + + const std::vector& GetComponents() const { + return nested_composite_components; + } + + void AddComponent(const NestedCompositeComponents& component) { + nested_composite_components.push_back(component); + } + + Instruction* GetComponentVariable() const { return component_variable; } + + void SetSingleComponentVariable(Instruction* var) { + component_variable = var; + } + + private: + std::vector nested_composite_components; + Instruction* component_variable; + }; + + // Collects all interface variables used by the |entry_point|. + std::vector CollectInterfaceVariables(Instruction& entry_point); + + // Returns whether |var| has the extra arrayness for the entry point + // |entry_point| or not. + bool HasExtraArrayness(Instruction& entry_point, Instruction* var); + + // Finds a Location BuiltIn decoration of |var| and returns it via + // |location|. Returns true whether the location exists or not. + bool GetVariableLocation(Instruction* var, uint32_t* location); + + // Finds a Component BuiltIn decoration of |var| and returns it via + // |component|. Returns true whether the component exists or not. + bool GetVariableComponent(Instruction* var, uint32_t* component); + + // Returns the interface variable instruction whose result id is + // |interface_var_id|. + Instruction* GetInterfaceVariable(uint32_t interface_var_id); + + // Returns the type of |var| as an instruction. + Instruction* GetTypeOfVariable(Instruction* var); + + // Replaces an interface variable |interface_var| whose type is + // |interface_var_type| with scalars and returns whether it succeeds or not. + // |location| is the value of Location Decoration for |interface_var|. + // |component| is the value of Component Decoration for |interface_var|. + // If |extra_array_length| is 0, it means |interface_var| has a Patch + // decoration. Otherwise, |extra_array_length| denotes the length of the extra + // array of |interface_var|. + bool ReplaceInterfaceVariableWithScalars(Instruction* interface_var, + Instruction* interface_var_type, + uint32_t location, + uint32_t component, + uint32_t extra_array_length); + + // Creates scalar variables with the storage classe |storage_class| to replace + // an interface variable whose type is |interface_var_type|. If + // |extra_array_length| is not zero, adds the extra arrayness to the created + // scalar variables. + NestedCompositeComponents CreateScalarInterfaceVarsForReplacement( + Instruction* interface_var_type, SpvStorageClass storage_class, + uint32_t extra_array_length); + + // Creates scalar variables with the storage classe |storage_class| to replace + // the interface variable whose type is OpTypeArray |interface_var_type| with. + // If |extra_array_length| is not zero, adds the extra arrayness to all the + // scalar variables. + NestedCompositeComponents CreateScalarInterfaceVarsForArray( + Instruction* interface_var_type, SpvStorageClass storage_class, + uint32_t extra_array_length); + + // Creates scalar variables with the storage classe |storage_class| to replace + // the interface variable whose type is OpTypeMatrix |interface_var_type| + // with. If |extra_array_length| is not zero, adds the extra arrayness to all + // the scalar variables. + NestedCompositeComponents CreateScalarInterfaceVarsForMatrix( + Instruction* interface_var_type, SpvStorageClass storage_class, + uint32_t extra_array_length); + + // Recursively adds Location and Component decorations to variables in + // |vars| with |location| and |component|. Increases |location| by one after + // it actually adds Location and Component decorations for a variable. + void AddLocationAndComponentDecorations(const NestedCompositeComponents& vars, + uint32_t* location, + uint32_t component); + + // Replaces the interface variable |interface_var| with + // |scalar_interface_vars| and returns whether it succeeds or not. + // |extra_arrayness| is the extra arrayness of the interface variable. + // |scalar_interface_vars| contains the nested variables to replace the + // interface variable with. + bool ReplaceInterfaceVarWith( + Instruction* interface_var, uint32_t extra_arrayness, + const NestedCompositeComponents& scalar_interface_vars); + + // Replaces |interface_var| in the operands of instructions + // |interface_var_users| with |scalar_interface_vars|. This is a recursive + // method and |interface_var_component_indices| is used to specify which + // recursive component of |interface_var| is replaced. Returns composite + // construct instructions to be replaced with load instructions of + // |interface_var_users| via |loads_to_composites|. Returns composite + // construct instructions to be replaced with load instructions of access + // chain instructions in |interface_var_users| via + // |loads_for_access_chain_to_composites|. + bool ReplaceComponentsOfInterfaceVarWith( + Instruction* interface_var, + const std::vector& interface_var_users, + const NestedCompositeComponents& scalar_interface_vars, + std::vector& interface_var_component_indices, + const uint32_t* extra_array_index, + std::unordered_map* loads_to_composites, + std::unordered_map* + loads_for_access_chain_to_composites); + + // Replaces |interface_var| in the operands of instructions + // |interface_var_users| with |components| that is a vector of components for + // the interface variable |interface_var|. This is a recursive method and + // |interface_var_component_indices| is used to specify which recursive + // component of |interface_var| is replaced. Returns composite construct + // instructions to be replaced with load instructions of |interface_var_users| + // via |loads_to_composites|. Returns composite construct instructions to be + // replaced with load instructions of access chain instructions in + // |interface_var_users| via |loads_for_access_chain_to_composites|. + bool ReplaceMultipleComponentsOfInterfaceVarWith( + Instruction* interface_var, + const std::vector& interface_var_users, + const std::vector& components, + std::vector& interface_var_component_indices, + const uint32_t* extra_array_index, + std::unordered_map* loads_to_composites, + std::unordered_map* + loads_for_access_chain_to_composites); + + // Replaces a component of |interface_var| that is used as an operand of + // instruction |interface_var_user| with |scalar_var|. + // |interface_var_component_indices| is a vector of recursive indices for + // which recursive component of |interface_var| is replaced. If + // |interface_var_user| is a load, returns the component value via + // |loads_to_component_values|. If |interface_var_user| is an access chain, + // returns the component value for loads of |interface_var_user| via + // |loads_for_access_chain_to_component_values|. + bool ReplaceComponentOfInterfaceVarWith( + Instruction* interface_var, Instruction* interface_var_user, + Instruction* scalar_var, + const std::vector& interface_var_component_indices, + const uint32_t* extra_array_index, + std::unordered_map* loads_to_component_values, + std::unordered_map* + loads_for_access_chain_to_component_values); + + // Creates instructions to load |scalar_var| and inserts them before + // |insert_before|. If |extra_array_index| is not null, they load + // |extra_array_index| th component of |scalar_var| instead of |scalar_var| + // itself. + Instruction* LoadScalarVar(Instruction* scalar_var, + const uint32_t* extra_array_index, + Instruction* insert_before); + + // Creates instructions to load an access chain to |var| and inserts them + // before |insert_before|. |Indexes| will be Indexes operand of the access + // chain. + Instruction* LoadAccessChainToVar(Instruction* var, + const std::vector& indexes, + Instruction* insert_before); + + // Creates instructions to store a component of an aggregate whose id is + // |value_id| to an access chain to |scalar_var| and inserts the created + // instructions before |insert_before|. To get the component, recursively + // traverses the aggregate with |component_indices| as indexes. + // Numbers in |access_chain_indices| are the Indexes operand of the access + // chain to |scalar_var| + void StoreComponentOfValueToAccessChainToScalarVar( + uint32_t value_id, const std::vector& component_indices, + Instruction* scalar_var, + const std::vector& access_chain_indices, + Instruction* insert_before); + + // Creates instructions to store a component of an aggregate whose id is + // |value_id| to |scalar_var| and inserts the created instructions before + // |insert_before|. To get the component, recursively traverses the aggregate + // using |extra_array_index| and |component_indices| as indexes. + void StoreComponentOfValueToScalarVar( + uint32_t value_id, const std::vector& component_indices, + Instruction* scalar_var, const uint32_t* extra_array_index, + Instruction* insert_before); + + // Creates instructions to store a component of an aggregate whose id is + // |value_id| to |ptr| and inserts the created instructions before + // |insert_before|. To get the component, recursively traverses the aggregate + // using |extra_array_index| and |component_indices| as indexes. + // |component_type_id| is the id of the type instruction of the component. + void StoreComponentOfValueTo(uint32_t component_type_id, uint32_t value_id, + const std::vector& component_indices, + Instruction* ptr, + const uint32_t* extra_array_index, + Instruction* insert_before); + + // Creates new OpCompositeExtract with |type_id| for Result Type, + // |composite_id| for Composite operand, and |indexes| for Indexes operands. + // If |extra_first_index| is not nullptr, uses it as the first Indexes + // operand. + Instruction* CreateCompositeExtract(uint32_t type_id, uint32_t composite_id, + const std::vector& indexes, + const uint32_t* extra_first_index); + + // Creates a new OpLoad whose Result Type is |type_id| and Pointer operand is + // |ptr|. Inserts the new instruction before |insert_before|. + Instruction* CreateLoad(uint32_t type_id, Instruction* ptr, + Instruction* insert_before); + + // Clones an annotation instruction |annotation_inst| and sets the target + // operand of the new annotation instruction as |var_id|. + void CloneAnnotationForVariable(Instruction* annotation_inst, + uint32_t var_id); + + // Replaces the interface variable |interface_var| in the operands of the + // entry point |entry_point| with |scalar_var_id|. If it cannot find + // |interface_var| from the operands of the entry point |entry_point|, adds + // |scalar_var_id| as an operand of the entry point |entry_point|. + bool ReplaceInterfaceVarInEntryPoint(Instruction* interface_var, + Instruction* entry_point, + uint32_t scalar_var_id); + + // Creates an access chain instruction whose Base operand is |var| and Indexes + // operand is |index|. |component_type_id| is the id of the type instruction + // that is the type of component. Inserts the new access chain before + // |insert_before|. + Instruction* CreateAccessChainWithIndex(uint32_t component_type_id, + Instruction* var, uint32_t index, + Instruction* insert_before); + + // Returns the pointee type of the type of variable |var|. + uint32_t GetPointeeTypeIdOfVar(Instruction* var); + + // Replaces the access chain |access_chain| and its users with a new access + // chain that points |scalar_var| as the Base operand having + // |interface_var_component_indices| as Indexes operands and users of the new + // access chain. When some of the users are load instructions, returns the + // original load instruction to the new instruction that loads a component of + // the original load value via |loads_to_component_values|. + void ReplaceAccessChainWith( + Instruction* access_chain, + const std::vector& interface_var_component_indices, + Instruction* scalar_var, + std::unordered_map* + loads_to_component_values); + + // Assuming that |access_chain| is an access chain instruction whose Base + // operand is |base_access_chain|, replaces the operands of |access_chain| + // with operands of |base_access_chain| and Indexes operands of + // |access_chain|. + void UseBaseAccessChainForAccessChain(Instruction* access_chain, + Instruction* base_access_chain); + + // Creates composite construct instructions for load instructions that are the + // keys of |loads_to_component_values| if no such composite construct + // instructions exist. Adds a component of the composite as an operand of the + // created composite construct instruction. Each value of + // |loads_to_component_values| is the component. Returns the created composite + // construct instructions using |loads_to_composites|. |depth_to_component| is + // the number of recursive access steps to get the component from the + // composite. + void AddComponentsToCompositesForLoads( + const std::unordered_map& + loads_to_component_values, + std::unordered_map* loads_to_composites, + uint32_t depth_to_component); + + // Creates a composite construct instruction for a component of the value of + // instruction |load| in |depth_to_component| th recursive depth and inserts + // it after |load|. + Instruction* CreateCompositeConstructForComponentOfLoad( + Instruction* load, uint32_t depth_to_component); + + // Creates a new access chain instruction that points to variable |var| whose + // type is the instruction with |var_type_id| and inserts it before + // |insert_before|. The new access chain will have |index_ids| for Indexes + // operands. Returns the type id of the component that is pointed by the new + // access chain via |component_type_id|. + Instruction* CreateAccessChainToVar(uint32_t var_type_id, Instruction* var, + const std::vector& index_ids, + Instruction* insert_before, + uint32_t* component_type_id); + + // Returns the result id of OpTypeArray instrunction whose Element Type + // operand is |elem_type_id| and Length operand is |array_length|. + uint32_t GetArrayType(uint32_t elem_type_id, uint32_t array_length); + + // Returns the result id of OpTypePointer instrunction whose Type + // operand is |type_id| and Storage Class operand is |storage_class|. + uint32_t GetPointerType(uint32_t type_id, SpvStorageClass storage_class); + + // Kills an instrunction |inst| and its users. + void KillInstructionAndUsers(Instruction* inst); + + // Kills a vector of instrunctions |insts| and their users. + void KillInstructionsAndUsers(const std::vector& insts); + + // Kills all OpDecorate instructions for Location and Component of the + // variable whose id is |var_id|. + void KillLocationAndComponentDecorations(uint32_t var_id); + + // If |var| has the extra arrayness for an entry point, reports an error and + // returns true. Otherwise, returns false. + bool ReportErrorIfHasExtraArraynessForOtherEntry(Instruction* var); + + // If |var| does not have the extra arrayness for an entry point, reports an + // error and returns true. Otherwise, returns false. + bool ReportErrorIfHasNoExtraArraynessForOtherEntry(Instruction* var); + + // If |interface_var| has the extra arrayness for an entry point but it does + // not have one for another entry point, reports an error and returns false. + // Otherwise, returns true. |has_extra_arrayness| denotes whether it has an + // extra arrayness for an entry point or not. + bool CheckExtraArraynessConflictBetweenEntries(Instruction* interface_var, + bool has_extra_arrayness); + + // Conducts the scalar replacement for the interface variables used by the + // |entry_point|. + Pass::Status ReplaceInterfaceVarsWithScalars(Instruction& entry_point); + + // A set of interface variable ids that were already removed from operands of + // the entry point. + std::unordered_set + interface_vars_removed_from_entry_point_operands_; + + // A mapping from ids of new composite construct instructions that load + // instructions are replaced with to the recursive depth of the component of + // load that the new component construct instruction is used for. + std::unordered_map composite_ids_to_component_depths; + + // A set of interface variables with the extra arrayness for any of the entry + // points. + std::unordered_set vars_with_extra_arrayness; + + // A set of interface variables without the extra arrayness for any of the + // entry points. + std::unordered_set vars_without_extra_arrayness; +}; + +} // namespace opt +} // namespace spvtools + +#endif // SOURCE_OPT_INTERFACE_VAR_SROA_H_ diff --git a/third_party/spirv-tools/source/opt/interp_fixup_pass.cpp b/third_party/spirv-tools/source/opt/interp_fixup_pass.cpp index ad29e6a720..e8cdd99f1c 100644 --- a/third_party/spirv-tools/source/opt/interp_fixup_pass.cpp +++ b/third_party/spirv-tools/source/opt/interp_fixup_pass.cpp @@ -31,13 +31,6 @@ namespace { // Input Operand Indices static const int kSpvVariableStorageClassInIdx = 0; -// Avoid unused variable warning/error on Linux -#ifndef NDEBUG -#define USE_ASSERT(x) assert(x) -#else -#define USE_ASSERT(x) ((void)(x)) -#endif - // Folding rule function which attempts to replace |op(OpLoad(a),...)| // by |op(a,...)|, where |op| is one of the GLSLstd450 InterpolateAt* // instructions. Returns true if replaced, false otherwise. diff --git a/third_party/spirv-tools/source/opt/ir_builder.h b/third_party/spirv-tools/source/opt/ir_builder.h index 4433cf0d15..9d4fa8fe3d 100644 --- a/third_party/spirv-tools/source/opt/ir_builder.h +++ b/third_party/spirv-tools/source/opt/ir_builder.h @@ -487,6 +487,15 @@ class InstructionBuilder { return AddInstruction(std::move(new_inst)); } + Instruction* AddVariable(uint32_t type_id, uint32_t storage_class) { + std::vector operands; + operands.push_back({SPV_OPERAND_TYPE_ID, {storage_class}}); + std::unique_ptr new_inst( + new Instruction(GetContext(), SpvOpVariable, type_id, + GetContext()->TakeNextId(), operands)); + return AddInstruction(std::move(new_inst)); + } + Instruction* AddStore(uint32_t ptr_id, uint32_t obj_id) { std::vector operands; operands.push_back({SPV_OPERAND_TYPE_ID, {ptr_id}}); diff --git a/third_party/spirv-tools/source/opt/ir_context.cpp b/third_party/spirv-tools/source/opt/ir_context.cpp index 612a831add..c9c3f1b5dc 100644 --- a/third_party/spirv-tools/source/opt/ir_context.cpp +++ b/third_party/spirv-tools/source/opt/ir_context.cpp @@ -41,6 +41,8 @@ namespace spvtools { namespace opt { void IRContext::BuildInvalidAnalyses(IRContext::Analysis set) { + set = Analysis(set & ~valid_analyses_); + if (set & kAnalysisDefUse) { BuildDefUseManager(); } @@ -106,7 +108,7 @@ void IRContext::InvalidateAnalyses(IRContext::Analysis analyses_to_invalidate) { analyses_to_invalidate |= kAnalysisDebugInfo; } - // The dominator analysis hold the psuedo entry and exit nodes from the CFG. + // The dominator analysis hold the pseudo entry and exit nodes from the CFG. // Also if the CFG change the dominators many changed as well, so the // dominator analysis should be invalidated as well. if (analyses_to_invalidate & kAnalysisCFG) { @@ -317,7 +319,7 @@ bool IRContext::IsConsistent() { #else if (AreAnalysesValid(kAnalysisDefUse)) { analysis::DefUseManager new_def_use(module()); - if (*get_def_use_mgr() != new_def_use) { + if (!CompareAndPrintDifferences(*get_def_use_mgr(), new_def_use)) { return false; } } @@ -623,9 +625,8 @@ void IRContext::AddCombinatorsForCapability(uint32_t capability) { void IRContext::AddCombinatorsForExtension(Instruction* extension) { assert(extension->opcode() == SpvOpExtInstImport && "Expecting an import of an extension's instruction set."); - const char* extension_name = - reinterpret_cast(&extension->GetInOperand(0).words[0]); - if (!strcmp(extension_name, "GLSL.std.450")) { + const std::string extension_name = extension->GetInOperand(0).AsString(); + if (extension_name == "GLSL.std.450") { combinator_ops_[extension->result_id()] = {GLSLstd450Round, GLSLstd450RoundEven, GLSLstd450Trunc, @@ -925,6 +926,19 @@ bool IRContext::ProcessCallTreeFromRoots(ProcessFunction& pfn, return modified; } +void IRContext::CollectCallTreeFromRoots(unsigned entryId, + std::unordered_set* funcs) { + std::queue roots; + roots.push(entryId); + while (!roots.empty()) { + const uint32_t fi = roots.front(); + roots.pop(); + funcs->insert(fi); + Function* fn = GetFunction(fi); + AddCalls(fn, &roots); + } +} + void IRContext::EmitErrorMessage(std::string message, Instruction* inst) { if (!consumer()) { return; @@ -944,11 +958,11 @@ void IRContext::EmitErrorMessage(std::string message, Instruction* inst) { uint32_t line_number = 0; uint32_t col_number = 0; - char* source = nullptr; + std::string source; if (line_inst != nullptr) { Instruction* file_name = get_def_use_mgr()->GetDef(line_inst->GetSingleWordInOperand(0)); - source = reinterpret_cast(&file_name->GetInOperand(0).words[0]); + source = file_name->GetInOperand(0).AsString(); // Get the line number and column number. line_number = line_inst->GetSingleWordInOperand(1); @@ -957,7 +971,7 @@ void IRContext::EmitErrorMessage(std::string message, Instruction* inst) { message += "\n " + inst->PrettyPrint(SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES); - consumer()(SPV_MSG_ERROR, source, {line_number, col_number, 0}, + consumer()(SPV_MSG_ERROR, source.c_str(), {line_number, col_number, 0}, message.c_str()); } diff --git a/third_party/spirv-tools/source/opt/ir_context.h b/third_party/spirv-tools/source/opt/ir_context.h index 658534760d..2f27942b4c 100644 --- a/third_party/spirv-tools/source/opt/ir_context.h +++ b/third_party/spirv-tools/source/opt/ir_context.h @@ -43,6 +43,7 @@ #include "source/opt/type_manager.h" #include "source/opt/value_number_table.h" #include "source/util/make_unique.h" +#include "source/util/string_utils.h" namespace spvtools { namespace opt { @@ -301,7 +302,7 @@ class IRContext { } } - // Returns a pointer the decoration manager. If the decoration manger is + // Returns a pointer the decoration manager. If the decoration manager is // invalid, it is rebuilt first. analysis::DecorationManager* get_decoration_mgr() { if (!AreAnalysesValid(kAnalysisDecorations)) { @@ -384,7 +385,7 @@ class IRContext { // Deletes the instruction defining the given |id|. Returns true on // success, false if the given |id| is not defined at all. This method also - // erases the name, decorations, and defintion of |id|. + // erases the name, decorations, and definition of |id|. // // Pointers and iterators pointing to the deleted instructions become invalid. // However other pointers and iterators are still valid. @@ -410,6 +411,10 @@ class IRContext { void CollectNonSemanticTree(Instruction* inst, std::unordered_set* to_kill); + // Collect function reachable from |entryId|, returns |funcs| + void CollectCallTreeFromRoots(unsigned entryId, + std::unordered_set* funcs); + // Returns true if all of the given analyses are valid. bool AreAnalysesValid(Analysis set) { return (set & valid_analyses_) == set; } @@ -518,6 +523,18 @@ class IRContext { std::string message = "ID overflow. Try running compact-ids."; consumer()(SPV_MSG_ERROR, "", {0, 0, 0}, message.c_str()); } +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + // If TakeNextId returns 0, it is very likely that execution will + // subsequently fail. Such failures are false alarms from a fuzzing point + // of view: they are due to the fact that too many ids were used, rather + // than being due to an actual bug. Thus, during a fuzzing build, it is + // preferable to bail out when ID overflow occurs. + // + // A zero exit code is returned here because a non-zero code would cause + // ClusterFuzz/OSS-Fuzz to regard the termination as a crash, and spurious + // crash reports is what this guard aims to avoid. + exit(0); +#endif } return next_id; } @@ -789,7 +806,7 @@ class IRContext { // iterators to traverse instructions. std::unordered_map id_to_func_; - // A bitset indicating which analyes are currently valid. + // A bitset indicating which analyzes are currently valid. Analysis valid_analyses_; // Opcodes of shader capability core executable instructions @@ -854,8 +871,7 @@ inline IRContext::Analysis operator|(IRContext::Analysis lhs, inline IRContext::Analysis& operator|=(IRContext::Analysis& lhs, IRContext::Analysis rhs) { - lhs = static_cast(static_cast(lhs) | - static_cast(rhs)); + lhs = lhs | rhs; return lhs; } @@ -1020,11 +1036,7 @@ void IRContext::AddCapability(std::unique_ptr&& c) { } void IRContext::AddExtension(const std::string& ext_name) { - const auto num_chars = ext_name.size(); - // Compute num words, accommodate the terminating null character. - const auto num_words = (num_chars + 1 + 3) / 4; - std::vector ext_words(num_words, 0u); - std::memcpy(ext_words.data(), ext_name.data(), num_chars); + std::vector ext_words = spvtools::utils::MakeVector(ext_name); AddExtension(std::unique_ptr( new Instruction(this, SpvOpExtension, 0u, 0u, {{SPV_OPERAND_TYPE_LITERAL_STRING, ext_words}}))); @@ -1041,11 +1053,7 @@ void IRContext::AddExtension(std::unique_ptr&& e) { } void IRContext::AddExtInstImport(const std::string& name) { - const auto num_chars = name.size(); - // Compute num words, accommodate the terminating null character. - const auto num_words = (num_chars + 1 + 3) / 4; - std::vector ext_words(num_words, 0u); - std::memcpy(ext_words.data(), name.data(), num_chars); + std::vector ext_words = spvtools::utils::MakeVector(name); AddExtInstImport(std::unique_ptr( new Instruction(this, SpvOpExtInstImport, 0u, TakeNextId(), {{SPV_OPERAND_TYPE_LITERAL_STRING, ext_words}}))); @@ -1086,6 +1094,9 @@ void IRContext::AddDebug2Inst(std::unique_ptr&& d) { id_to_name_->insert({d->GetSingleWordInOperand(0), d.get()}); } } + if (AreAnalysesValid(kAnalysisDefUse)) { + get_def_use_mgr()->AnalyzeInstDefUse(d.get()); + } module()->AddDebug2Inst(std::move(d)); } diff --git a/third_party/spirv-tools/source/opt/ir_loader.cpp b/third_party/spirv-tools/source/opt/ir_loader.cpp index a82b530e6c..97db9d8f7f 100644 --- a/third_party/spirv-tools/source/opt/ir_loader.cpp +++ b/third_party/spirv-tools/source/opt/ir_loader.cpp @@ -189,7 +189,8 @@ bool IrLoader::AddInstruction(const spv_parsed_instruction_t* inst) { module_->SetMemoryModel(std::move(spv_inst)); } else if (opcode == SpvOpEntryPoint) { module_->AddEntryPoint(std::move(spv_inst)); - } else if (opcode == SpvOpExecutionMode) { + } else if (opcode == SpvOpExecutionMode || + opcode == SpvOpExecutionModeId) { module_->AddExecutionMode(std::move(spv_inst)); } else if (IsDebug1Inst(opcode)) { module_->AddDebug1Inst(std::move(spv_inst)); diff --git a/third_party/spirv-tools/source/opt/local_access_chain_convert_pass.cpp b/third_party/spirv-tools/source/opt/local_access_chain_convert_pass.cpp index da9ba8cc01..da4cac3790 100644 --- a/third_party/spirv-tools/source/opt/local_access_chain_convert_pass.cpp +++ b/third_party/spirv-tools/source/opt/local_access_chain_convert_pass.cpp @@ -19,6 +19,7 @@ #include "ir_builder.h" #include "ir_context.h" #include "iterator.h" +#include "source/util/string_utils.h" namespace spvtools { namespace opt { @@ -27,8 +28,6 @@ namespace { const uint32_t kStoreValIdInIdx = 1; const uint32_t kAccessChainPtrIdInIdx = 0; -const uint32_t kConstantValueInIdx = 0; -const uint32_t kTypeIntWidthInIdx = 0; } // anonymous namespace @@ -66,7 +65,19 @@ void LocalAccessChainConvertPass::AppendConstantOperands( ptrInst->ForEachInId([&iidIdx, &in_opnds, this](const uint32_t* iid) { if (iidIdx > 0) { const Instruction* cInst = get_def_use_mgr()->GetDef(*iid); - uint32_t val = cInst->GetSingleWordInOperand(kConstantValueInIdx); + const auto* constant_value = + context()->get_constant_mgr()->GetConstantFromInst(cInst); + assert(constant_value != nullptr && + "Expecting the index to be a constant."); + + // We take the sign extended value because OpAccessChain interprets the + // index as signed. + int64_t long_value = constant_value->GetSignExtendedValue(); + assert(long_value <= UINT32_MAX && long_value >= 0 && + "The index value is too large for a composite insert or extract " + "instruction."); + + uint32_t val = static_cast(long_value); in_opnds->push_back( {spv_operand_type_t::SPV_OPERAND_TYPE_LITERAL_INTEGER, {val}}); } @@ -168,13 +179,16 @@ bool LocalAccessChainConvertPass::GenAccessChainStoreReplacement( return true; } -bool LocalAccessChainConvertPass::IsConstantIndexAccessChain( +bool LocalAccessChainConvertPass::Is32BitConstantIndexAccessChain( const Instruction* acp) const { uint32_t inIdx = 0; return acp->WhileEachInId([&inIdx, this](const uint32_t* tid) { if (inIdx > 0) { Instruction* opInst = get_def_use_mgr()->GetDef(*tid); if (opInst->opcode() != SpvOpConstant) return false; + const auto* index = + context()->get_constant_mgr()->GetConstantFromInst(opInst); + if (index->GetSignExtendedValue() > UINT32_MAX) return false; } ++inIdx; return true; @@ -230,7 +244,7 @@ void LocalAccessChainConvertPass::FindTargetVars(Function* func) { break; } // Rule out variables accessed with non-constant indices - if (!IsConstantIndexAccessChain(ptrInst)) { + if (!Is32BitConstantIndexAccessChain(ptrInst)) { seen_non_target_vars_.insert(varId); seen_target_vars_.erase(varId); break; @@ -328,8 +342,7 @@ bool LocalAccessChainConvertPass::AllExtensionsSupported() const { return false; // If any extension not in allowlist, return false for (auto& ei : get_module()->extensions()) { - const char* extName = - reinterpret_cast(&ei.GetInOperand(0).words[0]); + const std::string extName = ei.GetInOperand(0).AsString(); if (extensions_allowlist_.find(extName) == extensions_allowlist_.end()) return false; } @@ -339,11 +352,9 @@ bool LocalAccessChainConvertPass::AllExtensionsSupported() const { for (auto& inst : context()->module()->ext_inst_imports()) { assert(inst.opcode() == SpvOpExtInstImport && "Expecting an import of an extension's instruction set."); - const char* extension_name = - reinterpret_cast(&inst.GetInOperand(0).words[0]); - if (0 == std::strncmp(extension_name, "NonSemantic.", 12) && - 0 != std::strncmp(extension_name, "NonSemantic.Shader.DebugInfo.100", - 32)) { + const std::string extension_name = inst.GetInOperand(0).AsString(); + if (spvtools::utils::starts_with(extension_name, "NonSemantic.") && + extension_name != "NonSemantic.Shader.DebugInfo.100") { return false; } } @@ -351,12 +362,6 @@ bool LocalAccessChainConvertPass::AllExtensionsSupported() const { } Pass::Status LocalAccessChainConvertPass::ProcessImpl() { - // If non-32-bit integer type in module, terminate processing - // TODO(): Handle non-32-bit integer constants in access chains - for (const Instruction& inst : get_module()->types_values()) - if (inst.opcode() == SpvOpTypeInt && - inst.GetSingleWordInOperand(kTypeIntWidthInIdx) != 32) - return Status::SuccessWithoutChange; // Do not process if module contains OpGroupDecorate. Additional // support required in KillNamesAndDecorates(). // TODO(greg-lunarg): Add support for OpGroupDecorate @@ -436,6 +441,8 @@ void LocalAccessChainConvertPass::InitExtensions() { "SPV_KHR_integer_dot_product", "SPV_EXT_shader_image_int64", "SPV_KHR_non_semantic_info", + "SPV_KHR_uniform_group_instructions", + "SPV_KHR_fragment_shader_barycentric", }); } diff --git a/third_party/spirv-tools/source/opt/local_access_chain_convert_pass.h b/third_party/spirv-tools/source/opt/local_access_chain_convert_pass.h index 552062e52f..8548e164a0 100644 --- a/third_party/spirv-tools/source/opt/local_access_chain_convert_pass.h +++ b/third_party/spirv-tools/source/opt/local_access_chain_convert_pass.h @@ -81,7 +81,7 @@ class LocalAccessChainConvertPass : public MemPass { std::vector* in_opnds); // Create a load/insert/store equivalent to a store of - // |valId| through (constant index) access chaing |ptrInst|. + // |valId| through (constant index) access chain |ptrInst|. // Append to |newInsts|. Returns true if successful. bool GenAccessChainStoreReplacement( const Instruction* ptrInst, uint32_t valId, @@ -95,7 +95,8 @@ class LocalAccessChainConvertPass : public MemPass { Instruction* original_load); // Return true if all indices of access chain |acp| are OpConstant integers - bool IsConstantIndexAccessChain(const Instruction* acp) const; + // whose values can fit into an unsigned 32-bit value. + bool Is32BitConstantIndexAccessChain(const Instruction* acp) const; // Identify all function scope variables of target type which are // accessed only with loads, stores and access chains with constant diff --git a/third_party/spirv-tools/source/opt/local_single_block_elim_pass.cpp b/third_party/spirv-tools/source/opt/local_single_block_elim_pass.cpp index 5fd4f658d4..a58e8e4cc7 100644 --- a/third_party/spirv-tools/source/opt/local_single_block_elim_pass.cpp +++ b/third_party/spirv-tools/source/opt/local_single_block_elim_pass.cpp @@ -19,6 +19,7 @@ #include #include "source/opt/iterator.h" +#include "source/util/string_utils.h" namespace spvtools { namespace opt { @@ -183,8 +184,7 @@ void LocalSingleBlockLoadStoreElimPass::Initialize() { bool LocalSingleBlockLoadStoreElimPass::AllExtensionsSupported() const { // If any extension not in allowlist, return false for (auto& ei : get_module()->extensions()) { - const char* extName = - reinterpret_cast(&ei.GetInOperand(0).words[0]); + const std::string extName = ei.GetInOperand(0).AsString(); if (extensions_allowlist_.find(extName) == extensions_allowlist_.end()) return false; } @@ -194,11 +194,9 @@ bool LocalSingleBlockLoadStoreElimPass::AllExtensionsSupported() const { for (auto& inst : context()->module()->ext_inst_imports()) { assert(inst.opcode() == SpvOpExtInstImport && "Expecting an import of an extension's instruction set."); - const char* extension_name = - reinterpret_cast(&inst.GetInOperand(0).words[0]); - if (0 == std::strncmp(extension_name, "NonSemantic.", 12) && - 0 != std::strncmp(extension_name, "NonSemantic.Shader.DebugInfo.100", - 32)) { + const std::string extension_name = inst.GetInOperand(0).AsString(); + if (spvtools::utils::starts_with(extension_name, "NonSemantic.") && + extension_name != "NonSemantic.Shader.DebugInfo.100") { return false; } } @@ -288,6 +286,8 @@ void LocalSingleBlockLoadStoreElimPass::InitExtensions() { "SPV_KHR_integer_dot_product", "SPV_EXT_shader_image_int64", "SPV_KHR_non_semantic_info", + "SPV_KHR_uniform_group_instructions", + "SPV_KHR_fragment_shader_barycentric", }); } diff --git a/third_party/spirv-tools/source/opt/local_single_store_elim_pass.cpp b/third_party/spirv-tools/source/opt/local_single_store_elim_pass.cpp index 051bcada76..8cdd0abdc9 100644 --- a/third_party/spirv-tools/source/opt/local_single_store_elim_pass.cpp +++ b/third_party/spirv-tools/source/opt/local_single_store_elim_pass.cpp @@ -19,6 +19,7 @@ #include "source/cfa.h" #include "source/latest_version_glsl_std_450_header.h" #include "source/opt/iterator.h" +#include "source/util/string_utils.h" namespace spvtools { namespace opt { @@ -48,8 +49,7 @@ bool LocalSingleStoreElimPass::LocalSingleStoreElim(Function* func) { bool LocalSingleStoreElimPass::AllExtensionsSupported() const { // If any extension not in allowlist, return false for (auto& ei : get_module()->extensions()) { - const char* extName = - reinterpret_cast(&ei.GetInOperand(0).words[0]); + const std::string extName = ei.GetInOperand(0).AsString(); if (extensions_allowlist_.find(extName) == extensions_allowlist_.end()) return false; } @@ -59,11 +59,9 @@ bool LocalSingleStoreElimPass::AllExtensionsSupported() const { for (auto& inst : context()->module()->ext_inst_imports()) { assert(inst.opcode() == SpvOpExtInstImport && "Expecting an import of an extension's instruction set."); - const char* extension_name = - reinterpret_cast(&inst.GetInOperand(0).words[0]); - if (0 == std::strncmp(extension_name, "NonSemantic.", 12) && - 0 != std::strncmp(extension_name, "NonSemantic.Shader.DebugInfo.100", - 32)) { + const std::string extension_name = inst.GetInOperand(0).AsString(); + if (spvtools::utils::starts_with(extension_name, "NonSemantic.") && + extension_name != "NonSemantic.Shader.DebugInfo.100") { return false; } } @@ -141,6 +139,8 @@ void LocalSingleStoreElimPass::InitExtensionAllowList() { "SPV_KHR_integer_dot_product", "SPV_EXT_shader_image_int64", "SPV_KHR_non_semantic_info", + "SPV_KHR_uniform_group_instructions", + "SPV_KHR_fragment_shader_barycentric", }); } bool LocalSingleStoreElimPass::ProcessVariable(Instruction* var_inst) { diff --git a/third_party/spirv-tools/source/opt/loop_descriptor.cpp b/third_party/spirv-tools/source/opt/loop_descriptor.cpp index b5b5630984..4feb64e865 100644 --- a/third_party/spirv-tools/source/opt/loop_descriptor.cpp +++ b/third_party/spirv-tools/source/opt/loop_descriptor.cpp @@ -719,7 +719,7 @@ bool Loop::FindNumberOfIterations(const Instruction* induction, step_value = -step_value; } - // Find the inital value of the loop and make sure it is a constant integer. + // Find the initial value of the loop and make sure it is a constant integer. int64_t init_value = 0; if (!GetInductionInitValue(induction, &init_value)) return false; @@ -751,9 +751,13 @@ bool Loop::FindNumberOfIterations(const Instruction* induction, // We retrieve the number of iterations using the following formula, diff / // |step_value| where diff is calculated differently according to the // |condition| and uses the |condition_value| and |init_value|. If diff / -// |step_value| is NOT cleanly divisable then we add one to the sum. +// |step_value| is NOT cleanly divisible then we add one to the sum. int64_t Loop::GetIterations(SpvOp condition, int64_t condition_value, int64_t init_value, int64_t step_value) const { + if (step_value == 0) { + return 0; + } + int64_t diff = 0; switch (condition) { @@ -795,7 +799,7 @@ int64_t Loop::GetIterations(SpvOp condition, int64_t condition_value, // If the condition is not met to begin with the loop will never iterate. if (!(init_value >= condition_value)) return 0; - // We subract one to make it the same as SpvOpGreaterThan as it is + // We subtract one to make it the same as SpvOpGreaterThan as it is // functionally equivalent. diff = init_value - (condition_value - 1); diff --git a/third_party/spirv-tools/source/opt/loop_descriptor.h b/third_party/spirv-tools/source/opt/loop_descriptor.h index 4b4f8bc75d..df012274c0 100644 --- a/third_party/spirv-tools/source/opt/loop_descriptor.h +++ b/third_party/spirv-tools/source/opt/loop_descriptor.h @@ -395,10 +395,11 @@ class Loop { // Sets |merge| as the loop merge block. No checks are performed here. inline void SetMergeBlockImpl(BasicBlock* merge) { loop_merge_ = merge; } - // Each differnt loop |condition| affects how we calculate the number of + // Each different loop |condition| affects how we calculate the number of // iterations using the |condition_value|, |init_value|, and |step_values| of // the induction variable. This method will return the number of iterations in - // a loop with those values for a given |condition|. + // a loop with those values for a given |condition|. Returns 0 if the number + // of iterations could not be computed. int64_t GetIterations(SpvOp condition, int64_t condition_value, int64_t init_value, int64_t step_value) const; diff --git a/third_party/spirv-tools/source/opt/loop_fission.cpp b/third_party/spirv-tools/source/opt/loop_fission.cpp index 0678113c47..b4df8c6216 100644 --- a/third_party/spirv-tools/source/opt/loop_fission.cpp +++ b/third_party/spirv-tools/source/opt/loop_fission.cpp @@ -29,7 +29,7 @@ // 2 - For each loop in the list, group each instruction into a set of related // instructions by traversing each instructions users and operands recursively. // We stop if we encounter an instruction we have seen before or an instruction -// which we don't consider relevent (i.e OpLoopMerge). We then group these +// which we don't consider relevant (i.e OpLoopMerge). We then group these // groups into two different sets, one for the first loop and one for the // second. // @@ -453,7 +453,7 @@ Pass::Status LoopFissionPass::Process() { for (Function& f : *context()->module()) { // We collect all the inner most loops in the function and run the loop // splitting util on each. The reason we do this is to allow us to iterate - // over each, as creating new loops will invalidate the the loop iterator. + // over each, as creating new loops will invalidate the loop iterator. std::vector inner_most_loops{}; LoopDescriptor& loop_descriptor = *context()->GetLoopDescriptor(&f); for (Loop& loop : loop_descriptor) { diff --git a/third_party/spirv-tools/source/opt/loop_fission.h b/third_party/spirv-tools/source/opt/loop_fission.h index e7a59c1858..9bc12c0fdb 100644 --- a/third_party/spirv-tools/source/opt/loop_fission.h +++ b/third_party/spirv-tools/source/opt/loop_fission.h @@ -33,7 +33,7 @@ namespace opt { class LoopFissionPass : public Pass { public: - // Fuction used to determine if a given loop should be split. Takes register + // Function used to determine if a given loop should be split. Takes register // pressure region for that loop as a parameter and returns true if the loop // should be split. using FissionCriteriaFunction = diff --git a/third_party/spirv-tools/source/opt/loop_fusion.cpp b/third_party/spirv-tools/source/opt/loop_fusion.cpp index 07d171a0af..f3aab2837f 100644 --- a/third_party/spirv-tools/source/opt/loop_fusion.cpp +++ b/third_party/spirv-tools/source/opt/loop_fusion.cpp @@ -165,7 +165,7 @@ bool LoopFusion::AreCompatible() { // Check adjacency, |loop_0_| should come just before |loop_1_|. // There is always at least one block between loops, even if it's empty. - // We'll check at most 2 preceeding blocks. + // We'll check at most 2 preceding blocks. auto pre_header_1 = loop_1_->GetPreHeaderBlock(); @@ -712,7 +712,7 @@ void LoopFusion::Fuse() { ld->RemoveLoop(loop_1_); - // Kill unnessecary instructions and remove all empty blocks. + // Kill unnecessary instructions and remove all empty blocks. for (auto inst : instr_to_delete) { context_->KillInst(inst); } diff --git a/third_party/spirv-tools/source/opt/loop_fusion.h b/third_party/spirv-tools/source/opt/loop_fusion.h index d61d6783c8..769da5f1af 100644 --- a/third_party/spirv-tools/source/opt/loop_fusion.h +++ b/third_party/spirv-tools/source/opt/loop_fusion.h @@ -40,7 +40,7 @@ class LoopFusion { // That means: // * they both have one induction variable // * they have the same upper and lower bounds - // - same inital value + // - same initial value // - same condition // * they have the same update step // * they are adjacent, with |loop_0| appearing before |loop_1| diff --git a/third_party/spirv-tools/source/opt/loop_fusion_pass.h b/third_party/spirv-tools/source/opt/loop_fusion_pass.h index 3a0be60004..9d5b7ccdae 100644 --- a/third_party/spirv-tools/source/opt/loop_fusion_pass.h +++ b/third_party/spirv-tools/source/opt/loop_fusion_pass.h @@ -33,7 +33,7 @@ class LoopFusionPass : public Pass { // Processes the given |module|. Returns Status::Failure if errors occur when // processing. Returns the corresponding Status::Success if processing is - // succesful to indicate whether changes have been made to the modue. + // successful to indicate whether changes have been made to the module. Status Process() override; private: diff --git a/third_party/spirv-tools/source/opt/loop_peeling.h b/third_party/spirv-tools/source/opt/loop_peeling.h index 413f896f25..2a55fe44da 100644 --- a/third_party/spirv-tools/source/opt/loop_peeling.h +++ b/third_party/spirv-tools/source/opt/loop_peeling.h @@ -261,7 +261,7 @@ class LoopPeelingPass : public Pass { // Processes the given |module|. Returns Status::Failure if errors occur when // processing. Returns the corresponding Status::Success if processing is - // succesful to indicate whether changes have been made to the modue. + // successful to indicate whether changes have been made to the module. Pass::Status Process() override; private: diff --git a/third_party/spirv-tools/source/opt/loop_unroller.cpp b/third_party/spirv-tools/source/opt/loop_unroller.cpp index aff191febc..28ff072996 100644 --- a/third_party/spirv-tools/source/opt/loop_unroller.cpp +++ b/third_party/spirv-tools/source/opt/loop_unroller.cpp @@ -163,7 +163,7 @@ struct LoopUnrollState { }; // This class implements the actual unrolling. It uses a LoopUnrollState to -// maintain the state of the unrolling inbetween steps. +// maintain the state of the unrolling in between steps. class LoopUnrollerUtilsImpl { public: using BasicBlockListTy = std::vector>; @@ -209,7 +209,7 @@ class LoopUnrollerUtilsImpl { // Add all blocks_to_add_ to function_ at the |insert_point|. void AddBlocksToFunction(const BasicBlock* insert_point); - // Duplicates the |old_loop|, cloning each body and remaping the ids without + // Duplicates the |old_loop|, cloning each body and remapping the ids without // removing instructions or changing relative structure. Result will be stored // in |new_loop|. void DuplicateLoop(Loop* old_loop, Loop* new_loop); @@ -241,7 +241,7 @@ class LoopUnrollerUtilsImpl { // Remap all the in |basic_block| to new IDs and keep the mapping of new ids // to old // ids. |loop| is used to identify special loop blocks (header, continue, - // ect). + // etc). void AssignNewResultIds(BasicBlock* basic_block); // Using the map built by AssignNewResultIds, replace the uses in |inst| @@ -320,7 +320,7 @@ class LoopUnrollerUtilsImpl { // and then be remapped at the end. std::vector loop_phi_instructions_; - // The number of loop iterations that the loop would preform pre-unroll. + // The number of loop iterations that the loop would perform pre-unroll. size_t number_of_loop_iterations_; // The amount that the loop steps each iteration. @@ -839,7 +839,7 @@ void LoopUnrollerUtilsImpl::DuplicateLoop(Loop* old_loop, Loop* new_loop) { new_loop->SetMergeBlock(new_merge); } -// Whenever the utility copies a block it stores it in a tempory buffer, this +// Whenever the utility copies a block it stores it in a temporary buffer, this // function adds the buffer into the Function. The blocks will be inserted // after the block |insert_point|. void LoopUnrollerUtilsImpl::AddBlocksToFunction( diff --git a/third_party/spirv-tools/source/opt/loop_unswitch_pass.cpp b/third_party/spirv-tools/source/opt/loop_unswitch_pass.cpp index d805ecf3cc..1ee7e5e227 100644 --- a/third_party/spirv-tools/source/opt/loop_unswitch_pass.cpp +++ b/third_party/spirv-tools/source/opt/loop_unswitch_pass.cpp @@ -118,7 +118,7 @@ class LoopUnswitch { // Find a value that can be used to select the default path. // If none are possible, then it will just use 0. The value does not matter - // because this path will never be taken becaues the new switch outside of + // because this path will never be taken because the new switch outside of // the loop cannot select this path either. std::vector existing_values; for (uint32_t i = 2; i < switch_inst->NumInOperands(); i += 2) { diff --git a/third_party/spirv-tools/source/opt/loop_unswitch_pass.h b/third_party/spirv-tools/source/opt/loop_unswitch_pass.h index 3ecdd61162..4f7295d437 100644 --- a/third_party/spirv-tools/source/opt/loop_unswitch_pass.h +++ b/third_party/spirv-tools/source/opt/loop_unswitch_pass.h @@ -30,7 +30,7 @@ class LoopUnswitchPass : public Pass { // Processes the given |module|. Returns Status::Failure if errors occur when // processing. Returns the corresponding Status::Success if processing is - // succesful to indicate whether changes have been made to the modue. + // successful to indicate whether changes have been made to the module. Pass::Status Process() override; private: diff --git a/third_party/spirv-tools/source/opt/loop_utils.h b/third_party/spirv-tools/source/opt/loop_utils.h index a4e61900bc..70060fc4f0 100644 --- a/third_party/spirv-tools/source/opt/loop_utils.h +++ b/third_party/spirv-tools/source/opt/loop_utils.h @@ -123,7 +123,7 @@ class LoopUtils { // Clone the |loop_| and make the new loop branch to the second loop on exit. Loop* CloneAndAttachLoopToHeader(LoopCloningResult* cloning_result); - // Perfom a partial unroll of |loop| by given |factor|. This will copy the + // Perform a partial unroll of |loop| by given |factor|. This will copy the // body of the loop |factor| times. So a |factor| of one would give a new loop // with the original body plus one unrolled copy body. bool PartiallyUnroll(size_t factor); @@ -139,7 +139,7 @@ class LoopUtils { // 1. That the loop is in structured order. // 2. That the continue block is a branch to the header. // 3. That the only phi used in the loop is the induction variable. - // TODO(stephen@codeplay.com): This is a temporary mesure, after the loop is + // TODO(stephen@codeplay.com): This is a temporary measure, after the loop is // converted into LCSAA form and has a single entry and exit we can rewrite // the other phis. // 4. That this is an inner most loop, or that loops contained within this diff --git a/third_party/spirv-tools/source/opt/merge_return_pass.cpp b/third_party/spirv-tools/source/opt/merge_return_pass.cpp index a962a7ccb0..7710deae2a 100644 --- a/third_party/spirv-tools/source/opt/merge_return_pass.cpp +++ b/third_party/spirv-tools/source/opt/merge_return_pass.cpp @@ -431,6 +431,7 @@ bool MergeReturnPass::BreakFromConstruct( std::list* order, Instruction* break_merge_inst) { // Make sure the CFG is build here. If we don't then it becomes very hard // to know which new blocks need to be updated. + context()->InvalidateAnalyses(IRContext::kAnalysisCFG); context()->BuildInvalidAnalyses(IRContext::kAnalysisCFG); // When predicating, be aware of whether this block is a header block, a diff --git a/third_party/spirv-tools/source/opt/merge_return_pass.h b/third_party/spirv-tools/source/opt/merge_return_pass.h index 4096ce7dd4..a35cf269f2 100644 --- a/third_party/spirv-tools/source/opt/merge_return_pass.h +++ b/third_party/spirv-tools/source/opt/merge_return_pass.h @@ -247,7 +247,7 @@ class MergeReturnPass : public MemPass { // Add new phi nodes for any id that no longer dominate all of it uses. A phi // node is added to a block |bb| for an id if the id is defined between the - // original immediate dominator of |bb| and its new immidiate dominator. It + // original immediate dominator of |bb| and its new immediate dominator. It // is assumed that at this point there are no unreachable blocks in the // control flow graph. void AddNewPhiNodes(); @@ -273,7 +273,7 @@ class MergeReturnPass : public MemPass { void InsertAfterElement(BasicBlock* element, BasicBlock* new_element, std::list* list); - // Creates a single case switch around all of the exectuable code of the + // Creates a single case switch around all of the executable code of the // current function where the switch and case value are both zero and the // default is the merge block. Returns after the switch is executed. Sets // |final_return_block_|. diff --git a/third_party/spirv-tools/source/opt/module.cpp b/third_party/spirv-tools/source/opt/module.cpp index f97defbd6f..5983abb126 100644 --- a/third_party/spirv-tools/source/opt/module.cpp +++ b/third_party/spirv-tools/source/opt/module.cpp @@ -139,7 +139,7 @@ void Module::ToBinary(std::vector* binary, bool skip_nop) const { // TODO(antiagainst): should we change the generator number? binary->push_back(header_.generator); binary->push_back(header_.bound); - binary->push_back(header_.reserved); + binary->push_back(header_.schema); size_t bound_idx = binary->size() - 2; DebugScope last_scope(kNoDebugScope, kNoInlinedAt); @@ -260,9 +260,7 @@ bool Module::HasExplicitCapability(uint32_t cap) { uint32_t Module::GetExtInstImportId(const char* extstr) { for (auto& ei : ext_inst_imports_) - if (!strcmp(extstr, - reinterpret_cast(&(ei.GetInOperand(0).words[0])))) - return ei.result_id(); + if (!ei.GetInOperand(0).AsString().compare(extstr)) return ei.result_id(); return 0; } diff --git a/third_party/spirv-tools/source/opt/module.h b/third_party/spirv-tools/source/opt/module.h index 0360b7d5b4..230be70950 100644 --- a/third_party/spirv-tools/source/opt/module.h +++ b/third_party/spirv-tools/source/opt/module.h @@ -36,7 +36,7 @@ struct ModuleHeader { uint32_t version; uint32_t generator; uint32_t bound; - uint32_t reserved; + uint32_t schema; }; // A SPIR-V module. It contains all the information for a SPIR-V module and @@ -61,7 +61,7 @@ class Module { } // Returns the Id bound. - uint32_t IdBound() { return header_.bound; } + uint32_t IdBound() const { return header_.bound; } // Returns the current Id bound and increases it to the next available value. // If the id bound has already reached its maximum value, then 0 is returned. @@ -141,6 +141,8 @@ class Module { inline uint32_t id_bound() const { return header_.bound; } inline uint32_t version() const { return header_.version; } + inline uint32_t generator() const { return header_.generator; } + inline uint32_t schema() const { return header_.schema; } inline void set_version(uint32_t v) { header_.version = v; } diff --git a/third_party/spirv-tools/source/opt/optimizer.cpp b/third_party/spirv-tools/source/opt/optimizer.cpp index e74db26f0c..29761518f4 100644 --- a/third_party/spirv-tools/source/opt/optimizer.cpp +++ b/third_party/spirv-tools/source/opt/optimizer.cpp @@ -288,6 +288,8 @@ bool Optimizer::RegisterPassFromFlag(const std::string& flag) { RegisterPass(CreateStripDebugInfoPass()); } else if (pass_name == "strip-reflect") { RegisterPass(CreateStripReflectInfoPass()); + } else if (pass_name == "strip-nonsemantic") { + RegisterPass(CreateStripNonSemanticInfoPass()); } else if (pass_name == "set-spec-const-default-value") { if (pass_args.size() > 0) { auto spec_ids_vals = @@ -322,6 +324,8 @@ bool Optimizer::RegisterPassFromFlag(const std::string& flag) { RegisterPass(CreateLocalAccessChainConvertPass()); } else if (pass_name == "replace-desc-array-access-using-var-index") { RegisterPass(CreateReplaceDescArrayAccessUsingVarIndexPass()); + } else if (pass_name == "spread-volatile-semantics") { + RegisterPass(CreateSpreadVolatileSemanticsPass()); } else if (pass_name == "descriptor-scalar-replacement") { RegisterPass(CreateDescriptorScalarReplacementPass()); } else if (pass_name == "eliminate-dead-code-aggressive") { @@ -517,6 +521,12 @@ bool Optimizer::RegisterPassFromFlag(const std::string& flag) { RegisterPass(CreateAmdExtToKhrPass()); } else if (pass_name == "interpolate-fixup") { RegisterPass(CreateInterpolateFixupPass()); + } else if (pass_name == "remove-dont-inline") { + RegisterPass(CreateRemoveDontInlinePass()); + } else if (pass_name == "eliminate-dead-input-components") { + RegisterPass(CreateEliminateDeadInputComponentsPass()); + } else if (pass_name == "fix-func-call-param") { + RegisterPass(CreateFixFuncCallArgumentsPass()); } else if (pass_name == "convert-to-sampled-image") { if (pass_args.size() > 0) { auto descriptor_set_binding_pairs = @@ -653,8 +663,12 @@ Optimizer::PassToken CreateStripDebugInfoPass() { } Optimizer::PassToken CreateStripReflectInfoPass() { + return CreateStripNonSemanticInfoPass(); +} + +Optimizer::PassToken CreateStripNonSemanticInfoPass() { return MakeUnique( - MakeUnique()); + MakeUnique()); } Optimizer::PassToken CreateEliminateDeadFunctionsPass() { @@ -764,6 +778,11 @@ Optimizer::PassToken CreateLocalMultiStoreElimPass() { MakeUnique()); } +Optimizer::PassToken CreateAggressiveDCEPass() { + return MakeUnique( + MakeUnique(false)); +} + Optimizer::PassToken CreateAggressiveDCEPass(bool preserve_interface) { return MakeUnique( MakeUnique(preserve_interface)); @@ -965,6 +984,11 @@ Optimizer::PassToken CreateReplaceDescArrayAccessUsingVarIndexPass() { MakeUnique()); } +Optimizer::PassToken CreateSpreadVolatileSemanticsPass() { + return MakeUnique( + MakeUnique()); +} + Optimizer::PassToken CreateDescriptorScalarReplacementPass() { return MakeUnique( MakeUnique()); @@ -984,6 +1008,11 @@ Optimizer::PassToken CreateInterpolateFixupPass() { MakeUnique()); } +Optimizer::PassToken CreateEliminateDeadInputComponentsPass() { + return MakeUnique( + MakeUnique()); +} + Optimizer::PassToken CreateConvertToSampledImagePass( const std::vector& descriptor_set_binding_pairs) { @@ -991,4 +1020,18 @@ Optimizer::PassToken CreateConvertToSampledImagePass( MakeUnique(descriptor_set_binding_pairs)); } +Optimizer::PassToken CreateInterfaceVariableScalarReplacementPass() { + return MakeUnique( + MakeUnique()); +} + +Optimizer::PassToken CreateRemoveDontInlinePass() { + return MakeUnique( + MakeUnique()); +} + +Optimizer::PassToken CreateFixFuncCallArgumentsPass() { + return MakeUnique( + MakeUnique()); +} } // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/pass.h b/third_party/spirv-tools/source/opt/pass.h index a8c9c4b43c..b2303e2316 100644 --- a/third_party/spirv-tools/source/opt/pass.h +++ b/third_party/spirv-tools/source/opt/pass.h @@ -28,6 +28,13 @@ #include "spirv-tools/libspirv.hpp" #include "types.h" +// Avoid unused variable warning/error on Linux +#ifndef NDEBUG +#define USE_ASSERT(x) assert(x) +#else +#define USE_ASSERT(x) ((void)(x)) +#endif + namespace spvtools { namespace opt { @@ -129,7 +136,7 @@ class Pass { // Processes the given |module|. Returns Status::Failure if errors occur when // processing. Returns the corresponding Status::Success if processing is - // succesful to indicate whether changes are made to the module. + // successful to indicate whether changes are made to the module. virtual Status Process() = 0; // Return the next available SSA id and increment it. diff --git a/third_party/spirv-tools/source/opt/pass_manager.cpp b/third_party/spirv-tools/source/opt/pass_manager.cpp index be53d3440e..a73ff7cf4a 100644 --- a/third_party/spirv-tools/source/opt/pass_manager.cpp +++ b/third_party/spirv-tools/source/opt/pass_manager.cpp @@ -35,10 +35,18 @@ Pass::Status PassManager::Run(IRContext* context) { if (print_all_stream_) { std::vector binary; context->module()->ToBinary(&binary, false); - SpirvTools t(SPV_ENV_UNIVERSAL_1_2); + SpirvTools t(target_env_); + t.SetMessageConsumer(consumer()); std::string disassembly; - t.Disassemble(binary, &disassembly, 0); - *print_all_stream_ << preamble << (pass ? pass->name() : "") << "\n" + std::string pass_name = (pass ? pass->name() : ""); + if (!t.Disassemble(binary, &disassembly, 0)) { + std::string msg = "Disassembly failed before pass "; + msg += pass_name + "\n"; + spv_position_t null_pos{0, 0, 0}; + consumer()(SPV_MSG_WARNING, "", null_pos, msg.c_str()); + return; + } + *print_all_stream_ << preamble << pass_name << "\n" << disassembly << std::endl; } }; diff --git a/third_party/spirv-tools/source/opt/pass_manager.h b/third_party/spirv-tools/source/opt/pass_manager.h index 9686dddc26..11961a3305 100644 --- a/third_party/spirv-tools/source/opt/pass_manager.h +++ b/third_party/spirv-tools/source/opt/pass_manager.h @@ -54,7 +54,7 @@ class PassManager { // Adds an externally constructed pass. void AddPass(std::unique_ptr pass); // Uses the argument |args| to construct a pass instance of type |T|, and adds - // the pass instance to this pass manger. The pass added will use this pass + // the pass instance to this pass manager. The pass added will use this pass // manager's message consumer. template void AddPass(Args&&... args); @@ -70,7 +70,7 @@ class PassManager { // Runs all passes on the given |module|. Returns Status::Failure if errors // occur when processing using one of the registered passes. All passes // registered after the error-reporting pass will be skipped. Returns the - // corresponding Status::Success if processing is succesful to indicate + // corresponding Status::Success if processing is successful to indicate // whether changes are made to the module. // // After running all the passes, they are removed from the list. diff --git a/third_party/spirv-tools/source/opt/passes.h b/third_party/spirv-tools/source/opt/passes.h index f3c30d578b..21354c77b1 100644 --- a/third_party/spirv-tools/source/opt/passes.h +++ b/third_party/spirv-tools/source/opt/passes.h @@ -34,8 +34,10 @@ #include "source/opt/desc_sroa.h" #include "source/opt/eliminate_dead_constant_pass.h" #include "source/opt/eliminate_dead_functions_pass.h" +#include "source/opt/eliminate_dead_input_components_pass.h" #include "source/opt/eliminate_dead_members_pass.h" #include "source/opt/empty_pass.h" +#include "source/opt/fix_func_call_arguments.h" #include "source/opt/fix_storage_class.h" #include "source/opt/flatten_decoration_pass.h" #include "source/opt/fold_spec_constant_op_and_composite_pass.h" @@ -47,6 +49,7 @@ #include "source/opt/inst_bindless_check_pass.h" #include "source/opt/inst_buff_addr_check_pass.h" #include "source/opt/inst_debug_printf_pass.h" +#include "source/opt/interface_var_sroa.h" #include "source/opt/interp_fixup_pass.h" #include "source/opt/licm_pass.h" #include "source/opt/local_access_chain_convert_pass.h" @@ -64,6 +67,7 @@ #include "source/opt/reduce_load_size.h" #include "source/opt/redundancy_elimination.h" #include "source/opt/relax_float_ops_pass.h" +#include "source/opt/remove_dontinline_pass.h" #include "source/opt/remove_duplicates_pass.h" #include "source/opt/remove_unused_interface_variables_pass.h" #include "source/opt/replace_desc_array_access_using_var_index.h" @@ -71,10 +75,11 @@ #include "source/opt/scalar_replacement_pass.h" #include "source/opt/set_spec_constant_default_value_pass.h" #include "source/opt/simplification_pass.h" +#include "source/opt/spread_volatile_semantics.h" #include "source/opt/ssa_rewrite_pass.h" #include "source/opt/strength_reduction_pass.h" #include "source/opt/strip_debug_info_pass.h" -#include "source/opt/strip_reflect_info_pass.h" +#include "source/opt/strip_nonsemantic_info_pass.h" #include "source/opt/unify_const_pass.h" #include "source/opt/upgrade_memory_model.h" #include "source/opt/vector_dce.h" diff --git a/third_party/spirv-tools/source/opt/private_to_local_pass.cpp b/third_party/spirv-tools/source/opt/private_to_local_pass.cpp index 12a226d5f1..80fb4c535d 100644 --- a/third_party/spirv-tools/source/opt/private_to_local_pass.cpp +++ b/third_party/spirv-tools/source/opt/private_to_local_pass.cpp @@ -135,7 +135,7 @@ bool PrivateToLocalPass::MoveVariable(Instruction* variable, // Place the variable at the start of the first basic block. context()->AnalyzeUses(variable); context()->set_instr_block(variable, &*function->begin()); - function->begin()->begin()->InsertBefore(move(var)); + function->begin()->begin()->InsertBefore(std::move(var)); // Update uses where the type may have changed. return UpdateUses(variable); diff --git a/third_party/spirv-tools/source/opt/private_to_local_pass.h b/third_party/spirv-tools/source/opt/private_to_local_pass.h index c6127d67f9..e96a965e91 100644 --- a/third_party/spirv-tools/source/opt/private_to_local_pass.h +++ b/third_party/spirv-tools/source/opt/private_to_local_pass.h @@ -44,7 +44,7 @@ class PrivateToLocalPass : public Pass { // class of |function|. Returns false if the variable could not be moved. bool MoveVariable(Instruction* variable, Function* function); - // |inst| is an instruction declaring a varible. If that variable is + // |inst| is an instruction declaring a variable. If that variable is // referenced in a single function and all of uses are valid as defined by // |IsValidUse|, then that function is returned. Otherwise, the return // value is |nullptr|. diff --git a/third_party/spirv-tools/source/opt/redundancy_elimination.h b/third_party/spirv-tools/source/opt/redundancy_elimination.h index 91809b5d57..40451f40e2 100644 --- a/third_party/spirv-tools/source/opt/redundancy_elimination.h +++ b/third_party/spirv-tools/source/opt/redundancy_elimination.h @@ -41,7 +41,7 @@ class RedundancyEliminationPass : public LocalRedundancyEliminationPass { // in the function containing |bb|. // // |value_to_ids| is a map from value number to ids. If {vn, id} is in - // |value_to_ids| then vn is the value number of id, and the defintion of id + // |value_to_ids| then vn is the value number of id, and the definition of id // dominates |bb|. // // Returns true if at least one instruction is deleted. diff --git a/third_party/spirv-tools/source/opt/register_pressure.cpp b/third_party/spirv-tools/source/opt/register_pressure.cpp index 5750c6d409..1ad337387b 100644 --- a/third_party/spirv-tools/source/opt/register_pressure.cpp +++ b/third_party/spirv-tools/source/opt/register_pressure.cpp @@ -378,7 +378,7 @@ void RegisterLiveness::SimulateFusion( // The loop fusion is injecting the l1 before the l2, the latch of l1 will be // connected to the header of l2. // To compute the register usage, we inject the loop live-in (union of l1 and - // l2 live-in header blocks) into the the live in/out of each basic block of + // l2 live-in header blocks) into the live in/out of each basic block of // l1 to get the peak register usage. We then repeat the operation to for l2 // basic blocks but in this case we inject the live-out of the latch of l1. auto live_loop = MakeFilterIteratorRange( diff --git a/third_party/spirv-tools/source/opt/remove_dontinline_pass.cpp b/third_party/spirv-tools/source/opt/remove_dontinline_pass.cpp new file mode 100644 index 0000000000..4dd1cd4f24 --- /dev/null +++ b/third_party/spirv-tools/source/opt/remove_dontinline_pass.cpp @@ -0,0 +1,49 @@ +// Copyright (c) 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "source/opt/remove_dontinline_pass.h" + +namespace spvtools { +namespace opt { + +Pass::Status RemoveDontInline::Process() { + bool modified = false; + modified = ClearDontInlineFunctionControl(); + return (modified ? Status::SuccessWithChange : Status::SuccessWithoutChange); +} + +bool RemoveDontInline::ClearDontInlineFunctionControl() { + bool modified = false; + for (auto& func : *get_module()) { + ClearDontInlineFunctionControl(&func); + } + return modified; +} + +bool RemoveDontInline::ClearDontInlineFunctionControl(Function* function) { + constexpr uint32_t kFunctionControlInOperandIdx = 0; + Instruction* function_inst = &function->DefInst(); + uint32_t function_control = + function_inst->GetSingleWordInOperand(kFunctionControlInOperandIdx); + + if ((function_control & SpvFunctionControlDontInlineMask) == 0) { + return false; + } + function_control &= ~SpvFunctionControlDontInlineMask; + function_inst->SetInOperand(kFunctionControlInOperandIdx, {function_control}); + return true; +} + +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/remove_dontinline_pass.h b/third_party/spirv-tools/source/opt/remove_dontinline_pass.h new file mode 100644 index 0000000000..162431991b --- /dev/null +++ b/third_party/spirv-tools/source/opt/remove_dontinline_pass.h @@ -0,0 +1,42 @@ +// Copyright (c) 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef SOURCE_OPT_REMOVE_DONTINLINE_PASS_H_ +#define SOURCE_OPT_REMOVE_DONTINLINE_PASS_H_ + +#include "source/opt/pass.h" + +namespace spvtools { +namespace opt { + +// See optimizer.hpp for documentation. +class RemoveDontInline : public Pass { + public: + const char* name() const override { return "remove-dont-inline"; } + Status Process() override; + + private: + // Clears the DontInline function control from every function in the module. + // Returns true of a change was made. + bool ClearDontInlineFunctionControl(); + + // Clears the DontInline function control from |function|. + // Returns true of a change was made. + bool ClearDontInlineFunctionControl(Function* function); +}; + +} // namespace opt +} // namespace spvtools + +#endif // SOURCE_OPT_REMOVE_DONTINLINE_PASS_H_ diff --git a/third_party/spirv-tools/source/opt/remove_duplicates_pass.cpp b/third_party/spirv-tools/source/opt/remove_duplicates_pass.cpp index 0e65cc8d14..1ed8e2a046 100644 --- a/third_party/spirv-tools/source/opt/remove_duplicates_pass.cpp +++ b/third_party/spirv-tools/source/opt/remove_duplicates_pass.cpp @@ -72,9 +72,8 @@ bool RemoveDuplicatesPass::RemoveDuplicatesExtInstImports() const { std::unordered_map ext_inst_imports; for (auto* i = &*context()->ext_inst_import_begin(); i;) { - auto res = ext_inst_imports.emplace( - reinterpret_cast(i->GetInOperand(0u).words.data()), - i->result_id()); + auto res = ext_inst_imports.emplace(i->GetInOperand(0u).AsString(), + i->result_id()); if (res.second) { // Never seen before, keep it. i = i->NextNode(); diff --git a/third_party/spirv-tools/source/opt/replace_desc_array_access_using_var_index.cpp b/third_party/spirv-tools/source/opt/replace_desc_array_access_using_var_index.cpp index 1082e679b6..e97593ef35 100644 --- a/third_party/spirv-tools/source/opt/replace_desc_array_access_using_var_index.cpp +++ b/third_party/spirv-tools/source/opt/replace_desc_array_access_using_var_index.cpp @@ -95,7 +95,7 @@ void ReplaceDescArrayAccessUsingVarIndex::ReplaceUsersOfAccessChain( CollectRecursiveUsersWithConcreteType(access_chain, &final_users); for (auto* inst : final_users) { std::deque insts_to_be_cloned = - CollectRequiredImageInsts(inst); + CollectRequiredImageAndAccessInsts(inst); ReplaceNonUniformAccessWithSwitchCase( inst, access_chain, number_of_elements, insts_to_be_cloned); } @@ -121,8 +121,8 @@ void ReplaceDescArrayAccessUsingVarIndex::CollectRecursiveUsersWithConcreteType( } std::deque -ReplaceDescArrayAccessUsingVarIndex::CollectRequiredImageInsts( - Instruction* user_of_image_insts) const { +ReplaceDescArrayAccessUsingVarIndex::CollectRequiredImageAndAccessInsts( + Instruction* user) const { std::unordered_set seen_inst_ids; std::queue work_list; @@ -131,21 +131,23 @@ ReplaceDescArrayAccessUsingVarIndex::CollectRequiredImageInsts( if (!seen_inst_ids.insert(*idp).second) return; Instruction* operand = get_def_use_mgr()->GetDef(*idp); if (context()->get_instr_block(operand) != nullptr && - HasImageOrImagePtrType(operand)) { + (HasImageOrImagePtrType(operand) || + operand->opcode() == SpvOpAccessChain || + operand->opcode() == SpvOpInBoundsAccessChain)) { work_list.push(operand); } }; - std::deque required_image_insts; - required_image_insts.push_front(user_of_image_insts); - user_of_image_insts->ForEachInId(decision_to_include_operand); + std::deque required_insts; + required_insts.push_front(user); + user->ForEachInId(decision_to_include_operand); while (!work_list.empty()) { auto* inst_from_work_list = work_list.front(); work_list.pop(); - required_image_insts.push_front(inst_from_work_list); + required_insts.push_front(inst_from_work_list); inst_from_work_list->ForEachInId(decision_to_include_operand); } - return required_image_insts; + return required_insts; } bool ReplaceDescArrayAccessUsingVarIndex::HasImageOrImagePtrType( @@ -253,8 +255,12 @@ void ReplaceDescArrayAccessUsingVarIndex::ReplaceNonUniformAccessWithSwitchCase( Instruction* access_chain_final_user, Instruction* access_chain, uint32_t number_of_elements, const std::deque& insts_to_be_cloned) const { - // Create merge block and add terminator auto* block = context()->get_instr_block(access_chain_final_user); + // If the instruction does not belong to a block (i.e. in the case of + // OpDecorate), no replacement is needed. + if (!block) return; + + // Create merge block and add terminator auto* merge_block = SeparateInstructionsIntoNewBlock( block, access_chain_final_user->NextNode()); diff --git a/third_party/spirv-tools/source/opt/replace_desc_array_access_using_var_index.h b/third_party/spirv-tools/source/opt/replace_desc_array_access_using_var_index.h index e18222c858..51817c15f7 100644 --- a/third_party/spirv-tools/source/opt/replace_desc_array_access_using_var_index.h +++ b/third_party/spirv-tools/source/opt/replace_desc_array_access_using_var_index.h @@ -47,7 +47,7 @@ class ReplaceDescArrayAccessUsingVarIndex : public Pass { } private: - // Replaces all acceses to |var| using variable indices with constant + // Replaces all accesses to |var| using variable indices with constant // elements of the array |var|. Creates switch-case statements to determine // the value of the variable index for all the possible cases. Returns // whether replacement is done or not. @@ -76,11 +76,12 @@ class ReplaceDescArrayAccessUsingVarIndex : public Pass { void CollectRecursiveUsersWithConcreteType( Instruction* access_chain, std::vector* final_users) const; - // Recursively collects the operands of |user_of_image_insts| (and operands - // of the operands) whose result types are images/samplers or pointers/array/ - // struct of them and returns them. - std::deque CollectRequiredImageInsts( - Instruction* user_of_image_insts) const; + // Recursively collects the operands of |user| (and operands of the operands) + // whose result types are images/samplers (or pointers/arrays/ structs of + // them) and access chains instructions and returns them. The returned + // collection includes |user|. + std::deque CollectRequiredImageAndAccessInsts( + Instruction* user) const; // Returns whether result type of |inst| is an image/sampler/pointer of image // or sampler or not. @@ -170,7 +171,7 @@ class ReplaceDescArrayAccessUsingVarIndex : public Pass { // Creates and adds an OpSwitch used for the selection of OpAccessChain whose // first Indexes operand is |access_chain_index_var_id|. The OpSwitch will be // added at the end of |parent_block|. It will jump to |default_id| for the - // default case and jumps to one of case blocks whoes ids are |case_block_ids| + // default case and jumps to one of case blocks whose ids are |case_block_ids| // if |access_chain_index_var_id| matches the case number. |merge_id| is the // merge block id. void AddSwitchForAccessChain( diff --git a/third_party/spirv-tools/source/opt/replace_invalid_opc.cpp b/third_party/spirv-tools/source/opt/replace_invalid_opc.cpp index e3b9d3e403..1dcd06f591 100644 --- a/third_party/spirv-tools/source/opt/replace_invalid_opc.cpp +++ b/third_party/spirv-tools/source/opt/replace_invalid_opc.cpp @@ -112,8 +112,7 @@ bool ReplaceInvalidOpcodePass::RewriteFunction(Function* function, } Instruction* file_name = context()->get_def_use_mgr()->GetDef(file_name_id); - const char* source = reinterpret_cast( - &file_name->GetInOperand(0).words[0]); + const std::string source = file_name->GetInOperand(0).AsString(); // Get the line number and column number. uint32_t line_number = @@ -121,7 +120,7 @@ bool ReplaceInvalidOpcodePass::RewriteFunction(Function* function, uint32_t col_number = last_line_dbg_inst->GetSingleWordInOperand(2); // Replace the instruction. - ReplaceInstruction(inst, source, line_number, col_number); + ReplaceInstruction(inst, source.c_str(), line_number, col_number); } } }, diff --git a/third_party/spirv-tools/source/opt/scalar_analysis.cpp b/third_party/spirv-tools/source/opt/scalar_analysis.cpp index 38555e649e..2b0a824cf0 100644 --- a/third_party/spirv-tools/source/opt/scalar_analysis.cpp +++ b/third_party/spirv-tools/source/opt/scalar_analysis.cpp @@ -581,7 +581,7 @@ static void PushToString(T id, std::u32string* str) { // Implements the hashing of SENodes. size_t SENodeHash::operator()(const SENode* node) const { - // Concatinate the terms into a string which we can hash. + // Concatenate the terms into a string which we can hash. std::u32string hash_string{}; // Hashing the type as a string is safer than hashing the enum as the enum is diff --git a/third_party/spirv-tools/source/opt/scalar_analysis_nodes.h b/third_party/spirv-tools/source/opt/scalar_analysis_nodes.h index b0e3fefd6f..91ce446f3d 100644 --- a/third_party/spirv-tools/source/opt/scalar_analysis_nodes.h +++ b/third_party/spirv-tools/source/opt/scalar_analysis_nodes.h @@ -167,7 +167,7 @@ class SENode { const ChildContainerType& GetChildren() const { return children_; } ChildContainerType& GetChildren() { return children_; } - // Return true if this node is a cant compute node. + // Return true if this node is a can't compute node. bool IsCantCompute() const { return GetType() == CanNotCompute; } // Implements a casting method for each type. diff --git a/third_party/spirv-tools/source/opt/scalar_analysis_simplification.cpp b/third_party/spirv-tools/source/opt/scalar_analysis_simplification.cpp index 52f2d6ad90..3c1ecc082a 100644 --- a/third_party/spirv-tools/source/opt/scalar_analysis_simplification.cpp +++ b/third_party/spirv-tools/source/opt/scalar_analysis_simplification.cpp @@ -88,7 +88,7 @@ class SENodeSimplifyImpl { private: // Recursively descend through the graph to build up the accumulator objects - // which are used to flatten the graph. |child| is the node currenty being + // which are used to flatten the graph. |child| is the node currently being // traversed and the |negation| flag is used to signify that this operation // was preceded by a unary negative operation and as such the result should be // negated. @@ -134,7 +134,7 @@ class SENodeSimplifyImpl { // offset. SENode* EliminateZeroCoefficientRecurrents(SENode* node); - // A reference the the analysis which requested the simplification. + // A reference the analysis which requested the simplification. ScalarEvolutionAnalysis& analysis_; // The node being simplified. diff --git a/third_party/spirv-tools/source/opt/scalar_replacement_pass.cpp b/third_party/spirv-tools/source/opt/scalar_replacement_pass.cpp index 4d6a7aadd5..e27c828b06 100644 --- a/third_party/spirv-tools/source/opt/scalar_replacement_pass.cpp +++ b/third_party/spirv-tools/source/opt/scalar_replacement_pass.cpp @@ -24,6 +24,7 @@ #include "source/opt/reflect.h" #include "source/opt/types.h" #include "source/util/make_unique.h" +#include "types.h" static const uint32_t kDebugValueOperandValueIndex = 5; static const uint32_t kDebugValueOperandExpressionIndex = 6; @@ -395,7 +396,7 @@ bool ScalarReplacementPass::CreateReplacementVariables( if (!components_used || components_used->count(elem)) { CreateVariable(*id, inst, elem, replacements); } else { - replacements->push_back(CreateNullConstant(*id)); + replacements->push_back(GetUndef(*id)); } elem++; }); @@ -406,8 +407,8 @@ bool ScalarReplacementPass::CreateReplacementVariables( CreateVariable(type->GetSingleWordInOperand(0u), inst, i, replacements); } else { - replacements->push_back( - CreateNullConstant(type->GetSingleWordInOperand(0u))); + uint32_t element_type_id = type->GetSingleWordInOperand(0); + replacements->push_back(GetUndef(element_type_id)); } } break; @@ -429,6 +430,10 @@ bool ScalarReplacementPass::CreateReplacementVariables( replacements->end(); } +Instruction* ScalarReplacementPass::GetUndef(uint32_t type_id) { + return get_def_use_mgr()->GetDef(Type2Undef(type_id)); +} + void ScalarReplacementPass::TransferAnnotations( const Instruction* source, std::vector* replacements) { // Only transfer invariant and restrict decorations on the variable. There are @@ -981,20 +986,6 @@ ScalarReplacementPass::GetUsedComponents(Instruction* inst) { return result; } -Instruction* ScalarReplacementPass::CreateNullConstant(uint32_t type_id) { - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - analysis::ConstantManager* const_mgr = context()->get_constant_mgr(); - - const analysis::Type* type = type_mgr->GetType(type_id); - const analysis::Constant* null_const = const_mgr->GetConstant(type, {}); - Instruction* null_inst = - const_mgr->GetDefiningInstruction(null_const, type_id); - if (null_inst != nullptr) { - context()->UpdateDefUse(null_inst); - } - return null_inst; -} - uint64_t ScalarReplacementPass::GetMaxLegalIndex( const Instruction* var_inst) const { assert(var_inst->opcode() == SpvOpVariable && diff --git a/third_party/spirv-tools/source/opt/scalar_replacement_pass.h b/third_party/spirv-tools/source/opt/scalar_replacement_pass.h index 0928830c07..76afc2674a 100644 --- a/third_party/spirv-tools/source/opt/scalar_replacement_pass.h +++ b/third_party/spirv-tools/source/opt/scalar_replacement_pass.h @@ -23,14 +23,14 @@ #include #include "source/opt/function.h" -#include "source/opt/pass.h" +#include "source/opt/mem_pass.h" #include "source/opt/type_manager.h" namespace spvtools { namespace opt { // Documented in optimizer.hpp -class ScalarReplacementPass : public Pass { +class ScalarReplacementPass : public MemPass { private: static const uint32_t kDefaultLimit = 100; @@ -234,10 +234,8 @@ class ScalarReplacementPass : public Pass { std::unique_ptr> GetUsedComponents( Instruction* inst); - // Returns an instruction defining a null constant with type |type_id|. If - // one already exists, it is returned. Otherwise a new one is created. - // Returns |nullptr| if the new constant could not be created. - Instruction* CreateNullConstant(uint32_t type_id); + // Returns an instruction defining an undefined value type |type_id|. + Instruction* GetUndef(uint32_t type_id); // Maps storage type to a pointer type enclosing that type. std::unordered_map pointee_to_pointer_; diff --git a/third_party/spirv-tools/source/opt/spread_volatile_semantics.cpp b/third_party/spirv-tools/source/opt/spread_volatile_semantics.cpp new file mode 100644 index 0000000000..b61fd0f4c1 --- /dev/null +++ b/third_party/spirv-tools/source/opt/spread_volatile_semantics.cpp @@ -0,0 +1,298 @@ +// Copyright (c) 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "source/opt/spread_volatile_semantics.h" + +#include "source/opt/decoration_manager.h" +#include "source/opt/ir_builder.h" +#include "source/spirv_constant.h" + +namespace spvtools { +namespace opt { +namespace { + +const uint32_t kOpDecorateInOperandBuiltinDecoration = 2u; +const uint32_t kOpLoadInOperandMemoryOperands = 1u; +const uint32_t kOpEntryPointInOperandEntryPoint = 1u; +const uint32_t kOpEntryPointInOperandInterface = 3u; + +bool HasBuiltinDecoration(analysis::DecorationManager* decoration_manager, + uint32_t var_id, uint32_t built_in) { + return decoration_manager->FindDecoration( + var_id, SpvDecorationBuiltIn, [built_in](const Instruction& inst) { + return built_in == inst.GetSingleWordInOperand( + kOpDecorateInOperandBuiltinDecoration); + }); +} + +bool IsBuiltInForRayTracingVolatileSemantics(uint32_t built_in) { + switch (built_in) { + case SpvBuiltInSMIDNV: + case SpvBuiltInWarpIDNV: + case SpvBuiltInSubgroupSize: + case SpvBuiltInSubgroupLocalInvocationId: + case SpvBuiltInSubgroupEqMask: + case SpvBuiltInSubgroupGeMask: + case SpvBuiltInSubgroupGtMask: + case SpvBuiltInSubgroupLeMask: + case SpvBuiltInSubgroupLtMask: + return true; + default: + return false; + } +} + +bool HasBuiltinForRayTracingVolatileSemantics( + analysis::DecorationManager* decoration_manager, uint32_t var_id) { + return decoration_manager->FindDecoration( + var_id, SpvDecorationBuiltIn, [](const Instruction& inst) { + uint32_t built_in = + inst.GetSingleWordInOperand(kOpDecorateInOperandBuiltinDecoration); + return IsBuiltInForRayTracingVolatileSemantics(built_in); + }); +} + +bool HasVolatileDecoration(analysis::DecorationManager* decoration_manager, + uint32_t var_id) { + return decoration_manager->HasDecoration(var_id, SpvDecorationVolatile); +} + +} // namespace + +Pass::Status SpreadVolatileSemantics::Process() { + if (HasNoExecutionModel()) { + return Status::SuccessWithoutChange; + } + const bool is_vk_memory_model_enabled = + context()->get_feature_mgr()->HasCapability( + SpvCapabilityVulkanMemoryModel); + CollectTargetsForVolatileSemantics(is_vk_memory_model_enabled); + + // If VulkanMemoryModel capability is not enabled, we have to set Volatile + // decoration for interface variables instead of setting Volatile for load + // instructions. If an interface (or pointers to it) is used by two load + // instructions in two entry points and one must be volatile while another + // is not, we have to report an error for the conflict. + if (!is_vk_memory_model_enabled && + HasInterfaceInConflictOfVolatileSemantics()) { + return Status::Failure; + } + + return SpreadVolatileSemanticsToVariables(is_vk_memory_model_enabled); +} + +Pass::Status SpreadVolatileSemantics::SpreadVolatileSemanticsToVariables( + const bool is_vk_memory_model_enabled) { + Status status = Status::SuccessWithoutChange; + for (Instruction& var : context()->types_values()) { + auto entry_function_ids = + EntryFunctionsToSpreadVolatileSemanticsForVar(var.result_id()); + if (entry_function_ids.empty()) { + continue; + } + + if (is_vk_memory_model_enabled) { + SetVolatileForLoadsInEntries(&var, entry_function_ids); + } else { + DecorateVarWithVolatile(&var); + } + status = Status::SuccessWithChange; + } + return status; +} + +bool SpreadVolatileSemantics::IsTargetUsedByNonVolatileLoadInEntryPoint( + uint32_t var_id, Instruction* entry_point) { + uint32_t entry_function_id = + entry_point->GetSingleWordInOperand(kOpEntryPointInOperandEntryPoint); + std::unordered_set funcs; + context()->CollectCallTreeFromRoots(entry_function_id, &funcs); + return !VisitLoadsOfPointersToVariableInEntries( + var_id, + [](Instruction* load) { + // If it has a load without volatile memory operand, finish traversal + // and return false. + if (load->NumInOperands() <= kOpLoadInOperandMemoryOperands) { + return false; + } + uint32_t memory_operands = + load->GetSingleWordInOperand(kOpLoadInOperandMemoryOperands); + return (memory_operands & SpvMemoryAccessVolatileMask) != 0; + }, + funcs); +} + +bool SpreadVolatileSemantics::HasInterfaceInConflictOfVolatileSemantics() { + for (Instruction& entry_point : get_module()->entry_points()) { + SpvExecutionModel execution_model = + static_cast(entry_point.GetSingleWordInOperand(0)); + for (uint32_t operand_index = kOpEntryPointInOperandInterface; + operand_index < entry_point.NumInOperands(); ++operand_index) { + uint32_t var_id = entry_point.GetSingleWordInOperand(operand_index); + if (!EntryFunctionsToSpreadVolatileSemanticsForVar(var_id).empty() && + !IsTargetForVolatileSemantics(var_id, execution_model) && + IsTargetUsedByNonVolatileLoadInEntryPoint(var_id, &entry_point)) { + Instruction* inst = context()->get_def_use_mgr()->GetDef(var_id); + context()->EmitErrorMessage( + "Variable is a target for Volatile semantics for an entry point, " + "but it is not for another entry point", + inst); + return true; + } + } + } + return false; +} + +void SpreadVolatileSemantics::MarkVolatileSemanticsForVariable( + uint32_t var_id, Instruction* entry_point) { + uint32_t entry_function_id = + entry_point->GetSingleWordInOperand(kOpEntryPointInOperandEntryPoint); + auto itr = var_ids_to_entry_fn_for_volatile_semantics_.find(var_id); + if (itr == var_ids_to_entry_fn_for_volatile_semantics_.end()) { + var_ids_to_entry_fn_for_volatile_semantics_[var_id] = {entry_function_id}; + return; + } + itr->second.insert(entry_function_id); +} + +void SpreadVolatileSemantics::CollectTargetsForVolatileSemantics( + const bool is_vk_memory_model_enabled) { + for (Instruction& entry_point : get_module()->entry_points()) { + SpvExecutionModel execution_model = + static_cast(entry_point.GetSingleWordInOperand(0)); + for (uint32_t operand_index = kOpEntryPointInOperandInterface; + operand_index < entry_point.NumInOperands(); ++operand_index) { + uint32_t var_id = entry_point.GetSingleWordInOperand(operand_index); + if (!IsTargetForVolatileSemantics(var_id, execution_model)) { + continue; + } + if (is_vk_memory_model_enabled || + IsTargetUsedByNonVolatileLoadInEntryPoint(var_id, &entry_point)) { + MarkVolatileSemanticsForVariable(var_id, &entry_point); + } + } + } +} + +void SpreadVolatileSemantics::DecorateVarWithVolatile(Instruction* var) { + analysis::DecorationManager* decoration_manager = + context()->get_decoration_mgr(); + uint32_t var_id = var->result_id(); + if (HasVolatileDecoration(decoration_manager, var_id)) { + return; + } + get_decoration_mgr()->AddDecoration( + SpvOpDecorate, {{spv_operand_type_t::SPV_OPERAND_TYPE_ID, {var_id}}, + {spv_operand_type_t::SPV_OPERAND_TYPE_LITERAL_INTEGER, + {SpvDecorationVolatile}}}); +} + +bool SpreadVolatileSemantics::VisitLoadsOfPointersToVariableInEntries( + uint32_t var_id, const std::function& handle_load, + const std::unordered_set& function_ids) { + std::vector worklist({var_id}); + auto* def_use_mgr = context()->get_def_use_mgr(); + while (!worklist.empty()) { + uint32_t ptr_id = worklist.back(); + worklist.pop_back(); + bool finish_traversal = !def_use_mgr->WhileEachUser( + ptr_id, [this, &worklist, &ptr_id, handle_load, + &function_ids](Instruction* user) { + BasicBlock* block = context()->get_instr_block(user); + if (block == nullptr || + function_ids.find(block->GetParent()->result_id()) == + function_ids.end()) { + return true; + } + + if (user->opcode() == SpvOpAccessChain || + user->opcode() == SpvOpInBoundsAccessChain || + user->opcode() == SpvOpPtrAccessChain || + user->opcode() == SpvOpInBoundsPtrAccessChain || + user->opcode() == SpvOpCopyObject) { + if (ptr_id == user->GetSingleWordInOperand(0)) + worklist.push_back(user->result_id()); + return true; + } + + if (user->opcode() != SpvOpLoad) { + return true; + } + + return handle_load(user); + }); + if (finish_traversal) return false; + } + return true; +} + +void SpreadVolatileSemantics::SetVolatileForLoadsInEntries( + Instruction* var, const std::unordered_set& entry_function_ids) { + // Set Volatile memory operand for all load instructions if they do not have + // it. + for (auto entry_id : entry_function_ids) { + std::unordered_set funcs; + context()->CollectCallTreeFromRoots(entry_id, &funcs); + VisitLoadsOfPointersToVariableInEntries( + var->result_id(), + [](Instruction* load) { + if (load->NumInOperands() <= kOpLoadInOperandMemoryOperands) { + load->AddOperand({SPV_OPERAND_TYPE_MEMORY_ACCESS, + {SpvMemoryAccessVolatileMask}}); + return true; + } + uint32_t memory_operands = + load->GetSingleWordInOperand(kOpLoadInOperandMemoryOperands); + memory_operands |= SpvMemoryAccessVolatileMask; + load->SetInOperand(kOpLoadInOperandMemoryOperands, {memory_operands}); + return true; + }, + funcs); + } +} + +bool SpreadVolatileSemantics::IsTargetForVolatileSemantics( + uint32_t var_id, SpvExecutionModel execution_model) { + analysis::DecorationManager* decoration_manager = + context()->get_decoration_mgr(); + if (execution_model == SpvExecutionModelFragment) { + return get_module()->version() >= SPV_SPIRV_VERSION_WORD(1, 6) && + HasBuiltinDecoration(decoration_manager, var_id, + SpvBuiltInHelperInvocation); + } + + if (execution_model == SpvExecutionModelIntersectionKHR || + execution_model == SpvExecutionModelIntersectionNV) { + if (HasBuiltinDecoration(decoration_manager, var_id, + SpvBuiltInRayTmaxKHR)) { + return true; + } + } + + switch (execution_model) { + case SpvExecutionModelRayGenerationKHR: + case SpvExecutionModelClosestHitKHR: + case SpvExecutionModelMissKHR: + case SpvExecutionModelCallableKHR: + case SpvExecutionModelIntersectionKHR: + return HasBuiltinForRayTracingVolatileSemantics(decoration_manager, + var_id); + default: + return false; + } +} + +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/spread_volatile_semantics.h b/third_party/spirv-tools/source/opt/spread_volatile_semantics.h new file mode 100644 index 0000000000..014858d3f3 --- /dev/null +++ b/third_party/spirv-tools/source/opt/spread_volatile_semantics.h @@ -0,0 +1,116 @@ +// Copyright (c) 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef SOURCE_OPT_SPREAD_VOLATILE_SEMANTICS_H_ +#define SOURCE_OPT_SPREAD_VOLATILE_SEMANTICS_H_ + +#include "source/opt/pass.h" + +namespace spvtools { +namespace opt { + +// See optimizer.hpp for documentation. +class SpreadVolatileSemantics : public Pass { + public: + SpreadVolatileSemantics() {} + + const char* name() const override { return "spread-volatile-semantics"; } + + Status Process() override; + + IRContext::Analysis GetPreservedAnalyses() override { + return IRContext::kAnalysisDefUse | IRContext::kAnalysisDecorations | + IRContext::kAnalysisInstrToBlockMapping; + } + + private: + // Returns true if it does not have an execution model. Linkage shaders do not + // have an execution model. + bool HasNoExecutionModel() { + return get_module()->entry_points().empty() && + context()->get_feature_mgr()->HasCapability(SpvCapabilityLinkage); + } + + // Iterates interface variables and spreads the Volatile semantics if it has + // load instructions for the Volatile semantics. + Pass::Status SpreadVolatileSemanticsToVariables( + const bool is_vk_memory_model_enabled); + + // Returns whether |var_id| is the result id of a target builtin variable for + // the volatile semantics for |execution_model| based on the Vulkan spec + // VUID-StandaloneSpirv-VulkanMemoryModel-04678 or + // VUID-StandaloneSpirv-VulkanMemoryModel-04679. + bool IsTargetForVolatileSemantics(uint32_t var_id, + SpvExecutionModel execution_model); + + // Collects interface variables that need the volatile semantics. + // |is_vk_memory_model_enabled| is true if VulkanMemoryModel capability is + // enabled. + void CollectTargetsForVolatileSemantics( + const bool is_vk_memory_model_enabled); + + // Reports an error if an interface variable is used by two entry points and + // it needs the Volatile decoration for one but not for another. Returns true + // if the error must be reported. + bool HasInterfaceInConflictOfVolatileSemantics(); + + // Returns whether the variable whose result is |var_id| is used by a + // non-volatile load or a pointer to it is used by a non-volatile load in + // |entry_point| or not. + bool IsTargetUsedByNonVolatileLoadInEntryPoint(uint32_t var_id, + Instruction* entry_point); + + // Visits load instructions of pointers to variable whose result id is + // |var_id| if the load instructions are in reachable functions from entry + // points. |handle_load| is a function to do some actions for the load + // instructions. Finishes the traversal and returns false if |handle_load| + // returns false for a load instruction. Otherwise, returns true after running + // |handle_load| for all the load instructions. + bool VisitLoadsOfPointersToVariableInEntries( + uint32_t var_id, const std::function& handle_load, + const std::unordered_set& function_ids); + + // Sets Memory Operands of OpLoad instructions that load |var| or pointers + // of |var| as Volatile if the function id of the OpLoad instruction is + // included in |entry_function_ids|. + void SetVolatileForLoadsInEntries( + Instruction* var, const std::unordered_set& entry_function_ids); + + // Adds OpDecorate Volatile for |var| if it does not exist. + void DecorateVarWithVolatile(Instruction* var); + + // Returns a set of entry function ids to spread the volatile semantics for + // the variable with the result id |var_id|. + std::unordered_set EntryFunctionsToSpreadVolatileSemanticsForVar( + uint32_t var_id) { + auto itr = var_ids_to_entry_fn_for_volatile_semantics_.find(var_id); + if (itr == var_ids_to_entry_fn_for_volatile_semantics_.end()) return {}; + return itr->second; + } + + // Specifies that we have to spread the volatile semantics for the + // variable with the result id |var_id| for the entry point |entry_point|. + void MarkVolatileSemanticsForVariable(uint32_t var_id, + Instruction* entry_point); + + // Result ids of variables to entry function ids for the volatile semantics + // spread. + std::unordered_map> + var_ids_to_entry_fn_for_volatile_semantics_; +}; + +} // namespace opt +} // namespace spvtools + +#endif // SOURCE_OPT_SPREAD_VOLATILE_SEMANTICS_H_ diff --git a/third_party/spirv-tools/source/opt/strength_reduction_pass.h b/third_party/spirv-tools/source/opt/strength_reduction_pass.h index 8dfeb307bf..1cbbbcc6d0 100644 --- a/third_party/spirv-tools/source/opt/strength_reduction_pass.h +++ b/third_party/spirv-tools/source/opt/strength_reduction_pass.h @@ -34,7 +34,7 @@ class StrengthReductionPass : public Pass { // Returns true if something changed. bool ReplaceMultiplyByPowerOf2(BasicBlock::iterator*); - // Scan the types and constants in the module looking for the the integer + // Scan the types and constants in the module looking for the integer // types that we are // interested in. The shift operation needs a small unsigned integer. We // need to find diff --git a/third_party/spirv-tools/source/opt/strip_debug_info_pass.cpp b/third_party/spirv-tools/source/opt/strip_debug_info_pass.cpp index c86ce57828..6a0ebf2482 100644 --- a/third_party/spirv-tools/source/opt/strip_debug_info_pass.cpp +++ b/third_party/spirv-tools/source/opt/strip_debug_info_pass.cpp @@ -14,6 +14,7 @@ #include "source/opt/strip_debug_info_pass.h" #include "source/opt/ir_context.h" +#include "source/util/string_utils.h" namespace spvtools { namespace opt { @@ -21,9 +22,8 @@ namespace opt { Pass::Status StripDebugInfoPass::Process() { bool uses_non_semantic_info = false; for (auto& inst : context()->module()->extensions()) { - const char* ext_name = - reinterpret_cast(&inst.GetInOperand(0).words[0]); - if (0 == std::strcmp(ext_name, "SPV_KHR_non_semantic_info")) { + const std::string ext_name = inst.GetInOperand(0).AsString(); + if (ext_name == "SPV_KHR_non_semantic_info") { uses_non_semantic_info = true; } } @@ -46,9 +46,10 @@ Pass::Status StripDebugInfoPass::Process() { if (use->opcode() == SpvOpExtInst) { auto ext_inst_set = def_use->GetDef(use->GetSingleWordInOperand(0u)); - const char* extension_name = reinterpret_cast( - &ext_inst_set->GetInOperand(0).words[0]); - if (0 == std::strncmp(extension_name, "NonSemantic.", 12)) { + const std::string extension_name = + ext_inst_set->GetInOperand(0).AsString(); + if (spvtools::utils::starts_with(extension_name, + "NonSemantic.")) { // found a non-semantic use, return false as we cannot // remove this OpString return false; diff --git a/third_party/spirv-tools/source/opt/strip_reflect_info_pass.cpp b/third_party/spirv-tools/source/opt/strip_nonsemantic_info_pass.cpp similarity index 65% rename from third_party/spirv-tools/source/opt/strip_reflect_info_pass.cpp rename to third_party/spirv-tools/source/opt/strip_nonsemantic_info_pass.cpp index 8b0f2db7ff..cd1fbb632f 100644 --- a/third_party/spirv-tools/source/opt/strip_reflect_info_pass.cpp +++ b/third_party/spirv-tools/source/opt/strip_nonsemantic_info_pass.cpp @@ -12,18 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "source/opt/strip_reflect_info_pass.h" +#include "source/opt/strip_nonsemantic_info_pass.h" #include #include #include "source/opt/instruction.h" #include "source/opt/ir_context.h" +#include "source/util/string_utils.h" namespace spvtools { namespace opt { -Pass::Status StripReflectInfoPass::Process() { +Pass::Status StripNonSemanticInfoPass::Process() { bool modified = false; std::vector to_remove; @@ -32,7 +33,8 @@ Pass::Status StripReflectInfoPass::Process() { for (auto& inst : context()->module()->annotations()) { switch (inst.opcode()) { case SpvOpDecorateStringGOOGLE: - if (inst.GetSingleWordInOperand(1) == SpvDecorationHlslSemanticGOOGLE) { + if (inst.GetSingleWordInOperand(1) == SpvDecorationHlslSemanticGOOGLE || + inst.GetSingleWordInOperand(1) == SpvDecorationUserTypeGOOGLE) { to_remove.push_back(&inst); } else { other_uses_for_decorate_string = true; @@ -40,7 +42,8 @@ Pass::Status StripReflectInfoPass::Process() { break; case SpvOpMemberDecorateStringGOOGLE: - if (inst.GetSingleWordInOperand(2) == SpvDecorationHlslSemanticGOOGLE) { + if (inst.GetSingleWordInOperand(2) == SpvDecorationHlslSemanticGOOGLE || + inst.GetSingleWordInOperand(2) == SpvDecorationUserTypeGOOGLE) { to_remove.push_back(&inst); } else { other_uses_for_decorate_string = true; @@ -60,33 +63,26 @@ Pass::Status StripReflectInfoPass::Process() { } for (auto& inst : context()->module()->extensions()) { - const char* ext_name = - reinterpret_cast(&inst.GetInOperand(0).words[0]); - if (0 == std::strcmp(ext_name, "SPV_GOOGLE_hlsl_functionality1")) { + const std::string ext_name = inst.GetInOperand(0).AsString(); + if (ext_name == "SPV_GOOGLE_hlsl_functionality1") { + to_remove.push_back(&inst); + } else if (ext_name == "SPV_GOOGLE_user_type") { to_remove.push_back(&inst); } else if (!other_uses_for_decorate_string && - 0 == std::strcmp(ext_name, "SPV_GOOGLE_decorate_string")) { + ext_name == "SPV_GOOGLE_decorate_string") { to_remove.push_back(&inst); - } else if (0 == std::strcmp(ext_name, "SPV_KHR_non_semantic_info")) { + } else if (ext_name == "SPV_KHR_non_semantic_info") { to_remove.push_back(&inst); } } - // clear all debug data now if it hasn't been cleared already, to remove any - // remaining OpString that may have been referenced by non-semantic extinsts - for (auto& dbg : context()->debugs1()) to_remove.push_back(&dbg); - for (auto& dbg : context()->debugs2()) to_remove.push_back(&dbg); - for (auto& dbg : context()->debugs3()) to_remove.push_back(&dbg); - for (auto& dbg : context()->ext_inst_debuginfo()) to_remove.push_back(&dbg); - // remove any extended inst imports that are non semantic std::unordered_set non_semantic_sets; for (auto& inst : context()->module()->ext_inst_imports()) { assert(inst.opcode() == SpvOpExtInstImport && "Expecting an import of an extension's instruction set."); - const char* extension_name = - reinterpret_cast(&inst.GetInOperand(0).words[0]); - if (0 == std::strncmp(extension_name, "NonSemantic.", 12)) { + const std::string extension_name = inst.GetInOperand(0).AsString(); + if (spvtools::utils::starts_with(extension_name, "NonSemantic.")) { non_semantic_sets.insert(inst.result_id()); to_remove.push_back(&inst); } @@ -103,19 +99,10 @@ Pass::Status StripReflectInfoPass::Process() { to_remove.push_back(inst); } } - }); + }, + true); } - // OpName must come first, since they may refer to other debug instructions. - // If they are after the instructions that refer to, then they will be killed - // when that instruction is killed, which will lead to a double kill. - std::sort(to_remove.begin(), to_remove.end(), - [](Instruction* lhs, Instruction* rhs) -> bool { - if (lhs->opcode() == SpvOpName && rhs->opcode() != SpvOpName) - return true; - return false; - }); - for (auto* inst : to_remove) { modified = true; context()->KillInst(inst); diff --git a/third_party/spirv-tools/source/opt/strip_reflect_info_pass.h b/third_party/spirv-tools/source/opt/strip_nonsemantic_info_pass.h similarity index 82% rename from third_party/spirv-tools/source/opt/strip_reflect_info_pass.h rename to third_party/spirv-tools/source/opt/strip_nonsemantic_info_pass.h index 4e1999ed36..ff4e2e1ddf 100644 --- a/third_party/spirv-tools/source/opt/strip_reflect_info_pass.h +++ b/third_party/spirv-tools/source/opt/strip_nonsemantic_info_pass.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SOURCE_OPT_STRIP_REFLECT_INFO_PASS_H_ -#define SOURCE_OPT_STRIP_REFLECT_INFO_PASS_H_ +#ifndef SOURCE_OPT_STRIP_NONSEMANTIC_INFO_PASS_H_ +#define SOURCE_OPT_STRIP_NONSEMANTIC_INFO_PASS_H_ #include "source/opt/ir_context.h" #include "source/opt/module.h" @@ -23,9 +23,9 @@ namespace spvtools { namespace opt { // See optimizer.hpp for documentation. -class StripReflectInfoPass : public Pass { +class StripNonSemanticInfoPass : public Pass { public: - const char* name() const override { return "strip-reflect"; } + const char* name() const override { return "strip-nonsemantic"; } Status Process() override; // Return the mask of preserved Analyses. @@ -41,4 +41,4 @@ class StripReflectInfoPass : public Pass { } // namespace opt } // namespace spvtools -#endif // SOURCE_OPT_STRIP_REFLECT_INFO_PASS_H_ +#endif // SOURCE_OPT_STRIP_NONSEMANTIC_INFO_PASS_H_ diff --git a/third_party/spirv-tools/source/opt/type_manager.cpp b/third_party/spirv-tools/source/opt/type_manager.cpp index 7935ad3313..a0006f5586 100644 --- a/third_party/spirv-tools/source/opt/type_manager.cpp +++ b/third_party/spirv-tools/source/opt/type_manager.cpp @@ -23,6 +23,7 @@ #include "source/opt/log.h" #include "source/opt/reflect.h" #include "source/util/make_unique.h" +#include "source/util/string_utils.h" namespace spvtools { namespace opt { @@ -234,6 +235,7 @@ uint32_t TypeManager::GetTypeInstruction(const Type* type) { DefineParameterlessCase(PipeStorage); DefineParameterlessCase(NamedBarrier); DefineParameterlessCase(AccelerationStructureNV); + DefineParameterlessCase(RayQueryKHR); #undef DefineParameterlessCase case Type::kInteger: typeInst = MakeUnique( @@ -349,11 +351,8 @@ uint32_t TypeManager::GetTypeInstruction(const Type* type) { } case Type::kOpaque: { const Opaque* opaque = type->AsOpaque(); - size_t size = opaque->name().size(); // Convert to null-terminated packed UTF-8 string. - std::vector words(size / 4 + 1, 0); - char* dst = reinterpret_cast(words.data()); - strncpy(dst, opaque->name().c_str(), size); + std::vector words = spvtools::utils::MakeVector(opaque->name()); typeInst = MakeUnique( context(), SpvOpTypeOpaque, 0, id, std::initializer_list{ @@ -529,6 +528,7 @@ Type* TypeManager::RebuildType(const Type& type) { DefineNoSubtypeCase(PipeStorage); DefineNoSubtypeCase(NamedBarrier); DefineNoSubtypeCase(AccelerationStructureNV); + DefineNoSubtypeCase(RayQueryKHR); #undef DefineNoSubtypeCase case Type::kVector: { const Vector* vec_ty = type.AsVector(); @@ -781,8 +781,7 @@ Type* TypeManager::RecordIfTypeDefinition(const Instruction& inst) { } } break; case SpvOpTypeOpaque: { - const uint32_t* data = inst.GetInOperand(0).words.data(); - type = new Opaque(reinterpret_cast(data)); + type = new Opaque(inst.GetInOperand(0).AsString()); } break; case SpvOpTypePointer: { uint32_t pointee_type_id = inst.GetSingleWordInOperand(1); diff --git a/third_party/spirv-tools/source/opt/type_manager.h b/third_party/spirv-tools/source/opt/type_manager.h index ce9d83d410..72e37f4870 100644 --- a/third_party/spirv-tools/source/opt/type_manager.h +++ b/third_party/spirv-tools/source/opt/type_manager.h @@ -160,6 +160,13 @@ class TypeManager { uint32_t GetFloatTypeId() { return GetTypeInstruction(GetFloatType()); } + Type* GetDoubleType() { + Float float_type(64); + return GetRegisteredType(&float_type); + } + + uint32_t GetDoubleTypeId() { return GetTypeInstruction(GetDoubleType()); } + Type* GetUIntVectorType(uint32_t size) { Vector vec_type(GetUIntType(), size); return GetRegisteredType(&vec_type); diff --git a/third_party/spirv-tools/source/opt/types.cpp b/third_party/spirv-tools/source/opt/types.cpp index b1eb3a5084..ebbdc367be 100644 --- a/third_party/spirv-tools/source/opt/types.cpp +++ b/third_party/spirv-tools/source/opt/types.cpp @@ -21,6 +21,7 @@ #include #include +#include "source/util/hash_combine.h" #include "source/util/make_unique.h" #include "spirv/unified1/spirv.h" @@ -28,6 +29,7 @@ namespace spvtools { namespace opt { namespace analysis { +using spvtools::utils::hash_combine; using U32VecVec = std::vector>; namespace { @@ -182,23 +184,26 @@ bool Type::operator==(const Type& other) const { } } -void Type::GetHashWords(std::vector* words, - std::unordered_set* seen) const { - if (!seen->insert(this).second) { - return; +size_t Type::ComputeHashValue(size_t hash, SeenTypes* seen) const { + // Linear search through a dense, cache coherent vector is faster than O(log + // n) search in a complex data structure (eg std::set) for the generally small + // number of nodes. It also skips the overhead of an new/delete per Type + // (when inserting/removing from a set). + if (std::find(seen->begin(), seen->end(), this) != seen->end()) { + return hash; } - words->push_back(kind_); + seen->push_back(this); + + hash = hash_combine(hash, uint32_t(kind_)); for (const auto& d : decorations_) { - for (auto w : d) { - words->push_back(w); - } + hash = hash_combine(hash, d); } switch (kind_) { -#define DeclareKindCase(type) \ - case k##type: \ - As##type()->GetExtraHashWords(words, seen); \ +#define DeclareKindCase(type) \ + case k##type: \ + hash = As##type()->ComputeExtraStateHash(hash, seen); \ break DeclareKindCase(Void); DeclareKindCase(Bool); @@ -232,18 +237,13 @@ void Type::GetHashWords(std::vector* words, break; } - seen->erase(this); + seen->pop_back(); + return hash; } size_t Type::HashValue() const { - std::u32string h; - std::vector words; - GetHashWords(&words); - for (auto w : words) { - h.push_back(w); - } - - return std::hash()(h); + SeenTypes seen; + return ComputeHashValue(0, &seen); } bool Integer::IsSameImpl(const Type* that, IsSameCache*) const { @@ -258,10 +258,8 @@ std::string Integer::str() const { return oss.str(); } -void Integer::GetExtraHashWords(std::vector* words, - std::unordered_set*) const { - words->push_back(width_); - words->push_back(signed_); +size_t Integer::ComputeExtraStateHash(size_t hash, SeenTypes*) const { + return hash_combine(hash, width_, signed_); } bool Float::IsSameImpl(const Type* that, IsSameCache*) const { @@ -275,9 +273,8 @@ std::string Float::str() const { return oss.str(); } -void Float::GetExtraHashWords(std::vector* words, - std::unordered_set*) const { - words->push_back(width_); +size_t Float::ComputeExtraStateHash(size_t hash, SeenTypes*) const { + return hash_combine(hash, width_); } Vector::Vector(const Type* type, uint32_t count) @@ -299,10 +296,11 @@ std::string Vector::str() const { return oss.str(); } -void Vector::GetExtraHashWords(std::vector* words, - std::unordered_set* seen) const { - element_type_->GetHashWords(words, seen); - words->push_back(count_); +size_t Vector::ComputeExtraStateHash(size_t hash, SeenTypes* seen) const { + // prefer form that doesn't require push/pop from stack: add state and + // make tail call. + hash = hash_combine(hash, count_); + return element_type_->ComputeHashValue(hash, seen); } Matrix::Matrix(const Type* type, uint32_t count) @@ -324,10 +322,9 @@ std::string Matrix::str() const { return oss.str(); } -void Matrix::GetExtraHashWords(std::vector* words, - std::unordered_set* seen) const { - element_type_->GetHashWords(words, seen); - words->push_back(count_); +size_t Matrix::ComputeExtraStateHash(size_t hash, SeenTypes* seen) const { + hash = hash_combine(hash, count_); + return element_type_->ComputeHashValue(hash, seen); } Image::Image(Type* type, SpvDim dimen, uint32_t d, bool array, bool multisample, @@ -362,16 +359,10 @@ std::string Image::str() const { return oss.str(); } -void Image::GetExtraHashWords(std::vector* words, - std::unordered_set* seen) const { - sampled_type_->GetHashWords(words, seen); - words->push_back(dim_); - words->push_back(depth_); - words->push_back(arrayed_); - words->push_back(ms_); - words->push_back(sampled_); - words->push_back(format_); - words->push_back(access_qualifier_); +size_t Image::ComputeExtraStateHash(size_t hash, SeenTypes* seen) const { + hash = hash_combine(hash, uint32_t(dim_), depth_, arrayed_, ms_, sampled_, + uint32_t(format_), uint32_t(access_qualifier_)); + return sampled_type_->ComputeHashValue(hash, seen); } bool SampledImage::IsSameImpl(const Type* that, IsSameCache* seen) const { @@ -387,9 +378,8 @@ std::string SampledImage::str() const { return oss.str(); } -void SampledImage::GetExtraHashWords( - std::vector* words, std::unordered_set* seen) const { - image_type_->GetHashWords(words, seen); +size_t SampledImage::ComputeExtraStateHash(size_t hash, SeenTypes* seen) const { + return image_type_->ComputeHashValue(hash, seen); } Array::Array(const Type* type, const Array::LengthInfo& length_info_arg) @@ -422,16 +412,19 @@ std::string Array::str() const { return oss.str(); } -void Array::GetExtraHashWords(std::vector* words, - std::unordered_set* seen) const { - element_type_->GetHashWords(words, seen); - // This should mirror the logic in IsSameImpl - words->insert(words->end(), length_info_.words.begin(), - length_info_.words.end()); +size_t Array::ComputeExtraStateHash(size_t hash, SeenTypes* seen) const { + hash = hash_combine(hash, length_info_.words); + return element_type_->ComputeHashValue(hash, seen); } void Array::ReplaceElementType(const Type* type) { element_type_ = type; } +Array::LengthInfo Array::GetConstantLengthInfo(uint32_t const_id, + uint32_t length) const { + std::vector extra_words{LengthInfo::Case::kConstant, length}; + return {const_id, extra_words}; +} + RuntimeArray::RuntimeArray(const Type* type) : Type(kRuntimeArray), element_type_(type) { assert(!type->AsVoid()); @@ -450,9 +443,8 @@ std::string RuntimeArray::str() const { return oss.str(); } -void RuntimeArray::GetExtraHashWords( - std::vector* words, std::unordered_set* seen) const { - element_type_->GetHashWords(words, seen); +size_t RuntimeArray::ComputeExtraStateHash(size_t hash, SeenTypes* seen) const { + return element_type_->ComputeHashValue(hash, seen); } void RuntimeArray::ReplaceElementType(const Type* type) { @@ -509,19 +501,14 @@ std::string Struct::str() const { return oss.str(); } -void Struct::GetExtraHashWords(std::vector* words, - std::unordered_set* seen) const { +size_t Struct::ComputeExtraStateHash(size_t hash, SeenTypes* seen) const { for (auto* t : element_types_) { - t->GetHashWords(words, seen); + hash = t->ComputeHashValue(hash, seen); } for (const auto& pair : element_decorations_) { - words->push_back(pair.first); - for (const auto& d : pair.second) { - for (auto w : d) { - words->push_back(w); - } - } + hash = hash_combine(hash, pair.first, pair.second); } + return hash; } bool Opaque::IsSameImpl(const Type* that, IsSameCache*) const { @@ -536,11 +523,8 @@ std::string Opaque::str() const { return oss.str(); } -void Opaque::GetExtraHashWords(std::vector* words, - std::unordered_set*) const { - for (auto c : name_) { - words->push_back(static_cast(c)); - } +size_t Opaque::ComputeExtraStateHash(size_t hash, SeenTypes*) const { + return hash_combine(hash, name_); } Pointer::Pointer(const Type* type, SpvStorageClass sc) @@ -569,10 +553,9 @@ std::string Pointer::str() const { return os.str(); } -void Pointer::GetExtraHashWords(std::vector* words, - std::unordered_set* seen) const { - pointee_type_->GetHashWords(words, seen); - words->push_back(storage_class_); +size_t Pointer::ComputeExtraStateHash(size_t hash, SeenTypes* seen) const { + hash = hash_combine(hash, uint32_t(storage_class_)); + return pointee_type_->ComputeHashValue(hash, seen); } void Pointer::SetPointeeType(const Type* type) { pointee_type_ = type; } @@ -606,12 +589,11 @@ std::string Function::str() const { return oss.str(); } -void Function::GetExtraHashWords(std::vector* words, - std::unordered_set* seen) const { - return_type_->GetHashWords(words, seen); +size_t Function::ComputeExtraStateHash(size_t hash, SeenTypes* seen) const { for (const auto* t : param_types_) { - t->GetHashWords(words, seen); + hash = t->ComputeHashValue(hash, seen); } + return return_type_->ComputeHashValue(hash, seen); } void Function::SetReturnType(const Type* type) { return_type_ = type; } @@ -628,9 +610,8 @@ std::string Pipe::str() const { return oss.str(); } -void Pipe::GetExtraHashWords(std::vector* words, - std::unordered_set*) const { - words->push_back(access_qualifier_); +size_t Pipe::ComputeExtraStateHash(size_t hash, SeenTypes*) const { + return hash_combine(hash, uint32_t(access_qualifier_)); } bool ForwardPointer::IsSameImpl(const Type* that, IsSameCache*) const { @@ -653,11 +634,11 @@ std::string ForwardPointer::str() const { return oss.str(); } -void ForwardPointer::GetExtraHashWords( - std::vector* words, std::unordered_set* seen) const { - words->push_back(target_id_); - words->push_back(storage_class_); - if (pointer_) pointer_->GetHashWords(words, seen); +size_t ForwardPointer::ComputeExtraStateHash(size_t hash, + SeenTypes* seen) const { + hash = hash_combine(hash, target_id_, uint32_t(storage_class_)); + if (pointer_) hash = pointer_->ComputeHashValue(hash, seen); + return hash; } CooperativeMatrixNV::CooperativeMatrixNV(const Type* type, const uint32_t scope, @@ -681,12 +662,10 @@ std::string CooperativeMatrixNV::str() const { return oss.str(); } -void CooperativeMatrixNV::GetExtraHashWords( - std::vector* words, std::unordered_set* pSet) const { - component_type_->GetHashWords(words, pSet); - words->push_back(scope_id_); - words->push_back(rows_id_); - words->push_back(columns_id_); +size_t CooperativeMatrixNV::ComputeExtraStateHash(size_t hash, + SeenTypes* seen) const { + hash = hash_combine(hash, scope_id_, rows_id_, columns_id_); + return component_type_->ComputeHashValue(hash, seen); } bool CooperativeMatrixNV::IsSameImpl(const Type* that, diff --git a/third_party/spirv-tools/source/opt/types.h b/third_party/spirv-tools/source/opt/types.h index 9ecd41a6b0..f5a4a6be4f 100644 --- a/third_party/spirv-tools/source/opt/types.h +++ b/third_party/spirv-tools/source/opt/types.h @@ -28,6 +28,7 @@ #include "source/latest_version_spirv_header.h" #include "source/opt/instruction.h" +#include "source/util/small_vector.h" #include "spirv-tools/libspirv.h" namespace spvtools { @@ -67,6 +68,8 @@ class Type { public: typedef std::set> IsSameCache; + using SeenTypes = spvtools::utils::SmallVector; + // Available subtypes. // // When adding a new derived class of Type, please add an entry to the enum. @@ -96,7 +99,8 @@ class Type { kNamedBarrier, kAccelerationStructureNV, kCooperativeMatrixNV, - kRayQueryKHR + kRayQueryKHR, + kLast }; Type(Kind k) : kind_(k) {} @@ -154,21 +158,7 @@ class Type { // Returns the hash value of this type. size_t HashValue() const; - // Adds the necessary words to compute a hash value of this type to |words|. - void GetHashWords(std::vector* words) const { - std::unordered_set seen; - GetHashWords(words, &seen); - } - - // Adds the necessary words to compute a hash value of this type to |words|. - void GetHashWords(std::vector* words, - std::unordered_set* seen) const; - - // Adds necessary extra words for a subtype to calculate a hash value into - // |words|. - virtual void GetExtraHashWords( - std::vector* words, - std::unordered_set* pSet) const = 0; + size_t ComputeHashValue(size_t hash, SeenTypes* seen) const; // A bunch of methods for casting this type to a given type. Returns this if the // cast can be done, nullptr otherwise. @@ -204,6 +194,10 @@ class Type { DeclareCastMethod(RayQueryKHR) #undef DeclareCastMethod +protected: + // Add any type-specific state to |hash| and returns new hash. + virtual size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const = 0; + protected: // Decorations attached to this type. Each decoration is encoded as a vector // of uint32_t numbers. The first uint32_t number is the decoration value, @@ -232,8 +226,7 @@ class Integer : public Type { uint32_t width() const { return width_; } bool IsSigned() const { return signed_; } - void GetExtraHashWords(std::vector* words, - std::unordered_set* pSet) const override; + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; private: bool IsSameImpl(const Type* that, IsSameCache*) const override; @@ -253,8 +246,7 @@ class Float : public Type { const Float* AsFloat() const override { return this; } uint32_t width() const { return width_; } - void GetExtraHashWords(std::vector* words, - std::unordered_set* pSet) const override; + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; private: bool IsSameImpl(const Type* that, IsSameCache*) const override; @@ -274,8 +266,7 @@ class Vector : public Type { Vector* AsVector() override { return this; } const Vector* AsVector() const override { return this; } - void GetExtraHashWords(std::vector* words, - std::unordered_set* pSet) const override; + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; private: bool IsSameImpl(const Type* that, IsSameCache*) const override; @@ -296,8 +287,7 @@ class Matrix : public Type { Matrix* AsMatrix() override { return this; } const Matrix* AsMatrix() const override { return this; } - void GetExtraHashWords(std::vector* words, - std::unordered_set* pSet) const override; + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; private: bool IsSameImpl(const Type* that, IsSameCache*) const override; @@ -327,8 +317,7 @@ class Image : public Type { SpvImageFormat format() const { return format_; } SpvAccessQualifier access_qualifier() const { return access_qualifier_; } - void GetExtraHashWords(std::vector* words, - std::unordered_set* pSet) const override; + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; private: bool IsSameImpl(const Type* that, IsSameCache*) const override; @@ -355,8 +344,7 @@ class SampledImage : public Type { const Type* image_type() const { return image_type_; } - void GetExtraHashWords(std::vector* words, - std::unordered_set* pSet) const override; + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; private: bool IsSameImpl(const Type* that, IsSameCache*) const override; @@ -399,10 +387,10 @@ class Array : public Type { Array* AsArray() override { return this; } const Array* AsArray() const override { return this; } - void GetExtraHashWords(std::vector* words, - std::unordered_set* pSet) const override; + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; void ReplaceElementType(const Type* element_type); + LengthInfo GetConstantLengthInfo(uint32_t const_id, uint32_t length) const; private: bool IsSameImpl(const Type* that, IsSameCache*) const override; @@ -422,8 +410,7 @@ class RuntimeArray : public Type { RuntimeArray* AsRuntimeArray() override { return this; } const RuntimeArray* AsRuntimeArray() const override { return this; } - void GetExtraHashWords(std::vector* words, - std::unordered_set* pSet) const override; + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; void ReplaceElementType(const Type* element_type); @@ -459,8 +446,7 @@ class Struct : public Type { Struct* AsStruct() override { return this; } const Struct* AsStruct() const override { return this; } - void GetExtraHashWords(std::vector* words, - std::unordered_set* pSet) const override; + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; private: bool IsSameImpl(const Type* that, IsSameCache*) const override; @@ -491,8 +477,7 @@ class Opaque : public Type { const std::string& name() const { return name_; } - void GetExtraHashWords(std::vector* words, - std::unordered_set* pSet) const override; + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; private: bool IsSameImpl(const Type* that, IsSameCache*) const override; @@ -512,8 +497,7 @@ class Pointer : public Type { Pointer* AsPointer() override { return this; } const Pointer* AsPointer() const override { return this; } - void GetExtraHashWords(std::vector* words, - std::unordered_set* pSet) const override; + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; void SetPointeeType(const Type* type); @@ -539,8 +523,7 @@ class Function : public Type { const std::vector& param_types() const { return param_types_; } std::vector& param_types() { return param_types_; } - void GetExtraHashWords(std::vector* words, - std::unordered_set*) const override; + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; void SetReturnType(const Type* type); @@ -564,8 +547,7 @@ class Pipe : public Type { SpvAccessQualifier access_qualifier() const { return access_qualifier_; } - void GetExtraHashWords(std::vector* words, - std::unordered_set* pSet) const override; + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; private: bool IsSameImpl(const Type* that, IsSameCache*) const override; @@ -592,8 +574,7 @@ class ForwardPointer : public Type { ForwardPointer* AsForwardPointer() override { return this; } const ForwardPointer* AsForwardPointer() const override { return this; } - void GetExtraHashWords(std::vector* words, - std::unordered_set* pSet) const override; + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; private: bool IsSameImpl(const Type* that, IsSameCache*) const override; @@ -616,8 +597,7 @@ class CooperativeMatrixNV : public Type { return this; } - void GetExtraHashWords(std::vector*, - std::unordered_set*) const override; + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; const Type* component_type() const { return component_type_; } uint32_t scope_id() const { return scope_id_; } @@ -633,24 +613,25 @@ class CooperativeMatrixNV : public Type { const uint32_t columns_id_; }; -#define DefineParameterlessType(type, name) \ - class type : public Type { \ - public: \ - type() : Type(k##type) {} \ - type(const type&) = default; \ - \ - std::string str() const override { return #name; } \ - \ - type* As##type() override { return this; } \ - const type* As##type() const override { return this; } \ - \ - void GetExtraHashWords(std::vector*, \ - std::unordered_set*) const override {} \ - \ - private: \ - bool IsSameImpl(const Type* that, IsSameCache*) const override { \ - return that->As##type() && HasSameDecorations(that); \ - } \ +#define DefineParameterlessType(type, name) \ + class type : public Type { \ + public: \ + type() : Type(k##type) {} \ + type(const type&) = default; \ + \ + std::string str() const override { return #name; } \ + \ + type* As##type() override { return this; } \ + const type* As##type() const override { return this; } \ + \ + size_t ComputeExtraStateHash(size_t hash, SeenTypes*) const override { \ + return hash; \ + } \ + \ + private: \ + bool IsSameImpl(const Type* that, IsSameCache*) const override { \ + return that->As##type() && HasSameDecorations(that); \ + } \ } DefineParameterlessType(Void, void); DefineParameterlessType(Bool, bool); diff --git a/third_party/spirv-tools/source/opt/unify_const_pass.cpp b/third_party/spirv-tools/source/opt/unify_const_pass.cpp index 227fd61da2..6bfa11a5bd 100644 --- a/third_party/spirv-tools/source/opt/unify_const_pass.cpp +++ b/third_party/spirv-tools/source/opt/unify_const_pass.cpp @@ -151,7 +151,7 @@ Pass::Status UnifyConstantPass::Process() { // 'SpecId' decoration and all of them should be treated as unique. // 'SpecId' is not applicable to SpecConstants defined with // OpSpecConstant{Op|Composite}, their values are not necessary to be - // unique. When all the operands/compoents are the same between two + // unique. When all the operands/components are the same between two // OpSpecConstant{Op|Composite} results, their result values must be the // same so are unifiable. case SpvOp::SpvOpSpecConstantOp: diff --git a/third_party/spirv-tools/source/opt/upgrade_memory_model.cpp b/third_party/spirv-tools/source/opt/upgrade_memory_model.cpp index ab252059fa..9d6a5bceb4 100644 --- a/third_party/spirv-tools/source/opt/upgrade_memory_model.cpp +++ b/third_party/spirv-tools/source/opt/upgrade_memory_model.cpp @@ -20,6 +20,7 @@ #include "source/opt/ir_context.h" #include "source/spirv_constant.h" #include "source/util/make_unique.h" +#include "source/util/string_utils.h" namespace spvtools { namespace opt { @@ -58,9 +59,7 @@ void UpgradeMemoryModel::UpgradeMemoryModelInstruction() { std::initializer_list{ {SPV_OPERAND_TYPE_CAPABILITY, {SpvCapabilityVulkanMemoryModelKHR}}})); const std::string extension = "SPV_KHR_vulkan_memory_model"; - std::vector words(extension.size() / 4 + 1, 0); - char* dst = reinterpret_cast(words.data()); - strncpy(dst, extension.c_str(), extension.size()); + std::vector words = spvtools::utils::MakeVector(extension); context()->AddExtension( MakeUnique(context(), SpvOpExtension, 0, 0, std::initializer_list{ @@ -85,8 +84,7 @@ void UpgradeMemoryModel::UpgradeInstructions() { if (ext_inst == GLSLstd450Modf || ext_inst == GLSLstd450Frexp) { auto import = get_def_use_mgr()->GetDef(inst->GetSingleWordInOperand(0u)); - if (reinterpret_cast(import->GetInOperand(0u).words.data()) == - std::string("GLSL.std.450")) { + if (import->GetInOperand(0u).AsString() == "GLSL.std.450") { UpgradeExtInst(inst); } } diff --git a/third_party/spirv-tools/source/opt/vector_dce.h b/third_party/spirv-tools/source/opt/vector_dce.h index 4d30b926b8..a55bda692c 100644 --- a/third_party/spirv-tools/source/opt/vector_dce.h +++ b/third_party/spirv-tools/source/opt/vector_dce.h @@ -73,7 +73,7 @@ class VectorDCE : public MemPass { bool RewriteInstructions(Function* function, const LiveComponentMap& live_components); - // Makrs all DebugValue instructions that use |composite| for their values as + // Makes all DebugValue instructions that use |composite| for their values as // dead instructions by putting them into |dead_dbg_value|. void MarkDebugValueUsesAsDead(Instruction* composite, std::vector* dead_dbg_value); diff --git a/third_party/spirv-tools/source/parsed_operand.cpp b/third_party/spirv-tools/source/parsed_operand.cpp index 7ad369cdb2..5f8e94db84 100644 --- a/third_party/spirv-tools/source/parsed_operand.cpp +++ b/third_party/spirv-tools/source/parsed_operand.cpp @@ -24,7 +24,9 @@ namespace spvtools { void EmitNumericLiteral(std::ostream* out, const spv_parsed_instruction_t& inst, const spv_parsed_operand_t& operand) { if (operand.type != SPV_OPERAND_TYPE_LITERAL_INTEGER && - operand.type != SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER) + operand.type != SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER && + operand.type != SPV_OPERAND_TYPE_OPTIONAL_LITERAL_INTEGER && + operand.type != SPV_OPERAND_TYPE_OPTIONAL_TYPED_LITERAL_INTEGER) return; if (operand.num_words < 1) return; // TODO(dneto): Support more than 64-bits at a time. diff --git a/third_party/spirv-tools/source/reduce/remove_struct_member_reduction_opportunity.cpp b/third_party/spirv-tools/source/reduce/remove_struct_member_reduction_opportunity.cpp index da096e1ebe..e72ed3514c 100644 --- a/third_party/spirv-tools/source/reduce/remove_struct_member_reduction_opportunity.cpp +++ b/third_party/spirv-tools/source/reduce/remove_struct_member_reduction_opportunity.cpp @@ -153,7 +153,7 @@ void RemoveStructMemberReductionOpportunity::AdjustAccessedIndices( next_type = type_inst->GetSingleWordInOperand(0); break; case SpvOpTypeStruct: { - // Struct types are special becuase (a) we may need to adjust the index + // Struct types are special because (a) we may need to adjust the index // being used, if the struct type is the one from which we are removing // a member, and (b) the type encountered by following the current index // is dependent on the value of the index. diff --git a/third_party/spirv-tools/source/reduce/remove_unused_struct_member_reduction_opportunity_finder.cpp b/third_party/spirv-tools/source/reduce/remove_unused_struct_member_reduction_opportunity_finder.cpp index e72be625e2..cd0c4e4d7b 100644 --- a/third_party/spirv-tools/source/reduce/remove_unused_struct_member_reduction_opportunity_finder.cpp +++ b/third_party/spirv-tools/source/reduce/remove_unused_struct_member_reduction_opportunity_finder.cpp @@ -136,9 +136,9 @@ RemoveUnusedStructMemberReductionOpportunityFinder::GetAvailableOpportunities( } } - // We now know those struct indices that are unsed, and we make a reduction + // We now know those struct indices that are unused, and we make a reduction // opportunity for each of them. By mapping each relevant member index to the - // structs in which it is unsed, we will group all opportunities to remove + // structs in which it is unused, we will group all opportunities to remove // member k of a struct (for some k) together. This reduces the likelihood // that opportunities to remove members from the same struct will be adjacent, // which is good because such opportunities mutually disable one another. diff --git a/third_party/spirv-tools/source/reduce/structured_construct_to_block_reduction_opportunity_finder.cpp b/third_party/spirv-tools/source/reduce/structured_construct_to_block_reduction_opportunity_finder.cpp index dc20f689bc..29fbe551ad 100644 --- a/third_party/spirv-tools/source/reduce/structured_construct_to_block_reduction_opportunity_finder.cpp +++ b/third_party/spirv-tools/source/reduce/structured_construct_to_block_reduction_opportunity_finder.cpp @@ -96,7 +96,7 @@ StructuredConstructToBlockReductionOpportunityFinder::GetAvailableOpportunities( // This also means that we don't add a region. continue; } - // We have a reachable header block with a rechable merge that + // We have a reachable header block with a reachable merge that // postdominates the header: this means we have a new region. regions.emplace(&block, std::unordered_set()); } @@ -128,7 +128,7 @@ bool StructuredConstructToBlockReductionOpportunityFinder:: if (!block->WhileEachInst( [context, &header, ®ion](opt::Instruction* inst) -> bool { if (inst->result_id() == 0) { - // The instruction does not genreate a result id, thus it cannot + // The instruction does not generate a result id, thus it cannot // be referred to outside the region - this is fine. return true; } diff --git a/third_party/spirv-tools/source/spirv_definition.h b/third_party/spirv-tools/source/spirv_definition.h index 63a4ef0db2..5dbd6ab205 100644 --- a/third_party/spirv-tools/source/spirv_definition.h +++ b/third_party/spirv-tools/source/spirv_definition.h @@ -27,7 +27,7 @@ typedef struct spv_header_t { uint32_t generator; uint32_t bound; uint32_t schema; // NOTE: Reserved - const uint32_t* instructions; // NOTE: Unfixed pointer to instruciton stream + const uint32_t* instructions; // NOTE: Unfixed pointer to instruction stream } spv_header_t; #endif // SOURCE_SPIRV_DEFINITION_H_ diff --git a/third_party/spirv-tools/source/spirv_endian.h b/third_party/spirv-tools/source/spirv_endian.h index c2540bec92..b4927f318d 100644 --- a/third_party/spirv-tools/source/spirv_endian.h +++ b/third_party/spirv-tools/source/spirv_endian.h @@ -31,7 +31,7 @@ uint64_t spvFixDoubleWord(const uint32_t low, const uint32_t high, spv_result_t spvBinaryEndianness(const spv_const_binary binary, spv_endianness_t* endian); -// Returns true if the given endianness matches the host's native endiannes. +// Returns true if the given endianness matches the host's native endianness. bool spvIsHostEndian(spv_endianness_t endian); #endif // SOURCE_SPIRV_ENDIAN_H_ diff --git a/third_party/spirv-tools/source/spirv_target_env.cpp b/third_party/spirv-tools/source/spirv_target_env.cpp index 187ab61ec9..9a03817426 100644 --- a/third_party/spirv-tools/source/spirv_target_env.cpp +++ b/third_party/spirv-tools/source/spirv_target_env.cpp @@ -72,6 +72,10 @@ const char* spvTargetEnvDescription(spv_target_env env) { return "SPIR-V 1.5"; case SPV_ENV_VULKAN_1_2: return "SPIR-V 1.5 (under Vulkan 1.2 semantics)"; + case SPV_ENV_UNIVERSAL_1_6: + return "SPIR-V 1.6"; + case SPV_ENV_VULKAN_1_3: + return "SPIR-V 1.6 (under Vulkan 1.3 semantics)"; case SPV_ENV_MAX: assert(false && "Invalid target environment value."); break; @@ -113,6 +117,9 @@ uint32_t spvVersionForTargetEnv(spv_target_env env) { case SPV_ENV_UNIVERSAL_1_5: case SPV_ENV_VULKAN_1_2: return SPV_SPIRV_VERSION_WORD(1, 5); + case SPV_ENV_UNIVERSAL_1_6: + case SPV_ENV_VULKAN_1_3: + return SPV_SPIRV_VERSION_WORD(1, 6); case SPV_ENV_MAX: assert(false && "Invalid target environment value."); break; @@ -125,12 +132,14 @@ static const std::pair spvTargetEnvNameMap[] = { {"vulkan1.0", SPV_ENV_VULKAN_1_0}, {"vulkan1.1", SPV_ENV_VULKAN_1_1}, {"vulkan1.2", SPV_ENV_VULKAN_1_2}, + {"vulkan1.3", SPV_ENV_VULKAN_1_3}, {"spv1.0", SPV_ENV_UNIVERSAL_1_0}, {"spv1.1", SPV_ENV_UNIVERSAL_1_1}, {"spv1.2", SPV_ENV_UNIVERSAL_1_2}, {"spv1.3", SPV_ENV_UNIVERSAL_1_3}, {"spv1.4", SPV_ENV_UNIVERSAL_1_4}, {"spv1.5", SPV_ENV_UNIVERSAL_1_5}, + {"spv1.6", SPV_ENV_UNIVERSAL_1_6}, {"opencl1.2embedded", SPV_ENV_OPENCL_EMBEDDED_1_2}, {"opencl1.2", SPV_ENV_OPENCL_1_2}, {"opencl2.0embedded", SPV_ENV_OPENCL_EMBEDDED_2_0}, @@ -177,7 +186,8 @@ static const VulkanEnv ordered_vulkan_envs[] = { {SPV_ENV_VULKAN_1_0, VULKAN_VER(1, 0), SPIRV_VER(1, 0)}, {SPV_ENV_VULKAN_1_1, VULKAN_VER(1, 1), SPIRV_VER(1, 3)}, {SPV_ENV_VULKAN_1_1_SPIRV_1_4, VULKAN_VER(1, 1), SPIRV_VER(1, 4)}, - {SPV_ENV_VULKAN_1_2, VULKAN_VER(1, 2), SPIRV_VER(1, 5)}}; + {SPV_ENV_VULKAN_1_2, VULKAN_VER(1, 2), SPIRV_VER(1, 5)}, + {SPV_ENV_VULKAN_1_3, VULKAN_VER(1, 3), SPIRV_VER(1, 6)}}; bool spvParseVulkanEnv(uint32_t vulkan_ver, uint32_t spirv_ver, spv_target_env* env) { @@ -211,11 +221,13 @@ bool spvIsVulkanEnv(spv_target_env env) { case SPV_ENV_UNIVERSAL_1_3: case SPV_ENV_UNIVERSAL_1_4: case SPV_ENV_UNIVERSAL_1_5: + case SPV_ENV_UNIVERSAL_1_6: return false; case SPV_ENV_VULKAN_1_0: case SPV_ENV_VULKAN_1_1: case SPV_ENV_VULKAN_1_1_SPIRV_1_4: case SPV_ENV_VULKAN_1_2: + case SPV_ENV_VULKAN_1_3: return true; case SPV_ENV_WEBGPU_0: assert(false && "Deprecated target environment value."); @@ -244,6 +256,8 @@ bool spvIsOpenCLEnv(spv_target_env env) { case SPV_ENV_VULKAN_1_1_SPIRV_1_4: case SPV_ENV_UNIVERSAL_1_5: case SPV_ENV_VULKAN_1_2: + case SPV_ENV_UNIVERSAL_1_6: + case SPV_ENV_VULKAN_1_3: return false; case SPV_ENV_OPENCL_1_2: case SPV_ENV_OPENCL_EMBEDDED_1_2: @@ -284,6 +298,8 @@ bool spvIsOpenGLEnv(spv_target_env env) { case SPV_ENV_VULKAN_1_1_SPIRV_1_4: case SPV_ENV_UNIVERSAL_1_5: case SPV_ENV_VULKAN_1_2: + case SPV_ENV_UNIVERSAL_1_6: + case SPV_ENV_VULKAN_1_3: return false; case SPV_ENV_OPENGL_4_0: case SPV_ENV_OPENGL_4_1: @@ -321,6 +337,8 @@ bool spvIsValidEnv(spv_target_env env) { case SPV_ENV_VULKAN_1_1_SPIRV_1_4: case SPV_ENV_UNIVERSAL_1_5: case SPV_ENV_VULKAN_1_2: + case SPV_ENV_UNIVERSAL_1_6: + case SPV_ENV_VULKAN_1_3: case SPV_ENV_OPENGL_4_0: case SPV_ENV_OPENGL_4_1: case SPV_ENV_OPENGL_4_2: @@ -355,16 +373,18 @@ std::string spvLogStringForEnv(spv_target_env env) { } case SPV_ENV_VULKAN_1_0: case SPV_ENV_VULKAN_1_1: - case SPV_ENV_VULKAN_1_1_SPIRV_1_4: { - case SPV_ENV_VULKAN_1_2: - return "Vulkan"; + case SPV_ENV_VULKAN_1_1_SPIRV_1_4: + case SPV_ENV_VULKAN_1_2: + case SPV_ENV_VULKAN_1_3: { + return "Vulkan"; } case SPV_ENV_UNIVERSAL_1_0: case SPV_ENV_UNIVERSAL_1_1: case SPV_ENV_UNIVERSAL_1_2: case SPV_ENV_UNIVERSAL_1_3: case SPV_ENV_UNIVERSAL_1_4: - case SPV_ENV_UNIVERSAL_1_5: { + case SPV_ENV_UNIVERSAL_1_5: + case SPV_ENV_UNIVERSAL_1_6: { return "Universal"; } case SPV_ENV_WEBGPU_0: diff --git a/third_party/spirv-tools/source/spirv_target_env.h b/third_party/spirv-tools/source/spirv_target_env.h index cc06deca74..f3b0c2f6f2 100644 --- a/third_party/spirv-tools/source/spirv_target_env.h +++ b/third_party/spirv-tools/source/spirv_target_env.h @@ -40,7 +40,7 @@ std::string spvLogStringForEnv(spv_target_env env); // Returns a formatted list of all SPIR-V target environment names that // can be parsed by spvParseTargetEnv. -// |pad| is the number of space characters that the begining of each line +// |pad| is the number of space characters that the beginning of each line // except the first one will be padded with. // |wrap| is the max length of lines the user desires. Word-wrapping will // occur to satisfy this limit. diff --git a/third_party/spirv-tools/source/table.cpp b/third_party/spirv-tools/source/table.cpp index d4a2d7e967..822cefebd7 100644 --- a/third_party/spirv-tools/source/table.cpp +++ b/third_party/spirv-tools/source/table.cpp @@ -41,6 +41,8 @@ spv_context spvContextCreate(spv_target_env env) { case SPV_ENV_UNIVERSAL_1_4: case SPV_ENV_UNIVERSAL_1_5: case SPV_ENV_VULKAN_1_2: + case SPV_ENV_UNIVERSAL_1_6: + case SPV_ENV_VULKAN_1_3: break; default: return nullptr; diff --git a/third_party/spirv-tools/source/text.cpp b/third_party/spirv-tools/source/text.cpp index 88a8e8ffad..90f69c5255 100644 --- a/third_party/spirv-tools/source/text.cpp +++ b/third_party/spirv-tools/source/text.cpp @@ -403,9 +403,10 @@ spv_result_t spvTextEncodeOperand(const spvtools::AssemblyGrammar& grammar, case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS: case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS: { uint32_t value; - if (grammar.parseMaskOperand(type, textValue, &value)) { - return context->diagnostic() << "Invalid " << spvOperandTypeStr(type) - << " operand '" << textValue << "'."; + if (auto error = grammar.parseMaskOperand(type, textValue, &value)) { + return context->diagnostic(error) + << "Invalid " << spvOperandTypeStr(type) << " operand '" + << textValue << "'."; } if (auto error = context->binaryEncodeU32(value, pInst)) return error; // Prepare to parse the operands for this logical operand. @@ -622,7 +623,8 @@ spv_result_t spvTextEncodeOpcode(const spvtools::AssemblyGrammar& grammar, break; } else { return context->diagnostic() - << "Expected operand, found end of stream."; + << "Expected operand for " << opcodeName + << " instruction, but found the end of the stream."; } } assert(error == SPV_SUCCESS && "Somebody added another way to fail"); @@ -632,7 +634,8 @@ spv_result_t spvTextEncodeOpcode(const spvtools::AssemblyGrammar& grammar, break; } else { return context->diagnostic() - << "Expected operand, found next instruction instead."; + << "Expected operand for " << opcodeName + << " instruction, but found the next instruction instead."; } } @@ -666,7 +669,7 @@ spv_result_t spvTextEncodeOpcode(const spvtools::AssemblyGrammar& grammar, if (pInst->words.size() > SPV_LIMIT_INSTRUCTION_WORD_COUNT_MAX) { return context->diagnostic() - << "Instruction too long: " << pInst->words.size() + << opcodeName << " Instruction too long: " << pInst->words.size() << " words, but the limit is " << SPV_LIMIT_INSTRUCTION_WORD_COUNT_MAX; } @@ -715,6 +718,12 @@ spv_result_t GetNumericIds(const spvtools::AssemblyGrammar& grammar, while (context.hasText()) { spv_instruction_t inst; + // Operand parsing sometimes involves knowing the opcode of the instruction + // being parsed. A malformed input might feature such an operand *before* + // the opcode is known. To guard against accessing an uninitialized opcode, + // the instruction's opcode is initialized to a default value. + inst.opcode = SpvOpMax; + if (spvTextEncodeOpcode(grammar, &context, &inst)) { return SPV_ERROR_INVALID_TEXT; } @@ -763,8 +772,8 @@ spv_result_t spvTextToBinaryInternal(const spvtools::AssemblyGrammar& grammar, instructions.push_back({}); spv_instruction_t& inst = instructions.back(); - if (spvTextEncodeOpcode(grammar, &context, &inst)) { - return SPV_ERROR_INVALID_TEXT; + if (auto error = spvTextEncodeOpcode(grammar, &context, &inst)) { + return error; } if (context.advance()) break; diff --git a/third_party/spirv-tools/source/text_handler.cpp b/third_party/spirv-tools/source/text_handler.cpp index 46b9845617..fe12a26e38 100644 --- a/third_party/spirv-tools/source/text_handler.cpp +++ b/third_party/spirv-tools/source/text_handler.cpp @@ -29,6 +29,7 @@ #include "source/util/bitutils.h" #include "source/util/hex_float.h" #include "source/util/parse_number.h" +#include "source/util/string_utils.h" namespace spvtools { namespace { @@ -307,14 +308,8 @@ spv_result_t AssemblyContext::binaryEncodeString(const char* value, << SPV_LIMIT_INSTRUCTION_WORD_COUNT_MAX << " words."; } - pInst->words.resize(newWordCount); - - // Make sure all the bytes in the last word are 0, in case we only - // write a partial word at the end. - pInst->words.back() = 0; - - char* dest = (char*)&pInst->words[oldWordCount]; - strncpy(dest, value, length + 1); + pInst->words.reserve(newWordCount); + spvtools::utils::AppendToVector(value, &pInst->words); return SPV_SUCCESS; } diff --git a/third_party/spirv-tools/source/util/bit_vector.h b/third_party/spirv-tools/source/util/bit_vector.h index 3e189cb10d..826d62f023 100644 --- a/third_party/spirv-tools/source/util/bit_vector.h +++ b/third_party/spirv-tools/source/util/bit_vector.h @@ -32,7 +32,7 @@ class BitVector { enum { kInitialNumBits = 1024 }; public: - // Creates a bit vector contianing 0s. + // Creates a bit vector containing 0s. BitVector(uint32_t reserved_size = kInitialNumBits) : bits_((reserved_size - 1) / kBitContainerSize + 1, 0) {} diff --git a/third_party/spirv-tools/source/util/hash_combine.h b/third_party/spirv-tools/source/util/hash_combine.h new file mode 100644 index 0000000000..1a2dbc332a --- /dev/null +++ b/third_party/spirv-tools/source/util/hash_combine.h @@ -0,0 +1,53 @@ +// Copyright (c) 2022 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef SOURCE_UTIL_HASH_COMBINE_H_ +#define SOURCE_UTIL_HASH_COMBINE_H_ + +#include +#include +#include + +namespace spvtools { +namespace utils { + +// Helpers for incrementally computing hashes. +// For reference, see +// http://open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3876.pdf + +template +inline size_t hash_combine(std::size_t seed, const T& val) { + return seed ^ (std::hash()(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2)); +} + +template +inline size_t hash_combine(std::size_t hash, const std::vector& vals) { + for (const T& val : vals) { + hash = hash_combine(hash, val); + } + return hash; +} + +inline size_t hash_combine(std::size_t hash) { return hash; } + +template +inline size_t hash_combine(std::size_t hash, const T& val, + const Types&... args) { + return hash_combine(hash_combine(hash, val), args...); +} + +} // namespace utils +} // namespace spvtools + +#endif // SOURCE_UTIL_HASH_COMBINE_H_ diff --git a/third_party/spirv-tools/source/util/hex_float.h b/third_party/spirv-tools/source/util/hex_float.h index be28eae3ae..903b62880c 100644 --- a/third_party/spirv-tools/source/util/hex_float.h +++ b/third_party/spirv-tools/source/util/hex_float.h @@ -199,7 +199,7 @@ bool operator==(const FloatProxy& first, const FloatProxy& second) { // Reads a FloatProxy value as a normal float from a stream. template std::istream& operator>>(std::istream& is, FloatProxy& value) { - T float_val; + T float_val = static_cast(0.0); is >> float_val; value = FloatProxy(float_val); return is; diff --git a/third_party/spirv-tools/source/util/ilist.h b/third_party/spirv-tools/source/util/ilist.h index 9837b09b32..42d5e62b91 100644 --- a/third_party/spirv-tools/source/util/ilist.h +++ b/third_party/spirv-tools/source/util/ilist.h @@ -59,7 +59,7 @@ class IntrusiveList { // Moves the contents of the given list to the list being constructed. IntrusiveList(IntrusiveList&&); - // Destorys the list. Note that the elements of the list will not be deleted, + // Destroys the list. Note that the elements of the list will not be deleted, // but they will be removed from the list. virtual ~IntrusiveList(); @@ -348,6 +348,7 @@ void IntrusiveList::Check(NodeType* start) { p = p->next_node_; } while (p != start); assert(sentinel_count == 1 && "List should have exactly 1 sentinel node."); + (void)sentinel_count; p = start; do { diff --git a/third_party/spirv-tools/source/util/parse_number.h b/third_party/spirv-tools/source/util/parse_number.h index 729aac54bf..d0f2a09a36 100644 --- a/third_party/spirv-tools/source/util/parse_number.h +++ b/third_party/spirv-tools/source/util/parse_number.h @@ -220,7 +220,7 @@ EncodeNumberStatus ParseAndEncodeIntegerNumber( std::function emit, std::string* error_msg); // Parses a floating point value of a given |type| from the given |text| and -// encodes the number by the given |emit| funciton. On success, returns +// encodes the number by the given |emit| function. On success, returns // EncodeNumberStatus::kSuccess and the parsed number will be consumed by the // given |emit| function word by word (least significant word first). On // failure, this function returns the error code of the encoding status and diff --git a/third_party/spirv-tools/source/util/pooled_linked_list.h b/third_party/spirv-tools/source/util/pooled_linked_list.h new file mode 100644 index 0000000000..faaa4c44e1 --- /dev/null +++ b/third_party/spirv-tools/source/util/pooled_linked_list.h @@ -0,0 +1,236 @@ +// Copyright (c) 2021 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef SOURCE_UTIL_POOLED_LINKED_LIST_H_ +#define SOURCE_UTIL_POOLED_LINKED_LIST_H_ + +#include +#include + +namespace spvtools { +namespace utils { + +// Shared storage of nodes for PooledLinkedList. +template +class PooledLinkedListNodes { + public: + struct Node { + Node(T e, int32_t n = -1) : element(e), next(n) {} + + T element = {}; + int32_t next = -1; + }; + + PooledLinkedListNodes() = default; + PooledLinkedListNodes(const PooledLinkedListNodes&) = delete; + PooledLinkedListNodes& operator=(const PooledLinkedListNodes&) = delete; + + PooledLinkedListNodes(PooledLinkedListNodes&& that) { + *this = std::move(that); + } + + PooledLinkedListNodes& operator=(PooledLinkedListNodes&& that) { + vec_ = std::move(that.vec_); + free_nodes_ = that.free_nodes_; + return *this; + } + + size_t total_nodes() { return vec_.size(); } + size_t free_nodes() { return free_nodes_; } + size_t used_nodes() { return total_nodes() - free_nodes(); } + + private: + template + friend class PooledLinkedList; + + Node& at(int32_t index) { return vec_[index]; } + const Node& at(int32_t index) const { return vec_[index]; } + + int32_t insert(T element) { + int32_t index = int32_t(vec_.size()); + vec_.emplace_back(element); + return index; + } + + std::vector vec_; + size_t free_nodes_ = 0; +}; + +// Implements a linked-list where list nodes come from a shared pool. This is +// meant to be used in scenarios where it is desirable to avoid many small +// allocations. +// +// Instead of pointers, the list uses indices to allow the underlying storage +// to be modified without needing to modify the list. When removing elements +// from the list, nodes are not deleted or recycled: to reclaim unused space, +// perform a sequence of |move_nodes| operations into a temporary pool, which +// then is moved into the old pool. +// +// This does *not* attempt to implement a full stl-compatible interface. +template +class PooledLinkedList { + public: + using NodePool = PooledLinkedListNodes; + using Node = typename NodePool::Node; + + PooledLinkedList() = delete; + PooledLinkedList(NodePool* nodes) : nodes_(nodes) {} + + // Shared iterator implementation (for iterator and const_iterator). + template + class iterator_base { + public: + iterator_base(const iterator_base& i) + : nodes_(i.nodes_), index_(i.index_) {} + + iterator_base& operator++() { + index_ = nodes_->at(index_).next; + return *this; + } + + iterator_base& operator=(const iterator_base& i) { + nodes_ = i.nodes_; + index_ = i.index_; + return *this; + } + + ElementT& operator*() const { return nodes_->at(index_).element; } + ElementT* operator->() const { return &nodes_->at(index_).element; } + + friend inline bool operator==(const iterator_base& lhs, + const iterator_base& rhs) { + return lhs.nodes_ == rhs.nodes_ && lhs.index_ == rhs.index_; + } + friend inline bool operator!=(const iterator_base& lhs, + const iterator_base& rhs) { + return lhs.nodes_ != rhs.nodes_ || lhs.index_ != rhs.index_; + } + + // Define standard iterator types needs so this class can be + // used with . + using iterator_category = std::forward_iterator_tag; + using difference_type = std::ptrdiff_t; + using value_type = ElementT; + using pointer = ElementT*; + using const_pointer = const ElementT*; + using reference = ElementT&; + using const_reference = const ElementT&; + using size_type = size_t; + + private: + friend PooledLinkedList; + + iterator_base(PoolT* pool, int32_t index) : nodes_(pool), index_(index) {} + + PoolT* nodes_; + int32_t index_ = -1; + }; + + using iterator = iterator_base>; + using const_iterator = iterator_base>; + + bool empty() const { return head_ == -1; } + + T& front() { return nodes_->at(head_).element; } + T& back() { return nodes_->at(tail_).element; } + const T& front() const { return nodes_->at(head_).element; } + const T& back() const { return nodes_->at(tail_).element; } + + iterator begin() { return iterator(&nodes_->vec_, head_); } + iterator end() { return iterator(&nodes_->vec_, -1); } + const_iterator begin() const { return const_iterator(&nodes_->vec_, head_); } + const_iterator end() const { return const_iterator(&nodes_->vec_, -1); } + + // Inserts |element| at the back of the list. + void push_back(T element) { + int32_t new_tail = nodes_->insert(element); + if (head_ == -1) { + head_ = new_tail; + tail_ = new_tail; + } else { + nodes_->at(tail_).next = new_tail; + tail_ = new_tail; + } + } + + // Removes the first occurrence of |element| from the list. + // Returns if |element| was removed. + bool remove_first(T element) { + int32_t* prev_next = &head_; + for (int32_t prev_index = -1, index = head_; index != -1; /**/) { + auto& node = nodes_->at(index); + if (node.element == element) { + // Snip from of the list, optionally fixing up tail pointer. + if (tail_ == index) { + assert(node.next == -1); + tail_ = prev_index; + } + *prev_next = node.next; + nodes_->free_nodes_++; + return true; + } else { + prev_next = &node.next; + } + prev_index = index; + index = node.next; + } + return false; + } + + // Returns the PooledLinkedListNodes that owns this list's nodes. + NodePool* pool() { return nodes_; } + + // Moves the nodes in this list into |new_pool|, providing a way to compact + // storage and reclaim unused space. + // + // Upon completing a sequence of |move_nodes| calls, you must ensure you + // retain ownership of the new storage your lists point to. Example usage: + // + // unique_ptr new_pool = ...; + // for (PooledLinkedList& list : lists) { + // list.move_to(new_pool); + // } + // my_pool_ = std::move(new_pool); + void move_nodes(NodePool* new_pool) { + // Be sure to construct the list in the same order, instead of simply + // doing a sequence of push_backs. + int32_t prev_entry = -1; + int32_t nodes_freed = 0; + for (int32_t index = head_; index != -1; nodes_freed++) { + const auto& node = nodes_->at(index); + int32_t this_entry = new_pool->insert(node.element); + index = node.next; + if (prev_entry == -1) { + head_ = this_entry; + } else { + new_pool->at(prev_entry).next = this_entry; + } + prev_entry = this_entry; + } + tail_ = prev_entry; + // Update our old pool's free count, now we're a member of the new pool. + nodes_->free_nodes_ += nodes_freed; + nodes_ = new_pool; + } + + private: + NodePool* nodes_; + int32_t head_ = -1; + int32_t tail_ = -1; +}; + +} // namespace utils +} // namespace spvtools + +#endif // SOURCE_UTIL_POOLED_LINKED_LIST_H_ \ No newline at end of file diff --git a/third_party/spirv-tools/source/util/small_vector.h b/third_party/spirv-tools/source/util/small_vector.h index f2c1147bed..648a34824f 100644 --- a/third_party/spirv-tools/source/util/small_vector.h +++ b/third_party/spirv-tools/source/util/small_vector.h @@ -64,6 +64,11 @@ class SmallVector { } } + template + SmallVector(InputIt first, InputIt last) : SmallVector() { + insert(end(), first, last); + } + SmallVector(std::vector&& vec) : SmallVector() { if (vec.size() > small_size) { large_data_ = MakeUnique>(std::move(vec)); @@ -175,9 +180,12 @@ class SmallVector { return true; } +// Avoid infinite recursion from rewritten operators in C++20 +#if __cplusplus <= 201703L friend bool operator==(const std::vector& lhs, const SmallVector& rhs) { return rhs == lhs; } +#endif friend bool operator!=(const SmallVector& lhs, const std::vector& rhs) { return !(lhs == rhs); @@ -325,6 +333,15 @@ class SmallVector { ++size_; } + void pop_back() { + if (large_data_) { + large_data_->pop_back(); + } else { + --size_; + small_data_[size_].~T(); + } + } + template iterator insert(iterator pos, InputIt first, InputIt last) { size_t element_idx = (pos - begin()); @@ -363,7 +380,7 @@ class SmallVector { } } - // Upate the size. + // Update the size. size_ += num_of_new_elements; return pos; } @@ -449,7 +466,7 @@ class SmallVector { T* small_data_; // The actual data used to store the array elements. It must never be used - // directly, but must only be accesed through |small_data_|. + // directly, but must only be accessed through |small_data_|. typename std::aligned_storage::value>::type buffer[small_size]; diff --git a/third_party/spirv-tools/source/util/string_utils.h b/third_party/spirv-tools/source/util/string_utils.h index 4282aa9496..03e20b3d63 100644 --- a/third_party/spirv-tools/source/util/string_utils.h +++ b/third_party/spirv-tools/source/util/string_utils.h @@ -16,6 +16,8 @@ #define SOURCE_UTIL_STRING_UTILS_H_ #include + +#include #include #include #include @@ -44,9 +46,10 @@ std::string CardinalToOrdinal(size_t cardinal); // string will be empty. std::pair SplitFlagArgs(const std::string& flag); -// Encodes a string as a sequence of words, using the SPIR-V encoding. -inline std::vector MakeVector(std::string input) { - std::vector result; +// Encodes a string as a sequence of words, using the SPIR-V encoding, appending +// to an existing vector. +inline void AppendToVector(const std::string& input, + std::vector* result) { uint32_t word = 0; size_t num_bytes = input.size(); // SPIR-V strings are null-terminated. The byte_index == num_bytes @@ -56,24 +59,36 @@ inline std::vector MakeVector(std::string input) { (byte_index < num_bytes ? uint8_t(input[byte_index]) : uint8_t(0)); word |= (new_byte << (8 * (byte_index % sizeof(uint32_t)))); if (3 == (byte_index % sizeof(uint32_t))) { - result.push_back(word); + result->push_back(word); word = 0; } } // Emit a trailing partial word. if ((num_bytes + 1) % sizeof(uint32_t)) { - result.push_back(word); + result->push_back(word); } +} + +// Encodes a string as a sequence of words, using the SPIR-V encoding. +inline std::vector MakeVector(const std::string& input) { + std::vector result; + AppendToVector(input, &result); return result; } -// Decode a string from a sequence of words, using the SPIR-V encoding. -template -inline std::string MakeString(const VectorType& words) { +// Decode a string from a sequence of words between first and last, using the +// SPIR-V encoding. Assert that a terminating 0-byte was found (unless +// assert_found_terminating_null is passed as false). +template +inline std::string MakeString(InputIt first, InputIt last, + bool assert_found_terminating_null = true) { std::string result; + constexpr size_t kCharsPerWord = sizeof(*first); + static_assert(kCharsPerWord == 4, "expect 4-byte word"); - for (uint32_t word : words) { - for (int byte_index = 0; byte_index < 4; byte_index++) { + for (InputIt pos = first; pos != last; ++pos) { + uint32_t word = *pos; + for (size_t byte_index = 0; byte_index < kCharsPerWord; byte_index++) { uint32_t extracted_word = (word >> (8 * byte_index)) & 0xFF; char c = static_cast(extracted_word); if (c == 0) { @@ -82,9 +97,33 @@ inline std::string MakeString(const VectorType& words) { result += c; } } - assert(false && "Did not find terminating null for the string."); + assert(!assert_found_terminating_null && + "Did not find terminating null for the string."); + (void)assert_found_terminating_null; /* No unused parameters in release + builds. */ return result; -} // namespace utils +} + +// Decode a string from a sequence of words in a vector, using the SPIR-V +// encoding. +template +inline std::string MakeString(const VectorType& words, + bool assert_found_terminating_null = true) { + return MakeString(words.cbegin(), words.cend(), + assert_found_terminating_null); +} + +// Decode a string from array words, consuming up to count words, using the +// SPIR-V encoding. +inline std::string MakeString(const uint32_t* words, size_t num_words, + bool assert_found_terminating_null = true) { + return MakeString(words, words + num_words, assert_found_terminating_null); +} + +// Check if str starts with prefix (only included since C++20) +inline bool starts_with(const std::string& str, const char* prefix) { + return 0 == str.compare(0, std::strlen(prefix), prefix); +} } // namespace utils } // namespace spvtools diff --git a/third_party/spirv-tools/source/util/timer.h b/third_party/spirv-tools/source/util/timer.h index fc4b747b98..080831196f 100644 --- a/third_party/spirv-tools/source/util/timer.h +++ b/third_party/spirv-tools/source/util/timer.h @@ -206,16 +206,16 @@ class Timer { // Variable to save the result of clock_gettime(CLOCK_PROCESS_CPUTIME_ID) when // Timer::Stop() is called. It is used as the last status of CPU time. The - // resouce usage is measured by subtracting |cpu_before_| from it. + // resource usage is measured by subtracting |cpu_before_| from it. timespec cpu_after_; // Variable to save the result of clock_gettime(CLOCK_MONOTONIC) when // Timer::Stop() is called. It is used as the last status of WALL time. The - // resouce usage is measured by subtracting |wall_before_| from it. + // resource usage is measured by subtracting |wall_before_| from it. timespec wall_after_; // Variable to save the result of getrusage() when Timer::Stop() is called. It - // is used as the last status of USR time, SYS time, and RSS. Those resouce + // is used as the last status of USR time, SYS time, and RSS. Those resource // usages are measured by subtracting |usage_before_| from it. rusage usage_after_; diff --git a/third_party/spirv-tools/source/val/basic_block.h b/third_party/spirv-tools/source/val/basic_block.h index 5af4b9e4d2..47cd06d07a 100644 --- a/third_party/spirv-tools/source/val/basic_block.h +++ b/third_party/spirv-tools/source/val/basic_block.h @@ -84,26 +84,26 @@ class BasicBlock { type_.set(type); } - /// Sets the immedate dominator of this basic block + /// Sets the immediate dominator of this basic block /// /// @param[in] dom_block The dominator block void SetImmediateDominator(BasicBlock* dom_block); - /// Sets the immedate post dominator of this basic block + /// Sets the immediate post dominator of this basic block /// /// @param[in] pdom_block The post dominator block void SetImmediatePostDominator(BasicBlock* pdom_block); - /// Returns the immedate dominator of this basic block + /// Returns the immediate dominator of this basic block BasicBlock* immediate_dominator(); - /// Returns the immedate dominator of this basic block + /// Returns the immediate dominator of this basic block const BasicBlock* immediate_dominator() const; - /// Returns the immedate post dominator of this basic block + /// Returns the immediate post dominator of this basic block BasicBlock* immediate_post_dominator(); - /// Returns the immedate post dominator of this basic block + /// Returns the immediate post dominator of this basic block const BasicBlock* immediate_post_dominator() const; /// Returns the label instruction for the block, or nullptr if not set. diff --git a/third_party/spirv-tools/source/val/function.cpp b/third_party/spirv-tools/source/val/function.cpp index 9ad68e8672..f3292b0e78 100644 --- a/third_party/spirv-tools/source/val/function.cpp +++ b/third_party/spirv-tools/source/val/function.cpp @@ -57,7 +57,7 @@ spv_result_t Function::RegisterFunctionParameter(uint32_t parameter_id, uint32_t type_id) { assert(current_block_ == nullptr && "RegisterFunctionParameter can only be called when parsing the binary " - "ouside of a block"); + "outside of a block"); // TODO(umar): Validate function parameter type order and count // TODO(umar): Use these variables to validate parameter type (void)parameter_id; @@ -130,7 +130,7 @@ spv_result_t Function::RegisterBlock(uint32_t block_id, bool is_definition) { undefined_blocks_.erase(block_id); current_block_ = &inserted_block->second; ordered_blocks_.push_back(current_block_); - } else if (success) { // Block doesn't exsist but this is not a definition + } else if (success) { // Block doesn't exist but this is not a definition undefined_blocks_.insert(block_id); } diff --git a/third_party/spirv-tools/source/val/function.h b/third_party/spirv-tools/source/val/function.h index 400bb6348d..2fe30bdc81 100644 --- a/third_party/spirv-tools/source/val/function.h +++ b/third_party/spirv-tools/source/val/function.h @@ -73,8 +73,8 @@ class Function { /// Registers a variable in the current block /// - /// @param[in] type_id The type ID of the varaible - /// @param[in] id The ID of the varaible + /// @param[in] type_id The type ID of the variable + /// @param[in] id The ID of the variable /// @param[in] storage The storage of the variable /// @param[in] init_id The initializer ID of the variable /// @@ -197,10 +197,10 @@ class Function { /// been identified and dominators have been computed. int GetBlockDepth(BasicBlock* bb); - /// Prints a GraphViz digraph of the CFG of the current funciton + /// Prints a GraphViz digraph of the CFG of the current function void PrintDotGraph() const; - /// Prints a directed graph of the CFG of the current funciton + /// Prints a directed graph of the CFG of the current function void PrintBlocks() const; /// Registers execution model limitation such as "Feature X is only available @@ -285,7 +285,7 @@ class Function { /// The type of the return value uint32_t result_type_id_; - /// The control fo the funciton + /// The control fo the function SpvFunctionControlMask function_control_; /// The type of declaration of each function diff --git a/third_party/spirv-tools/source/val/instruction.cpp b/third_party/spirv-tools/source/val/instruction.cpp index b9155898ac..f16fcd7300 100644 --- a/third_party/spirv-tools/source/val/instruction.cpp +++ b/third_party/spirv-tools/source/val/instruction.cpp @@ -16,6 +16,9 @@ #include +#include "source/binary.h" +#include "source/util/string_utils.h" + namespace spvtools { namespace val { @@ -41,5 +44,12 @@ bool operator==(const Instruction& lhs, uint32_t rhs) { return lhs.id() == rhs; } +template <> +std::string Instruction::GetOperandAs(size_t index) const { + const spv_parsed_operand_t& o = operands_.at(index); + assert(o.offset + o.num_words <= inst_.num_words); + return spvtools::utils::MakeString(words_.data() + o.offset, o.num_words); +} + } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/source/val/instruction.h b/third_party/spirv-tools/source/val/instruction.h index 617cb0660d..6d1f9f4f12 100644 --- a/third_party/spirv-tools/source/val/instruction.h +++ b/third_party/spirv-tools/source/val/instruction.h @@ -133,6 +133,9 @@ bool operator<(const Instruction& lhs, uint32_t rhs); bool operator==(const Instruction& lhs, const Instruction& rhs); bool operator==(const Instruction& lhs, uint32_t rhs); +template <> +std::string Instruction::GetOperandAs(size_t index) const; + } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/source/val/validate.cpp b/third_party/spirv-tools/source/val/validate.cpp index 45b6a463e6..ecc9fdb639 100644 --- a/third_party/spirv-tools/source/val/validate.cpp +++ b/third_party/spirv-tools/source/val/validate.cpp @@ -202,7 +202,7 @@ spv_result_t ValidateBinaryUsingContextAndValidationState( /* diagnostic = */ nullptr); // Parse the module and perform inline validation checks. These checks do - // not require the the knowledge of the whole module. + // not require the knowledge of the whole module. if (auto error = spvBinaryParse(&context, vstate, words, num_words, /*parsed_header =*/nullptr, ProcessInstruction, pDiagnostic)) { @@ -219,9 +219,7 @@ spv_result_t ValidateBinaryUsingContextAndValidationState( if (inst->opcode() == SpvOpEntryPoint) { const auto entry_point = inst->GetOperandAs(1); const auto execution_model = inst->GetOperandAs(0); - const char* str = reinterpret_cast( - inst->words().data() + inst->operand(2).offset); - const std::string desc_name(str); + const std::string desc_name = inst->GetOperandAs(2); ValidationState_t::EntryPointDescription desc; desc.name = desc_name; @@ -237,9 +235,8 @@ spv_result_t ValidateBinaryUsingContextAndValidationState( for (const Instruction* check_inst : visited_entry_points) { const auto check_execution_model = check_inst->GetOperandAs(0); - const char* check_str = reinterpret_cast( - check_inst->words().data() + inst->operand(2).offset); - const std::string check_name(check_str); + const std::string check_name = + check_inst->GetOperandAs(2); if (desc_name == check_name && execution_model == check_execution_model) { @@ -351,7 +348,7 @@ spv_result_t ValidateBinaryUsingContextAndValidationState( } // Validate the preconditions involving adjacent instructions. e.g. SpvOpPhi - // must only be preceeded by SpvOpLabel, SpvOpPhi, or SpvOpLine. + // must only be preceded by SpvOpLabel, SpvOpPhi, or SpvOpLine. if (auto error = ValidateAdjacency(*vstate)) return error; if (auto error = ValidateEntryPoints(*vstate)) return error; diff --git a/third_party/spirv-tools/source/val/validate.h b/third_party/spirv-tools/source/val/validate.h index 3fc183de88..cb1d05a572 100644 --- a/third_party/spirv-tools/source/val/validate.h +++ b/third_party/spirv-tools/source/val/validate.h @@ -70,7 +70,7 @@ spv_result_t CheckIdDefinitionDominateUse(ValidationState_t& _); /// /// This function will iterate over all instructions and check for any required /// predecessor and/or successor instructions. e.g. SpvOpPhi must only be -/// preceeded by SpvOpLabel, SpvOpPhi, or SpvOpLine. +/// preceded by SpvOpLabel, SpvOpPhi, or SpvOpLine. /// /// @param[in] _ the validation state of the module /// diff --git a/third_party/spirv-tools/source/val/validate_annotation.cpp b/third_party/spirv-tools/source/val/validate_annotation.cpp index 3a77552e18..233861a89d 100644 --- a/third_party/spirv-tools/source/val/validate_annotation.cpp +++ b/third_party/spirv-tools/source/val/validate_annotation.cpp @@ -136,8 +136,8 @@ std::string LogStringForDecoration(uint32_t decoration) { return "PerViewNV"; case SpvDecorationPerTaskNV: return "PerTaskNV"; - case SpvDecorationPerVertexNV: - return "PerVertexNV"; + case SpvDecorationPerVertexKHR: + return "PerVertexKHR"; case SpvDecorationNonUniform: return "NonUniform"; case SpvDecorationRestrictPointer: @@ -230,7 +230,7 @@ bool IsNotMemberDecoration(SpvDecoration dec) { spv_result_t ValidateDecorationTarget(ValidationState_t& _, SpvDecoration dec, const Instruction* inst, const Instruction* target) { - auto fail = [&_, dec, inst, target](uint32_t vuid = 0) -> DiagnosticStream { + auto fail = [&_, dec, inst, target](uint32_t vuid) -> DiagnosticStream { DiagnosticStream ds = std::move( _.diag(SPV_ERROR_INVALID_ID, inst) << _.VkErrorID(vuid) << LogStringForDecoration(dec) @@ -240,7 +240,7 @@ spv_result_t ValidateDecorationTarget(ValidationState_t& _, SpvDecoration dec, switch (dec) { case SpvDecorationSpecId: if (!spvOpcodeIsScalarSpecConstant(target->opcode())) { - return fail() << "must be a scalar specialization constant"; + return fail(0) << "must be a scalar specialization constant"; } break; case SpvDecorationBlock: @@ -249,14 +249,14 @@ spv_result_t ValidateDecorationTarget(ValidationState_t& _, SpvDecoration dec, case SpvDecorationGLSLPacked: case SpvDecorationCPacked: if (target->opcode() != SpvOpTypeStruct) { - return fail() << "must be a structure type"; + return fail(0) << "must be a structure type"; } break; case SpvDecorationArrayStride: if (target->opcode() != SpvOpTypeArray && target->opcode() != SpvOpTypeRuntimeArray && target->opcode() != SpvOpTypePointer) { - return fail() << "must be an array or pointer type"; + return fail(0) << "must be an array or pointer type"; } break; case SpvDecorationBuiltIn: @@ -269,10 +269,10 @@ spv_result_t ValidateDecorationTarget(ValidationState_t& _, SpvDecoration dec, if (_.HasCapability(SpvCapabilityShader) && inst->GetOperandAs(2) == SpvBuiltInWorkgroupSize) { if (!spvOpcodeIsConstant(target->opcode())) { - return fail() << "must be a constant for WorkgroupSize"; + return fail(0) << "must be a constant for WorkgroupSize"; } } else if (target->opcode() != SpvOpVariable) { - return fail() << "must be a variable"; + return fail(0) << "must be a variable"; } break; case SpvDecorationNoPerspective: @@ -294,10 +294,10 @@ spv_result_t ValidateDecorationTarget(ValidationState_t& _, SpvDecoration dec, case SpvDecorationAliasedPointer: if (target->opcode() != SpvOpVariable && target->opcode() != SpvOpFunctionParameter) { - return fail() << "must be a memory object declaration"; + return fail(0) << "must be a memory object declaration"; } if (_.GetIdOpcode(target->type_id()) != SpvOpTypePointer) { - return fail() << "must be a pointer type"; + return fail(0) << "must be a pointer type"; } break; case SpvDecorationInvariant: @@ -308,7 +308,7 @@ spv_result_t ValidateDecorationTarget(ValidationState_t& _, SpvDecoration dec, case SpvDecorationDescriptorSet: case SpvDecorationInputAttachmentIndex: if (target->opcode() != SpvOpVariable) { - return fail() << "must be a variable"; + return fail(0) << "must be a variable"; } break; default: @@ -326,19 +326,22 @@ spv_result_t ValidateDecorationTarget(ValidationState_t& _, SpvDecoration dec, case SpvDecorationLocation: case SpvDecorationComponent: // Location is used for input, output and ray tracing stages. - if (sc == SpvStorageClassStorageBuffer || - sc == SpvStorageClassUniform || - sc == SpvStorageClassUniformConstant || - sc == SpvStorageClassWorkgroup || sc == SpvStorageClassPrivate || - sc == SpvStorageClassFunction) { + if (sc != SpvStorageClassInput && sc != SpvStorageClassOutput && + sc != SpvStorageClassRayPayloadKHR && + sc != SpvStorageClassIncomingRayPayloadKHR && + sc != SpvStorageClassHitAttributeKHR && + sc != SpvStorageClassCallableDataKHR && + sc != SpvStorageClassIncomingCallableDataKHR && + sc != SpvStorageClassShaderRecordBufferKHR) { return _.diag(SPV_ERROR_INVALID_ID, target) - << LogStringForDecoration(dec) + << _.VkErrorID(6672) << LogStringForDecoration(dec) << " decoration must not be applied to this storage class"; } break; case SpvDecorationIndex: + // Langauge from SPIR-V definition of Index if (sc != SpvStorageClassOutput) { - return fail() << "must be in the Output storage class"; + return fail(0) << "must be in the Output storage class"; } break; case SpvDecorationBinding: @@ -346,13 +349,13 @@ spv_result_t ValidateDecorationTarget(ValidationState_t& _, SpvDecoration dec, if (sc != SpvStorageClassStorageBuffer && sc != SpvStorageClassUniform && sc != SpvStorageClassUniformConstant) { - return fail() << "must be in the StorageBuffer, Uniform, or " - "UniformConstant storage class"; + return fail(6491) << "must be in the StorageBuffer, Uniform, or " + "UniformConstant storage class"; } break; case SpvDecorationInputAttachmentIndex: if (sc != SpvStorageClassUniformConstant) { - return fail() << "must be in the UniformConstant storage class"; + return fail(6678) << "must be in the UniformConstant storage class"; } break; case SpvDecorationFlat: diff --git a/third_party/spirv-tools/source/val/validate_arithmetics.cpp b/third_party/spirv-tools/source/val/validate_arithmetics.cpp index 433330d743..bae9b5dcac 100644 --- a/third_party/spirv-tools/source/val/validate_arithmetics.cpp +++ b/third_party/spirv-tools/source/val/validate_arithmetics.cpp @@ -155,7 +155,7 @@ spv_result_t ArithmeticsPass(ValidationState_t& _, const Instruction* inst) { first_vector_num_components = num_components; } else if (num_components != first_vector_num_components) { return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected operands to have the same number of componenets: " + << "Expected operands to have the same number of components: " << spvOpcodeString(opcode); } } diff --git a/third_party/spirv-tools/source/val/validate_atomics.cpp b/third_party/spirv-tools/source/val/validate_atomics.cpp index cfa15d9f72..3b0a7fa8e5 100644 --- a/third_party/spirv-tools/source/val/validate_atomics.cpp +++ b/third_party/spirv-tools/source/val/validate_atomics.cpp @@ -39,7 +39,7 @@ bool IsStorageClassAllowedByUniversalRules(uint32_t storage_class) { case SpvStorageClassAtomicCounter: case SpvStorageClassImage: case SpvStorageClassFunction: - case SpvStorageClassPhysicalStorageBufferEXT: + case SpvStorageClassPhysicalStorageBuffer: return true; break; default: diff --git a/third_party/spirv-tools/source/val/validate_bitwise.cpp b/third_party/spirv-tools/source/val/validate_bitwise.cpp index d46b3fcabb..e6e97c4a5a 100644 --- a/third_party/spirv-tools/source/val/validate_bitwise.cpp +++ b/third_party/spirv-tools/source/val/validate_bitwise.cpp @@ -14,16 +14,48 @@ // Validates correctness of bitwise instructions. -#include "source/val/validate.h" - #include "source/diagnostic.h" #include "source/opcode.h" +#include "source/spirv_target_env.h" #include "source/val/instruction.h" +#include "source/val/validate.h" #include "source/val/validation_state.h" namespace spvtools { namespace val { +// Validates when base and result need to be the same type +spv_result_t ValidateBaseType(ValidationState_t& _, const Instruction* inst, + const uint32_t base_type) { + const SpvOp opcode = inst->opcode(); + + if (!_.IsIntScalarType(base_type) && !_.IsIntVectorType(base_type)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << _.VkErrorID(4781) + << "Expected int scalar or vector type for Base operand: " + << spvOpcodeString(opcode); + } + + // Vulkan has a restriction to 32 bit for base + if (spvIsVulkanEnv(_.context()->target_env)) { + if (_.GetBitWidth(base_type) != 32) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << _.VkErrorID(4781) + << "Expected 32-bit int type for Base operand: " + << spvOpcodeString(opcode); + } + } + + // OpBitCount just needs same number of components + if (base_type != inst->type_id() && opcode != SpvOpBitCount) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected Base Type to be equal to Result Type: " + << spvOpcodeString(opcode); + } + + return SPV_SUCCESS; +} + // Validates correctness of bitwise instructions. spv_result_t BitwisePass(ValidationState_t& _, const Instruction* inst) { const SpvOp opcode = inst->opcode(); @@ -109,20 +141,14 @@ spv_result_t BitwisePass(ValidationState_t& _, const Instruction* inst) { } case SpvOpBitFieldInsert: { - if (!_.IsIntScalarType(result_type) && !_.IsIntVectorType(result_type)) - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected int scalar or vector type as Result Type: " - << spvOpcodeString(opcode); - const uint32_t base_type = _.GetOperandTypeId(inst, 2); const uint32_t insert_type = _.GetOperandTypeId(inst, 3); const uint32_t offset_type = _.GetOperandTypeId(inst, 4); const uint32_t count_type = _.GetOperandTypeId(inst, 5); - if (base_type != result_type) - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected Base Type to be equal to Result Type: " - << spvOpcodeString(opcode); + if (spv_result_t error = ValidateBaseType(_, inst, base_type)) { + return error; + } if (insert_type != result_type) return _.diag(SPV_ERROR_INVALID_DATA, inst) @@ -143,19 +169,13 @@ spv_result_t BitwisePass(ValidationState_t& _, const Instruction* inst) { case SpvOpBitFieldSExtract: case SpvOpBitFieldUExtract: { - if (!_.IsIntScalarType(result_type) && !_.IsIntVectorType(result_type)) - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected int scalar or vector type as Result Type: " - << spvOpcodeString(opcode); - const uint32_t base_type = _.GetOperandTypeId(inst, 2); const uint32_t offset_type = _.GetOperandTypeId(inst, 3); const uint32_t count_type = _.GetOperandTypeId(inst, 4); - if (base_type != result_type) - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected Base Type to be equal to Result Type: " - << spvOpcodeString(opcode); + if (spv_result_t error = ValidateBaseType(_, inst, base_type)) { + return error; + } if (!offset_type || !_.IsIntScalarType(offset_type)) return _.diag(SPV_ERROR_INVALID_DATA, inst) @@ -170,17 +190,12 @@ spv_result_t BitwisePass(ValidationState_t& _, const Instruction* inst) { } case SpvOpBitReverse: { - if (!_.IsIntScalarType(result_type) && !_.IsIntVectorType(result_type)) - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected int scalar or vector type as Result Type: " - << spvOpcodeString(opcode); - const uint32_t base_type = _.GetOperandTypeId(inst, 2); - if (base_type != result_type) - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected Base Type to be equal to Result Type: " - << spvOpcodeString(opcode); + if (spv_result_t error = ValidateBaseType(_, inst, base_type)) { + return error; + } + break; } @@ -191,15 +206,13 @@ spv_result_t BitwisePass(ValidationState_t& _, const Instruction* inst) { << spvOpcodeString(opcode); const uint32_t base_type = _.GetOperandTypeId(inst, 2); - if (!base_type || - (!_.IsIntScalarType(base_type) && !_.IsIntVectorType(base_type))) - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected Base Type to be int scalar or vector: " - << spvOpcodeString(opcode); - const uint32_t base_dimension = _.GetDimension(base_type); const uint32_t result_dimension = _.GetDimension(result_type); + if (spv_result_t error = ValidateBaseType(_, inst, base_type)) { + return error; + } + if (base_dimension != result_dimension) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected Base dimension to be equal to Result Type " diff --git a/third_party/spirv-tools/source/val/validate_builtins.cpp b/third_party/spirv-tools/source/val/validate_builtins.cpp index 57dde8ad92..379705ac0c 100644 --- a/third_party/spirv-tools/source/val/validate_builtins.cpp +++ b/third_party/spirv-tools/source/val/validate_builtins.cpp @@ -120,7 +120,7 @@ typedef enum VUIDError_ { VUIDErrorMax, } VUIDError; -const static uint32_t NumVUIDBuiltins = 33; +const static uint32_t NumVUIDBuiltins = 36; typedef struct { SpvBuiltIn builtIn; @@ -162,6 +162,9 @@ std::array builtinVUIDInfo = {{ {SpvBuiltInFragSizeEXT, {4220, 4221, 4222}}, {SpvBuiltInFragStencilRefEXT, {4223, 4224, 4225}}, {SpvBuiltInFullyCoveredEXT, {4232, 4233, 4234}}, + {SpvBuiltInCullMaskKHR, {6735, 6736, 6737}}, + {SpvBuiltInBaryCoordKHR, {4154, 4155, 4156}}, + {SpvBuiltInBaryCoordNoPerspKHR, {4160, 4161, 4162}}, // clang-format off } }; @@ -208,6 +211,7 @@ bool IsExecutionModelValidForRtBuiltIn(SpvBuiltIn builtin, case SpvBuiltInRayTmaxKHR: case SpvBuiltInWorldRayDirectionKHR: case SpvBuiltInWorldRayOriginKHR: + case SpvBuiltInCullMaskKHR: switch (stage) { case SpvExecutionModelIntersectionKHR: case SpvExecutionModelAnyHitKHR: @@ -331,7 +335,9 @@ class BuiltInsValidator { const Decoration& decoration, const Instruction& inst); spv_result_t ValidateSMBuiltinsAtDefinition(const Decoration& decoration, const Instruction& inst); - + // Used for BaryCoord, BaryCoordNoPersp. + spv_result_t ValidateFragmentShaderF32Vec3InputAtDefinition( + const Decoration& decoration, const Instruction& inst); // Used for SubgroupEqMask, SubgroupGeMask, SubgroupGtMask, SubgroupLtMask, // SubgroupLeMask. spv_result_t ValidateI32Vec4InputAtDefinition(const Decoration& decoration, @@ -509,6 +515,13 @@ class BuiltInsValidator { const Decoration& decoration, const Instruction& built_in_inst, const Instruction& referenced_inst, const Instruction& referenced_from_inst); + + // Used for BaryCoord, BaryCoordNoPersp. + spv_result_t ValidateFragmentShaderF32Vec3InputAtReference( + const Decoration& decoration, const Instruction& built_in_inst, + const Instruction& referenced_inst, + const Instruction& referenced_from_inst); + // Used for SubgroupId and NumSubgroups. spv_result_t ValidateComputeI32InputAtReference( const Decoration& decoration, const Instruction& built_in_inst, @@ -2788,6 +2801,80 @@ spv_result_t BuiltInsValidator::ValidateLayerOrViewportIndexAtReference( return SPV_SUCCESS; } +spv_result_t BuiltInsValidator::ValidateFragmentShaderF32Vec3InputAtDefinition( + const Decoration& decoration, const Instruction& inst) { + if (spvIsVulkanEnv(_.context()->target_env)) { + const SpvBuiltIn builtin = SpvBuiltIn(decoration.params()[0]); + if (spv_result_t error = ValidateF32Vec( + decoration, inst, 3, + [this, &inst, builtin](const std::string& message) -> spv_result_t { + uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorType); + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << _.VkErrorID(vuid) << "According to the " + << spvLogStringForEnv(_.context()->target_env) + << " spec BuiltIn " + << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, + builtin) + << " variable needs to be a 3-component 32-bit float " + "vector. " + << message; + })) { + return error; + } + } + + // Seed at reference checks with this built-in. + return ValidateFragmentShaderF32Vec3InputAtReference(decoration, inst, inst, + inst); +} + +spv_result_t BuiltInsValidator::ValidateFragmentShaderF32Vec3InputAtReference( + const Decoration& decoration, const Instruction& built_in_inst, + const Instruction& referenced_inst, + const Instruction& referenced_from_inst) { + + if (spvIsVulkanEnv(_.context()->target_env)) { + const SpvBuiltIn builtin = SpvBuiltIn(decoration.params()[0]); + const SpvStorageClass storage_class = GetStorageClass(referenced_from_inst); + if (storage_class != SpvStorageClassMax && + storage_class != SpvStorageClassInput) { + uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorStorageClass); + return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst) + << _.VkErrorID(vuid) << spvLogStringForEnv(_.context()->target_env) + << " spec allows BuiltIn " + << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, builtin) + << " to be only used for variables with Input storage class. " + << GetReferenceDesc(decoration, built_in_inst, referenced_inst, + referenced_from_inst) + << " " << GetStorageClassDesc(referenced_from_inst); + } + + for (const SpvExecutionModel execution_model : execution_models_) { + if (execution_model != SpvExecutionModelFragment) { + uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorExecutionModel); + return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst) + << _.VkErrorID(vuid) + << spvLogStringForEnv(_.context()->target_env) + << " spec allows BuiltIn " + << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, builtin) + << " to be used only with Fragment execution model. " + << GetReferenceDesc(decoration, built_in_inst, referenced_inst, + referenced_from_inst, execution_model); + } + } + } + + if (function_id_ == 0) { + // Propagate this rule to all dependant ids in the global scope. + id_to_at_reference_checks_[referenced_from_inst.id()].push_back(std::bind( + &BuiltInsValidator::ValidateFragmentShaderF32Vec3InputAtReference, this, + decoration, built_in_inst, referenced_from_inst, + std::placeholders::_1)); + } + + return SPV_SUCCESS; +} + spv_result_t BuiltInsValidator::ValidateComputeShaderI32Vec3InputAtDefinition( const Decoration& decoration, const Instruction& inst) { if (spvIsVulkanEnv(_.context()->target_env)) { @@ -3851,6 +3938,7 @@ spv_result_t BuiltInsValidator::ValidateRayTracingBuiltinsAtDefinition( case SpvBuiltInInstanceId: case SpvBuiltInRayGeometryIndexKHR: case SpvBuiltInIncomingRayFlagsKHR: + case SpvBuiltInCullMaskKHR: // i32 scalar if (spv_result_t error = ValidateI32( decoration, inst, @@ -4027,6 +4115,10 @@ spv_result_t BuiltInsValidator::ValidateSingleBuiltInAtDefinition( case SpvBuiltInWorkgroupId: { return ValidateComputeShaderI32Vec3InputAtDefinition(decoration, inst); } + case SpvBuiltInBaryCoordKHR: + case SpvBuiltInBaryCoordNoPerspKHR: { + return ValidateFragmentShaderF32Vec3InputAtDefinition(decoration, inst); + } case SpvBuiltInHelperInvocation: { return ValidateHelperInvocationAtDefinition(decoration, inst); } @@ -4151,7 +4243,8 @@ spv_result_t BuiltInsValidator::ValidateSingleBuiltInAtDefinition( case SpvBuiltInObjectToWorldKHR: // alias SpvBuiltInObjectToWorldNV case SpvBuiltInWorldToObjectKHR: // alias SpvBuiltInWorldToObjectNV case SpvBuiltInIncomingRayFlagsKHR: // alias SpvBuiltInIncomingRayFlagsNV - case SpvBuiltInRayGeometryIndexKHR: { // NOT present in NV + case SpvBuiltInRayGeometryIndexKHR: // NOT present in NV + case SpvBuiltInCullMaskKHR: { return ValidateRayTracingBuiltinsAtDefinition(decoration, inst); } case SpvBuiltInWorkDim: @@ -4182,8 +4275,6 @@ spv_result_t BuiltInsValidator::ValidateSingleBuiltInAtDefinition( case SpvBuiltInLayerPerViewNV: case SpvBuiltInMeshViewCountNV: case SpvBuiltInMeshViewIndicesNV: - case SpvBuiltInBaryCoordNV: - case SpvBuiltInBaryCoordNoPerspNV: case SpvBuiltInCurrentRayTimeNV: // No validation rules (for the moment). break; diff --git a/third_party/spirv-tools/source/val/validate_cfg.cpp b/third_party/spirv-tools/source/val/validate_cfg.cpp index 7842e56de2..dd605d2e33 100644 --- a/third_party/spirv-tools/source/val/validate_cfg.cpp +++ b/third_party/spirv-tools/source/val/validate_cfg.cpp @@ -27,6 +27,7 @@ #include "source/cfa.h" #include "source/opcode.h" +#include "source/spirv_constant.h" #include "source/spirv_target_env.h" #include "source/spirv_validator_options.h" #include "source/val/basic_block.h" @@ -54,8 +55,7 @@ spv_result_t ValidatePhi(ValidationState_t& _, const Instruction* inst) { } if (_.IsPointerType(inst->type_id()) && _.addressing_model() == SpvAddressingModelLogical) { - if (!_.features().variable_pointers && - !_.features().variable_pointers_storage_buffer) { + if (!_.features().variable_pointers) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Using pointers with OpPhi requires capability " << "VariablePointers or VariablePointersStorageBuffer"; @@ -191,6 +191,12 @@ spv_result_t ValidateBranchConditional(ValidationState_t& _, "ID of an OpLabel instruction"; } + if (_.version() >= SPV_SPIRV_VERSION_WORD(1, 6) && true_id == false_id) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "In SPIR-V 1.6 or later, True Label and False Label must be " + "different labels"; + } + return SPV_SUCCESS; } @@ -242,13 +248,9 @@ spv_result_t ValidateReturnValue(ValidationState_t& _, << _.getIdName(value->type_id()) << "' is missing or void."; } - const bool uses_variable_pointer = - _.features().variable_pointers || - _.features().variable_pointers_storage_buffer; - if (_.addressing_model() == SpvAddressingModelLogical && - SpvOpTypePointer == value_type->opcode() && !uses_variable_pointer && - !_.options()->relax_logical_pointer) { + SpvOpTypePointer == value_type->opcode() && + !_.features().variable_pointers && !_.options()->relax_logical_pointer) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "OpReturnValue value's type '" << _.getIdName(value->type_id()) @@ -668,7 +670,7 @@ spv_result_t ValidateStructuredSelections( } else if (terminator->opcode() == SpvOpSwitch) { if (!merge) { return _.diag(SPV_ERROR_INVALID_CFG, terminator) - << "OpSwitch must be preceeded by an OpSelectionMerge " + << "OpSwitch must be preceded by an OpSelectionMerge " "instruction"; } // Mark the targets as seen. @@ -910,7 +912,7 @@ spv_result_t PerformCfgChecks(ValidationState_t& _) { } } } - // If we have structed control flow, check that no block has a control + // If we have structured control flow, check that no block has a control // flow nesting depth larger than the limit. if (_.HasCapability(SpvCapabilityShader)) { const int control_flow_nesting_depth_limit = diff --git a/third_party/spirv-tools/source/val/validate_decorations.cpp b/third_party/spirv-tools/source/val/validate_decorations.cpp index 3cdb471c70..73d512a8f4 100644 --- a/third_party/spirv-tools/source/val/validate_decorations.cpp +++ b/third_party/spirv-tools/source/val/validate_decorations.cpp @@ -21,11 +21,13 @@ #include #include +#include "source/binary.h" #include "source/diagnostic.h" #include "source/opcode.h" #include "source/spirv_constant.h" #include "source/spirv_target_env.h" #include "source/spirv_validator_options.h" +#include "source/util/string_utils.h" #include "source/val/validate_scopes.h" #include "source/val/validation_state.h" @@ -96,6 +98,14 @@ bool isBuiltInStruct(uint32_t struct_id, ValidationState_t& vstate) { }); } +// Returns true if the given structure type has a Block decoration. +bool isBlock(uint32_t struct_id, ValidationState_t& vstate) { + const auto& decorations = vstate.id_decorations(struct_id); + return std::any_of( + decorations.begin(), decorations.end(), + [](const Decoration& d) { return SpvDecorationBlock == d.dec_type(); }); +} + // Returns true if the given ID has the Import LinkageAttributes decoration. bool hasImportLinkageAttribute(uint32_t id, ValidationState_t& vstate) { const auto& decorations = vstate.id_decorations(id); @@ -455,7 +465,7 @@ spv_result_t checkLayout(uint32_t struct_id, const char* storage_class_str, return lhs.offset < rhs.offset; }); - // Now scan from lowest offest to highest offset. + // Now scan from lowest offset to highest offset. uint32_t nextValidOffset = 0; for (size_t ordered_member_idx = 0; ordered_member_idx < member_offsets.size(); ordered_member_idx++) { @@ -702,7 +712,7 @@ spv_result_t CheckBuiltInVariable(uint32_t var_id, ValidationState_t& vstate) { if (d.dec_type() == SpvDecorationLocation || d.dec_type() == SpvDecorationComponent) { return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(var_id)) - << "A BuiltIn variable (id " << var_id + << vstate.VkErrorID(4915) << "A BuiltIn variable (id " << var_id << ") cannot have any Location or Component decorations"; } } @@ -710,12 +720,12 @@ spv_result_t CheckBuiltInVariable(uint32_t var_id, ValidationState_t& vstate) { return SPV_SUCCESS; } -// Checks whether proper decorations have been appied to the entry points. +// Checks whether proper decorations have been applied to the entry points. spv_result_t CheckDecorationsOfEntryPoints(ValidationState_t& vstate) { for (uint32_t entry_point : vstate.entry_points()) { const auto& descs = vstate.entry_point_descriptions(entry_point); - int num_builtin_inputs = 0; - int num_builtin_outputs = 0; + int num_builtin_block_inputs = 0; + int num_builtin_block_outputs = 0; int num_workgroup_variables = 0; int num_workgroup_variables_with_block = 0; int num_workgroup_variables_with_aliased = 0; @@ -766,9 +776,20 @@ spv_result_t CheckDecorationsOfEntryPoints(ValidationState_t& vstate) { Instruction* type_instr = vstate.FindDef(type_id); if (type_instr && SpvOpTypeStruct == type_instr->opcode() && isBuiltInStruct(type_id, vstate)) { - if (storage_class == SpvStorageClassInput) ++num_builtin_inputs; - if (storage_class == SpvStorageClassOutput) ++num_builtin_outputs; - if (num_builtin_inputs > 1 || num_builtin_outputs > 1) break; + if (!isBlock(type_id, vstate)) { + return vstate.diag(SPV_ERROR_INVALID_DATA, vstate.FindDef(type_id)) + << vstate.VkErrorID(4919) + << "Interface struct has no Block decoration but has " + "BuiltIn members. " + "Location decorations must be used on each member of " + "OpVariable with a structure type that is a block not " + "decorated with Location."; + } + if (storage_class == SpvStorageClassInput) ++num_builtin_block_inputs; + if (storage_class == SpvStorageClassOutput) + ++num_builtin_block_outputs; + if (num_builtin_block_inputs > 1 || num_builtin_block_outputs > 1) + break; if (auto error = CheckBuiltInVariable(interface, vstate)) return error; } else if (isBuiltInVar(interface, vstate)) { @@ -786,7 +807,7 @@ spv_result_t CheckDecorationsOfEntryPoints(ValidationState_t& vstate) { } } } - if (num_builtin_inputs > 1 || num_builtin_outputs > 1) { + if (num_builtin_block_inputs > 1 || num_builtin_block_outputs > 1) { return vstate.diag(SPV_ERROR_INVALID_BINARY, vstate.FindDef(entry_point)) << "There must be at most one object per Storage Class that can " @@ -798,8 +819,8 @@ spv_result_t CheckDecorationsOfEntryPoints(ValidationState_t& vstate) { // targeted by an OpEntryPoint instruction for (auto& decoration : vstate.id_decorations(entry_point)) { if (SpvDecorationLinkageAttributes == decoration.dec_type()) { - const char* linkage_name = - reinterpret_cast(&decoration.params()[0]); + const std::string linkage_name = + spvtools::utils::MakeString(decoration.params()); return vstate.diag(SPV_ERROR_INVALID_BINARY, vstate.FindDef(entry_point)) << "The LinkageAttributes Decoration (Linkage name: " @@ -935,41 +956,41 @@ spv_result_t CheckDecorationsOfBuffers(ValidationState_t& vstate) { const bool storage_buffer = storageClass == SpvStorageClassStorageBuffer; if (spvIsVulkanEnv(vstate.context()->target_env)) { - // Vulkan 14.5.1: There must be no more than one PushConstant block - // per entry point. + // Vulkan: There must be no more than one PushConstant block per entry + // point. if (push_constant) { auto entry_points = vstate.EntryPointReferences(var_id); for (auto ep_id : entry_points) { const bool already_used = !uses_push_constant.insert(ep_id).second; if (already_used) { return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(var_id)) - << "Entry point id '" << ep_id + << vstate.VkErrorID(6674) << "Entry point id '" << ep_id << "' uses more than one PushConstant interface.\n" - << "From Vulkan spec, section 14.5.1:\n" + << "From Vulkan spec:\n" << "There must be no more than one push constant block " << "statically used per shader entry point."; } } } - // Vulkan 14.5.2: Check DescriptorSet and Binding decoration for + // Vulkan: Check DescriptorSet and Binding decoration for // UniformConstant which cannot be a struct. if (uniform_constant) { auto entry_points = vstate.EntryPointReferences(var_id); if (!entry_points.empty() && !hasDecoration(var_id, SpvDecorationDescriptorSet, vstate)) { return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(var_id)) - << "UniformConstant id '" << var_id + << vstate.VkErrorID(6677) << "UniformConstant id '" << var_id << "' is missing DescriptorSet decoration.\n" - << "From Vulkan spec, section 14.5.2:\n" + << "From Vulkan spec:\n" << "These variables must have DescriptorSet and Binding " "decorations specified"; } if (!entry_points.empty() && !hasDecoration(var_id, SpvDecorationBinding, vstate)) { return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(var_id)) - << "UniformConstant id '" << var_id + << vstate.VkErrorID(6677) << "UniformConstant id '" << var_id << "' is missing Binding decoration.\n" - << "From Vulkan spec, section 14.5.2:\n" + << "From Vulkan spec:\n" << "These variables must have DescriptorSet and Binding " "decorations specified"; } @@ -996,7 +1017,7 @@ spv_result_t CheckDecorationsOfBuffers(ValidationState_t& vstate) { } const bool phys_storage_buffer = - storageClass == SpvStorageClassPhysicalStorageBufferEXT; + storageClass == SpvStorageClassPhysicalStorageBuffer; const bool workgroup = storageClass == SpvStorageClassWorkgroup && vstate.HasCapability(SpvCapabilityWorkgroupMemoryExplicitLayoutKHR); @@ -1030,55 +1051,55 @@ spv_result_t CheckDecorationsOfBuffers(ValidationState_t& vstate) { hasDecoration(id, SpvDecorationBufferBlock, vstate); if (storage_buffer && buffer_block) { return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(var_id)) - << "Storage buffer id '" << var_id + << vstate.VkErrorID(6675) << "Storage buffer id '" << var_id << " In Vulkan, BufferBlock is disallowed on variables in " "the StorageBuffer storage class"; } - // Vulkan 14.5.1/2: Check Block decoration for PushConstant, Uniform + // Vulkan: Check Block decoration for PushConstant, Uniform // and StorageBuffer variables. Uniform can also use BufferBlock. if (push_constant && !block) { return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id)) - << "PushConstant id '" << id + << vstate.VkErrorID(6675) << "PushConstant id '" << id << "' is missing Block decoration.\n" - << "From Vulkan spec, section 14.5.1:\n" + << "From Vulkan spec:\n" << "Such variables must be identified with a Block " "decoration"; } if (storage_buffer && !block) { return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id)) - << "StorageBuffer id '" << id + << vstate.VkErrorID(6675) << "StorageBuffer id '" << id << "' is missing Block decoration.\n" - << "From Vulkan spec, section 14.5.2:\n" + << "From Vulkan spec:\n" << "Such variables must be identified with a Block " "decoration"; } if (uniform && !block && !buffer_block) { return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id)) - << "Uniform id '" << id + << vstate.VkErrorID(6676) << "Uniform id '" << id << "' is missing Block or BufferBlock decoration.\n" - << "From Vulkan spec, section 14.5.2:\n" + << "From Vulkan spec:\n" << "Such variables must be identified with a Block or " "BufferBlock decoration"; } - // Vulkan 14.5.2: Check DescriptorSet and Binding decoration for + // Vulkan: Check DescriptorSet and Binding decoration for // Uniform and StorageBuffer variables. if (uniform || storage_buffer) { auto entry_points = vstate.EntryPointReferences(var_id); if (!entry_points.empty() && !hasDecoration(var_id, SpvDecorationDescriptorSet, vstate)) { return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(var_id)) - << sc_str << " id '" << var_id + << vstate.VkErrorID(6677) << sc_str << " id '" << var_id << "' is missing DescriptorSet decoration.\n" - << "From Vulkan spec, section 14.5.2:\n" + << "From Vulkan spec:\n" << "These variables must have DescriptorSet and Binding " "decorations specified"; } if (!entry_points.empty() && !hasDecoration(var_id, SpvDecorationBinding, vstate)) { return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(var_id)) - << sc_str << " id '" << var_id + << vstate.VkErrorID(6677) << sc_str << " id '" << var_id << "' is missing Binding decoration.\n" - << "From Vulkan spec, section 14.5.2:\n" + << "From Vulkan spec:\n" << "These variables must have DescriptorSet and Binding " "decorations specified"; } @@ -1386,11 +1407,11 @@ spv_result_t CheckFPRoundingModeForShaders(ValidationState_t& vstate, storage != SpvStorageClassUniform && storage != SpvStorageClassPushConstant && storage != SpvStorageClassInput && storage != SpvStorageClassOutput && - storage != SpvStorageClassPhysicalStorageBufferEXT) { + storage != SpvStorageClassPhysicalStorageBuffer) { return vstate.diag(SPV_ERROR_INVALID_ID, &inst) << "FPRoundingMode decoration can be applied only to the " "Object operand of an OpStore in the StorageBuffer, " - "PhysicalStorageBufferEXT, Uniform, PushConstant, Input, or " + "PhysicalStorageBuffer, Uniform, PushConstant, Input, or " "Output Storage Classes."; } } diff --git a/third_party/spirv-tools/source/val/validate_extensions.cpp b/third_party/spirv-tools/source/val/validate_extensions.cpp index dccbe14908..fcf04e207a 100644 --- a/third_party/spirv-tools/source/val/validate_extensions.cpp +++ b/third_party/spirv-tools/source/val/validate_extensions.cpp @@ -129,7 +129,7 @@ spv_result_t ValidateUint32ConstantOperandForDebugInfo( } // True if the operand of a debug info instruction |inst| at |word_index| -// satisifies |expectation| that is given as a function. Otherwise, +// satisfies |expectation| that is given as a function. Otherwise, // returns false. bool DoesDebugInfoOperandMatchExpectation( const ValidationState_t& _, @@ -147,6 +147,24 @@ bool DoesDebugInfoOperandMatchExpectation( return true; } +// Overload for NonSemanticShaderDebugInfo100Instructions. +bool DoesDebugInfoOperandMatchExpectation( + const ValidationState_t& _, + const std::function& + expectation, + const Instruction* inst, uint32_t word_index) { + if (inst->words().size() <= word_index) return false; + auto* debug_inst = _.FindDef(inst->word(word_index)); + if (debug_inst->opcode() != SpvOpExtInst || + (debug_inst->ext_inst_type() != + SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100) || + !expectation( + NonSemanticShaderDebugInfo100Instructions(debug_inst->word(4)))) { + return false; + } + return true; +} + // Check that the operand of a debug info instruction |inst| at |word_index| // is a result id of an debug info instruction whose debug instruction type // is |expected_debug_inst|. @@ -223,6 +241,18 @@ spv_result_t ValidateOperandDebugType( const Instruction* inst, uint32_t word_index, const std::function& ext_inst_name, bool allow_template_param) { + // Check for NonSemanticShaderDebugInfo100 specific types. + if (inst->ext_inst_type() == + SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100) { + std::function expectation = + [](NonSemanticShaderDebugInfo100Instructions dbg_inst) { + return dbg_inst == NonSemanticShaderDebugInfo100DebugTypeMatrix; + }; + if (DoesDebugInfoOperandMatchExpectation(_, expectation, inst, word_index)) + return SPV_SUCCESS; + } + + // Check for common types. std::function expectation = [&allow_template_param](CommonDebugInfoInstructions dbg_inst) { if (allow_template_param && @@ -280,8 +310,7 @@ spv_result_t ValidateClspvReflectionKernel(ValidationState_t& _, return _.diag(SPV_ERROR_INVALID_ID, inst) << "Name must be an OpString"; } - const std::string name_str = reinterpret_cast( - name->words().data() + name->operands()[1].offset); + const std::string name_str = name->GetOperandAs(1); bool found = false; for (auto& desc : _.entry_point_descriptions(kernel_id)) { if (name_str == desc.name) { @@ -740,9 +769,9 @@ spv_result_t ValidateExtension(ValidationState_t& _, const Instruction* inst) { spv_result_t ValidateExtInstImport(ValidationState_t& _, const Instruction* inst) { const auto name_id = 1; - if (!_.HasExtension(kSPV_KHR_non_semantic_info)) { - const std::string name(reinterpret_cast( - inst->words().data() + inst->operands()[name_id].offset)); + if (_.version() <= SPV_SPIRV_VERSION_WORD(1, 5) && + !_.HasExtension(kSPV_KHR_non_semantic_info)) { + const std::string name = inst->GetOperandAs(name_id); if (name.find("NonSemantic.") == 0) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "NonSemantic extended instruction sets cannot be declared " @@ -774,7 +803,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { assert(import_inst); std::ostringstream ss; - ss << reinterpret_cast(import_inst->words().data() + 2); + ss << import_inst->GetOperandAs(1); ss << " "; ss << desc->name; @@ -2720,6 +2749,86 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { auto num_words = inst->words().size(); + // Handle any non-common NonSemanticShaderDebugInfo instructions. + if (vulkanDebugInfo) { + const NonSemanticShaderDebugInfo100Instructions ext_inst_key = + NonSemanticShaderDebugInfo100Instructions(ext_inst_index); + switch (ext_inst_key) { + // The following block of instructions will be handled by the common + // validation. + case NonSemanticShaderDebugInfo100DebugInfoNone: + case NonSemanticShaderDebugInfo100DebugCompilationUnit: + case NonSemanticShaderDebugInfo100DebugTypeBasic: + case NonSemanticShaderDebugInfo100DebugTypePointer: + case NonSemanticShaderDebugInfo100DebugTypeQualifier: + case NonSemanticShaderDebugInfo100DebugTypeArray: + case NonSemanticShaderDebugInfo100DebugTypeVector: + case NonSemanticShaderDebugInfo100DebugTypedef: + case NonSemanticShaderDebugInfo100DebugTypeFunction: + case NonSemanticShaderDebugInfo100DebugTypeEnum: + case NonSemanticShaderDebugInfo100DebugTypeComposite: + case NonSemanticShaderDebugInfo100DebugTypeMember: + case NonSemanticShaderDebugInfo100DebugTypeInheritance: + case NonSemanticShaderDebugInfo100DebugTypePtrToMember: + case NonSemanticShaderDebugInfo100DebugTypeTemplate: + case NonSemanticShaderDebugInfo100DebugTypeTemplateParameter: + case NonSemanticShaderDebugInfo100DebugTypeTemplateTemplateParameter: + case NonSemanticShaderDebugInfo100DebugTypeTemplateParameterPack: + case NonSemanticShaderDebugInfo100DebugGlobalVariable: + case NonSemanticShaderDebugInfo100DebugFunctionDeclaration: + case NonSemanticShaderDebugInfo100DebugFunction: + case NonSemanticShaderDebugInfo100DebugLexicalBlock: + case NonSemanticShaderDebugInfo100DebugLexicalBlockDiscriminator: + case NonSemanticShaderDebugInfo100DebugScope: + case NonSemanticShaderDebugInfo100DebugNoScope: + case NonSemanticShaderDebugInfo100DebugInlinedAt: + case NonSemanticShaderDebugInfo100DebugLocalVariable: + case NonSemanticShaderDebugInfo100DebugInlinedVariable: + case NonSemanticShaderDebugInfo100DebugDeclare: + case NonSemanticShaderDebugInfo100DebugValue: + case NonSemanticShaderDebugInfo100DebugOperation: + case NonSemanticShaderDebugInfo100DebugExpression: + case NonSemanticShaderDebugInfo100DebugMacroDef: + case NonSemanticShaderDebugInfo100DebugMacroUndef: + case NonSemanticShaderDebugInfo100DebugImportedEntity: + case NonSemanticShaderDebugInfo100DebugSource: + break; + case NonSemanticShaderDebugInfo100DebugTypeMatrix: { + CHECK_DEBUG_OPERAND("Vector Type", CommonDebugInfoDebugTypeVector, 5); + + CHECK_CONST_UINT_OPERAND("Vector Count", 6); + + uint32_t vector_count = inst->word(6); + uint64_t const_val; + if (!_.GetConstantValUint64(vector_count, &const_val)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << ext_inst_name() + << ": Vector Count must be 32-bit integer OpConstant"; + } + + vector_count = const_val & 0xffffffff; + if (!vector_count || vector_count > 4) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << ext_inst_name() << ": Vector Count must be positive " + << "integer less than or equal to 4"; + } + break; + } + // TODO: Add validation rules for remaining cases as well. + case NonSemanticShaderDebugInfo100DebugFunctionDefinition: + case NonSemanticShaderDebugInfo100DebugSourceContinued: + case NonSemanticShaderDebugInfo100DebugLine: + case NonSemanticShaderDebugInfo100DebugNoLine: + case NonSemanticShaderDebugInfo100DebugBuildIdentifier: + case NonSemanticShaderDebugInfo100DebugStoragePath: + case NonSemanticShaderDebugInfo100DebugEntryPoint: + break; + case NonSemanticShaderDebugInfo100InstructionsMax: + assert(0); + break; + } + } + // Handle any non-common OpenCL insts, then common if (ext_inst_type != SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100 || OpenCLDebugInfo100Instructions(ext_inst_index) != @@ -2805,8 +2914,9 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { bool invalid = false; auto* component_count = _.FindDef(inst->word(i)); if (IsConstIntScalarTypeWith32Or64Bits(_, component_count)) { - // TODO: We need a spec discussion for the bindless array. - if (!component_count->word(3)) { + // TODO: We need a spec discussion for the runtime array for + // OpenCL. + if (!vulkanDebugInfo && !component_count->word(3)) { invalid = true; } } else if (component_count->words().size() > 6 && @@ -3264,8 +3374,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { } } else if (ext_inst_type == SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION) { auto import_inst = _.FindDef(inst->GetOperandAs(2)); - const std::string name(reinterpret_cast( - import_inst->words().data() + import_inst->operands()[1].offset)); + const std::string name = import_inst->GetOperandAs(1); const std::string reflection = "NonSemantic.ClspvReflection."; char* end_ptr; auto version_string = name.substr(reflection.size()); diff --git a/third_party/spirv-tools/source/val/validate_function.cpp b/third_party/spirv-tools/source/val/validate_function.cpp index 596186bbe6..2a5fed8e27 100644 --- a/third_party/spirv-tools/source/val/validate_function.cpp +++ b/third_party/spirv-tools/source/val/validate_function.cpp @@ -147,8 +147,8 @@ spv_result_t ValidateFunctionParameter(ValidationState_t& _, "type of the same index."; } - // Validate that PhysicalStorageBufferEXT have one of Restrict, Aliased, - // RestrictPointerEXT, or AliasedPointerEXT. + // Validate that PhysicalStorageBuffer have one of Restrict, Aliased, + // RestrictPointer, or AliasedPointer. auto param_nonarray_type_id = param_type->id(); while (_.GetIdOpcode(param_nonarray_type_id) == SpvOpTypeArray) { param_nonarray_type_id = @@ -157,7 +157,7 @@ spv_result_t ValidateFunctionParameter(ValidationState_t& _, if (_.GetIdOpcode(param_nonarray_type_id) == SpvOpTypePointer) { auto param_nonarray_type = _.FindDef(param_nonarray_type_id); if (param_nonarray_type->GetOperandAs(1u) == - SpvStorageClassPhysicalStorageBufferEXT) { + SpvStorageClassPhysicalStorageBuffer) { // check for Aliased or Restrict const auto& decorations = _.id_decorations(inst->id()); @@ -174,14 +174,14 @@ spv_result_t ValidateFunctionParameter(ValidationState_t& _, if (!foundAliased && !foundRestrict) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "OpFunctionParameter " << inst->id() - << ": expected Aliased or Restrict for PhysicalStorageBufferEXT " + << ": expected Aliased or Restrict for PhysicalStorageBuffer " "pointer."; } if (foundAliased && foundRestrict) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "OpFunctionParameter " << inst->id() << ": can't specify both Aliased and Restrict for " - "PhysicalStorageBufferEXT pointer."; + "PhysicalStorageBuffer pointer."; } } else { const auto pointee_type_id = @@ -189,31 +189,31 @@ spv_result_t ValidateFunctionParameter(ValidationState_t& _, const auto pointee_type = _.FindDef(pointee_type_id); if (SpvOpTypePointer == pointee_type->opcode() && pointee_type->GetOperandAs(1u) == - SpvStorageClassPhysicalStorageBufferEXT) { - // check for AliasedPointerEXT/RestrictPointerEXT + SpvStorageClassPhysicalStorageBuffer) { + // check for AliasedPointer/RestrictPointer const auto& decorations = _.id_decorations(inst->id()); bool foundAliased = std::any_of( decorations.begin(), decorations.end(), [](const Decoration& d) { - return SpvDecorationAliasedPointerEXT == d.dec_type(); + return SpvDecorationAliasedPointer == d.dec_type(); }); bool foundRestrict = std::any_of( decorations.begin(), decorations.end(), [](const Decoration& d) { - return SpvDecorationRestrictPointerEXT == d.dec_type(); + return SpvDecorationRestrictPointer == d.dec_type(); }); if (!foundAliased && !foundRestrict) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "OpFunctionParameter " << inst->id() - << ": expected AliasedPointerEXT or RestrictPointerEXT for " - "PhysicalStorageBufferEXT pointer."; + << ": expected AliasedPointer or RestrictPointer for " + "PhysicalStorageBuffer pointer."; } if (foundAliased && foundRestrict) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "OpFunctionParameter " << inst->id() - << ": can't specify both AliasedPointerEXT and " - "RestrictPointerEXT for PhysicalStorageBufferEXT pointer."; + << ": can't specify both AliasedPointer and " + "RestrictPointer for PhysicalStorageBuffer pointer."; } } } @@ -300,7 +300,7 @@ spv_result_t ValidateFunctionCall(ValidationState_t& _, // These are always allowed. break; case SpvStorageClassStorageBuffer: - if (!_.features().variable_pointers_storage_buffer) { + if (!_.features().variable_pointers) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "StorageBuffer pointer operand " << _.getIdName(argument_id) @@ -316,11 +316,10 @@ spv_result_t ValidateFunctionCall(ValidationState_t& _, // Validate memory object declaration requirements. if (argument->opcode() != SpvOpVariable && argument->opcode() != SpvOpFunctionParameter) { - const bool ssbo_vptr = - _.features().variable_pointers_storage_buffer && - sc == SpvStorageClassStorageBuffer; - const bool wg_vptr = - _.features().variable_pointers && sc == SpvStorageClassWorkgroup; + const bool ssbo_vptr = _.features().variable_pointers && + sc == SpvStorageClassStorageBuffer; + const bool wg_vptr = _.HasCapability(SpvCapabilityVariablePointers) && + sc == SpvStorageClassWorkgroup; const bool uc_ptr = sc == SpvStorageClassUniformConstant; if (!ssbo_vptr && !wg_vptr && !uc_ptr) { return _.diag(SPV_ERROR_INVALID_ID, inst) diff --git a/third_party/spirv-tools/source/val/validate_image.cpp b/third_party/spirv-tools/source/val/validate_image.cpp index 64f6ba7bde..f6d7d103c7 100644 --- a/third_party/spirv-tools/source/val/validate_image.cpp +++ b/third_party/spirv-tools/source/val/validate_image.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Google Inc. +// Copyright (c) 2017 Google Inc. // Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights // reserved. // @@ -20,6 +20,7 @@ #include "source/diagnostic.h" #include "source/opcode.h" +#include "source/spirv_constant.h" #include "source/spirv_target_env.h" #include "source/util/bitutils.h" #include "source/val/instruction.h" @@ -71,6 +72,7 @@ bool CheckAllImageOperandsHandled() { // blocks other PRs. // https://github.com/KhronosGroup/SPIRV-Tools/issues/4565 case SpvImageOperandsOffsetsMask: + case SpvImageOperandsNontemporalMask: return true; } return false; @@ -258,7 +260,8 @@ spv_result_t ValidateImageOperands(ValidationState_t& _, mask & ~uint32_t(SpvImageOperandsNonPrivateTexelKHRMask | SpvImageOperandsVolatileTexelKHRMask | SpvImageOperandsSignExtendMask | - SpvImageOperandsZeroExtendMask); + SpvImageOperandsZeroExtendMask | + SpvImageOperandsNontemporalMask); size_t expected_num_image_operand_words = spvtools::utils::CountSetBits(mask_bits_having_operands); if (mask & SpvImageOperandsGradMask) { @@ -500,7 +503,7 @@ spv_result_t ValidateImageOperands(ValidationState_t& _, if (!_.IsIntVectorType(component_type) || _.GetDimension(component_type) != 2) { return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected Image Operand ConstOffsets array componenets to be " + << "Expected Image Operand ConstOffsets array components to be " "int vectors of size 2"; } @@ -630,68 +633,71 @@ spv_result_t ValidateImageOperands(ValidationState_t& _, // TODO: add validation } + if (mask & SpvImageOperandsNontemporalMask) { + // Checked elsewhere: SPIR-V 1.6 version or later. + } + return SPV_SUCCESS; } -// Checks some of the validation rules which are common to multiple opcodes. -spv_result_t ValidateImageCommon(ValidationState_t& _, const Instruction* inst, - const ImageTypeInfo& info) { - const SpvOp opcode = inst->opcode(); - if (IsProj(opcode)) { - if (info.dim != SpvDim1D && info.dim != SpvDim2D && info.dim != SpvDim3D && - info.dim != SpvDimRect) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected Image 'Dim' parameter to be 1D, 2D, 3D or Rect"; - } - - if (info.multisampled != 0) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected Image 'MS' parameter to be 0"; - } - - if (info.arrayed != 0) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected Image 'arrayed' parameter to be 0"; - } +// Validate OpImage*Proj* instructions +spv_result_t ValidateImageProj(ValidationState_t& _, const Instruction* inst, + const ImageTypeInfo& info) { + if (info.dim != SpvDim1D && info.dim != SpvDim2D && info.dim != SpvDim3D && + info.dim != SpvDimRect) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected Image 'Dim' parameter to be 1D, 2D, 3D or Rect"; } - if (opcode == SpvOpImageRead || opcode == SpvOpImageSparseRead || - opcode == SpvOpImageWrite) { - if (info.sampled == 0) { - } else if (info.sampled == 2) { - if (info.dim == SpvDim1D && !_.HasCapability(SpvCapabilityImage1D)) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Capability Image1D is required to access storage image"; - } else if (info.dim == SpvDimRect && - !_.HasCapability(SpvCapabilityImageRect)) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Capability ImageRect is required to access storage image"; - } else if (info.dim == SpvDimBuffer && - !_.HasCapability(SpvCapabilityImageBuffer)) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Capability ImageBuffer is required to access storage image"; - } else if (info.dim == SpvDimCube && info.arrayed == 1 && - !_.HasCapability(SpvCapabilityImageCubeArray)) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Capability ImageCubeArray is required to access " - << "storage image"; - } + if (info.multisampled != 0) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected Image 'MS' parameter to be 0"; + } - if (info.multisampled == 1 && - !_.HasCapability(SpvCapabilityImageMSArray)) { -#if 0 - // TODO(atgoo@github.com) The description of this rule in the spec - // is unclear and Glslang doesn't declare ImageMSArray. Need to clarify - // and reenable. - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Capability ImageMSArray is required to access storage " - << "image"; -#endif - } - } else { + if (info.arrayed != 0) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected Image 'arrayed' parameter to be 0"; + } + + return SPV_SUCCESS; +} + +// Validate OpImage*Read and OpImage*Write instructions +spv_result_t ValidateImageReadWrite(ValidationState_t& _, + const Instruction* inst, + const ImageTypeInfo& info) { + if (info.sampled == 2) { + if (info.dim == SpvDim1D && !_.HasCapability(SpvCapabilityImage1D)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected Image 'Sampled' parameter to be 0 or 2"; + << "Capability Image1D is required to access storage image"; + } else if (info.dim == SpvDimRect && + !_.HasCapability(SpvCapabilityImageRect)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Capability ImageRect is required to access storage image"; + } else if (info.dim == SpvDimBuffer && + !_.HasCapability(SpvCapabilityImageBuffer)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Capability ImageBuffer is required to access storage image"; + } else if (info.dim == SpvDimCube && info.arrayed == 1 && + !_.HasCapability(SpvCapabilityImageCubeArray)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Capability ImageCubeArray is required to access " + << "storage image"; } + + if (info.multisampled == 1 && !_.HasCapability(SpvCapabilityImageMSArray)) { +#if 0 + // TODO(atgoo@github.com) The description of this rule in the spec + // is unclear and Glslang doesn't declare ImageMSArray. Need to clarify + // and reenable. + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Capability ImageMSArray is required to access storage " + << "image"; +#endif + } + } else if (info.sampled != 0) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected Image 'Sampled' parameter to be 0 or 2"; } return SPV_SUCCESS; @@ -806,7 +812,8 @@ spv_result_t ValidateTypeImage(ValidationState_t& _, const Instruction* inst) { } } - // Dim is checked elsewhere. + // Universal checks on image type operands + // Dim and Format and Access Qualifier are checked elsewhere. if (info.depth > 2) { return _.diag(SPV_ERROR_INVALID_DATA, inst) @@ -818,6 +825,35 @@ spv_result_t ValidateTypeImage(ValidationState_t& _, const Instruction* inst) { << "Invalid Arrayed " << info.arrayed << " (must be 0 or 1)"; } + if (info.multisampled > 1) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Invalid MS " << info.multisampled << " (must be 0 or 1)"; + } + + if (info.sampled > 2) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Invalid Sampled " << info.sampled << " (must be 0, 1 or 2)"; + } + + if (info.dim == SpvDimSubpassData) { + if (info.sampled != 2) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << _.VkErrorID(6214) << "Dim SubpassData requires Sampled to be 2"; + } + + if (info.format != SpvImageFormatUnknown) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Dim SubpassData requires format Unknown"; + } + } else { + if (info.multisampled && (info.sampled == 2) && + !_.HasCapability(SpvCapabilityStorageImageMultisample)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Capability StorageImageMultisample is required when using " + "multisampled storage image"; + } + } + if (spvIsOpenCLEnv(target_env)) { if ((info.arrayed == 1) && (info.dim != SpvDim1D) && (info.dim != SpvDim2D)) { @@ -825,23 +861,22 @@ spv_result_t ValidateTypeImage(ValidationState_t& _, const Instruction* inst) { << "In the OpenCL environment, Arrayed may only be set to 1 " << "when Dim is either 1D or 2D."; } - } - if (info.multisampled > 1) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Invalid MS " << info.multisampled << " (must be 0 or 1)"; - } - - if (spvIsOpenCLEnv(target_env)) { if (info.multisampled != 0) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "MS must be 0 in the OpenCL environment."; } - } - if (info.sampled > 2) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Invalid Sampled " << info.sampled << " (must be 0, 1 or 2)"; + if (info.sampled != 0) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Sampled must be 0 in the OpenCL environment."; + } + + if (info.access_qualifier == SpvAccessQualifierMax) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "In the OpenCL environment, the optional Access Qualifier" + << " must be present."; + } } if (spvIsVulkanEnv(target_env)) { @@ -850,43 +885,10 @@ spv_result_t ValidateTypeImage(ValidationState_t& _, const Instruction* inst) { << _.VkErrorID(4657) << "Sampled must be 1 or 2 in the Vulkan environment."; } - } - if (spvIsOpenCLEnv(_.context()->target_env)) { - if (info.sampled != 0) { + if (info.dim == SpvDimSubpassData && info.arrayed != 0) { return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Sampled must be 0 in the OpenCL environment."; - } - } - - if (info.dim == SpvDimSubpassData) { - if (info.sampled != 2) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Dim SubpassData requires Sampled to be 2"; - } - - if (info.format != SpvImageFormatUnknown) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Dim SubpassData requires format Unknown"; - } - } - - // Format and Access Qualifier are also checked elsewhere. - - if (spvIsOpenCLEnv(_.context()->target_env)) { - if (info.access_qualifier == SpvAccessQualifierMax) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "In the OpenCL environment, the optional Access Qualifier" - << " must be present."; - } - } - - if (info.multisampled && (info.sampled == 2) && - (info.dim != SpvDimSubpassData)) { - if (!_.HasCapability(SpvCapabilityStorageImageMultisample)) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Capability StorageImageMultisample is required when using " - "multisampled storage image"; + << _.VkErrorID(6214) << "Dim SubpassData requires Arrayed to be 0"; } } @@ -915,6 +917,13 @@ spv_result_t ValidateTypeSampledImage(ValidationState_t& _, "operand set to 0 or 1"; } + // This covers both OpTypeSampledImage and OpSampledImage. + if (_.version() >= SPV_SPIRV_VERSION_WORD(1, 6) && info.dim == SpvDimBuffer) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "In SPIR-V 1.6 or later, sampled image dimension must not be " + "Buffer"; + } + return SPV_SUCCESS; } @@ -971,8 +980,9 @@ spv_result_t ValidateSampledImage(ValidationState_t& _, if (spvIsVulkanEnv(_.context()->target_env)) { if (info.sampled != 1) { return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected Image 'Sampled' parameter to be 1 " - << "for Vulkan environment."; + << _.VkErrorID(6671) + << "Expected Image 'Sampled' parameter to be 1 for Vulkan " + "environment."; } } else { if (info.sampled != 0 && info.sampled != 1) { @@ -1030,7 +1040,7 @@ spv_result_t ValidateSampledImage(ValidationState_t& _, << "Result from OpSampledImage instruction must not appear " "as operand for Op" << spvOpcodeString(static_cast(consumer_opcode)) - << ", since it is not specificed as taking an " + << ", since it is not specified as taking an " << "OpTypeSampledImage." << " Found result '" << _.getIdName(inst->id()) << "' as an operand of '" @@ -1191,7 +1201,9 @@ spv_result_t ValidateImageLod(ValidationState_t& _, const Instruction* inst) { << "Corrupt image type definition"; } - if (spv_result_t result = ValidateImageCommon(_, inst, info)) return result; + if (IsProj(opcode)) { + if (spv_result_t result = ValidateImageProj(_, inst, info)) return result; + } if (info.multisampled) { // When using image operands, the Sample image operand is required if and @@ -1254,6 +1266,27 @@ spv_result_t ValidateImageLod(ValidationState_t& _, const Instruction* inst) { return SPV_SUCCESS; } +// Validates anything OpImage*Dref* instruction +spv_result_t ValidateImageDref(ValidationState_t& _, const Instruction* inst, + const ImageTypeInfo& info) { + const uint32_t dref_type = _.GetOperandTypeId(inst, 4); + if (!_.IsFloatScalarType(dref_type) || _.GetBitWidth(dref_type) != 32) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected Dref to be of 32-bit float type"; + } + + if (spvIsVulkanEnv(_.context()->target_env)) { + if (info.dim == SpvDim3D) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << _.VkErrorID(4777) + << "In Vulkan, OpImage*Dref* instructions must not use images " + "with a 3D Dim"; + } + } + + return SPV_SUCCESS; +} + spv_result_t ValidateImageDrefLod(ValidationState_t& _, const Instruction* inst) { const SpvOp opcode = inst->opcode(); @@ -1281,7 +1314,9 @@ spv_result_t ValidateImageDrefLod(ValidationState_t& _, << "Corrupt image type definition"; } - if (spv_result_t result = ValidateImageCommon(_, inst, info)) return result; + if (IsProj(opcode)) { + if (spv_result_t result = ValidateImageProj(_, inst, info)) return result; + } if (info.multisampled) { // When using image operands, the Sample image operand is required if and @@ -1311,11 +1346,7 @@ spv_result_t ValidateImageDrefLod(ValidationState_t& _, << " components, but given only " << actual_coord_size; } - const uint32_t dref_type = _.GetOperandTypeId(inst, 4); - if (!_.IsFloatScalarType(dref_type) || _.GetBitWidth(dref_type) != 32) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected Dref to be of 32-bit float type"; - } + if (spv_result_t result = ValidateImageDref(_, inst, info)) return result; if (spv_result_t result = ValidateImageOperands(_, inst, info, /* word_index = */ 7)) @@ -1450,7 +1481,8 @@ spv_result_t ValidateImageGather(ValidationState_t& _, if (info.dim != SpvDim2D && info.dim != SpvDimCube && info.dim != SpvDimRect) { return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected Image 'Dim' cannot be Cube"; + << _.VkErrorID(4777) + << "Expected Image 'Dim' to be 2D, Cube, or Rect"; } const uint32_t coord_type = _.GetOperandTypeId(inst, 3); @@ -1486,11 +1518,7 @@ spv_result_t ValidateImageGather(ValidationState_t& _, } else { assert(opcode == SpvOpImageDrefGather || opcode == SpvOpImageSparseDrefGather); - const uint32_t dref_type = _.GetOperandTypeId(inst, 4); - if (!_.IsFloatScalarType(dref_type) || _.GetBitWidth(dref_type) != 32) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected Dref to be of 32-bit float type"; - } + if (spv_result_t result = ValidateImageDref(_, inst, info)) return result; } if (spv_result_t result = @@ -1558,6 +1586,13 @@ spv_result_t ValidateImageRead(ValidationState_t& _, const Instruction* inst) { << " to have 4 components"; } } + + const uint32_t mask = inst->words().size() <= 5 ? 0 : inst->word(5); + if (mask & SpvImageOperandsConstOffsetMask) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "ConstOffset image operand not allowed " + << "in the OpenCL environment."; + } } if (info.dim == SpvDimSubpassData) { @@ -1583,7 +1618,8 @@ spv_result_t ValidateImageRead(ValidationState_t& _, const Instruction* inst) { } } - if (spv_result_t result = ValidateImageCommon(_, inst, info)) return result; + if (spv_result_t result = ValidateImageReadWrite(_, inst, info)) + return result; const uint32_t coord_type = _.GetOperandTypeId(inst, 3); if (!_.IsIntScalarOrVectorType(coord_type)) { @@ -1608,16 +1644,6 @@ spv_result_t ValidateImageRead(ValidationState_t& _, const Instruction* inst) { } } - const uint32_t mask = inst->words().size() <= 5 ? 0 : inst->word(5); - - if (mask & SpvImageOperandsConstOffsetMask) { - if (spvIsOpenCLEnv(_.context()->target_env)) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "ConstOffset image operand not allowed " - << "in the OpenCL environment."; - } - } - if (spv_result_t result = ValidateImageOperands(_, inst, info, /* word_index = */ 6)) return result; @@ -1643,7 +1669,8 @@ spv_result_t ValidateImageWrite(ValidationState_t& _, const Instruction* inst) { << "Image 'Dim' cannot be SubpassData"; } - if (spv_result_t result = ValidateImageCommon(_, inst, info)) return result; + if (spv_result_t result = ValidateImageReadWrite(_, inst, info)) + return result; const uint32_t coord_type = _.GetOperandTypeId(inst, 1); if (!_.IsIntScalarOrVectorType(coord_type)) { @@ -1659,7 +1686,7 @@ spv_result_t ValidateImageWrite(ValidationState_t& _, const Instruction* inst) { << " components, but given only " << actual_coord_size; } - // TODO(atgoo@github.com) The spec doesn't explicitely say what the type + // TODO(atgoo@github.com) The spec doesn't explicitly say what the type // of texel should be. const uint32_t texel_type = _.GetOperandTypeId(inst, 2); if (!_.IsIntScalarOrVectorType(texel_type) && diff --git a/third_party/spirv-tools/source/val/validate_instruction.cpp b/third_party/spirv-tools/source/val/validate_instruction.cpp index dad98673b1..3edf163797 100644 --- a/third_party/spirv-tools/source/val/validate_instruction.cpp +++ b/third_party/spirv-tools/source/val/validate_instruction.cpp @@ -297,7 +297,7 @@ spv_result_t VersionCheck(ValidationState_t& _, const Instruction* inst) { } // OpTerminateInvocation is special because it is enabled by Shader - // capability, but also requries a extension and/or version check. + // capability, but also requires an extension and/or version check. const bool capability_check_is_sufficient = inst->opcode() != SpvOpTerminateInvocation; @@ -406,7 +406,7 @@ spv_result_t LimitCheckSwitch(ValidationState_t& _, const Instruction* inst) { // The instruction syntax is as follows: // OpSwitch literal label literal label ... // literal,label pairs come after the first 2 operands. - // It is guaranteed at this point that num_operands is an even numner. + // It is guaranteed at this point that num_operands is an even number. size_t num_pairs = (inst->operands().size() - 2) / 2; const unsigned int num_pairs_limit = _.options()->universal_limits_.max_switch_branches; diff --git a/third_party/spirv-tools/source/val/validate_interfaces.cpp b/third_party/spirv-tools/source/val/validate_interfaces.cpp index 7ccb6371bb..9a9a7fb386 100644 --- a/third_party/spirv-tools/source/val/validate_interfaces.cpp +++ b/third_party/spirv-tools/source/val/validate_interfaces.cpp @@ -154,7 +154,7 @@ spv_result_t NumConsumedLocations(ValidationState_t& _, const Instruction* type, // Members cannot have location decorations at this point. if (_.HasDecoration(type->id(), SpvDecorationLocation)) { return _.diag(SPV_ERROR_INVALID_DATA, type) - << "Members cannot be assigned a location"; + << _.VkErrorID(4918) << "Members cannot be assigned a location"; } // Structs consume locations equal to the sum of the locations consumed @@ -238,7 +238,7 @@ spv_result_t GetLocationsForVariable( uint32_t index = 0; bool has_patch = false; bool has_per_task_nv = false; - bool has_per_vertex_nv = false; + bool has_per_vertex_khr = false; for (auto& dec : _.id_decorations(variable->id())) { if (dec.dec_type() == SpvDecorationLocation) { if (has_location && dec.params()[0] != location) { @@ -272,8 +272,8 @@ spv_result_t GetLocationsForVariable( has_patch = true; } else if (dec.dec_type() == SpvDecorationPerTaskNV) { has_per_task_nv = true; - } else if (dec.dec_type() == SpvDecorationPerVertexNV) { - has_per_vertex_nv = true; + } else if (dec.dec_type() == SpvDecorationPerVertexKHR) { + has_per_vertex_khr = true; } } @@ -298,7 +298,7 @@ spv_result_t GetLocationsForVariable( } break; case SpvExecutionModelFragment: - if (!is_output && has_per_vertex_nv) { + if (!is_output && has_per_vertex_khr) { is_arrayed = true; } break; @@ -326,8 +326,9 @@ spv_result_t GetLocationsForVariable( // Only block-decorated structs don't need a location on the variable. const bool is_block = _.HasDecoration(type_id, SpvDecorationBlock); if (!has_location && !is_block) { + const auto vuid = (type->opcode() == SpvOpTypeStruct) ? 4917 : 4916; return _.diag(SPV_ERROR_INVALID_DATA, variable) - << "Variable must be decorated with a location"; + << _.VkErrorID(vuid) << "Variable must be decorated with a location"; } const std::string storage_class = is_output ? "output" : "input"; @@ -411,7 +412,7 @@ spv_result_t GetLocationsForVariable( auto where = member_locations.find(i - 1); if (where == member_locations.end()) { return _.diag(SPV_ERROR_INVALID_DATA, type) - << "Member index " << i - 1 + << _.VkErrorID(4919) << "Member index " << i - 1 << " is missing a location assignment"; } @@ -476,6 +477,9 @@ spv_result_t ValidateLocations(ValidationState_t& _, const Instruction* entry_point) { // According to Vulkan 14.1 only the following execution models have // locations assigned. + // TODO(dneto): SPV_NV_ray_tracing also uses locations on interface variables, + // in other shader stages. Similarly, the *provisional* version of + // SPV_KHR_ray_tracing did as well, but not the final version. switch (entry_point->GetOperandAs(0)) { case SpvExecutionModelVertex: case SpvExecutionModelTessellationControl: diff --git a/third_party/spirv-tools/source/val/validate_logicals.cpp b/third_party/spirv-tools/source/val/validate_logicals.cpp index bb35f558ec..5307988e39 100644 --- a/third_party/spirv-tools/source/val/validate_logicals.cpp +++ b/third_party/spirv-tools/source/val/validate_logicals.cpp @@ -163,8 +163,7 @@ spv_result_t LogicalsPass(ValidationState_t& _, const Instruction* inst) { switch (type_opcode) { case SpvOpTypePointer: { if (_.addressing_model() == SpvAddressingModelLogical && - !_.features().variable_pointers && - !_.features().variable_pointers_storage_buffer) + !_.features().variable_pointers) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Using pointers with OpSelect requires capability " << "VariablePointers or VariablePointersStorageBuffer"; diff --git a/third_party/spirv-tools/source/val/validate_memory.cpp b/third_party/spirv-tools/source/val/validate_memory.cpp index a7b0f82d5d..af9da678e1 100644 --- a/third_party/spirv-tools/source/val/validate_memory.cpp +++ b/third_party/spirv-tools/source/val/validate_memory.cpp @@ -315,11 +315,12 @@ spv_result_t CheckMemoryAccess(ValidationState_t& _, const Instruction* inst, SpvStorageClass dst_sc, src_sc; std::tie(dst_sc, src_sc) = GetStorageClass(_, inst); if (inst->operands().size() <= index) { - if (src_sc == SpvStorageClassPhysicalStorageBufferEXT || - dst_sc == SpvStorageClassPhysicalStorageBufferEXT) { + // Cases where lack of some operand is invalid + if (src_sc == SpvStorageClassPhysicalStorageBuffer || + dst_sc == SpvStorageClassPhysicalStorageBuffer) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "Memory accesses with PhysicalStorageBufferEXT must use " - "Aligned."; + << _.VkErrorID(4708) + << "Memory accesses with PhysicalStorageBuffer must use Aligned."; } return SPV_SUCCESS; } @@ -368,7 +369,7 @@ spv_result_t CheckMemoryAccess(ValidationState_t& _, const Instruction* inst, dst_sc != SpvStorageClassCrossWorkgroup && dst_sc != SpvStorageClassGeneric && dst_sc != SpvStorageClassImage && dst_sc != SpvStorageClassStorageBuffer && - dst_sc != SpvStorageClassPhysicalStorageBufferEXT) { + dst_sc != SpvStorageClassPhysicalStorageBuffer) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "NonPrivatePointerKHR requires a pointer in Uniform, " << "Workgroup, CrossWorkgroup, Generic, Image or StorageBuffer " @@ -379,7 +380,7 @@ spv_result_t CheckMemoryAccess(ValidationState_t& _, const Instruction* inst, src_sc != SpvStorageClassCrossWorkgroup && src_sc != SpvStorageClassGeneric && src_sc != SpvStorageClassImage && src_sc != SpvStorageClassStorageBuffer && - src_sc != SpvStorageClassPhysicalStorageBufferEXT) { + src_sc != SpvStorageClassPhysicalStorageBuffer) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "NonPrivatePointerKHR requires a pointer in Uniform, " << "Workgroup, CrossWorkgroup, Generic, Image or StorageBuffer " @@ -388,11 +389,11 @@ spv_result_t CheckMemoryAccess(ValidationState_t& _, const Instruction* inst, } if (!(mask & SpvMemoryAccessAlignedMask)) { - if (src_sc == SpvStorageClassPhysicalStorageBufferEXT || - dst_sc == SpvStorageClassPhysicalStorageBufferEXT) { + if (src_sc == SpvStorageClassPhysicalStorageBuffer || + dst_sc == SpvStorageClassPhysicalStorageBuffer) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "Memory accesses with PhysicalStorageBufferEXT must use " - "Aligned."; + << _.VkErrorID(4708) + << "Memory accesses with PhysicalStorageBuffer must use Aligned."; } } @@ -519,20 +520,21 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { } } - // Vulkan 14.5.1: Check type of PushConstant variables. - // Vulkan 14.5.2: Check type of UniformConstant and Uniform variables. if (spvIsVulkanEnv(_.context()->target_env)) { + // Vulkan Push Constant Interface section: Check type of PushConstant + // variables. if (storage_class == SpvStorageClassPushConstant) { - if (!IsAllowedTypeOrArrayOfSame(_, pointee, {SpvOpTypeStruct})) { + if (pointee->opcode() != SpvOpTypeStruct) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "PushConstant OpVariable '" << _.getIdName(inst->id()) << "' has illegal type.\n" - << "From Vulkan spec, section 14.5.1:\n" - << "Such variables must be typed as OpTypeStruct, " - << "or an array of this type"; + << "From Vulkan spec, Push Constant Interface section:\n" + << "Such variables must be typed as OpTypeStruct"; } } + // Vulkan Descriptor Set Interface: Check type of UniformConstant and + // Uniform variables. if (storage_class == SpvStorageClassUniformConstant) { if (!IsAllowedTypeOrArrayOfSame( _, pointee, @@ -596,23 +598,23 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { } } } - } - // Vulkan Appendix A: Check that if contains initializer, then - // storage class is Output, Private, or Function. - if (inst->operands().size() > 3 && storage_class != SpvStorageClassOutput && - storage_class != SpvStorageClassPrivate && - storage_class != SpvStorageClassFunction) { - if (spvIsVulkanEnv(_.context()->target_env)) { + // Initializers in Vulkan are only allowed in some storage clases + if (inst->operands().size() > 3) { if (storage_class == SpvStorageClassWorkgroup) { auto init_id = inst->GetOperandAs(3); auto init = _.FindDef(init_id); if (init->opcode() != SpvOpConstantNull) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "Variable initializers in Workgroup storage class are " - "limited to OpConstantNull"; + << _.VkErrorID(4734) << "OpVariable, '" + << _.getIdName(inst->id()) + << "', initializers are limited to OpConstantNull in " + "Workgroup " + "storage class"; } - } else { + } else if (storage_class != SpvStorageClassOutput && + storage_class != SpvStorageClassPrivate && + storage_class != SpvStorageClassFunction) { return _.diag(SPV_ERROR_INVALID_ID, inst) << _.VkErrorID(4651) << "OpVariable, '" << _.getIdName(inst->id()) @@ -627,9 +629,9 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { } } - if (storage_class == SpvStorageClassPhysicalStorageBufferEXT) { + if (storage_class == SpvStorageClassPhysicalStorageBuffer) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "PhysicalStorageBufferEXT must not be used with OpVariable."; + << "PhysicalStorageBuffer must not be used with OpVariable."; } auto pointee_base = pointee; @@ -638,23 +640,23 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { } if (pointee_base->opcode() == SpvOpTypePointer) { if (pointee_base->GetOperandAs(1u) == - SpvStorageClassPhysicalStorageBufferEXT) { - // check for AliasedPointerEXT/RestrictPointerEXT + SpvStorageClassPhysicalStorageBuffer) { + // check for AliasedPointer/RestrictPointer bool foundAliased = - _.HasDecoration(inst->id(), SpvDecorationAliasedPointerEXT); + _.HasDecoration(inst->id(), SpvDecorationAliasedPointer); bool foundRestrict = - _.HasDecoration(inst->id(), SpvDecorationRestrictPointerEXT); + _.HasDecoration(inst->id(), SpvDecorationRestrictPointer); if (!foundAliased && !foundRestrict) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "OpVariable " << inst->id() - << ": expected AliasedPointerEXT or RestrictPointerEXT for " - << "PhysicalStorageBufferEXT pointer."; + << ": expected AliasedPointer or RestrictPointer for " + << "PhysicalStorageBuffer pointer."; } if (foundAliased && foundRestrict) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "OpVariable " << inst->id() - << ": can't specify both AliasedPointerEXT and " - << "RestrictPointerEXT for PhysicalStorageBufferEXT pointer."; + << ": can't specify both AliasedPointer and " + << "RestrictPointer for PhysicalStorageBuffer pointer."; } } } @@ -667,7 +669,8 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { if (value_type && value_type->opcode() == SpvOpTypeRuntimeArray) { if (!_.HasCapability(SpvCapabilityRuntimeDescriptorArrayEXT)) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpVariable, '" << _.getIdName(inst->id()) + << _.VkErrorID(4680) << "OpVariable, '" + << _.getIdName(inst->id()) << "', is attempting to create memory for an illegal type, " << "OpTypeRuntimeArray.\nFor Vulkan OpTypeRuntimeArray can only " << "appear as the final member of an OpTypeStruct, thus cannot " @@ -679,6 +682,7 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { storage_class != SpvStorageClassUniform && storage_class != SpvStorageClassUniformConstant) { return _.diag(SPV_ERROR_INVALID_ID, inst) + << _.VkErrorID(4680) << "For Vulkan with RuntimeDescriptorArrayEXT, a variable " << "containing OpTypeRuntimeArray must have storage class of " << "StorageBuffer, Uniform, or UniformConstant."; @@ -692,25 +696,30 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { // as BufferBlock. if (value_type && value_type->opcode() == SpvOpTypeStruct) { if (DoesStructContainRTA(_, value_type)) { - if (storage_class == SpvStorageClassStorageBuffer) { + if (storage_class == SpvStorageClassStorageBuffer || + storage_class == SpvStorageClassPhysicalStorageBuffer) { if (!_.HasDecoration(value_id, SpvDecorationBlock)) { return _.diag(SPV_ERROR_INVALID_ID, inst) + << _.VkErrorID(4680) << "For Vulkan, an OpTypeStruct variable containing an " << "OpTypeRuntimeArray must be decorated with Block if it " - << "has storage class StorageBuffer."; + << "has storage class StorageBuffer or " + "PhysicalStorageBuffer."; } } else if (storage_class == SpvStorageClassUniform) { if (!_.HasDecoration(value_id, SpvDecorationBufferBlock)) { return _.diag(SPV_ERROR_INVALID_ID, inst) + << _.VkErrorID(4680) << "For Vulkan, an OpTypeStruct variable containing an " << "OpTypeRuntimeArray must be decorated with BufferBlock " << "if it has storage class Uniform."; } } else { return _.diag(SPV_ERROR_INVALID_ID, inst) + << _.VkErrorID(4680) << "For Vulkan, OpTypeStruct variables containing " << "OpTypeRuntimeArray must have storage class of " - << "StorageBuffer or Uniform."; + << "StorageBuffer, PhysicalStorageBuffer, or Uniform."; } } } @@ -745,7 +754,7 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { SPV_OPERAND_TYPE_STORAGE_CLASS, storage_class); switch (storage_class) { case SpvStorageClassStorageBuffer: - case SpvStorageClassPhysicalStorageBufferEXT: + case SpvStorageClassPhysicalStorageBuffer: if (!_.HasCapability(SpvCapabilityStorageBuffer16BitAccess)) { storage_class_ok = false; } @@ -807,7 +816,7 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { SPV_OPERAND_TYPE_STORAGE_CLASS, storage_class); switch (storage_class) { case SpvStorageClassStorageBuffer: - case SpvStorageClassPhysicalStorageBufferEXT: + case SpvStorageClassPhysicalStorageBuffer: if (!_.HasCapability(SpvCapabilityStorageBuffer8BitAccess)) { storage_class_ok = false; } @@ -861,17 +870,14 @@ spv_result_t ValidateLoad(ValidationState_t& _, const Instruction* inst) { << "' is not defined."; } - const bool uses_variable_pointers = - _.features().variable_pointers || - _.features().variable_pointers_storage_buffer; const auto pointer_index = 2; const auto pointer_id = inst->GetOperandAs(pointer_index); const auto pointer = _.FindDef(pointer_id); if (!pointer || ((_.addressing_model() == SpvAddressingModelLogical) && - ((!uses_variable_pointers && + ((!_.features().variable_pointers && !spvOpcodeReturnsLogicalPointer(pointer->opcode())) || - (uses_variable_pointers && + (_.features().variable_pointers && !spvOpcodeReturnsLogicalVariablePointer(pointer->opcode()))))) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "OpLoad Pointer '" << _.getIdName(pointer_id) @@ -917,17 +923,14 @@ spv_result_t ValidateLoad(ValidationState_t& _, const Instruction* inst) { } spv_result_t ValidateStore(ValidationState_t& _, const Instruction* inst) { - const bool uses_variable_pointer = - _.features().variable_pointers || - _.features().variable_pointers_storage_buffer; const auto pointer_index = 0; const auto pointer_id = inst->GetOperandAs(pointer_index); const auto pointer = _.FindDef(pointer_id); if (!pointer || (_.addressing_model() == SpvAddressingModelLogical && - ((!uses_variable_pointer && + ((!_.features().variable_pointers && !spvOpcodeReturnsLogicalPointer(pointer->opcode())) || - (uses_variable_pointer && + (_.features().variable_pointers && !spvOpcodeReturnsLogicalVariablePointer(pointer->opcode()))))) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "OpStore Pointer '" << _.getIdName(pointer_id) @@ -1138,8 +1141,6 @@ spv_result_t ValidateCopyMemory(ValidationState_t& _, const Instruction* inst) { << "'s type does not match Source '" << _.getIdName(source_type->id()) << "'s type."; } - - if (auto error = CheckMemoryAccess(_, inst, 2)) return error; } else { const auto size_id = inst->GetOperandAs(2); const auto size = _.FindDef(size_id); @@ -1182,8 +1183,6 @@ spv_result_t ValidateCopyMemory(ValidationState_t& _, const Instruction* inst) { // Cannot infer any other opcodes. break; } - - if (auto error = CheckMemoryAccess(_, inst, 3)) return error; } if (auto error = ValidateCopyMemoryMemoryAccess(_, inst)) return error; @@ -1357,8 +1356,7 @@ spv_result_t ValidateAccessChain(ValidationState_t& _, spv_result_t ValidatePtrAccessChain(ValidationState_t& _, const Instruction* inst) { if (_.addressing_model() == SpvAddressingModelLogical) { - if (!_.features().variable_pointers && - !_.features().variable_pointers_storage_buffer) { + if (!_.features().variable_pointers) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Generating variable pointers requires capability " << "VariablePointers or VariablePointersStorageBuffer"; @@ -1411,7 +1409,7 @@ spv_result_t ValidateArrayLength(ValidationState_t& state, << state.getIdName(inst->id()) << "' must be an OpTypeRuntimeArray."; } - // The array member must the the index of the last element (the run time + // The array member must the index of the last element (the run time // array). if (inst->GetOperandAs(3) != num_of_members - 1) { return state.diag(SPV_ERROR_INVALID_ID, inst) @@ -1476,18 +1474,15 @@ spv_result_t ValidateCooperativeMatrixLoadStoreNV(ValidationState_t& _, } } - const bool uses_variable_pointers = - _.features().variable_pointers || - _.features().variable_pointers_storage_buffer; const auto pointer_index = (inst->opcode() == SpvOpCooperativeMatrixLoadNV) ? 2u : 0u; const auto pointer_id = inst->GetOperandAs(pointer_index); const auto pointer = _.FindDef(pointer_id); if (!pointer || ((_.addressing_model() == SpvAddressingModelLogical) && - ((!uses_variable_pointers && + ((!_.features().variable_pointers && !spvOpcodeReturnsLogicalPointer(pointer->opcode())) || - (uses_variable_pointers && + (_.features().variable_pointers && !spvOpcodeReturnsLogicalVariablePointer(pointer->opcode()))))) { return _.diag(SPV_ERROR_INVALID_ID, inst) << opname << " Pointer '" << _.getIdName(pointer_id) @@ -1508,7 +1503,7 @@ spv_result_t ValidateCooperativeMatrixLoadStoreNV(ValidationState_t& _, if (storage_class != SpvStorageClassWorkgroup && storage_class != SpvStorageClassStorageBuffer && - storage_class != SpvStorageClassPhysicalStorageBufferEXT) { + storage_class != SpvStorageClassPhysicalStorageBuffer) { return _.diag(SPV_ERROR_INVALID_ID, inst) << opname << " storage class for pointer type '" << _.getIdName(pointer_type_id) @@ -1559,10 +1554,10 @@ spv_result_t ValidateCooperativeMatrixLoadStoreNV(ValidationState_t& _, spv_result_t ValidatePtrComparison(ValidationState_t& _, const Instruction* inst) { if (_.addressing_model() == SpvAddressingModelLogical && - !_.features().variable_pointers_storage_buffer) { + !_.features().variable_pointers) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "Instruction cannot be used without a variable pointers " - "capability"; + << "Instruction cannot for logical addressing model be used without " + "a variable pointers capability"; } const auto result_type = _.FindDef(inst->type_id()); @@ -1597,7 +1592,8 @@ spv_result_t ValidatePtrComparison(ValidationState_t& _, << "Invalid pointer storage class"; } - if (sc == SpvStorageClassWorkgroup && !_.features().variable_pointers) { + if (sc == SpvStorageClassWorkgroup && + !_.HasCapability(SpvCapabilityVariablePointers)) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "Workgroup storage class pointer requires VariablePointers " "capability to be specified"; diff --git a/third_party/spirv-tools/source/val/validate_non_uniform.cpp b/third_party/spirv-tools/source/val/validate_non_uniform.cpp index 2b6eb8b5bf..6d4f8a2840 100644 --- a/third_party/spirv-tools/source/val/validate_non_uniform.cpp +++ b/third_party/spirv-tools/source/val/validate_non_uniform.cpp @@ -63,6 +63,59 @@ spv_result_t ValidateGroupNonUniformBallotBitCount(ValidationState_t& _, return SPV_SUCCESS; } +spv_result_t ValidateGroupNonUniformRotateKHR(ValidationState_t& _, + const Instruction* inst) { + // Scope is already checked by ValidateExecutionScope() above. + const uint32_t result_type = inst->type_id(); + if (!_.IsIntScalarOrVectorType(result_type) && + !_.IsFloatScalarOrVectorType(result_type) && + !_.IsBoolScalarOrVectorType(result_type)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected Result Type to be a scalar or vector of " + "floating-point, integer or boolean type."; + } + + const uint32_t value_type = _.GetTypeId(inst->GetOperandAs(3)); + if (value_type != result_type) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result Type must be the same as the type of Value."; + } + + const uint32_t delta_type = _.GetTypeId(inst->GetOperandAs(4)); + if (!_.IsUnsignedIntScalarType(delta_type)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Delta must be a scalar of integer type, whose Signedness " + "operand is 0."; + } + + if (inst->words().size() > 6) { + const uint32_t cluster_size_op_id = inst->GetOperandAs(5); + const uint32_t cluster_size_type = _.GetTypeId(cluster_size_op_id); + if (!_.IsUnsignedIntScalarType(cluster_size_type)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "ClusterSize must be a scalar of integer type, whose " + "Signedness operand is 0."; + } + + uint64_t cluster_size; + if (!_.GetConstantValUint64(cluster_size_op_id, &cluster_size)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "ClusterSize must come from a constant instruction."; + } + + if ((cluster_size == 0) || ((cluster_size & (cluster_size - 1)) != 0)) { + return _.diag(SPV_WARNING, inst) + << "Behavior is undefined unless ClusterSize is at least 1 and a " + "power of 2."; + } + + // TODO(kpet) Warn about undefined behavior when ClusterSize is greater than + // the declared SubGroupSize + } + + return SPV_SUCCESS; +} + } // namespace // Validates correctness of non-uniform group instructions. @@ -79,6 +132,8 @@ spv_result_t NonUniformPass(ValidationState_t& _, const Instruction* inst) { switch (opcode) { case SpvOpGroupNonUniformBallotBitCount: return ValidateGroupNonUniformBallotBitCount(_, inst); + case SpvOpGroupNonUniformRotateKHR: + return ValidateGroupNonUniformRotateKHR(_, inst); default: break; } diff --git a/third_party/spirv-tools/source/val/validate_scopes.cpp b/third_party/spirv-tools/source/val/validate_scopes.cpp index 29ba583173..1c5f70a33c 100644 --- a/third_party/spirv-tools/source/val/validate_scopes.cpp +++ b/third_party/spirv-tools/source/val/validate_scopes.cpp @@ -225,7 +225,7 @@ spv_result_t ValidateMemoryScope(ValidationState_t& _, const Instruction* inst, << _.VkErrorID(4638) << spvOpcodeString(opcode) << ": in Vulkan environment, Memory Scope cannot be CrossDevice"; } - // Vulkan 1.0 specifc rules + // Vulkan 1.0 specific rules if (_.context()->target_env == SPV_ENV_VULKAN_1_0 && value != SpvScopeDevice && value != SpvScopeWorkgroup && value != SpvScopeInvocation) { @@ -234,7 +234,7 @@ spv_result_t ValidateMemoryScope(ValidationState_t& _, const Instruction* inst, << ": in Vulkan 1.0 environment Memory Scope is limited to " << "Device, Workgroup and Invocation"; } - // Vulkan 1.1 specifc rules + // Vulkan 1.1 specific rules if ((_.context()->target_env == SPV_ENV_VULKAN_1_1 || _.context()->target_env == SPV_ENV_VULKAN_1_2) && value != SpvScopeDevice && value != SpvScopeWorkgroup && diff --git a/third_party/spirv-tools/source/val/validate_type.cpp b/third_party/spirv-tools/source/val/validate_type.cpp index 4376b52c6d..2aded61658 100644 --- a/third_party/spirv-tools/source/val/validate_type.cpp +++ b/third_party/spirv-tools/source/val/validate_type.cpp @@ -228,8 +228,8 @@ spv_result_t ValidateTypeArray(ValidationState_t& _, const Instruction* inst) { if (spvIsVulkanEnv(_.context()->target_env) && element_type->opcode() == SpvOpTypeRuntimeArray) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpTypeArray Element Type '" << _.getIdName(element_type_id) - << "' is not valid in " + << _.VkErrorID(4680) << "OpTypeArray Element Type '" + << _.getIdName(element_type_id) << "' is not valid in " << spvLogStringForEnv(_.context()->target_env) << " environments."; } @@ -298,7 +298,7 @@ spv_result_t ValidateTypeRuntimeArray(ValidationState_t& _, if (spvIsVulkanEnv(_.context()->target_env) && element_type->opcode() == SpvOpTypeRuntimeArray) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpTypeRuntimeArray Element Type '" + << _.VkErrorID(4680) << "OpTypeRuntimeArray Element Type '" << _.getIdName(element_id) << "' is not valid in " << spvLogStringForEnv(_.context()->target_env) << " environments."; } @@ -373,7 +373,8 @@ spv_result_t ValidateTypeStruct(ValidationState_t& _, const Instruction* inst) { member_type_index == inst->operands().size() - 1; if (!is_last_member) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "In " << spvLogStringForEnv(_.context()->target_env) + << _.VkErrorID(4680) << "In " + << spvLogStringForEnv(_.context()->target_env) << ", OpTypeRuntimeArray must only be used for the last member " "of an OpTypeStruct"; } diff --git a/third_party/spirv-tools/source/val/validation_state.cpp b/third_party/spirv-tools/source/val/validation_state.cpp index 8d1a0d3f4e..87f71ee576 100644 --- a/third_party/spirv-tools/source/val/validation_state.cpp +++ b/third_party/spirv-tools/source/val/validation_state.cpp @@ -175,8 +175,18 @@ ValidationState_t::ValidationState_t(const spv_const_context ctx, } } - // LocalSizeId is always allowed in non-Vulkan environments. - features_.env_allow_localsizeid = !spvIsVulkanEnv(env); + // LocalSizeId is only disallowed prior to Vulkan 1.3 without maintenance4. + switch (env) { + case SPV_ENV_VULKAN_1_0: + case SPV_ENV_VULKAN_1_1: + case SPV_ENV_VULKAN_1_1_SPIRV_1_4: + case SPV_ENV_VULKAN_1_2: + features_.env_allow_localsizeid = false; + break; + default: + features_.env_allow_localsizeid = true; + break; + } // Only attempt to count if we have words, otherwise let the other validation // fail and generate an error. @@ -382,13 +392,19 @@ void ValidationState_t::RegisterCapability(SpvCapability cap) { features_.free_fp_rounding_mode = true; break; case SpvCapabilityVariablePointers: - features_.variable_pointers = true; - features_.variable_pointers_storage_buffer = true; - break; case SpvCapabilityVariablePointersStorageBuffer: - features_.variable_pointers_storage_buffer = true; + features_.variable_pointers = true; break; default: + // TODO(dneto): For now don't validate SPV_NV_ray_tracing, which uses + // capability SpvCapabilityRayTracingNV. + // SpvCapabilityRayTracingProvisionalKHR would need the same treatment. + // One of the differences going from SPV_KHR_ray_tracing from + // provisional to final spec was the provisional spec uses Locations + // for variables in certain storage classes, just like the + // SPV_NV_ray_tracing extension. So it mimics the NVIDIA extension. + // The final SPV_KHR_ray_tracing uses a different capability token + // number, so it doesn't fall into this case. break; } } @@ -441,7 +457,7 @@ void ValidationState_t::set_addressing_model(SpvAddressingModel am) { default: // fall through case SpvAddressingModelPhysical64: - case SpvAddressingModelPhysicalStorageBuffer64EXT: + case SpvAddressingModelPhysicalStorageBuffer64: pointer_size_and_alignment_ = 8; break; } @@ -479,7 +495,7 @@ spv_result_t ValidationState_t::RegisterFunctionEnd() { "inside of another function"); assert(in_block() == false && "RegisterFunctionParameter can only be called when parsing the binary " - "ouside of a block"); + "outside of a block"); current_function().RegisterFunctionEnd(); in_function_ = false; return SPV_SUCCESS; @@ -497,15 +513,13 @@ void ValidationState_t::RegisterDebugInstruction(const Instruction* inst) { switch (inst->opcode()) { case SpvOpName: { const auto target = inst->GetOperandAs(0); - const auto* str = reinterpret_cast(inst->words().data() + - inst->operand(1).offset); + const std::string str = inst->GetOperandAs(1); AssignNameToId(target, str); break; } case SpvOpMemberName: { const auto target = inst->GetOperandAs(0); - const auto* str = reinterpret_cast(inst->words().data() + - inst->operand(2).offset); + const std::string str = inst->GetOperandAs(2); AssignNameToId(target, str); break; } @@ -524,7 +538,7 @@ void ValidationState_t::RegisterInstruction(Instruction* inst) { if (inst->id()) all_definitions_.insert(std::make_pair(inst->id(), inst)); // Some validation checks are easier by getting all the consumers - for (uint16_t i = 0; i < inst->operands().size(); ++i) { + for (size_t i = 0; i < inst->operands().size(); ++i) { const spv_parsed_operand_t& operand = inst->operand(i); if ((SPV_OPERAND_TYPE_ID == operand.type) || (SPV_OPERAND_TYPE_TYPE_ID == operand.type)) { @@ -593,7 +607,7 @@ void ValidationState_t::RegisterStorageClassConsumer( if (message) { *message = errorVUID + - "in Vulkan evironment, Output Storage Class must not be " + "in Vulkan environment, Output Storage Class must not be " "used in GLCompute, RayGenerationKHR, IntersectionKHR, " "AnyHitKHR, ClosestHitKHR, MissKHR, or CallableKHR " "execution models"; @@ -615,7 +629,7 @@ void ValidationState_t::RegisterStorageClassConsumer( if (message) { *message = errorVUID + - "in Vulkan evironment, Workgroup Storage Class is limited " + "in Vulkan environment, Workgroup Storage Class is limited " "to MeshNV, TaskNV, and GLCompute execution model"; } return false; @@ -1390,13 +1404,25 @@ std::string ValidationState_t::VkErrorID(uint32_t id, return ""; } - // This large switch case is only searched when an error has occured. + // This large switch case is only searched when an error has occurred. // If an id is changed, the old case must be modified or removed. Each string // here is interpreted as being "implemented" // Clang format adds spaces between hyphens // clang-format off switch (id) { + case 4154: + return VUID_WRAP(VUID-BaryCoordKHR-BaryCoordKHR-04154); + case 4155: + return VUID_WRAP(VUID-BaryCoordKHR-BaryCoordKHR-04155); + case 4156: + return VUID_WRAP(VUID-BaryCoordKHR-BaryCoordKHR-04156); + case 4160: + return VUID_WRAP(VUID-BaryCoordNoPerspKHR-BaryCoordNoPerspKHR-04160); + case 4161: + return VUID_WRAP(VUID-BaryCoordNoPerspKHR-BaryCoordNoPerspKHR-04161); + case 4162: + return VUID_WRAP(VUID-BaryCoordNoPerspKHR-BaryCoordNoPerspKHR-04162); case 4181: return VUID_WRAP(VUID-BaseInstance-BaseInstance-04181); case 4182: @@ -1429,6 +1455,12 @@ std::string ValidationState_t::VkErrorID(uint32_t id, return VUID_WRAP(VUID-CullDistance-CullDistance-04199); case 4200: return VUID_WRAP(VUID-CullDistance-CullDistance-04200); + case 6735: + return VUID_WRAP(VUID-CullMaskKHR-CullMaskKHR-06735); // Execution Model + case 6736: + return VUID_WRAP(VUID-CullMaskKHR-CullMaskKHR-06736); // input storage + case 6737: + return VUID_WRAP(VUID-CullMaskKHR-CullMaskKHR-06737); // 32 int scalar case 4205: return VUID_WRAP(VUID-DeviceIndex-DeviceIndex-04205); case 4206: @@ -1845,6 +1877,8 @@ std::string ValidationState_t::VkErrorID(uint32_t id, return VUID_WRAP(VUID-StandaloneSpirv-FPRoundingMode-04675); case 4677: return VUID_WRAP(VUID-StandaloneSpirv-Invariant-04677); + case 4680: + return VUID_WRAP( VUID-StandaloneSpirv-OpTypeRuntimeArray-04680); case 4682: return VUID_WRAP(VUID-StandaloneSpirv-OpControlBarrier-04682); case 6426: @@ -1853,6 +1887,8 @@ std::string ValidationState_t::VkErrorID(uint32_t id, return VUID_WRAP(VUID-StandaloneSpirv-OpGroupNonUniformBallotBitCount-04685); case 4686: return VUID_WRAP(VUID-StandaloneSpirv-None-04686); + case 4708: + return VUID_WRAP(VUID-StandaloneSpirv-PhysicalStorageBuffer64-04708); case 4710: return VUID_WRAP(VUID-StandaloneSpirv-PhysicalStorageBuffer64-04710); case 4711: @@ -1865,8 +1901,42 @@ std::string ValidationState_t::VkErrorID(uint32_t id, return VUID_WRAP(VUID-StandaloneSpirv-OpMemoryBarrier-04732); case 4733: return VUID_WRAP(VUID-StandaloneSpirv-OpMemoryBarrier-04733); + case 4734: + return VUID_WRAP(VUID-StandaloneSpirv-OpVariable-04734); + case 4777: + return VUID_WRAP(VUID-StandaloneSpirv-OpImage-04777); case 4780: return VUID_WRAP(VUID-StandaloneSpirv-Result-04780); + case 4781: + return VUID_WRAP(VUID-StandaloneSpirv-Base-04781); + case 4915: + return VUID_WRAP(VUID-StandaloneSpirv-Location-04915); + case 4916: + return VUID_WRAP(VUID-StandaloneSpirv-Location-04916); + case 4917: + return VUID_WRAP(VUID-StandaloneSpirv-Location-04917); + case 4918: + return VUID_WRAP(VUID-StandaloneSpirv-Location-04918); + case 4919: + return VUID_WRAP(VUID-StandaloneSpirv-Location-04919); + case 6214: + return VUID_WRAP(VUID-StandaloneSpirv-OpTypeImage-06214); + case 6491: + return VUID_WRAP(VUID-StandaloneSpirv-DescriptorSet-06491); + case 6671: + return VUID_WRAP(VUID-StandaloneSpirv-OpTypeSampledImage-06671); + case 6672: + return VUID_WRAP(VUID-StandaloneSpirv-Location-06672); + case 6674: + return VUID_WRAP(VUID-StandaloneSpirv-OpEntryPoint-06674); + case 6675: + return VUID_WRAP(VUID-StandaloneSpirv-PushConstant-06675); + case 6676: + return VUID_WRAP(VUID-StandaloneSpirv-Uniform-06676); + case 6677: + return VUID_WRAP(VUID-StandaloneSpirv-UniformConstant-06677); + case 6678: + return VUID_WRAP(VUID-StandaloneSpirv-InputAttachmentIndex-06678); default: return ""; // unknown id } diff --git a/third_party/spirv-tools/source/val/validation_state.h b/third_party/spirv-tools/source/val/validation_state.h index 2ddfa4a938..4888840bda 100644 --- a/third_party/spirv-tools/source/val/validation_state.h +++ b/third_party/spirv-tools/source/val/validation_state.h @@ -67,14 +67,12 @@ class ValidationState_t { bool declare_int16_type = false; // Allow OpTypeInt with 16 bit width? bool declare_float16_type = false; // Allow OpTypeFloat with 16 bit width? bool free_fp_rounding_mode = false; // Allow the FPRoundingMode decoration - // and its vaules to be used without + // and its values to be used without // requiring any capability - // Allow functionalities enabled by VariablePointers capability. + // Allow functionalities enabled by VariablePointers or + // VariablePointersStorageBuffer capability. bool variable_pointers = false; - // Allow functionalities enabled by VariablePointersStorageBuffer - // capability. - bool variable_pointers_storage_buffer = false; // Permit group oerations Reduce, InclusiveScan, ExclusiveScan bool group_ops_reduce_and_scans = false; @@ -797,7 +795,7 @@ class ValidationState_t { /// IDs that are entry points, ie, arguments to OpEntryPoint. std::vector entry_points_; - /// Maps an entry point id to its desciptions. + /// Maps an entry point id to its descriptions. std::unordered_map> entry_point_descriptions_; @@ -844,7 +842,7 @@ class ValidationState_t { // have the same pointer size (for physical pointer types). uint32_t pointer_size_and_alignment_; - /// NOTE: See correspoding getter functions + /// NOTE: See corresponding getter functions bool in_function_; /// The state of optional features. These are determined by capabilities diff --git a/third_party/spirv-tools/source/wasm/spirv-tools.cpp b/third_party/spirv-tools/source/wasm/spirv-tools.cpp index 90407f328a..33f2f05fb0 100644 --- a/third_party/spirv-tools/source/wasm/spirv-tools.cpp +++ b/third_party/spirv-tools/source/wasm/spirv-tools.cpp @@ -78,7 +78,8 @@ EMSCRIPTEN_BINDINGS(my_module) { constant("SPV_ENV_VULKAN_1_1_SPIRV_1_4", static_cast(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); constant("SPV_ENV_UNIVERSAL_1_5", static_cast(SPV_ENV_UNIVERSAL_1_5)); constant("SPV_ENV_VULKAN_1_2", static_cast(SPV_ENV_VULKAN_1_2)); - + constant("SPV_ENV_UNIVERSAL_1_6", + static_cast(SPV_ENV_UNIVERSAL_1_6)); constant("SPV_BINARY_TO_TEXT_OPTION_NONE", static_cast(SPV_BINARY_TO_TEXT_OPTION_NONE)); constant("SPV_BINARY_TO_TEXT_OPTION_PRINT", static_cast(SPV_BINARY_TO_TEXT_OPTION_PRINT)); @@ -90,4 +91,4 @@ EMSCRIPTEN_BINDINGS(my_module) { constant("SPV_TEXT_TO_BINARY_OPTION_NONE", static_cast(SPV_TEXT_TO_BINARY_OPTION_NONE)); constant("SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS", static_cast(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS)); -} \ No newline at end of file +} diff --git a/third_party/spirv-tools/source/wasm/spirv-tools.d.ts b/third_party/spirv-tools/source/wasm/spirv-tools.d.ts index 9c197973d5..c06bdf1855 100644 --- a/third_party/spirv-tools/source/wasm/spirv-tools.d.ts +++ b/third_party/spirv-tools/source/wasm/spirv-tools.d.ts @@ -40,6 +40,7 @@ declare interface SpirvTools { SPV_ENV_VULKAN_1_1_SPIRV_1_4: number; SPV_ENV_UNIVERSAL_1_5: number; SPV_ENV_VULKAN_1_2: number; + SPV_ENV_UNIVERSAL_1_6: number; SPV_TEXT_TO_BINARY_OPTION_NONE: number; SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS: number; diff --git a/third_party/spirv-tools/test/CMakeLists.txt b/third_party/spirv-tools/test/CMakeLists.txt index e88df04d79..4ca8ef8fb9 100644 --- a/third_party/spirv-tools/test/CMakeLists.txt +++ b/third_party/spirv-tools/test/CMakeLists.txt @@ -185,6 +185,7 @@ add_spvtools_unittest( endif() +add_subdirectory(diff) add_subdirectory(link) add_subdirectory(lint) add_subdirectory(opt) diff --git a/third_party/spirv-tools/test/binary_header_get_test.cpp b/third_party/spirv-tools/test/binary_header_get_test.cpp index 3ce0b63a94..f94f0c1a64 100644 --- a/third_party/spirv-tools/test/binary_header_get_test.cpp +++ b/third_party/spirv-tools/test/binary_header_get_test.cpp @@ -51,8 +51,8 @@ TEST_F(BinaryHeaderGet, Default) { ASSERT_EQ(SPV_SUCCESS, spvBinaryHeaderGet(&const_bin, endian, &header)); ASSERT_EQ(static_cast(SpvMagicNumber), header.magic); - // Expect SPIRV-Headers updated to SPIR-V 1.5. - ASSERT_EQ(0x00010500u, header.version); + // Expect SPIRV-Headers updated to SPIR-V 1.6. + ASSERT_EQ(0x00010600u, header.version); ASSERT_EQ(static_cast(SPV_GENERATOR_CODEPLAY), header.generator); ASSERT_EQ(1u, header.bound); ASSERT_EQ(0u, header.schema); diff --git a/third_party/spirv-tools/test/binary_parse_test.cpp b/third_party/spirv-tools/test/binary_parse_test.cpp index 9a13f22ca5..f0810a3587 100644 --- a/third_party/spirv-tools/test/binary_parse_test.cpp +++ b/third_party/spirv-tools/test/binary_parse_test.cpp @@ -203,16 +203,7 @@ class BinaryParseTest : public spvtest::TextToBinaryTestBase<::testing::Test> { void Parse(const SpirvVector& words, spv_result_t expected_result, bool flip_words = false) { SpirvVector flipped_words(words); - SCOPED_TRACE(flip_words ? "Flipped Endianness" : "Normal Endianness"); - if (flip_words) { - std::transform(flipped_words.begin(), flipped_words.end(), - flipped_words.begin(), [](const uint32_t raw_word) { - return spvFixWord(raw_word, - I32_ENDIAN_HOST == I32_ENDIAN_BIG - ? SPV_ENDIANNESS_LITTLE - : SPV_ENDIANNESS_BIG); - }); - } + MaybeFlipWords(flip_words, flipped_words.begin(), flipped_words.end()); EXPECT_EQ(expected_result, spvBinaryParse(ScopedContext().context, &client_, flipped_words.data(), flipped_words.size(), @@ -486,27 +477,27 @@ TEST_F(BinaryParseTest, EarlyReturnWithTwoPassingCallbacks) { } TEST_F(BinaryParseTest, InstructionWithStringOperand) { - const std::string str = - "the future is already here, it's just not evenly distributed"; - const auto str_words = MakeVector(str); - const auto instruction = MakeInstruction(SpvOpName, {99}, str_words); - const auto words = Concatenate({ExpectedHeaderForBound(100), instruction}); - InSequence calls_expected_in_specific_order; - EXPECT_HEADER(100).WillOnce(Return(SPV_SUCCESS)); - const auto operands = std::vector{ - MakeSimpleOperand(1, SPV_OPERAND_TYPE_ID), - MakeLiteralStringOperand(2, static_cast(str_words.size()))}; - EXPECT_CALL(client_, - Instruction(ParsedInstruction(spv_parsed_instruction_t{ - instruction.data(), static_cast(instruction.size()), - SpvOpName, SPV_EXT_INST_TYPE_NONE, 0 /*type id*/, - 0 /* No result id for OpName*/, operands.data(), - static_cast(operands.size())}))) - .WillOnce(Return(SPV_SUCCESS)); - // Since we are actually checking the output, don't test the - // endian-swapped version. - Parse(words, SPV_SUCCESS, false); - EXPECT_EQ(nullptr, diagnostic_); + for (bool endian_swap : kSwapEndians) { + const std::string str = + "the future is already here, it's just not evenly distributed"; + const auto str_words = MakeVector(str); + const auto instruction = MakeInstruction(SpvOpName, {99}, str_words); + const auto words = Concatenate({ExpectedHeaderForBound(100), instruction}); + InSequence calls_expected_in_specific_order; + EXPECT_HEADER(100).WillOnce(Return(SPV_SUCCESS)); + const auto operands = std::vector{ + MakeSimpleOperand(1, SPV_OPERAND_TYPE_ID), + MakeLiteralStringOperand(2, static_cast(str_words.size()))}; + EXPECT_CALL(client_, Instruction(ParsedInstruction(spv_parsed_instruction_t{ + instruction.data(), + static_cast(instruction.size()), + SpvOpName, SPV_EXT_INST_TYPE_NONE, 0 /*type id*/, + 0 /* No result id for OpName*/, operands.data(), + static_cast(operands.size())}))) + .WillOnce(Return(SPV_SUCCESS)); + Parse(words, SPV_SUCCESS, endian_swap); + EXPECT_EQ(nullptr, diagnostic_); + } } // Checks for non-zero values for the result_id and ext_inst_type members @@ -613,7 +604,7 @@ INSTANTIATE_TEST_SUITE_P( MakeInstruction(SpvOpNop, {42})}), "Invalid instruction OpNop starting at word 5: expected " "no more operands after 1 words, but stated word count is 2."}, - // Supply several more unexpectd words. + // Supply several more unexpected words. {Concatenate({ExpectedHeaderForBound(1), MakeInstruction(SpvOpNop, {42, 43, 44, 45, 46, 47})}), "Invalid instruction OpNop starting at word 5: expected " diff --git a/third_party/spirv-tools/test/binary_to_text.literal_test.cpp b/third_party/spirv-tools/test/binary_to_text.literal_test.cpp index 02daac761b..5956984b13 100644 --- a/third_party/spirv-tools/test/binary_to_text.literal_test.cpp +++ b/third_party/spirv-tools/test/binary_to_text.literal_test.cpp @@ -27,8 +27,15 @@ using ::testing::Eq; using RoundTripLiteralsTest = spvtest::TextToBinaryTestBase<::testing::TestWithParam>; +static const bool kSwapEndians[] = {false, true}; + TEST_P(RoundTripLiteralsTest, Sample) { - EXPECT_THAT(EncodeAndDecodeSuccessfully(GetParam()), Eq(GetParam())); + for (bool endian_swap : kSwapEndians) { + EXPECT_THAT( + EncodeAndDecodeSuccessfully(GetParam(), SPV_BINARY_TO_TEXT_OPTION_NONE, + SPV_ENV_UNIVERSAL_1_0, endian_swap), + Eq(GetParam())); + } } // clang-format off @@ -58,8 +65,12 @@ using RoundTripSpecialCaseLiteralsTest = spvtest::TextToBinaryTestBase< // Test case where the generated disassembly is not the same as the // assembly passed in. TEST_P(RoundTripSpecialCaseLiteralsTest, Sample) { - EXPECT_THAT(EncodeAndDecodeSuccessfully(std::get<0>(GetParam())), - Eq(std::get<1>(GetParam()))); + for (bool endian_swap : kSwapEndians) { + EXPECT_THAT(EncodeAndDecodeSuccessfully(std::get<0>(GetParam()), + SPV_BINARY_TO_TEXT_OPTION_NONE, + SPV_ENV_UNIVERSAL_1_0, endian_swap), + Eq(std::get<1>(GetParam()))); + } } // clang-format off diff --git a/third_party/spirv-tools/test/c_interface_test.cpp b/third_party/spirv-tools/test/c_interface_test.cpp index 841bb2c6b1..4424d7f5f7 100644 --- a/third_party/spirv-tools/test/c_interface_test.cpp +++ b/third_party/spirv-tools/test/c_interface_test.cpp @@ -117,12 +117,15 @@ TEST(CInterface, SpecifyConsumerNullDiagnosticForAssembling) { const spv_position_t& position, const char* message) { ++invocation; EXPECT_EQ(SPV_MSG_ERROR, level); - // The error happens at scanning the begining of second line. + // The error happens at scanning the beginning of second line. EXPECT_STREQ("input", source); EXPECT_EQ(1u, position.line); EXPECT_EQ(0u, position.column); EXPECT_EQ(12u, position.index); - EXPECT_STREQ("Expected operand, found end of stream.", message); + EXPECT_STREQ( + "Expected operand for OpName instruction, but found the end of the " + "stream.", + message); }); spv_binary binary = nullptr; @@ -228,7 +231,10 @@ TEST(CInterface, SpecifyConsumerSpecifyDiagnosticForAssembling) { spvTextToBinary(context, input_text, sizeof(input_text), &binary, &diagnostic)); EXPECT_EQ(0, invocation); // Consumer should not be invoked at all. - EXPECT_STREQ("Expected operand, found end of stream.", diagnostic->error); + EXPECT_STREQ( + "Expected operand for OpName instruction, but found the end of the " + "stream.", + diagnostic->error); spvDiagnosticDestroy(diagnostic); spvBinaryDestroy(binary); diff --git a/third_party/spirv-tools/test/diff/CMakeLists.txt b/third_party/spirv-tools/test/diff/CMakeLists.txt new file mode 100644 index 0000000000..811805bd31 --- /dev/null +++ b/third_party/spirv-tools/test/diff/CMakeLists.txt @@ -0,0 +1,26 @@ +# Copyright (c) 2022 Google LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include(diff_files/diff_test_files_autogen.cmake) + +add_spvtools_unittest(TARGET lcs + SRCS lcs_test.cpp + LIBS SPIRV-Tools-diff +) + +add_spvtools_unittest(TARGET diff + SRCS diff_test.cpp diff_test_utils.h diff_test_utils.cpp + ${DIFF_TEST_FILES} ${spirv-tools_SOURCE_DIR}/tools/util/cli_consumer.cpp + LIBS SPIRV-Tools-diff +) diff --git a/third_party/spirv-tools/test/diff/diff_files/.gitignore b/third_party/spirv-tools/test/diff/diff_files/.gitignore new file mode 100644 index 0000000000..727526ef04 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/.gitignore @@ -0,0 +1,3 @@ +# To aid debugging no-dbg variants, the temporary files used to strip debug information are placed +# in a hidden directory and aren't removed after generation. +.no_dbg/ diff --git a/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_dst_only_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_dst_only_autogen.cpp new file mode 100644 index 0000000000..ce899eddc7 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_dst_only_autogen.cpp @@ -0,0 +1,242 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Tests a diff where the src shader doesn't have OpExtImport while the +// dst shader does (and uses OpExtInst). This test ensures that when matching, +// the OpExtImport instruction from the correct module is referenced. +constexpr char kSrc[] = R"( OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %9 "color" + OpName %11 "v" + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 + %13 = OpCompositeConstruct %7 %12 %12 %12 %12 + OpStore %9 %13 + OpReturn + OpFunctionEnd +)"; +constexpr char kDst[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %9 "color" + OpName %11 "v" + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + OpDecorate %14 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 + %13 = OpExtInst %6 %1 Log2 %12 + %14 = OpCompositeConstruct %7 %13 %13 %13 %13 + OpStore %9 %14 + OpReturn + OpFunctionEnd + +)"; + +TEST(DiffTest, OpextinstInDstOnly) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 14 ++; Bound: 16 + ; Schema: 0 + OpCapability Shader ++%14 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %9 "color" + OpName %11 "v" + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision ++OpDecorate %15 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 ++%15 = OpExtInst %6 %14 Log2 %12 +-%13 = OpCompositeConstruct %7 %12 %12 %12 %12 ++%13 = OpCompositeConstruct %7 %15 %15 %15 %15 + OpStore %9 %13 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, OpextinstInDstOnlyNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 + %13 = OpCompositeConstruct %7 %12 %12 %12 %12 + OpStore %9 %13 + OpReturn + OpFunctionEnd + +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + OpDecorate %14 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 + %13 = OpExtInst %6 %1 Log2 %12 + %14 = OpCompositeConstruct %7 %13 %13 %13 %13 + OpStore %9 %14 + OpReturn + OpFunctionEnd + +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 14 ++; Bound: 16 + ; Schema: 0 + OpCapability Shader ++%14 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision ++OpDecorate %15 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 ++%15 = OpExtInst %6 %14 Log2 %12 +-%13 = OpCompositeConstruct %7 %12 %12 %12 %12 ++%13 = OpCompositeConstruct %7 %15 %15 %15 %15 + OpStore %9 %13 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_dst_only_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_dst_only_dst.spvasm new file mode 100644 index 0000000000..e599d1e99b --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_dst_only_dst.spvasm @@ -0,0 +1,33 @@ + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %9 "color" + OpName %11 "v" + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + OpDecorate %14 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 + %13 = OpExtInst %6 %1 Log2 %12 + %14 = OpCompositeConstruct %7 %13 %13 %13 %13 + OpStore %9 %14 + OpReturn + OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_dst_only_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_dst_only_src.spvasm new file mode 100644 index 0000000000..9f6fc18c3d --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_dst_only_src.spvasm @@ -0,0 +1,33 @@ +;; Tests a diff where the src shader doesn't have OpExtImport while the +;; dst shader does (and uses OpExtInst). This test ensures that when matching, +;; the OpExtImport instruction from the correct module is referenced. + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %9 "color" + OpName %11 "v" + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 + %13 = OpCompositeConstruct %7 %12 %12 %12 %12 + OpStore %9 %13 + OpReturn + OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_src_only_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_src_only_autogen.cpp new file mode 100644 index 0000000000..9944c2cf1f --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_src_only_autogen.cpp @@ -0,0 +1,242 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Tests a diff where the dst shader doesn't have OpExtImport while the +// src shader does (and uses OpExtInst). This test ensures that when matching, +// the OpExtImport instruction from the correct module is referenced. +constexpr char kSrc[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %9 "color" + OpName %11 "v" + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + OpDecorate %14 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 + %13 = OpExtInst %6 %1 Log2 %12 + %14 = OpCompositeConstruct %7 %13 %13 %13 %13 + OpStore %9 %14 + OpReturn + OpFunctionEnd +)"; +constexpr char kDst[] = R"( OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %9 "color" + OpName %11 "v" + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 + %13 = OpCompositeConstruct %7 %12 %12 %12 %12 + OpStore %9 %13 + OpReturn + OpFunctionEnd + +)"; + +TEST(DiffTest, OpextinstInSrcOnly) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 15 ++; Bound: 16 + ; Schema: 0 + OpCapability Shader +-%1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %9 "color" + OpName %11 "v" + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision +-OpDecorate %13 RelaxedPrecision + OpDecorate %14 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 +-%13 = OpExtInst %6 %1 Log2 %12 +-%14 = OpCompositeConstruct %7 %13 %13 %13 %13 ++%14 = OpCompositeConstruct %7 %12 %12 %12 %12 + OpStore %9 %14 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, OpextinstInSrcOnlyNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + OpDecorate %14 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 + %13 = OpExtInst %6 %1 Log2 %12 + %14 = OpCompositeConstruct %7 %13 %13 %13 %13 + OpStore %9 %14 + OpReturn + OpFunctionEnd + +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 + %13 = OpCompositeConstruct %7 %12 %12 %12 %12 + OpStore %9 %13 + OpReturn + OpFunctionEnd + +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 15 ++; Bound: 16 + ; Schema: 0 + OpCapability Shader +-%1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision +-OpDecorate %13 RelaxedPrecision + OpDecorate %14 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 +-%13 = OpExtInst %6 %1 Log2 %12 +-%14 = OpCompositeConstruct %7 %13 %13 %13 %13 ++%14 = OpCompositeConstruct %7 %12 %12 %12 %12 + OpStore %9 %14 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_src_only_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_src_only_dst.spvasm new file mode 100644 index 0000000000..4723305176 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_src_only_dst.spvasm @@ -0,0 +1,30 @@ + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %9 "color" + OpName %11 "v" + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 + %13 = OpCompositeConstruct %7 %12 %12 %12 %12 + OpStore %9 %13 + OpReturn + OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_src_only_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_src_only_src.spvasm new file mode 100644 index 0000000000..efb663a999 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_src_only_src.spvasm @@ -0,0 +1,36 @@ +;; Tests a diff where the dst shader doesn't have OpExtImport while the +;; src shader does (and uses OpExtInst). This test ensures that when matching, +;; the OpExtImport instruction from the correct module is referenced. + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %9 "color" + OpName %11 "v" + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + OpDecorate %14 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 + %13 = OpExtInst %6 %1 Log2 %12 + %14 = OpCompositeConstruct %7 %13 %13 %13 %13 + OpStore %9 %14 + OpReturn + OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_basic_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_basic_autogen.cpp new file mode 100644 index 0000000000..af252b11f2 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_basic_autogen.cpp @@ -0,0 +1,136 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Basic test that OpTypeForwardPointer is matched +constexpr char kSrc[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %structptr "structptr" + OpTypeForwardPointer %structptr UniformConstant + %uint = OpTypeInt 32 0 + %structt1 = OpTypeStruct %structptr %uint + %structt2 = OpTypeStruct %uint %structptr + %structt3 = OpTypeStruct %uint %uint %structptr + %structt4 = OpTypeStruct %uint %uint %uint %structptr + %structptr = OpTypePointer UniformConstant %structt1)"; +constexpr char kDst[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %structptr "structptr" + OpName %structptr2 "structptr2" + OpTypeForwardPointer %structptr UniformConstant + OpTypeForwardPointer %structptr2 Function + %uint = OpTypeInt 32 0 + %structt1 = OpTypeStruct %structptr %uint + %structt2 = OpTypeStruct %uint %structptr + %structt3 = OpTypeStruct %uint %uint %structptr + %structt4 = OpTypeStruct %uint %uint %uint %structptr + %structptr = OpTypePointer UniformConstant %structt1 + %structptr2 = OpTypePointer Function %structt1 +)"; + +TEST(DiffTest, OptypeforwardpointerBasic) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 7 ++; Bound: 8 + ; Schema: 0 + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %1 "structptr" ++OpName %7 "structptr2" + OpTypeForwardPointer %1 UniformConstant ++OpTypeForwardPointer %7 Function + %2 = OpTypeInt 32 0 + %3 = OpTypeStruct %1 %2 + %4 = OpTypeStruct %2 %1 + %5 = OpTypeStruct %2 %2 %1 + %6 = OpTypeStruct %2 %2 %2 %1 + %1 = OpTypePointer UniformConstant %3 ++%7 = OpTypePointer Function %3 +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, OptypeforwardpointerBasicNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpTypeForwardPointer %structptr UniformConstant + %uint = OpTypeInt 32 0 + %structt1 = OpTypeStruct %structptr %uint + %structt2 = OpTypeStruct %uint %structptr + %structt3 = OpTypeStruct %uint %uint %structptr + %structt4 = OpTypeStruct %uint %uint %uint %structptr + %structptr = OpTypePointer UniformConstant %structt1 +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpTypeForwardPointer %structptr UniformConstant + OpTypeForwardPointer %structptr2 Function + %uint = OpTypeInt 32 0 + %structt1 = OpTypeStruct %structptr %uint + %structt2 = OpTypeStruct %uint %structptr + %structt3 = OpTypeStruct %uint %uint %structptr + %structt4 = OpTypeStruct %uint %uint %uint %structptr + %structptr = OpTypePointer UniformConstant %structt1 + %structptr2 = OpTypePointer Function %structt1 +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 7 ++; Bound: 8 + ; Schema: 0 + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpTypeForwardPointer %1 UniformConstant ++OpTypeForwardPointer %7 Function + %2 = OpTypeInt 32 0 + %3 = OpTypeStruct %1 %2 + %4 = OpTypeStruct %2 %1 + %5 = OpTypeStruct %2 %2 %1 + %6 = OpTypeStruct %2 %2 %2 %1 + %1 = OpTypePointer UniformConstant %3 ++%7 = OpTypePointer Function %3 +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_basic_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_basic_dst.spvasm new file mode 100644 index 0000000000..0c6e0cbefa --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_basic_dst.spvasm @@ -0,0 +1,15 @@ + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %structptr "structptr" + OpName %structptr2 "structptr2" + OpTypeForwardPointer %structptr UniformConstant + OpTypeForwardPointer %structptr2 Function + %uint = OpTypeInt 32 0 + %structt1 = OpTypeStruct %structptr %uint + %structt2 = OpTypeStruct %uint %structptr + %structt3 = OpTypeStruct %uint %uint %structptr + %structt4 = OpTypeStruct %uint %uint %uint %structptr + %structptr = OpTypePointer UniformConstant %structt1 + %structptr2 = OpTypePointer Function %structt1 diff --git a/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_basic_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_basic_src.spvasm new file mode 100644 index 0000000000..408ec98305 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_basic_src.spvasm @@ -0,0 +1,13 @@ +;; Basic test that OpTypeForwardPointer is matched + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %structptr "structptr" + OpTypeForwardPointer %structptr UniformConstant + %uint = OpTypeInt 32 0 + %structt1 = OpTypeStruct %structptr %uint + %structt2 = OpTypeStruct %uint %structptr + %structt3 = OpTypeStruct %uint %uint %structptr + %structt4 = OpTypeStruct %uint %uint %uint %structptr + %structptr = OpTypePointer UniformConstant %structt1 diff --git a/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_intertwined_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_intertwined_autogen.cpp new file mode 100644 index 0000000000..f2c9008eb8 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_intertwined_autogen.cpp @@ -0,0 +1,138 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Tests that two forwarded types whose declarations are intertwined match +// correctly +constexpr char kSrc[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %Aptr "Aptr" + OpName %Bptr "Bptr" + OpTypeForwardPointer %Aptr UniformConstant + OpTypeForwardPointer %Bptr UniformConstant + %uint = OpTypeInt 32 0 + %A = OpTypeStruct %Aptr %uint %Bptr + %B = OpTypeStruct %uint %Aptr %Bptr + %Aptr = OpTypePointer UniformConstant %A + %Bptr = OpTypePointer UniformConstant %B)"; +constexpr char kDst[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %Aptr "Aptr" + OpName %Bptr "Bptr" + OpTypeForwardPointer %Bptr UniformConstant + OpTypeForwardPointer %Aptr UniformConstant + %uint = OpTypeInt 32 0 + %B = OpTypeStruct %uint %Aptr %Bptr %uint + %A = OpTypeStruct %Aptr %uint %Bptr + %Aptr = OpTypePointer UniformConstant %A + %Bptr = OpTypePointer UniformConstant %B +)"; + +TEST(DiffTest, OptypeforwardpointerIntertwined) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 6 ++; Bound: 7 + ; Schema: 0 + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %1 "Aptr" + OpName %2 "Bptr" + OpTypeForwardPointer %1 UniformConstant + OpTypeForwardPointer %2 UniformConstant + %3 = OpTypeInt 32 0 ++%6 = OpTypeStruct %3 %1 %2 %3 + %4 = OpTypeStruct %1 %3 %2 +-%5 = OpTypeStruct %3 %1 %2 + %1 = OpTypePointer UniformConstant %4 +-%2 = OpTypePointer UniformConstant %5 ++%2 = OpTypePointer UniformConstant %6 +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, OptypeforwardpointerIntertwinedNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpTypeForwardPointer %Aptr UniformConstant + OpTypeForwardPointer %Bptr UniformConstant + %uint = OpTypeInt 32 0 + %A = OpTypeStruct %Aptr %uint %Bptr + %B = OpTypeStruct %uint %Aptr %Bptr + %Aptr = OpTypePointer UniformConstant %A + %Bptr = OpTypePointer UniformConstant %B +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpTypeForwardPointer %Bptr UniformConstant + OpTypeForwardPointer %Aptr UniformConstant + %uint = OpTypeInt 32 0 + %B = OpTypeStruct %uint %Aptr %Bptr %uint + %A = OpTypeStruct %Aptr %uint %Bptr + %Aptr = OpTypePointer UniformConstant %A + %Bptr = OpTypePointer UniformConstant %B +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 6 ++; Bound: 10 + ; Schema: 0 + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL +-OpTypeForwardPointer %1 UniformConstant +-OpTypeForwardPointer %2 UniformConstant ++OpTypeForwardPointer %6 UniformConstant ++OpTypeForwardPointer %7 UniformConstant + %3 = OpTypeInt 32 0 +-%4 = OpTypeStruct %1 %3 %2 +-%5 = OpTypeStruct %3 %1 %2 +-%1 = OpTypePointer UniformConstant %4 +-%2 = OpTypePointer UniformConstant %5 ++%8 = OpTypeStruct %3 %7 %6 %3 ++%9 = OpTypeStruct %7 %3 %6 ++%7 = OpTypePointer UniformConstant %9 ++%6 = OpTypePointer UniformConstant %8 +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_intertwined_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_intertwined_dst.spvasm new file mode 100644 index 0000000000..bd73501006 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_intertwined_dst.spvasm @@ -0,0 +1,13 @@ + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %Aptr "Aptr" + OpName %Bptr "Bptr" + OpTypeForwardPointer %Bptr UniformConstant + OpTypeForwardPointer %Aptr UniformConstant + %uint = OpTypeInt 32 0 + %B = OpTypeStruct %uint %Aptr %Bptr %uint + %A = OpTypeStruct %Aptr %uint %Bptr + %Aptr = OpTypePointer UniformConstant %A + %Bptr = OpTypePointer UniformConstant %B diff --git a/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_intertwined_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_intertwined_src.spvasm new file mode 100644 index 0000000000..8fdaf28f2d --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_intertwined_src.spvasm @@ -0,0 +1,15 @@ +;; Tests that two forwarded types whose declarations are intertwined match +;; correctly + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %Aptr "Aptr" + OpName %Bptr "Bptr" + OpTypeForwardPointer %Aptr UniformConstant + OpTypeForwardPointer %Bptr UniformConstant + %uint = OpTypeInt 32 0 + %A = OpTypeStruct %Aptr %uint %Bptr + %B = OpTypeStruct %uint %Aptr %Bptr + %Aptr = OpTypePointer UniformConstant %A + %Bptr = OpTypePointer UniformConstant %B diff --git a/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_mismatching_class_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_mismatching_class_autogen.cpp new file mode 100644 index 0000000000..0a59be32d4 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_mismatching_class_autogen.cpp @@ -0,0 +1,116 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Tests that two forwarded type pointers with mismatching storage classes +// aren't matched +constexpr char kSrc[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %Aptr "Aptr" + OpTypeForwardPointer %Aptr UniformConstant + %uint = OpTypeInt 32 0 + %A = OpTypeStruct %Aptr %uint + %Aptr = OpTypePointer UniformConstant %A)"; +constexpr char kDst[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %Aptr "Aptr" + OpTypeForwardPointer %Aptr Function + %uint = OpTypeInt 32 0 + %A = OpTypeStruct %Aptr %uint + %Aptr = OpTypePointer Function %A +)"; + +TEST(DiffTest, OptypeforwardpointerMismatchingClass) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 4 ++; Bound: 6 + ; Schema: 0 + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL +-OpName %1 "Aptr" ++OpName %4 "Aptr" +-OpTypeForwardPointer %1 UniformConstant ++OpTypeForwardPointer %4 Function + %2 = OpTypeInt 32 0 +-%3 = OpTypeStruct %1 %2 +-%1 = OpTypePointer UniformConstant %3 ++%5 = OpTypeStruct %4 %2 ++%4 = OpTypePointer Function %5 +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, OptypeforwardpointerMismatchingClassNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpTypeForwardPointer %Aptr UniformConstant + %uint = OpTypeInt 32 0 + %A = OpTypeStruct %Aptr %uint + %Aptr = OpTypePointer UniformConstant %A +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpTypeForwardPointer %Aptr Function + %uint = OpTypeInt 32 0 + %A = OpTypeStruct %Aptr %uint + %Aptr = OpTypePointer Function %A +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 4 ++; Bound: 6 + ; Schema: 0 + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL +-OpTypeForwardPointer %1 UniformConstant ++OpTypeForwardPointer %4 Function + %2 = OpTypeInt 32 0 +-%3 = OpTypeStruct %1 %2 +-%1 = OpTypePointer UniformConstant %3 ++%5 = OpTypeStruct %4 %2 ++%4 = OpTypePointer Function %5 +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_mismatching_class_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_mismatching_class_dst.spvasm new file mode 100644 index 0000000000..e874a0cad7 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_mismatching_class_dst.spvasm @@ -0,0 +1,9 @@ + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %Aptr "Aptr" + OpTypeForwardPointer %Aptr Function + %uint = OpTypeInt 32 0 + %A = OpTypeStruct %Aptr %uint + %Aptr = OpTypePointer Function %A diff --git a/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_mismatching_class_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_mismatching_class_src.spvasm new file mode 100644 index 0000000000..8a33933195 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_mismatching_class_src.spvasm @@ -0,0 +1,11 @@ +;; Tests that two forwarded type pointers with mismatching storage classes +;; aren't matched + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %Aptr "Aptr" + OpTypeForwardPointer %Aptr UniformConstant + %uint = OpTypeInt 32 0 + %A = OpTypeStruct %Aptr %uint + %Aptr = OpTypePointer UniformConstant %A diff --git a/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_mismatching_type_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_mismatching_type_autogen.cpp new file mode 100644 index 0000000000..0067cdf608 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_mismatching_type_autogen.cpp @@ -0,0 +1,111 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Tests that two forwarded type pointers with mismatching types aren't matched +constexpr char kSrc[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %Aptr "Aptr" + OpTypeForwardPointer %Aptr UniformConstant + %uint = OpTypeInt 32 0 + %A = OpTypeStruct %Aptr %uint + %Aptr = OpTypePointer UniformConstant %A)"; +constexpr char kDst[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %Aptr "Aptr" + OpTypeForwardPointer %Aptr UniformConstant + %uint = OpTypeInt 32 0 + %Aptr = OpTypePointer UniformConstant %uint +)"; + +TEST(DiffTest, OptypeforwardpointerMismatchingType) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 4 ++; Bound: 5 + ; Schema: 0 + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL +-OpName %1 "Aptr" ++OpName %4 "Aptr" +-OpTypeForwardPointer %1 UniformConstant ++OpTypeForwardPointer %4 UniformConstant + %2 = OpTypeInt 32 0 +-%3 = OpTypeStruct %1 %2 +-%1 = OpTypePointer UniformConstant %3 ++%4 = OpTypePointer UniformConstant %2 +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, OptypeforwardpointerMismatchingTypeNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpTypeForwardPointer %Aptr UniformConstant + %uint = OpTypeInt 32 0 + %A = OpTypeStruct %Aptr %uint + %Aptr = OpTypePointer UniformConstant %A +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpTypeForwardPointer %Aptr UniformConstant + %uint = OpTypeInt 32 0 + %Aptr = OpTypePointer UniformConstant %uint +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 4 ++; Bound: 5 + ; Schema: 0 + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL +-OpTypeForwardPointer %1 UniformConstant ++OpTypeForwardPointer %4 UniformConstant + %2 = OpTypeInt 32 0 +-%3 = OpTypeStruct %1 %2 +-%1 = OpTypePointer UniformConstant %3 ++%4 = OpTypePointer UniformConstant %2 +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_mismatching_type_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_mismatching_type_dst.spvasm new file mode 100644 index 0000000000..ee3d35c0fb --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_mismatching_type_dst.spvasm @@ -0,0 +1,8 @@ + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %Aptr "Aptr" + OpTypeForwardPointer %Aptr UniformConstant + %uint = OpTypeInt 32 0 + %Aptr = OpTypePointer UniformConstant %uint diff --git a/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_mismatching_type_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_mismatching_type_src.spvasm new file mode 100644 index 0000000000..a4596a0772 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_mismatching_type_src.spvasm @@ -0,0 +1,10 @@ +;; Tests that two forwarded type pointers with mismatching types aren't matched + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %Aptr "Aptr" + OpTypeForwardPointer %Aptr UniformConstant + %uint = OpTypeInt 32 0 + %A = OpTypeStruct %Aptr %uint + %Aptr = OpTypePointer UniformConstant %A diff --git a/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_nested_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_nested_autogen.cpp new file mode 100644 index 0000000000..d66c28ae2b --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_nested_autogen.cpp @@ -0,0 +1,127 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Tests that two forwarded declarations match even if the type pointer is used +// in a nested struct declaration, and in multiple places +constexpr char kSrc[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %Aptr "Aptr" + OpTypeForwardPointer %Aptr UniformConstant + %uint = OpTypeInt 32 0 + %C = OpTypeStruct %Aptr %uint %Aptr + %B = OpTypeStruct %C %Aptr %uint + %A = OpTypeStruct %B %C %B + %Aptr = OpTypePointer UniformConstant %A)"; +constexpr char kDst[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %Aptr "Aptr" + OpTypeForwardPointer %Aptr UniformConstant + %uint = OpTypeInt 32 0 + %C = OpTypeStruct %Aptr %uint %Aptr + %B = OpTypeStruct %C %Aptr + %A = OpTypeStruct %B %C %B + %Aptr = OpTypePointer UniformConstant %A +)"; + +TEST(DiffTest, OptypeforwardpointerNested) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 6 ++; Bound: 8 + ; Schema: 0 + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %1 "Aptr" + OpTypeForwardPointer %1 UniformConstant + %2 = OpTypeInt 32 0 + %3 = OpTypeStruct %1 %2 %1 +-%4 = OpTypeStruct %3 %1 %2 +-%5 = OpTypeStruct %4 %3 %4 ++%6 = OpTypeStruct %3 %1 ++%7 = OpTypeStruct %6 %3 %6 +-%1 = OpTypePointer UniformConstant %5 ++%1 = OpTypePointer UniformConstant %7 +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, OptypeforwardpointerNestedNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpTypeForwardPointer %Aptr UniformConstant + %uint = OpTypeInt 32 0 + %C = OpTypeStruct %Aptr %uint %Aptr + %B = OpTypeStruct %C %Aptr %uint + %A = OpTypeStruct %B %C %B + %Aptr = OpTypePointer UniformConstant %A +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpTypeForwardPointer %Aptr UniformConstant + %uint = OpTypeInt 32 0 + %C = OpTypeStruct %Aptr %uint %Aptr + %B = OpTypeStruct %C %Aptr + %A = OpTypeStruct %B %C %B + %Aptr = OpTypePointer UniformConstant %A +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 6 ++; Bound: 8 + ; Schema: 0 + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpTypeForwardPointer %1 UniformConstant + %2 = OpTypeInt 32 0 + %3 = OpTypeStruct %1 %2 %1 +-%4 = OpTypeStruct %3 %1 %2 +-%5 = OpTypeStruct %4 %3 %4 ++%6 = OpTypeStruct %3 %1 ++%7 = OpTypeStruct %6 %3 %6 +-%1 = OpTypePointer UniformConstant %5 ++%1 = OpTypePointer UniformConstant %7 +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_nested_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_nested_dst.spvasm new file mode 100644 index 0000000000..e248355682 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_nested_dst.spvasm @@ -0,0 +1,11 @@ + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %Aptr "Aptr" + OpTypeForwardPointer %Aptr UniformConstant + %uint = OpTypeInt 32 0 + %C = OpTypeStruct %Aptr %uint %Aptr + %B = OpTypeStruct %C %Aptr + %A = OpTypeStruct %B %C %B + %Aptr = OpTypePointer UniformConstant %A diff --git a/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_nested_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_nested_src.spvasm new file mode 100644 index 0000000000..035410e071 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_nested_src.spvasm @@ -0,0 +1,13 @@ +;; Tests that two forwarded declarations match even if the type pointer is used +;; in a nested struct declaration, and in multiple places + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %Aptr "Aptr" + OpTypeForwardPointer %Aptr UniformConstant + %uint = OpTypeInt 32 0 + %C = OpTypeStruct %Aptr %uint %Aptr + %B = OpTypeStruct %C %Aptr %uint + %A = OpTypeStruct %B %C %B + %Aptr = OpTypePointer UniformConstant %A diff --git a/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_onesided_debug_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_onesided_debug_autogen.cpp new file mode 100644 index 0000000000..df86fef26b --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_onesided_debug_autogen.cpp @@ -0,0 +1,124 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Test that OpTypeForwardPointer is matched when one SPIR-V doesn't have debug +// info +constexpr char kSrc[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %structptr "structptr" + OpTypeForwardPointer %structptr UniformConstant + %uint = OpTypeInt 32 0 + %structt1 = OpTypeStruct %structptr %uint + %structt2 = OpTypeStruct %uint %structptr + %structt3 = OpTypeStruct %uint %uint %structptr + %structt4 = OpTypeStruct %uint %uint %uint %structptr + %structptr = OpTypePointer UniformConstant %structt1)"; +constexpr char kDst[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpTypeForwardPointer %structptr UniformConstant + %uint = OpTypeInt 32 0 + %structt1 = OpTypeStruct %structptr %uint + %structt2 = OpTypeStruct %uint %structptr + %structt3 = OpTypeStruct %uint %uint %structptr + %structt4 = OpTypeStruct %uint %uint %uint %structptr + %structptr = OpTypePointer UniformConstant %structt1 +)"; + +TEST(DiffTest, OptypeforwardpointerOnesidedDebug) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 + ; Bound: 7 + ; Schema: 0 + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL +-OpName %1 "structptr" + OpTypeForwardPointer %1 UniformConstant + %2 = OpTypeInt 32 0 + %3 = OpTypeStruct %1 %2 + %4 = OpTypeStruct %2 %1 + %5 = OpTypeStruct %2 %2 %1 + %6 = OpTypeStruct %2 %2 %2 %1 + %1 = OpTypePointer UniformConstant %3 +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, OptypeforwardpointerOnesidedDebugNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpTypeForwardPointer %structptr UniformConstant + %uint = OpTypeInt 32 0 + %structt1 = OpTypeStruct %structptr %uint + %structt2 = OpTypeStruct %uint %structptr + %structt3 = OpTypeStruct %uint %uint %structptr + %structt4 = OpTypeStruct %uint %uint %uint %structptr + %structptr = OpTypePointer UniformConstant %structt1 +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpTypeForwardPointer %structptr UniformConstant + %uint = OpTypeInt 32 0 + %structt1 = OpTypeStruct %structptr %uint + %structt2 = OpTypeStruct %uint %structptr + %structt3 = OpTypeStruct %uint %uint %structptr + %structt4 = OpTypeStruct %uint %uint %uint %structptr + %structptr = OpTypePointer UniformConstant %structt1 +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 + ; Bound: 7 + ; Schema: 0 + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpTypeForwardPointer %1 UniformConstant + %2 = OpTypeInt 32 0 + %3 = OpTypeStruct %1 %2 + %4 = OpTypeStruct %2 %1 + %5 = OpTypeStruct %2 %2 %1 + %6 = OpTypeStruct %2 %2 %2 %1 + %1 = OpTypePointer UniformConstant %3 +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_onesided_debug_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_onesided_debug_dst.spvasm new file mode 100644 index 0000000000..7e25710e17 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_onesided_debug_dst.spvasm @@ -0,0 +1,11 @@ + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpTypeForwardPointer %structptr UniformConstant + %uint = OpTypeInt 32 0 + %structt1 = OpTypeStruct %structptr %uint + %structt2 = OpTypeStruct %uint %structptr + %structt3 = OpTypeStruct %uint %uint %structptr + %structt4 = OpTypeStruct %uint %uint %uint %structptr + %structptr = OpTypePointer UniformConstant %structt1 diff --git a/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_onesided_debug_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_onesided_debug_src.spvasm new file mode 100644 index 0000000000..e949b272f3 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/OpTypeForwardPointer_onesided_debug_src.spvasm @@ -0,0 +1,14 @@ +;; Test that OpTypeForwardPointer is matched when one SPIR-V doesn't have debug +;; info + OpCapability Kernel + OpCapability Addresses + OpCapability Linkage + OpMemoryModel Logical OpenCL + OpName %structptr "structptr" + OpTypeForwardPointer %structptr UniformConstant + %uint = OpTypeInt 32 0 + %structt1 = OpTypeStruct %structptr %uint + %structt2 = OpTypeStruct %uint %structptr + %structt3 = OpTypeStruct %uint %uint %structptr + %structt4 = OpTypeStruct %uint %uint %uint %structptr + %structptr = OpTypePointer UniformConstant %structt1 diff --git a/third_party/spirv-tools/test/diff/diff_files/README.md b/third_party/spirv-tools/test/diff/diff_files/README.md new file mode 100644 index 0000000000..5dcee25a00 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/README.md @@ -0,0 +1,17 @@ +# Diff tests + +This directory contains files used to ensure correctness of the `spirv-diff` implementation. The +`generate_tests.py` script takes `name_src.spvasm` and `name_dst.spvasm` (for each `name`) and +produces unit test files in the form of `name_autogen.cpp`. + +The unit test files test the diff between the src and dst inputs, as well as between debug-stripped +versions of those. Additionally, based on the `{variant}_TESTS` lists defined in +`generate_tests.py`, extra unit tests are added to exercise different options of spirv-diff. + +New tests are added simply by placing a new `name_src.spvasm` and `name_dst.spvasm` pair in this +directory and running `generate_tests.py`. Note that this script needs the path to the spirv-diff +executable that is built. + +The `generate_tests.py` script additionally expects `name_src.spvasm` to include a heading where the +purpose of the test is explained. This heading is parsed as a block of lines starting with `;;` at +the top of the file. diff --git a/third_party/spirv-tools/test/diff/diff_files/basic_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/basic_autogen.cpp new file mode 100644 index 0000000000..f3afc701b3 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/basic_autogen.cpp @@ -0,0 +1,407 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Basic test for spirv-diff +constexpr char kSrc[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Google ANGLE Shader Compiler; 0 +; Bound: 27 +; Schema: 0 +OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %22 "main" %4 %14 %19 + OpSource GLSL 450 + OpName %4 "_ua_position" + OpName %14 "ANGLEXfbPosition" + OpName %17 "gl_PerVertex" + OpMemberName %17 0 "gl_Position" +OpMemberName %17 1 "gl_PointSize" +OpMemberName %17 2 "gl_ClipDistance" + OpMemberName %17 3 "gl_CullDistance" + OpName %19 "" + OpName %22 "main" + OpDecorate %4 Location 0 + OpDecorate %14 Location 0 + OpMemberDecorate %17 1 RelaxedPrecision + OpMemberDecorate %17 0 BuiltIn Position + OpMemberDecorate %17 1 BuiltIn PointSize +OpMemberDecorate %17 2 BuiltIn ClipDistance +OpMemberDecorate %17 3 BuiltIn CullDistance +OpDecorate %17 Block +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeInt 32 0 +%6 = OpTypeInt 32 1 +%15 = OpConstant %5 8 +%16 = OpTypeArray %1 %15 +%17 = OpTypeStruct %2 %1 %16 %16 +%20 = OpTypeVoid +%25 = OpConstant %6 0 +%3 = OpTypePointer Input %2 +%13 = OpTypePointer Output %2 +%18 = OpTypePointer Output %17 +%21 = OpTypeFunction %20 +%4 = OpVariable %3 Input +%14 = OpVariable %13 Output +%19 = OpVariable %18 Output +%22 = OpFunction %20 None %21 +%23 = OpLabel +%24 = OpLoad %2 %4 +%26 = OpAccessChain %13 %19 %25 +OpStore %26 %24 +OpReturn +OpFunctionEnd)"; +constexpr char kDst[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 28 +; Schema: 0 +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %4 "main" %13 %17 %27 +OpSource GLSL 450 +OpName %4 "main" +OpName %11 "gl_PerVertex" +OpMemberName %11 0 "gl_Position" +OpMemberName %11 1 "gl_PointSize" +OpMemberName %11 2 "gl_ClipDistance" +OpMemberName %11 3 "gl_CullDistance" +OpName %13 "" +OpName %17 "_ua_position" +OpName %27 "ANGLEXfbPosition" +OpMemberDecorate %11 0 BuiltIn Position +OpMemberDecorate %11 1 BuiltIn PointSize +OpMemberDecorate %11 2 BuiltIn ClipDistance +OpMemberDecorate %11 3 BuiltIn CullDistance +OpDecorate %11 Block +OpDecorate %17 Location 0 +OpDecorate %27 Location 0 +%2 = OpTypeVoid +%3 = OpTypeFunction %2 +%6 = OpTypeFloat 32 +%7 = OpTypeVector %6 4 +%8 = OpTypeInt 32 0 +%9 = OpConstant %8 1 +%10 = OpTypeArray %6 %9 +%11 = OpTypeStruct %7 %6 %10 %10 +%12 = OpTypePointer Output %11 +%13 = OpVariable %12 Output +%14 = OpTypeInt 32 1 +%15 = OpConstant %14 0 +%16 = OpTypePointer Input %7 +%17 = OpVariable %16 Input +%19 = OpTypePointer Output %7 +%27 = OpVariable %19 Output +%4 = OpFunction %2 None %3 +%5 = OpLabel +%18 = OpLoad %7 %17 +%20 = OpAccessChain %19 %13 %15 +OpStore %20 %18 +OpReturn +OpFunctionEnd +)"; + +TEST(DiffTest, Basic) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 27 ++; Bound: 36 + ; Schema: 0 + OpCapability Shader ++%27 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 +-OpEntryPoint Vertex %22 "main" %4 %14 %19 ++OpEntryPoint Vertex %22 "main" %19 %4 %14 + OpSource GLSL 450 + OpName %4 "_ua_position" + OpName %14 "ANGLEXfbPosition" + OpName %17 "gl_PerVertex" + OpMemberName %17 0 "gl_Position" + OpMemberName %17 1 "gl_PointSize" + OpMemberName %17 2 "gl_ClipDistance" + OpMemberName %17 3 "gl_CullDistance" + OpName %19 "" + OpName %22 "main" + OpDecorate %4 Location 0 + OpDecorate %14 Location 0 +-OpMemberDecorate %17 1 RelaxedPrecision + OpMemberDecorate %17 0 BuiltIn Position + OpMemberDecorate %17 1 BuiltIn PointSize + OpMemberDecorate %17 2 BuiltIn ClipDistance + OpMemberDecorate %17 3 BuiltIn CullDistance + OpDecorate %17 Block + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %5 = OpTypeInt 32 0 + %6 = OpTypeInt 32 1 +-%15 = OpConstant %5 8 +-%16 = OpTypeArray %1 %15 +-%17 = OpTypeStruct %2 %1 %16 %16 ++%17 = OpTypeStruct %2 %1 %29 %29 ++%28 = OpConstant %5 1 ++%29 = OpTypeArray %1 %28 + %20 = OpTypeVoid + %25 = OpConstant %6 0 + %3 = OpTypePointer Input %2 + %13 = OpTypePointer Output %2 + %18 = OpTypePointer Output %17 + %21 = OpTypeFunction %20 + %4 = OpVariable %3 Input + %14 = OpVariable %13 Output + %19 = OpVariable %18 Output + %22 = OpFunction %20 None %21 + %23 = OpLabel + %24 = OpLoad %2 %4 + %26 = OpAccessChain %13 %19 %25 + OpStore %26 %24 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, BasicNoDebug) { + constexpr char kSrcNoDebug[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Google ANGLE Shader Compiler; 0 +; Bound: 27 +; Schema: 0 +OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %22 "main" %4 %14 %19 + OpSource GLSL 450 + OpDecorate %4 Location 0 + OpDecorate %14 Location 0 + OpMemberDecorate %17 1 RelaxedPrecision + OpMemberDecorate %17 0 BuiltIn Position + OpMemberDecorate %17 1 BuiltIn PointSize +OpMemberDecorate %17 2 BuiltIn ClipDistance +OpMemberDecorate %17 3 BuiltIn CullDistance +OpDecorate %17 Block +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeInt 32 0 +%6 = OpTypeInt 32 1 +%15 = OpConstant %5 8 +%16 = OpTypeArray %1 %15 +%17 = OpTypeStruct %2 %1 %16 %16 +%20 = OpTypeVoid +%25 = OpConstant %6 0 +%3 = OpTypePointer Input %2 +%13 = OpTypePointer Output %2 +%18 = OpTypePointer Output %17 +%21 = OpTypeFunction %20 +%4 = OpVariable %3 Input +%14 = OpVariable %13 Output +%19 = OpVariable %18 Output +%22 = OpFunction %20 None %21 +%23 = OpLabel +%24 = OpLoad %2 %4 +%26 = OpAccessChain %13 %19 %25 +OpStore %26 %24 +OpReturn +OpFunctionEnd +)"; + constexpr char kDstNoDebug[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 28 +; Schema: 0 +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %4 "main" %13 %17 %27 +OpSource GLSL 450 +OpMemberDecorate %11 0 BuiltIn Position +OpMemberDecorate %11 1 BuiltIn PointSize +OpMemberDecorate %11 2 BuiltIn ClipDistance +OpMemberDecorate %11 3 BuiltIn CullDistance +OpDecorate %11 Block +OpDecorate %17 Location 0 +OpDecorate %27 Location 0 +%2 = OpTypeVoid +%3 = OpTypeFunction %2 +%6 = OpTypeFloat 32 +%7 = OpTypeVector %6 4 +%8 = OpTypeInt 32 0 +%9 = OpConstant %8 1 +%10 = OpTypeArray %6 %9 +%11 = OpTypeStruct %7 %6 %10 %10 +%12 = OpTypePointer Output %11 +%13 = OpVariable %12 Output +%14 = OpTypeInt 32 1 +%15 = OpConstant %14 0 +%16 = OpTypePointer Input %7 +%17 = OpVariable %16 Input +%19 = OpTypePointer Output %7 +%27 = OpVariable %19 Output +%4 = OpFunction %2 None %3 +%5 = OpLabel +%18 = OpLoad %7 %17 +%20 = OpAccessChain %19 %13 %15 +OpStore %20 %18 +OpReturn +OpFunctionEnd +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 27 ++; Bound: 36 + ; Schema: 0 + OpCapability Shader ++%27 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 +-OpEntryPoint Vertex %22 "main" %4 %14 %19 ++OpEntryPoint Vertex %22 "main" %19 %4 %14 + OpSource GLSL 450 + OpDecorate %4 Location 0 + OpDecorate %14 Location 0 +-OpMemberDecorate %17 1 RelaxedPrecision + OpMemberDecorate %17 0 BuiltIn Position + OpMemberDecorate %17 1 BuiltIn PointSize + OpMemberDecorate %17 2 BuiltIn ClipDistance + OpMemberDecorate %17 3 BuiltIn CullDistance + OpDecorate %17 Block + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %5 = OpTypeInt 32 0 + %6 = OpTypeInt 32 1 +-%15 = OpConstant %5 8 +-%16 = OpTypeArray %1 %15 +-%17 = OpTypeStruct %2 %1 %16 %16 ++%17 = OpTypeStruct %2 %1 %29 %29 ++%28 = OpConstant %5 1 ++%29 = OpTypeArray %1 %28 + %20 = OpTypeVoid + %25 = OpConstant %6 0 + %3 = OpTypePointer Input %2 + %13 = OpTypePointer Output %2 + %18 = OpTypePointer Output %17 + %21 = OpTypeFunction %20 + %4 = OpVariable %3 Input + %14 = OpVariable %13 Output + %19 = OpVariable %18 Output + %22 = OpFunction %20 None %21 + %23 = OpLabel + %24 = OpLoad %2 %4 + %26 = OpAccessChain %13 %19 %25 + OpStore %26 %24 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +TEST(DiffTest, BasicDumpIds) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 27 ++; Bound: 36 + ; Schema: 0 + OpCapability Shader ++%27 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 +-OpEntryPoint Vertex %22 "main" %4 %14 %19 ++OpEntryPoint Vertex %22 "main" %19 %4 %14 + OpSource GLSL 450 + OpName %4 "_ua_position" + OpName %14 "ANGLEXfbPosition" + OpName %17 "gl_PerVertex" + OpMemberName %17 0 "gl_Position" + OpMemberName %17 1 "gl_PointSize" + OpMemberName %17 2 "gl_ClipDistance" + OpMemberName %17 3 "gl_CullDistance" + OpName %19 "" + OpName %22 "main" + OpDecorate %4 Location 0 + OpDecorate %14 Location 0 +-OpMemberDecorate %17 1 RelaxedPrecision + OpMemberDecorate %17 0 BuiltIn Position + OpMemberDecorate %17 1 BuiltIn PointSize + OpMemberDecorate %17 2 BuiltIn ClipDistance + OpMemberDecorate %17 3 BuiltIn CullDistance + OpDecorate %17 Block + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %5 = OpTypeInt 32 0 + %6 = OpTypeInt 32 1 +-%15 = OpConstant %5 8 +-%16 = OpTypeArray %1 %15 +-%17 = OpTypeStruct %2 %1 %16 %16 ++%17 = OpTypeStruct %2 %1 %29 %29 ++%28 = OpConstant %5 1 ++%29 = OpTypeArray %1 %28 + %20 = OpTypeVoid + %25 = OpConstant %6 0 + %3 = OpTypePointer Input %2 + %13 = OpTypePointer Output %2 + %18 = OpTypePointer Output %17 + %21 = OpTypeFunction %20 + %4 = OpVariable %3 Input + %14 = OpVariable %13 Output + %19 = OpVariable %18 Output + %22 = OpFunction %20 None %21 + %23 = OpLabel + %24 = OpLoad %2 %4 + %26 = OpAccessChain %13 %19 %25 + OpStore %26 %24 + OpReturn + OpFunctionEnd + Src -> Dst + 1 -> 6 [TypeFloat] + 2 -> 7 [TypeVector] + 3 -> 16 [TypePointer] + 4 -> 17 [Variable] + 5 -> 8 [TypeInt] + 6 -> 14 [TypeInt] + 13 -> 19 [TypePointer] + 14 -> 27 [Variable] + 15 -> 34 [Constant] + 16 -> 35 [TypeArray] + 17 -> 11 [TypeStruct] + 18 -> 12 [TypePointer] + 19 -> 13 [Variable] + 20 -> 2 [TypeVoid] + 21 -> 3 [TypeFunction] + 22 -> 4 [Function] + 23 -> 5 [Label] + 24 -> 18 [Load] + 25 -> 15 [Constant] + 26 -> 20 [AccessChain] +)"; + Options options; + options.dump_id_map = true; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/basic_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/basic_dst.spvasm new file mode 100644 index 0000000000..79cb888789 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/basic_dst.spvasm @@ -0,0 +1,49 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 28 +; Schema: 0 +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %4 "main" %13 %17 %27 +OpSource GLSL 450 +OpName %4 "main" +OpName %11 "gl_PerVertex" +OpMemberName %11 0 "gl_Position" +OpMemberName %11 1 "gl_PointSize" +OpMemberName %11 2 "gl_ClipDistance" +OpMemberName %11 3 "gl_CullDistance" +OpName %13 "" +OpName %17 "_ua_position" +OpName %27 "ANGLEXfbPosition" +OpMemberDecorate %11 0 BuiltIn Position +OpMemberDecorate %11 1 BuiltIn PointSize +OpMemberDecorate %11 2 BuiltIn ClipDistance +OpMemberDecorate %11 3 BuiltIn CullDistance +OpDecorate %11 Block +OpDecorate %17 Location 0 +OpDecorate %27 Location 0 +%2 = OpTypeVoid +%3 = OpTypeFunction %2 +%6 = OpTypeFloat 32 +%7 = OpTypeVector %6 4 +%8 = OpTypeInt 32 0 +%9 = OpConstant %8 1 +%10 = OpTypeArray %6 %9 +%11 = OpTypeStruct %7 %6 %10 %10 +%12 = OpTypePointer Output %11 +%13 = OpVariable %12 Output +%14 = OpTypeInt 32 1 +%15 = OpConstant %14 0 +%16 = OpTypePointer Input %7 +%17 = OpVariable %16 Input +%19 = OpTypePointer Output %7 +%27 = OpVariable %19 Output +%4 = OpFunction %2 None %3 +%5 = OpLabel +%18 = OpLoad %7 %17 +%20 = OpAccessChain %19 %13 %15 +OpStore %20 %18 +OpReturn +OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/basic_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/basic_src.spvasm new file mode 100644 index 0000000000..c55ec7afac --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/basic_src.spvasm @@ -0,0 +1,50 @@ +;; Basic test for spirv-diff +; SPIR-V +; Version: 1.0 +; Generator: Google ANGLE Shader Compiler; 0 +; Bound: 27 +; Schema: 0 +OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %22 "main" %4 %14 %19 + OpSource GLSL 450 + OpName %4 "_ua_position" + OpName %14 "ANGLEXfbPosition" + OpName %17 "gl_PerVertex" + OpMemberName %17 0 "gl_Position" +OpMemberName %17 1 "gl_PointSize" +OpMemberName %17 2 "gl_ClipDistance" + OpMemberName %17 3 "gl_CullDistance" + OpName %19 "" + OpName %22 "main" + OpDecorate %4 Location 0 + OpDecorate %14 Location 0 + OpMemberDecorate %17 1 RelaxedPrecision + OpMemberDecorate %17 0 BuiltIn Position + OpMemberDecorate %17 1 BuiltIn PointSize +OpMemberDecorate %17 2 BuiltIn ClipDistance +OpMemberDecorate %17 3 BuiltIn CullDistance +OpDecorate %17 Block +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeInt 32 0 +%6 = OpTypeInt 32 1 +%15 = OpConstant %5 8 +%16 = OpTypeArray %1 %15 +%17 = OpTypeStruct %2 %1 %16 %16 +%20 = OpTypeVoid +%25 = OpConstant %6 0 +%3 = OpTypePointer Input %2 +%13 = OpTypePointer Output %2 +%18 = OpTypePointer Output %17 +%21 = OpTypeFunction %20 +%4 = OpVariable %3 Input +%14 = OpVariable %13 Output +%19 = OpVariable %18 Output +%22 = OpFunction %20 None %21 +%23 = OpLabel +%24 = OpLoad %2 %4 +%26 = OpAccessChain %13 %19 %25 +OpStore %26 %24 +OpReturn +OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/constant_array_size_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/constant_array_size_autogen.cpp new file mode 100644 index 0000000000..16975ff47e --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/constant_array_size_autogen.cpp @@ -0,0 +1,306 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Tests that identical integer constants are matched when used as array size, +// regardless of int or uint. +constexpr char kSrc[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Google ANGLE Shader Compiler; 0 +; Bound: 27 +; Schema: 0 +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %22 "main" %4 %19 +OpSource GLSL 450 +OpName %4 "_ua_position" +OpName %17 "gl_PerVertex" +OpMemberName %17 0 "gl_Position" +OpMemberName %17 1 "gl_PointSize" +OpMemberName %17 2 "gl_ClipDistance" +OpMemberName %17 3 "gl_CullDistance" +OpName %19 "" +OpName %22 "main" +OpDecorate %4 Location 0 +OpMemberDecorate %17 1 RelaxedPrecision +OpMemberDecorate %17 0 BuiltIn Position +OpMemberDecorate %17 1 BuiltIn PointSize +OpMemberDecorate %17 2 BuiltIn ClipDistance +OpMemberDecorate %17 3 BuiltIn CullDistance +OpDecorate %17 Block +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeInt 32 0 +%8 = OpTypeVector %5 4 +%15 = OpConstant %5 8 +%16 = OpTypeArray %1 %15 +%17 = OpTypeStruct %2 %1 %16 %16 +%20 = OpTypeVoid +%25 = OpConstant %5 0 +%3 = OpTypePointer Input %2 +%13 = OpTypePointer Output %2 +%18 = OpTypePointer Output %17 +%21 = OpTypeFunction %20 +%4 = OpVariable %3 Input +%19 = OpVariable %18 Output +%22 = OpFunction %20 None %21 +%23 = OpLabel +%24 = OpLoad %2 %4 +%26 = OpAccessChain %13 %19 %25 +OpStore %26 %24 +OpReturn +OpFunctionEnd)"; +constexpr char kDst[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Google ANGLE Shader Compiler; 0 +; Bound: 27 +; Schema: 0 +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %22 "main" %4 %19 +OpSource GLSL 450 +OpName %4 "_ua_position" +OpName %17 "gl_PerVertex" +OpMemberName %17 0 "gl_Position" +OpMemberName %17 1 "gl_PointSize" +OpMemberName %17 2 "gl_ClipDistance" +OpMemberName %17 3 "gl_CullDistance" +OpName %19 "" +OpName %22 "main" +OpDecorate %4 Location 0 +OpMemberDecorate %17 1 RelaxedPrecision +OpMemberDecorate %17 0 BuiltIn Position +OpMemberDecorate %17 1 BuiltIn PointSize +OpMemberDecorate %17 2 BuiltIn ClipDistance +OpMemberDecorate %17 3 BuiltIn CullDistance +OpDecorate %17 Block +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeInt 32 0 +%6 = OpTypeInt 32 1 +%8 = OpTypeVector %5 4 +%15 = OpConstant %6 8 +%16 = OpTypeArray %1 %15 +%17 = OpTypeStruct %2 %1 %16 %16 +%20 = OpTypeVoid +%25 = OpConstant %5 0 +%3 = OpTypePointer Input %2 +%13 = OpTypePointer Output %2 +%18 = OpTypePointer Output %17 +%21 = OpTypeFunction %20 +%4 = OpVariable %3 Input +%19 = OpVariable %18 Output +%22 = OpFunction %20 None %21 +%23 = OpLabel +%24 = OpLoad %2 %4 +%26 = OpAccessChain %13 %19 %25 +OpStore %26 %24 +OpReturn +OpFunctionEnd +)"; + +TEST(DiffTest, ConstantArraySize) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 27 ++; Bound: 34 + ; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %22 "main" %4 %19 + OpSource GLSL 450 + OpName %4 "_ua_position" + OpName %17 "gl_PerVertex" + OpMemberName %17 0 "gl_Position" + OpMemberName %17 1 "gl_PointSize" + OpMemberName %17 2 "gl_ClipDistance" + OpMemberName %17 3 "gl_CullDistance" + OpName %19 "" + OpName %22 "main" + OpDecorate %4 Location 0 + OpMemberDecorate %17 1 RelaxedPrecision + OpMemberDecorate %17 0 BuiltIn Position + OpMemberDecorate %17 1 BuiltIn PointSize + OpMemberDecorate %17 2 BuiltIn ClipDistance + OpMemberDecorate %17 3 BuiltIn CullDistance + OpDecorate %17 Block + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %5 = OpTypeInt 32 0 ++%27 = OpTypeInt 32 1 + %8 = OpTypeVector %5 4 +-%15 = OpConstant %5 8 ++%15 = OpConstant %27 8 + %16 = OpTypeArray %1 %15 + %17 = OpTypeStruct %2 %1 %16 %16 + %20 = OpTypeVoid + %25 = OpConstant %5 0 + %3 = OpTypePointer Input %2 + %13 = OpTypePointer Output %2 + %18 = OpTypePointer Output %17 + %21 = OpTypeFunction %20 + %4 = OpVariable %3 Input + %19 = OpVariable %18 Output + %22 = OpFunction %20 None %21 + %23 = OpLabel + %24 = OpLoad %2 %4 + %26 = OpAccessChain %13 %19 %25 + OpStore %26 %24 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, ConstantArraySizeNoDebug) { + constexpr char kSrcNoDebug[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Google ANGLE Shader Compiler; 0 +; Bound: 27 +; Schema: 0 +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %22 "main" %4 %19 +OpSource GLSL 450 +OpDecorate %4 Location 0 +OpMemberDecorate %17 1 RelaxedPrecision +OpMemberDecorate %17 0 BuiltIn Position +OpMemberDecorate %17 1 BuiltIn PointSize +OpMemberDecorate %17 2 BuiltIn ClipDistance +OpMemberDecorate %17 3 BuiltIn CullDistance +OpDecorate %17 Block +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeInt 32 0 +%8 = OpTypeVector %5 4 +%15 = OpConstant %5 8 +%16 = OpTypeArray %1 %15 +%17 = OpTypeStruct %2 %1 %16 %16 +%20 = OpTypeVoid +%25 = OpConstant %5 0 +%3 = OpTypePointer Input %2 +%13 = OpTypePointer Output %2 +%18 = OpTypePointer Output %17 +%21 = OpTypeFunction %20 +%4 = OpVariable %3 Input +%19 = OpVariable %18 Output +%22 = OpFunction %20 None %21 +%23 = OpLabel +%24 = OpLoad %2 %4 +%26 = OpAccessChain %13 %19 %25 +OpStore %26 %24 +OpReturn +OpFunctionEnd +)"; + constexpr char kDstNoDebug[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Google ANGLE Shader Compiler; 0 +; Bound: 27 +; Schema: 0 +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %22 "main" %4 %19 +OpSource GLSL 450 +OpDecorate %4 Location 0 +OpMemberDecorate %17 1 RelaxedPrecision +OpMemberDecorate %17 0 BuiltIn Position +OpMemberDecorate %17 1 BuiltIn PointSize +OpMemberDecorate %17 2 BuiltIn ClipDistance +OpMemberDecorate %17 3 BuiltIn CullDistance +OpDecorate %17 Block +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeInt 32 0 +%6 = OpTypeInt 32 1 +%8 = OpTypeVector %5 4 +%15 = OpConstant %6 8 +%16 = OpTypeArray %1 %15 +%17 = OpTypeStruct %2 %1 %16 %16 +%20 = OpTypeVoid +%25 = OpConstant %5 0 +%3 = OpTypePointer Input %2 +%13 = OpTypePointer Output %2 +%18 = OpTypePointer Output %17 +%21 = OpTypeFunction %20 +%4 = OpVariable %3 Input +%19 = OpVariable %18 Output +%22 = OpFunction %20 None %21 +%23 = OpLabel +%24 = OpLoad %2 %4 +%26 = OpAccessChain %13 %19 %25 +OpStore %26 %24 +OpReturn +OpFunctionEnd +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 27 ++; Bound: 34 + ; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %22 "main" %4 %19 + OpSource GLSL 450 + OpDecorate %4 Location 0 + OpMemberDecorate %17 1 RelaxedPrecision + OpMemberDecorate %17 0 BuiltIn Position + OpMemberDecorate %17 1 BuiltIn PointSize + OpMemberDecorate %17 2 BuiltIn ClipDistance + OpMemberDecorate %17 3 BuiltIn CullDistance + OpDecorate %17 Block + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %5 = OpTypeInt 32 0 ++%27 = OpTypeInt 32 1 + %8 = OpTypeVector %5 4 +-%15 = OpConstant %5 8 ++%15 = OpConstant %27 8 + %16 = OpTypeArray %1 %15 + %17 = OpTypeStruct %2 %1 %16 %16 + %20 = OpTypeVoid + %25 = OpConstant %5 0 + %3 = OpTypePointer Input %2 + %13 = OpTypePointer Output %2 + %18 = OpTypePointer Output %17 + %21 = OpTypeFunction %20 + %4 = OpVariable %3 Input + %19 = OpVariable %18 Output + %22 = OpFunction %20 None %21 + %23 = OpLabel + %24 = OpLoad %2 %4 + %26 = OpAccessChain %13 %19 %25 + OpStore %26 %24 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/constant_array_size_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/constant_array_size_dst.spvasm new file mode 100644 index 0000000000..a432b6126e --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/constant_array_size_dst.spvasm @@ -0,0 +1,47 @@ +; SPIR-V +; Version: 1.0 +; Generator: Google ANGLE Shader Compiler; 0 +; Bound: 27 +; Schema: 0 +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %22 "main" %4 %19 +OpSource GLSL 450 +OpName %4 "_ua_position" +OpName %17 "gl_PerVertex" +OpMemberName %17 0 "gl_Position" +OpMemberName %17 1 "gl_PointSize" +OpMemberName %17 2 "gl_ClipDistance" +OpMemberName %17 3 "gl_CullDistance" +OpName %19 "" +OpName %22 "main" +OpDecorate %4 Location 0 +OpMemberDecorate %17 1 RelaxedPrecision +OpMemberDecorate %17 0 BuiltIn Position +OpMemberDecorate %17 1 BuiltIn PointSize +OpMemberDecorate %17 2 BuiltIn ClipDistance +OpMemberDecorate %17 3 BuiltIn CullDistance +OpDecorate %17 Block +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeInt 32 0 +%6 = OpTypeInt 32 1 +%8 = OpTypeVector %5 4 +%15 = OpConstant %6 8 +%16 = OpTypeArray %1 %15 +%17 = OpTypeStruct %2 %1 %16 %16 +%20 = OpTypeVoid +%25 = OpConstant %5 0 +%3 = OpTypePointer Input %2 +%13 = OpTypePointer Output %2 +%18 = OpTypePointer Output %17 +%21 = OpTypeFunction %20 +%4 = OpVariable %3 Input +%19 = OpVariable %18 Output +%22 = OpFunction %20 None %21 +%23 = OpLabel +%24 = OpLoad %2 %4 +%26 = OpAccessChain %13 %19 %25 +OpStore %26 %24 +OpReturn +OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/constant_array_size_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/constant_array_size_src.spvasm new file mode 100644 index 0000000000..4e1ba64642 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/constant_array_size_src.spvasm @@ -0,0 +1,48 @@ +;; Tests that identical integer constants are matched when used as array size, +;; regardless of int or uint. +; SPIR-V +; Version: 1.0 +; Generator: Google ANGLE Shader Compiler; 0 +; Bound: 27 +; Schema: 0 +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %22 "main" %4 %19 +OpSource GLSL 450 +OpName %4 "_ua_position" +OpName %17 "gl_PerVertex" +OpMemberName %17 0 "gl_Position" +OpMemberName %17 1 "gl_PointSize" +OpMemberName %17 2 "gl_ClipDistance" +OpMemberName %17 3 "gl_CullDistance" +OpName %19 "" +OpName %22 "main" +OpDecorate %4 Location 0 +OpMemberDecorate %17 1 RelaxedPrecision +OpMemberDecorate %17 0 BuiltIn Position +OpMemberDecorate %17 1 BuiltIn PointSize +OpMemberDecorate %17 2 BuiltIn ClipDistance +OpMemberDecorate %17 3 BuiltIn CullDistance +OpDecorate %17 Block +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeInt 32 0 +%8 = OpTypeVector %5 4 +%15 = OpConstant %5 8 +%16 = OpTypeArray %1 %15 +%17 = OpTypeStruct %2 %1 %16 %16 +%20 = OpTypeVoid +%25 = OpConstant %5 0 +%3 = OpTypePointer Input %2 +%13 = OpTypePointer Output %2 +%18 = OpTypePointer Output %17 +%21 = OpTypeFunction %20 +%4 = OpVariable %3 Input +%19 = OpVariable %18 Output +%22 = OpFunction %20 None %21 +%23 = OpLabel +%24 = OpLoad %2 %4 +%26 = OpAccessChain %13 %19 %25 +OpStore %26 %24 +OpReturn +OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/diff_test_files_autogen.cmake b/third_party/spirv-tools/test/diff/diff_files/diff_test_files_autogen.cmake new file mode 100644 index 0000000000..e6d3645207 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/diff_test_files_autogen.cmake @@ -0,0 +1,45 @@ +# GENERATED FILE - DO NOT EDIT. +# Generated by generate_tests.py +# +# Copyright (c) 2022 Google LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +list(APPEND DIFF_TEST_FILES +"diff_files/OpExtInst_in_dst_only_autogen.cpp" +"diff_files/OpExtInst_in_src_only_autogen.cpp" +"diff_files/OpTypeForwardPointer_basic_autogen.cpp" +"diff_files/OpTypeForwardPointer_intertwined_autogen.cpp" +"diff_files/OpTypeForwardPointer_mismatching_class_autogen.cpp" +"diff_files/OpTypeForwardPointer_mismatching_type_autogen.cpp" +"diff_files/OpTypeForwardPointer_nested_autogen.cpp" +"diff_files/OpTypeForwardPointer_onesided_debug_autogen.cpp" +"diff_files/basic_autogen.cpp" +"diff_files/constant_array_size_autogen.cpp" +"diff_files/different_decorations_fragment_autogen.cpp" +"diff_files/different_decorations_vertex_autogen.cpp" +"diff_files/different_function_parameter_count_autogen.cpp" +"diff_files/extra_if_block_autogen.cpp" +"diff_files/index_signedness_autogen.cpp" +"diff_files/int_vs_uint_constants_autogen.cpp" +"diff_files/large_functions_large_diffs_autogen.cpp" +"diff_files/large_functions_small_diffs_autogen.cpp" +"diff_files/multiple_different_entry_points_autogen.cpp" +"diff_files/multiple_same_entry_points_autogen.cpp" +"diff_files/reordered_if_blocks_autogen.cpp" +"diff_files/reordered_switch_blocks_autogen.cpp" +"diff_files/small_functions_small_diffs_autogen.cpp" +"diff_files/spec_constant_array_size_autogen.cpp" +"diff_files/spec_constant_composite_autogen.cpp" +"diff_files/unrelated_shaders_autogen.cpp" +) diff --git a/third_party/spirv-tools/test/diff/diff_files/different_decorations_fragment_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/different_decorations_fragment_autogen.cpp new file mode 100644 index 0000000000..0d34654f84 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/different_decorations_fragment_autogen.cpp @@ -0,0 +1,1626 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Test where variable set/binding/location decorations are different between +// src and dst fragment shaders. +constexpr char kSrc[] = R"(OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %63 "main" %4 %22 +OpExecutionMode %63 OriginUpperLeft +OpSource GLSL 450 +OpName %4 "_ue" +OpName %8 "_uf" +OpName %11 "_ug" +OpName %12 "_uA" +OpMemberName %12 0 "_ux" +OpName %14 "_uc" +OpName %15 "_uB" +OpMemberName %15 0 "_ux" +OpName %20 "_ud" +OpName %22 "_ucol" +OpName %26 "ANGLEDepthRangeParams" +OpMemberName %26 0 "near" +OpMemberName %26 1 "far" +OpMemberName %26 2 "diff" +OpMemberName %26 3 "reserved" +OpName %27 "ANGLEUniformBlock" +OpMemberName %27 0 "viewport" +OpMemberName %27 1 "clipDistancesEnabled" +OpMemberName %27 2 "xfbActiveUnpaused" +OpMemberName %27 3 "xfbVerticesPerInstance" +OpMemberName %27 4 "numSamples" +OpMemberName %27 5 "xfbBufferOffsets" +OpMemberName %27 6 "acbBufferOffsets" +OpMemberName %27 7 "depthRange" +OpName %29 "ANGLEUniforms" +OpName %33 "_uc" +OpName %32 "_uh" +OpName %49 "_ux" +OpName %50 "_uy" +OpName %48 "_ui" +OpName %63 "main" +OpName %65 "param" +OpName %68 "param" +OpName %73 "param" +OpDecorate %4 Location 0 +OpDecorate %8 RelaxedPrecision +OpDecorate %8 DescriptorSet 0 +OpDecorate %8 Binding 0 +OpDecorate %11 DescriptorSet 0 +OpDecorate %11 Binding 1 +OpMemberDecorate %12 0 Offset 0 +OpMemberDecorate %12 0 RelaxedPrecision +OpDecorate %12 Block +OpDecorate %14 DescriptorSet 0 +OpDecorate %14 Binding 2 +OpMemberDecorate %15 0 Offset 0 +OpMemberDecorate %15 0 RelaxedPrecision +OpDecorate %15 BufferBlock +OpDecorate %20 DescriptorSet 0 +OpDecorate %20 Binding 3 +OpDecorate %22 RelaxedPrecision +OpDecorate %22 Location 0 +OpMemberDecorate %26 0 Offset 0 +OpMemberDecorate %26 1 Offset 4 +OpMemberDecorate %26 2 Offset 8 +OpMemberDecorate %26 3 Offset 12 +OpMemberDecorate %27 0 Offset 0 +OpMemberDecorate %27 1 Offset 16 +OpMemberDecorate %27 2 Offset 20 +OpMemberDecorate %27 3 Offset 24 +OpMemberDecorate %27 4 Offset 28 +OpMemberDecorate %27 5 Offset 32 +OpMemberDecorate %27 6 Offset 48 +OpMemberDecorate %27 7 Offset 64 +OpMemberDecorate %27 2 RelaxedPrecision +OpMemberDecorate %27 4 RelaxedPrecision +OpDecorate %27 Block +OpDecorate %29 DescriptorSet 0 +OpDecorate %29 Binding 4 +OpDecorate %32 RelaxedPrecision +OpDecorate %33 RelaxedPrecision +OpDecorate %36 RelaxedPrecision +OpDecorate %37 RelaxedPrecision +OpDecorate %38 RelaxedPrecision +OpDecorate %39 RelaxedPrecision +OpDecorate %41 RelaxedPrecision +OpDecorate %42 RelaxedPrecision +OpDecorate %43 RelaxedPrecision +OpDecorate %48 RelaxedPrecision +OpDecorate %49 RelaxedPrecision +OpDecorate %50 RelaxedPrecision +OpDecorate %52 RelaxedPrecision +OpDecorate %53 RelaxedPrecision +OpDecorate %54 RelaxedPrecision +OpDecorate %55 RelaxedPrecision +OpDecorate %56 RelaxedPrecision +OpDecorate %57 RelaxedPrecision +OpDecorate %58 RelaxedPrecision +OpDecorate %59 RelaxedPrecision +OpDecorate %60 RelaxedPrecision +OpDecorate %67 RelaxedPrecision +OpDecorate %68 RelaxedPrecision +OpDecorate %72 RelaxedPrecision +OpDecorate %73 RelaxedPrecision +OpDecorate %75 RelaxedPrecision +OpDecorate %76 RelaxedPrecision +OpDecorate %77 RelaxedPrecision +OpDecorate %80 RelaxedPrecision +OpDecorate %81 RelaxedPrecision +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeImage %1 2D 0 0 0 1 Unknown +%6 = OpTypeSampledImage %5 +%9 = OpTypeImage %1 2D 0 0 0 2 Rgba8 +%12 = OpTypeStruct %2 +%15 = OpTypeStruct %2 +%16 = OpTypeInt 32 0 +%17 = OpConstant %16 2 +%18 = OpTypeArray %15 %17 +%23 = OpTypeInt 32 1 +%24 = OpTypeVector %23 4 +%25 = OpTypeVector %16 4 +%26 = OpTypeStruct %1 %1 %1 %1 +%27 = OpTypeStruct %2 %16 %16 %23 %23 %24 %25 %26 +%35 = OpTypeVector %1 2 +%40 = OpTypeVector %23 2 +%61 = OpTypeVoid +%69 = OpConstant %16 0 +%78 = OpConstant %16 1 +%3 = OpTypePointer Input %2 +%7 = OpTypePointer UniformConstant %6 +%10 = OpTypePointer UniformConstant %9 +%13 = OpTypePointer Uniform %12 +%19 = OpTypePointer Uniform %18 +%21 = OpTypePointer Output %2 +%28 = OpTypePointer Uniform %27 +%30 = OpTypePointer Function %2 +%70 = OpTypePointer Uniform %2 +%31 = OpTypeFunction %2 %30 +%47 = OpTypeFunction %2 %30 %30 +%62 = OpTypeFunction %61 +%4 = OpVariable %3 Input +%8 = OpVariable %7 UniformConstant +%11 = OpVariable %10 UniformConstant +%14 = OpVariable %13 Uniform +%20 = OpVariable %19 Uniform +%22 = OpVariable %21 Output +%29 = OpVariable %28 Uniform +%32 = OpFunction %2 None %31 +%33 = OpFunctionParameter %30 +%34 = OpLabel +%36 = OpLoad %6 %8 +%37 = OpLoad %2 %33 +%38 = OpVectorShuffle %35 %37 %37 0 1 +%39 = OpImageSampleImplicitLod %2 %36 %38 +%41 = OpLoad %2 %33 +%42 = OpVectorShuffle %35 %41 %41 2 3 +%43 = OpConvertFToS %40 %42 +%44 = OpLoad %9 %11 +%45 = OpImageRead %2 %44 %43 +%46 = OpFAdd %2 %39 %45 +OpReturnValue %46 +OpFunctionEnd +%48 = OpFunction %2 None %47 +%49 = OpFunctionParameter %30 +%50 = OpFunctionParameter %30 +%51 = OpLabel +%52 = OpLoad %2 %49 +%53 = OpVectorShuffle %35 %52 %52 0 1 +%54 = OpLoad %2 %50 +%55 = OpVectorShuffle %35 %54 %54 2 3 +%56 = OpCompositeExtract %1 %53 0 +%57 = OpCompositeExtract %1 %53 1 +%58 = OpCompositeExtract %1 %55 0 +%59 = OpCompositeExtract %1 %55 1 +%60 = OpCompositeConstruct %2 %56 %57 %58 %59 +OpReturnValue %60 +OpFunctionEnd +%63 = OpFunction %61 None %62 +%64 = OpLabel +%65 = OpVariable %30 Function +%68 = OpVariable %30 Function +%73 = OpVariable %30 Function +%66 = OpLoad %2 %4 +OpStore %65 %66 +%67 = OpFunctionCall %2 %32 %65 +%71 = OpAccessChain %70 %14 %69 +%72 = OpLoad %2 %71 +OpStore %68 %72 +%74 = OpAccessChain %70 %20 %69 %69 +%75 = OpLoad %2 %74 +OpStore %73 %75 +%76 = OpFunctionCall %2 %48 %68 %73 +%77 = OpFAdd %2 %67 %76 +%79 = OpAccessChain %70 %20 %78 %69 +%80 = OpLoad %2 %79 +%81 = OpFAdd %2 %77 %80 +OpStore %22 %81 +OpReturn +OpFunctionEnd +)"; +constexpr char kDst[] = R"(OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %63 "main" %4 %22 +OpExecutionMode %63 OriginUpperLeft +OpSource GLSL 450 +OpName %4 "_ue" +OpName %8 "_uf" +OpName %11 "_ug" +OpName %12 "_uA" +OpMemberName %12 0 "_ux" +OpName %14 "_uc" +OpName %15 "_uB" +OpMemberName %15 0 "_ux" +OpName %20 "_ud" +OpName %22 "_ucol" +OpName %26 "ANGLEDepthRangeParams" +OpMemberName %26 0 "near" +OpMemberName %26 1 "far" +OpMemberName %26 2 "diff" +OpMemberName %26 3 "reserved" +OpName %27 "ANGLEUniformBlock" +OpMemberName %27 0 "viewport" +OpMemberName %27 1 "clipDistancesEnabled" +OpMemberName %27 2 "xfbActiveUnpaused" +OpMemberName %27 3 "xfbVerticesPerInstance" +OpMemberName %27 4 "numSamples" +OpMemberName %27 5 "xfbBufferOffsets" +OpMemberName %27 6 "acbBufferOffsets" +OpMemberName %27 7 "depthRange" +OpName %29 "ANGLEUniforms" +OpName %33 "_uc" +OpName %32 "_uh" +OpName %49 "_ux" +OpName %50 "_uy" +OpName %48 "_ui" +OpName %63 "main" +OpName %65 "param" +OpName %68 "param" +OpName %73 "param" +OpDecorate %4 Location 1 +OpDecorate %8 RelaxedPrecision +OpDecorate %8 DescriptorSet 2 +OpDecorate %8 Binding 0 +OpDecorate %11 DescriptorSet 3 +OpDecorate %11 Binding 0 +OpMemberDecorate %12 0 Offset 0 +OpMemberDecorate %12 0 RelaxedPrecision +OpDecorate %12 Block +OpDecorate %14 DescriptorSet 3 +OpDecorate %14 Binding 1 +OpMemberDecorate %15 0 Offset 0 +OpMemberDecorate %15 0 RelaxedPrecision +OpDecorate %15 BufferBlock +OpDecorate %20 DescriptorSet 3 +OpDecorate %20 Binding 2 +OpDecorate %22 RelaxedPrecision +OpDecorate %22 Location 1 +OpMemberDecorate %26 0 Offset 0 +OpMemberDecorate %26 1 Offset 4 +OpMemberDecorate %26 2 Offset 8 +OpMemberDecorate %26 3 Offset 12 +OpMemberDecorate %27 0 Offset 0 +OpMemberDecorate %27 1 Offset 16 +OpMemberDecorate %27 2 Offset 20 +OpMemberDecorate %27 3 Offset 24 +OpMemberDecorate %27 4 Offset 28 +OpMemberDecorate %27 5 Offset 32 +OpMemberDecorate %27 6 Offset 48 +OpMemberDecorate %27 7 Offset 64 +OpMemberDecorate %27 2 RelaxedPrecision +OpMemberDecorate %27 4 RelaxedPrecision +OpDecorate %27 Block +OpDecorate %29 DescriptorSet 0 +OpDecorate %29 Binding 0 +OpDecorate %32 RelaxedPrecision +OpDecorate %33 RelaxedPrecision +OpDecorate %36 RelaxedPrecision +OpDecorate %37 RelaxedPrecision +OpDecorate %38 RelaxedPrecision +OpDecorate %39 RelaxedPrecision +OpDecorate %41 RelaxedPrecision +OpDecorate %42 RelaxedPrecision +OpDecorate %43 RelaxedPrecision +OpDecorate %48 RelaxedPrecision +OpDecorate %49 RelaxedPrecision +OpDecorate %50 RelaxedPrecision +OpDecorate %52 RelaxedPrecision +OpDecorate %53 RelaxedPrecision +OpDecorate %54 RelaxedPrecision +OpDecorate %55 RelaxedPrecision +OpDecorate %56 RelaxedPrecision +OpDecorate %57 RelaxedPrecision +OpDecorate %58 RelaxedPrecision +OpDecorate %59 RelaxedPrecision +OpDecorate %60 RelaxedPrecision +OpDecorate %67 RelaxedPrecision +OpDecorate %68 RelaxedPrecision +OpDecorate %72 RelaxedPrecision +OpDecorate %73 RelaxedPrecision +OpDecorate %75 RelaxedPrecision +OpDecorate %76 RelaxedPrecision +OpDecorate %77 RelaxedPrecision +OpDecorate %80 RelaxedPrecision +OpDecorate %81 RelaxedPrecision +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeImage %1 2D 0 0 0 1 Unknown +%6 = OpTypeSampledImage %5 +%9 = OpTypeImage %1 2D 0 0 0 2 Rgba8 +%12 = OpTypeStruct %2 +%15 = OpTypeStruct %2 +%16 = OpTypeInt 32 0 +%17 = OpConstant %16 2 +%18 = OpTypeArray %15 %17 +%23 = OpTypeInt 32 1 +%24 = OpTypeVector %23 4 +%25 = OpTypeVector %16 4 +%26 = OpTypeStruct %1 %1 %1 %1 +%27 = OpTypeStruct %2 %16 %16 %23 %23 %24 %25 %26 +%35 = OpTypeVector %1 2 +%40 = OpTypeVector %23 2 +%61 = OpTypeVoid +%69 = OpConstant %16 0 +%78 = OpConstant %16 1 +%82 = OpTypePointer Private %2 +%3 = OpTypePointer Input %2 +%7 = OpTypePointer UniformConstant %6 +%10 = OpTypePointer UniformConstant %9 +%13 = OpTypePointer Uniform %12 +%19 = OpTypePointer Uniform %18 +%83 = OpTypePointer Private %2 +%21 = OpTypePointer Output %2 +%28 = OpTypePointer Uniform %27 +%30 = OpTypePointer Function %2 +%70 = OpTypePointer Uniform %2 +%31 = OpTypeFunction %2 %30 +%47 = OpTypeFunction %2 %30 %30 +%62 = OpTypeFunction %61 +%4 = OpVariable %3 Input +%8 = OpVariable %7 UniformConstant +%11 = OpVariable %10 UniformConstant +%14 = OpVariable %13 Uniform +%20 = OpVariable %19 Uniform +%22 = OpVariable %21 Output +%29 = OpVariable %28 Uniform +%84 = OpConstant %23 0 +%85 = OpConstant %1 0.5 +%32 = OpFunction %2 None %31 +%33 = OpFunctionParameter %30 +%34 = OpLabel +%36 = OpLoad %6 %8 +%37 = OpLoad %2 %33 +%38 = OpVectorShuffle %35 %37 %37 0 1 +%39 = OpImageSampleImplicitLod %2 %36 %38 +%41 = OpLoad %2 %33 +%42 = OpVectorShuffle %35 %41 %41 2 3 +%43 = OpConvertFToS %40 %42 +%44 = OpLoad %9 %11 +%45 = OpImageRead %2 %44 %43 +%46 = OpFAdd %2 %39 %45 +OpReturnValue %46 +OpFunctionEnd +%48 = OpFunction %2 None %47 +%49 = OpFunctionParameter %30 +%50 = OpFunctionParameter %30 +%51 = OpLabel +%52 = OpLoad %2 %49 +%53 = OpVectorShuffle %35 %52 %52 0 1 +%54 = OpLoad %2 %50 +%55 = OpVectorShuffle %35 %54 %54 2 3 +%56 = OpCompositeExtract %1 %53 0 +%57 = OpCompositeExtract %1 %53 1 +%58 = OpCompositeExtract %1 %55 0 +%59 = OpCompositeExtract %1 %55 1 +%60 = OpCompositeConstruct %2 %56 %57 %58 %59 +OpReturnValue %60 +OpFunctionEnd +%63 = OpFunction %61 None %62 +%64 = OpLabel +%65 = OpVariable %30 Function +%68 = OpVariable %30 Function +%73 = OpVariable %30 Function +%66 = OpLoad %2 %4 +OpStore %65 %66 +%67 = OpFunctionCall %2 %32 %65 +%71 = OpAccessChain %70 %14 %69 +%72 = OpLoad %2 %71 +OpStore %68 %72 +%74 = OpAccessChain %70 %20 %69 %69 +%75 = OpLoad %2 %74 +OpStore %73 %75 +%76 = OpFunctionCall %2 %48 %68 %73 +%77 = OpFAdd %2 %67 %76 +%79 = OpAccessChain %70 %20 %78 %69 +%80 = OpLoad %2 %79 +%81 = OpFAdd %2 %77 %80 +OpStore %22 %81 +OpReturn +OpFunctionEnd +)"; + +TEST(DiffTest, DifferentDecorationsFragment) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 82 ++; Bound: 86 + ; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %63 "main" %4 %22 + OpExecutionMode %63 OriginUpperLeft + OpSource GLSL 450 + OpName %4 "_ue" + OpName %8 "_uf" + OpName %11 "_ug" + OpName %12 "_uA" + OpMemberName %12 0 "_ux" + OpName %14 "_uc" + OpName %15 "_uB" + OpMemberName %15 0 "_ux" + OpName %20 "_ud" + OpName %22 "_ucol" + OpName %26 "ANGLEDepthRangeParams" + OpMemberName %26 0 "near" + OpMemberName %26 1 "far" + OpMemberName %26 2 "diff" + OpMemberName %26 3 "reserved" + OpName %27 "ANGLEUniformBlock" + OpMemberName %27 0 "viewport" + OpMemberName %27 1 "clipDistancesEnabled" + OpMemberName %27 2 "xfbActiveUnpaused" + OpMemberName %27 3 "xfbVerticesPerInstance" + OpMemberName %27 4 "numSamples" + OpMemberName %27 5 "xfbBufferOffsets" + OpMemberName %27 6 "acbBufferOffsets" + OpMemberName %27 7 "depthRange" + OpName %29 "ANGLEUniforms" + OpName %33 "_uc" + OpName %32 "_uh" + OpName %49 "_ux" + OpName %50 "_uy" + OpName %48 "_ui" + OpName %63 "main" + OpName %65 "param" + OpName %68 "param" + OpName %73 "param" +-OpDecorate %4 Location 0 ++OpDecorate %4 Location 1 + OpDecorate %8 RelaxedPrecision +-OpDecorate %8 DescriptorSet 0 ++OpDecorate %8 DescriptorSet 2 + OpDecorate %8 Binding 0 +-OpDecorate %11 DescriptorSet 0 ++OpDecorate %11 DescriptorSet 3 +-OpDecorate %11 Binding 1 ++OpDecorate %11 Binding 0 + OpMemberDecorate %12 0 Offset 0 + OpMemberDecorate %12 0 RelaxedPrecision + OpDecorate %12 Block +-OpDecorate %14 DescriptorSet 0 ++OpDecorate %14 DescriptorSet 3 +-OpDecorate %14 Binding 2 ++OpDecorate %14 Binding 1 + OpMemberDecorate %15 0 Offset 0 + OpMemberDecorate %15 0 RelaxedPrecision + OpDecorate %15 BufferBlock +-OpDecorate %20 DescriptorSet 0 ++OpDecorate %20 DescriptorSet 3 +-OpDecorate %20 Binding 3 ++OpDecorate %20 Binding 2 + OpDecorate %22 RelaxedPrecision +-OpDecorate %22 Location 0 ++OpDecorate %22 Location 1 + OpMemberDecorate %26 0 Offset 0 + OpMemberDecorate %26 1 Offset 4 + OpMemberDecorate %26 2 Offset 8 + OpMemberDecorate %26 3 Offset 12 + OpMemberDecorate %27 0 Offset 0 + OpMemberDecorate %27 1 Offset 16 + OpMemberDecorate %27 2 Offset 20 + OpMemberDecorate %27 3 Offset 24 + OpMemberDecorate %27 4 Offset 28 + OpMemberDecorate %27 5 Offset 32 + OpMemberDecorate %27 6 Offset 48 + OpMemberDecorate %27 7 Offset 64 + OpMemberDecorate %27 2 RelaxedPrecision + OpMemberDecorate %27 4 RelaxedPrecision + OpDecorate %27 Block + OpDecorate %29 DescriptorSet 0 +-OpDecorate %29 Binding 4 ++OpDecorate %29 Binding 0 + OpDecorate %32 RelaxedPrecision + OpDecorate %33 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %38 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %43 RelaxedPrecision + OpDecorate %48 RelaxedPrecision + OpDecorate %49 RelaxedPrecision + OpDecorate %50 RelaxedPrecision + OpDecorate %52 RelaxedPrecision + OpDecorate %53 RelaxedPrecision + OpDecorate %54 RelaxedPrecision + OpDecorate %55 RelaxedPrecision + OpDecorate %56 RelaxedPrecision + OpDecorate %57 RelaxedPrecision + OpDecorate %58 RelaxedPrecision + OpDecorate %59 RelaxedPrecision + OpDecorate %60 RelaxedPrecision + OpDecorate %67 RelaxedPrecision + OpDecorate %68 RelaxedPrecision + OpDecorate %72 RelaxedPrecision + OpDecorate %73 RelaxedPrecision + OpDecorate %75 RelaxedPrecision + OpDecorate %76 RelaxedPrecision + OpDecorate %77 RelaxedPrecision + OpDecorate %80 RelaxedPrecision + OpDecorate %81 RelaxedPrecision + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %5 = OpTypeImage %1 2D 0 0 0 1 Unknown + %6 = OpTypeSampledImage %5 + %9 = OpTypeImage %1 2D 0 0 0 2 Rgba8 + %12 = OpTypeStruct %2 + %15 = OpTypeStruct %2 + %16 = OpTypeInt 32 0 + %17 = OpConstant %16 2 + %18 = OpTypeArray %15 %17 + %23 = OpTypeInt 32 1 + %24 = OpTypeVector %23 4 + %25 = OpTypeVector %16 4 + %26 = OpTypeStruct %1 %1 %1 %1 + %27 = OpTypeStruct %2 %16 %16 %23 %23 %24 %25 %26 + %35 = OpTypeVector %1 2 + %40 = OpTypeVector %23 2 + %61 = OpTypeVoid + %69 = OpConstant %16 0 + %78 = OpConstant %16 1 ++%82 = OpTypePointer Private %2 + %3 = OpTypePointer Input %2 + %7 = OpTypePointer UniformConstant %6 + %10 = OpTypePointer UniformConstant %9 + %13 = OpTypePointer Uniform %12 + %19 = OpTypePointer Uniform %18 ++%83 = OpTypePointer Private %2 + %21 = OpTypePointer Output %2 + %28 = OpTypePointer Uniform %27 + %30 = OpTypePointer Function %2 + %70 = OpTypePointer Uniform %2 + %31 = OpTypeFunction %2 %30 + %47 = OpTypeFunction %2 %30 %30 + %62 = OpTypeFunction %61 + %4 = OpVariable %3 Input + %8 = OpVariable %7 UniformConstant + %11 = OpVariable %10 UniformConstant + %14 = OpVariable %13 Uniform + %20 = OpVariable %19 Uniform + %22 = OpVariable %21 Output + %29 = OpVariable %28 Uniform ++%84 = OpConstant %23 0 ++%85 = OpConstant %1 0.5 + %32 = OpFunction %2 None %31 + %33 = OpFunctionParameter %30 + %34 = OpLabel + %36 = OpLoad %6 %8 + %37 = OpLoad %2 %33 + %38 = OpVectorShuffle %35 %37 %37 0 1 + %39 = OpImageSampleImplicitLod %2 %36 %38 + %41 = OpLoad %2 %33 + %42 = OpVectorShuffle %35 %41 %41 2 3 + %43 = OpConvertFToS %40 %42 + %44 = OpLoad %9 %11 + %45 = OpImageRead %2 %44 %43 + %46 = OpFAdd %2 %39 %45 + OpReturnValue %46 + OpFunctionEnd + %48 = OpFunction %2 None %47 + %49 = OpFunctionParameter %30 + %50 = OpFunctionParameter %30 + %51 = OpLabel + %52 = OpLoad %2 %49 + %53 = OpVectorShuffle %35 %52 %52 0 1 + %54 = OpLoad %2 %50 + %55 = OpVectorShuffle %35 %54 %54 2 3 + %56 = OpCompositeExtract %1 %53 0 + %57 = OpCompositeExtract %1 %53 1 + %58 = OpCompositeExtract %1 %55 0 + %59 = OpCompositeExtract %1 %55 1 + %60 = OpCompositeConstruct %2 %56 %57 %58 %59 + OpReturnValue %60 + OpFunctionEnd + %63 = OpFunction %61 None %62 + %64 = OpLabel + %65 = OpVariable %30 Function + %68 = OpVariable %30 Function + %73 = OpVariable %30 Function + %66 = OpLoad %2 %4 + OpStore %65 %66 + %67 = OpFunctionCall %2 %32 %65 + %71 = OpAccessChain %70 %14 %69 + %72 = OpLoad %2 %71 + OpStore %68 %72 + %74 = OpAccessChain %70 %20 %69 %69 + %75 = OpLoad %2 %74 + OpStore %73 %75 + %76 = OpFunctionCall %2 %48 %68 %73 + %77 = OpFAdd %2 %67 %76 + %79 = OpAccessChain %70 %20 %78 %69 + %80 = OpLoad %2 %79 + %81 = OpFAdd %2 %77 %80 + OpStore %22 %81 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, DifferentDecorationsFragmentNoDebug) { + constexpr char kSrcNoDebug[] = R"(OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %63 "main" %4 %22 +OpExecutionMode %63 OriginUpperLeft +OpSource GLSL 450 +OpDecorate %4 Location 0 +OpDecorate %8 RelaxedPrecision +OpDecorate %8 DescriptorSet 0 +OpDecorate %8 Binding 0 +OpDecorate %11 DescriptorSet 0 +OpDecorate %11 Binding 1 +OpMemberDecorate %12 0 Offset 0 +OpMemberDecorate %12 0 RelaxedPrecision +OpDecorate %12 Block +OpDecorate %14 DescriptorSet 0 +OpDecorate %14 Binding 2 +OpMemberDecorate %15 0 Offset 0 +OpMemberDecorate %15 0 RelaxedPrecision +OpDecorate %15 BufferBlock +OpDecorate %20 DescriptorSet 0 +OpDecorate %20 Binding 3 +OpDecorate %22 RelaxedPrecision +OpDecorate %22 Location 0 +OpMemberDecorate %26 0 Offset 0 +OpMemberDecorate %26 1 Offset 4 +OpMemberDecorate %26 2 Offset 8 +OpMemberDecorate %26 3 Offset 12 +OpMemberDecorate %27 0 Offset 0 +OpMemberDecorate %27 1 Offset 16 +OpMemberDecorate %27 2 Offset 20 +OpMemberDecorate %27 3 Offset 24 +OpMemberDecorate %27 4 Offset 28 +OpMemberDecorate %27 5 Offset 32 +OpMemberDecorate %27 6 Offset 48 +OpMemberDecorate %27 7 Offset 64 +OpMemberDecorate %27 2 RelaxedPrecision +OpMemberDecorate %27 4 RelaxedPrecision +OpDecorate %27 Block +OpDecorate %29 DescriptorSet 0 +OpDecorate %29 Binding 4 +OpDecorate %32 RelaxedPrecision +OpDecorate %33 RelaxedPrecision +OpDecorate %36 RelaxedPrecision +OpDecorate %37 RelaxedPrecision +OpDecorate %38 RelaxedPrecision +OpDecorate %39 RelaxedPrecision +OpDecorate %41 RelaxedPrecision +OpDecorate %42 RelaxedPrecision +OpDecorate %43 RelaxedPrecision +OpDecorate %48 RelaxedPrecision +OpDecorate %49 RelaxedPrecision +OpDecorate %50 RelaxedPrecision +OpDecorate %52 RelaxedPrecision +OpDecorate %53 RelaxedPrecision +OpDecorate %54 RelaxedPrecision +OpDecorate %55 RelaxedPrecision +OpDecorate %56 RelaxedPrecision +OpDecorate %57 RelaxedPrecision +OpDecorate %58 RelaxedPrecision +OpDecorate %59 RelaxedPrecision +OpDecorate %60 RelaxedPrecision +OpDecorate %67 RelaxedPrecision +OpDecorate %68 RelaxedPrecision +OpDecorate %72 RelaxedPrecision +OpDecorate %73 RelaxedPrecision +OpDecorate %75 RelaxedPrecision +OpDecorate %76 RelaxedPrecision +OpDecorate %77 RelaxedPrecision +OpDecorate %80 RelaxedPrecision +OpDecorate %81 RelaxedPrecision +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeImage %1 2D 0 0 0 1 Unknown +%6 = OpTypeSampledImage %5 +%9 = OpTypeImage %1 2D 0 0 0 2 Rgba8 +%12 = OpTypeStruct %2 +%15 = OpTypeStruct %2 +%16 = OpTypeInt 32 0 +%17 = OpConstant %16 2 +%18 = OpTypeArray %15 %17 +%23 = OpTypeInt 32 1 +%24 = OpTypeVector %23 4 +%25 = OpTypeVector %16 4 +%26 = OpTypeStruct %1 %1 %1 %1 +%27 = OpTypeStruct %2 %16 %16 %23 %23 %24 %25 %26 +%35 = OpTypeVector %1 2 +%40 = OpTypeVector %23 2 +%61 = OpTypeVoid +%69 = OpConstant %16 0 +%78 = OpConstant %16 1 +%3 = OpTypePointer Input %2 +%7 = OpTypePointer UniformConstant %6 +%10 = OpTypePointer UniformConstant %9 +%13 = OpTypePointer Uniform %12 +%19 = OpTypePointer Uniform %18 +%21 = OpTypePointer Output %2 +%28 = OpTypePointer Uniform %27 +%30 = OpTypePointer Function %2 +%70 = OpTypePointer Uniform %2 +%31 = OpTypeFunction %2 %30 +%47 = OpTypeFunction %2 %30 %30 +%62 = OpTypeFunction %61 +%4 = OpVariable %3 Input +%8 = OpVariable %7 UniformConstant +%11 = OpVariable %10 UniformConstant +%14 = OpVariable %13 Uniform +%20 = OpVariable %19 Uniform +%22 = OpVariable %21 Output +%29 = OpVariable %28 Uniform +%32 = OpFunction %2 None %31 +%33 = OpFunctionParameter %30 +%34 = OpLabel +%36 = OpLoad %6 %8 +%37 = OpLoad %2 %33 +%38 = OpVectorShuffle %35 %37 %37 0 1 +%39 = OpImageSampleImplicitLod %2 %36 %38 +%41 = OpLoad %2 %33 +%42 = OpVectorShuffle %35 %41 %41 2 3 +%43 = OpConvertFToS %40 %42 +%44 = OpLoad %9 %11 +%45 = OpImageRead %2 %44 %43 +%46 = OpFAdd %2 %39 %45 +OpReturnValue %46 +OpFunctionEnd +%48 = OpFunction %2 None %47 +%49 = OpFunctionParameter %30 +%50 = OpFunctionParameter %30 +%51 = OpLabel +%52 = OpLoad %2 %49 +%53 = OpVectorShuffle %35 %52 %52 0 1 +%54 = OpLoad %2 %50 +%55 = OpVectorShuffle %35 %54 %54 2 3 +%56 = OpCompositeExtract %1 %53 0 +%57 = OpCompositeExtract %1 %53 1 +%58 = OpCompositeExtract %1 %55 0 +%59 = OpCompositeExtract %1 %55 1 +%60 = OpCompositeConstruct %2 %56 %57 %58 %59 +OpReturnValue %60 +OpFunctionEnd +%63 = OpFunction %61 None %62 +%64 = OpLabel +%65 = OpVariable %30 Function +%68 = OpVariable %30 Function +%73 = OpVariable %30 Function +%66 = OpLoad %2 %4 +OpStore %65 %66 +%67 = OpFunctionCall %2 %32 %65 +%71 = OpAccessChain %70 %14 %69 +%72 = OpLoad %2 %71 +OpStore %68 %72 +%74 = OpAccessChain %70 %20 %69 %69 +%75 = OpLoad %2 %74 +OpStore %73 %75 +%76 = OpFunctionCall %2 %48 %68 %73 +%77 = OpFAdd %2 %67 %76 +%79 = OpAccessChain %70 %20 %78 %69 +%80 = OpLoad %2 %79 +%81 = OpFAdd %2 %77 %80 +OpStore %22 %81 +OpReturn +OpFunctionEnd + +)"; + constexpr char kDstNoDebug[] = R"(OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %63 "main" %4 %22 +OpExecutionMode %63 OriginUpperLeft +OpSource GLSL 450 +OpDecorate %4 Location 1 +OpDecorate %8 RelaxedPrecision +OpDecorate %8 DescriptorSet 2 +OpDecorate %8 Binding 0 +OpDecorate %11 DescriptorSet 3 +OpDecorate %11 Binding 0 +OpMemberDecorate %12 0 Offset 0 +OpMemberDecorate %12 0 RelaxedPrecision +OpDecorate %12 Block +OpDecorate %14 DescriptorSet 3 +OpDecorate %14 Binding 1 +OpMemberDecorate %15 0 Offset 0 +OpMemberDecorate %15 0 RelaxedPrecision +OpDecorate %15 BufferBlock +OpDecorate %20 DescriptorSet 3 +OpDecorate %20 Binding 2 +OpDecorate %22 RelaxedPrecision +OpDecorate %22 Location 1 +OpMemberDecorate %26 0 Offset 0 +OpMemberDecorate %26 1 Offset 4 +OpMemberDecorate %26 2 Offset 8 +OpMemberDecorate %26 3 Offset 12 +OpMemberDecorate %27 0 Offset 0 +OpMemberDecorate %27 1 Offset 16 +OpMemberDecorate %27 2 Offset 20 +OpMemberDecorate %27 3 Offset 24 +OpMemberDecorate %27 4 Offset 28 +OpMemberDecorate %27 5 Offset 32 +OpMemberDecorate %27 6 Offset 48 +OpMemberDecorate %27 7 Offset 64 +OpMemberDecorate %27 2 RelaxedPrecision +OpMemberDecorate %27 4 RelaxedPrecision +OpDecorate %27 Block +OpDecorate %29 DescriptorSet 0 +OpDecorate %29 Binding 0 +OpDecorate %32 RelaxedPrecision +OpDecorate %33 RelaxedPrecision +OpDecorate %36 RelaxedPrecision +OpDecorate %37 RelaxedPrecision +OpDecorate %38 RelaxedPrecision +OpDecorate %39 RelaxedPrecision +OpDecorate %41 RelaxedPrecision +OpDecorate %42 RelaxedPrecision +OpDecorate %43 RelaxedPrecision +OpDecorate %48 RelaxedPrecision +OpDecorate %49 RelaxedPrecision +OpDecorate %50 RelaxedPrecision +OpDecorate %52 RelaxedPrecision +OpDecorate %53 RelaxedPrecision +OpDecorate %54 RelaxedPrecision +OpDecorate %55 RelaxedPrecision +OpDecorate %56 RelaxedPrecision +OpDecorate %57 RelaxedPrecision +OpDecorate %58 RelaxedPrecision +OpDecorate %59 RelaxedPrecision +OpDecorate %60 RelaxedPrecision +OpDecorate %67 RelaxedPrecision +OpDecorate %68 RelaxedPrecision +OpDecorate %72 RelaxedPrecision +OpDecorate %73 RelaxedPrecision +OpDecorate %75 RelaxedPrecision +OpDecorate %76 RelaxedPrecision +OpDecorate %77 RelaxedPrecision +OpDecorate %80 RelaxedPrecision +OpDecorate %81 RelaxedPrecision +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeImage %1 2D 0 0 0 1 Unknown +%6 = OpTypeSampledImage %5 +%9 = OpTypeImage %1 2D 0 0 0 2 Rgba8 +%12 = OpTypeStruct %2 +%15 = OpTypeStruct %2 +%16 = OpTypeInt 32 0 +%17 = OpConstant %16 2 +%18 = OpTypeArray %15 %17 +%23 = OpTypeInt 32 1 +%24 = OpTypeVector %23 4 +%25 = OpTypeVector %16 4 +%26 = OpTypeStruct %1 %1 %1 %1 +%27 = OpTypeStruct %2 %16 %16 %23 %23 %24 %25 %26 +%35 = OpTypeVector %1 2 +%40 = OpTypeVector %23 2 +%61 = OpTypeVoid +%69 = OpConstant %16 0 +%78 = OpConstant %16 1 +%82 = OpTypePointer Private %2 +%3 = OpTypePointer Input %2 +%7 = OpTypePointer UniformConstant %6 +%10 = OpTypePointer UniformConstant %9 +%13 = OpTypePointer Uniform %12 +%19 = OpTypePointer Uniform %18 +%83 = OpTypePointer Private %2 +%21 = OpTypePointer Output %2 +%28 = OpTypePointer Uniform %27 +%30 = OpTypePointer Function %2 +%70 = OpTypePointer Uniform %2 +%31 = OpTypeFunction %2 %30 +%47 = OpTypeFunction %2 %30 %30 +%62 = OpTypeFunction %61 +%4 = OpVariable %3 Input +%8 = OpVariable %7 UniformConstant +%11 = OpVariable %10 UniformConstant +%14 = OpVariable %13 Uniform +%20 = OpVariable %19 Uniform +%22 = OpVariable %21 Output +%29 = OpVariable %28 Uniform +%84 = OpConstant %23 0 +%85 = OpConstant %1 0.5 +%32 = OpFunction %2 None %31 +%33 = OpFunctionParameter %30 +%34 = OpLabel +%36 = OpLoad %6 %8 +%37 = OpLoad %2 %33 +%38 = OpVectorShuffle %35 %37 %37 0 1 +%39 = OpImageSampleImplicitLod %2 %36 %38 +%41 = OpLoad %2 %33 +%42 = OpVectorShuffle %35 %41 %41 2 3 +%43 = OpConvertFToS %40 %42 +%44 = OpLoad %9 %11 +%45 = OpImageRead %2 %44 %43 +%46 = OpFAdd %2 %39 %45 +OpReturnValue %46 +OpFunctionEnd +%48 = OpFunction %2 None %47 +%49 = OpFunctionParameter %30 +%50 = OpFunctionParameter %30 +%51 = OpLabel +%52 = OpLoad %2 %49 +%53 = OpVectorShuffle %35 %52 %52 0 1 +%54 = OpLoad %2 %50 +%55 = OpVectorShuffle %35 %54 %54 2 3 +%56 = OpCompositeExtract %1 %53 0 +%57 = OpCompositeExtract %1 %53 1 +%58 = OpCompositeExtract %1 %55 0 +%59 = OpCompositeExtract %1 %55 1 +%60 = OpCompositeConstruct %2 %56 %57 %58 %59 +OpReturnValue %60 +OpFunctionEnd +%63 = OpFunction %61 None %62 +%64 = OpLabel +%65 = OpVariable %30 Function +%68 = OpVariable %30 Function +%73 = OpVariable %30 Function +%66 = OpLoad %2 %4 +OpStore %65 %66 +%67 = OpFunctionCall %2 %32 %65 +%71 = OpAccessChain %70 %14 %69 +%72 = OpLoad %2 %71 +OpStore %68 %72 +%74 = OpAccessChain %70 %20 %69 %69 +%75 = OpLoad %2 %74 +OpStore %73 %75 +%76 = OpFunctionCall %2 %48 %68 %73 +%77 = OpFAdd %2 %67 %76 +%79 = OpAccessChain %70 %20 %78 %69 +%80 = OpLoad %2 %79 +%81 = OpFAdd %2 %77 %80 +OpStore %22 %81 +OpReturn +OpFunctionEnd +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 82 ++; Bound: 92 + ; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %63 "main" %4 %22 + OpExecutionMode %63 OriginUpperLeft + OpSource GLSL 450 +-OpDecorate %4 Location 0 ++OpDecorate %4 Location 1 + OpDecorate %8 RelaxedPrecision +-OpDecorate %8 DescriptorSet 0 ++OpDecorate %8 DescriptorSet 2 + OpDecorate %8 Binding 0 +-OpDecorate %11 DescriptorSet 0 ++OpDecorate %11 DescriptorSet 3 +-OpDecorate %11 Binding 1 ++OpDecorate %11 Binding 0 + OpMemberDecorate %12 0 Offset 0 + OpMemberDecorate %12 0 RelaxedPrecision + OpDecorate %12 Block ++OpDecorate %82 DescriptorSet 3 ++OpDecorate %82 Binding 1 +-OpDecorate %14 DescriptorSet 0 ++OpDecorate %14 DescriptorSet 3 + OpDecorate %14 Binding 2 + OpMemberDecorate %15 0 Offset 0 + OpMemberDecorate %15 0 RelaxedPrecision + OpDecorate %15 BufferBlock +-OpDecorate %20 DescriptorSet 0 +-OpDecorate %20 Binding 3 + OpDecorate %22 RelaxedPrecision +-OpDecorate %22 Location 0 ++OpDecorate %22 Location 1 + OpMemberDecorate %26 0 Offset 0 + OpMemberDecorate %26 1 Offset 4 + OpMemberDecorate %26 2 Offset 8 + OpMemberDecorate %26 3 Offset 12 + OpMemberDecorate %27 0 Offset 0 + OpMemberDecorate %27 1 Offset 16 + OpMemberDecorate %27 2 Offset 20 + OpMemberDecorate %27 3 Offset 24 + OpMemberDecorate %27 4 Offset 28 + OpMemberDecorate %27 5 Offset 32 + OpMemberDecorate %27 6 Offset 48 + OpMemberDecorate %27 7 Offset 64 + OpMemberDecorate %27 2 RelaxedPrecision + OpMemberDecorate %27 4 RelaxedPrecision + OpDecorate %27 Block +-OpDecorate %29 DescriptorSet 0 +-OpDecorate %29 Binding 4 ++OpDecorate %83 DescriptorSet 0 ++OpDecorate %83 Binding 0 + OpDecorate %32 RelaxedPrecision +-OpDecorate %33 RelaxedPrecision ++OpDecorate %84 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %38 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %43 RelaxedPrecision + OpDecorate %48 RelaxedPrecision +-OpDecorate %49 RelaxedPrecision +-OpDecorate %50 RelaxedPrecision ++OpDecorate %85 RelaxedPrecision ++OpDecorate %86 RelaxedPrecision + OpDecorate %52 RelaxedPrecision + OpDecorate %53 RelaxedPrecision + OpDecorate %54 RelaxedPrecision + OpDecorate %55 RelaxedPrecision + OpDecorate %56 RelaxedPrecision + OpDecorate %57 RelaxedPrecision + OpDecorate %58 RelaxedPrecision + OpDecorate %59 RelaxedPrecision + OpDecorate %60 RelaxedPrecision + OpDecorate %67 RelaxedPrecision + OpDecorate %68 RelaxedPrecision + OpDecorate %72 RelaxedPrecision + OpDecorate %73 RelaxedPrecision + OpDecorate %75 RelaxedPrecision + OpDecorate %76 RelaxedPrecision + OpDecorate %77 RelaxedPrecision + OpDecorate %80 RelaxedPrecision + OpDecorate %81 RelaxedPrecision + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %5 = OpTypeImage %1 2D 0 0 0 1 Unknown + %6 = OpTypeSampledImage %5 + %9 = OpTypeImage %1 2D 0 0 0 2 Rgba8 + %12 = OpTypeStruct %2 + %15 = OpTypeStruct %2 + %16 = OpTypeInt 32 0 + %17 = OpConstant %16 2 + %18 = OpTypeArray %15 %17 + %23 = OpTypeInt 32 1 + %24 = OpTypeVector %23 4 + %25 = OpTypeVector %16 4 + %26 = OpTypeStruct %1 %1 %1 %1 + %27 = OpTypeStruct %2 %16 %16 %23 %23 %24 %25 %26 + %35 = OpTypeVector %1 2 + %40 = OpTypeVector %23 2 + %61 = OpTypeVoid + %69 = OpConstant %16 0 + %78 = OpConstant %16 1 ++%88 = OpTypePointer Private %2 + %3 = OpTypePointer Input %2 + %7 = OpTypePointer UniformConstant %6 + %10 = OpTypePointer UniformConstant %9 + %13 = OpTypePointer Uniform %12 + %19 = OpTypePointer Uniform %18 ++%89 = OpTypePointer Private %2 + %21 = OpTypePointer Output %2 + %28 = OpTypePointer Uniform %27 + %30 = OpTypePointer Function %2 + %70 = OpTypePointer Uniform %2 + %31 = OpTypeFunction %2 %30 + %47 = OpTypeFunction %2 %30 %30 + %62 = OpTypeFunction %61 + %4 = OpVariable %3 Input + %8 = OpVariable %7 UniformConstant + %11 = OpVariable %10 UniformConstant ++%82 = OpVariable %13 Uniform +-%14 = OpVariable %13 Uniform ++%14 = OpVariable %19 Uniform +-%20 = OpVariable %19 Uniform + %22 = OpVariable %21 Output +-%29 = OpVariable %28 Uniform ++%83 = OpVariable %28 Uniform ++%90 = OpConstant %23 0 ++%91 = OpConstant %1 0.5 + %32 = OpFunction %2 None %31 +-%33 = OpFunctionParameter %30 ++%84 = OpFunctionParameter %30 + %34 = OpLabel + %36 = OpLoad %6 %8 +-%37 = OpLoad %2 %33 ++%37 = OpLoad %2 %84 + %38 = OpVectorShuffle %35 %37 %37 0 1 + %39 = OpImageSampleImplicitLod %2 %36 %38 +-%41 = OpLoad %2 %33 ++%41 = OpLoad %2 %84 + %42 = OpVectorShuffle %35 %41 %41 2 3 + %43 = OpConvertFToS %40 %42 + %44 = OpLoad %9 %11 + %45 = OpImageRead %2 %44 %43 + %46 = OpFAdd %2 %39 %45 + OpReturnValue %46 + OpFunctionEnd + %48 = OpFunction %2 None %47 +-%49 = OpFunctionParameter %30 +-%50 = OpFunctionParameter %30 ++%85 = OpFunctionParameter %30 ++%86 = OpFunctionParameter %30 + %51 = OpLabel +-%52 = OpLoad %2 %49 ++%52 = OpLoad %2 %85 + %53 = OpVectorShuffle %35 %52 %52 0 1 +-%54 = OpLoad %2 %50 ++%54 = OpLoad %2 %86 + %55 = OpVectorShuffle %35 %54 %54 2 3 + %56 = OpCompositeExtract %1 %53 0 + %57 = OpCompositeExtract %1 %53 1 + %58 = OpCompositeExtract %1 %55 0 + %59 = OpCompositeExtract %1 %55 1 + %60 = OpCompositeConstruct %2 %56 %57 %58 %59 + OpReturnValue %60 + OpFunctionEnd + %63 = OpFunction %61 None %62 + %64 = OpLabel + %65 = OpVariable %30 Function + %68 = OpVariable %30 Function + %73 = OpVariable %30 Function + %66 = OpLoad %2 %4 + OpStore %65 %66 + %67 = OpFunctionCall %2 %32 %65 +-%71 = OpAccessChain %70 %14 %69 ++%87 = OpAccessChain %70 %82 %69 +-%72 = OpLoad %2 %71 ++%72 = OpLoad %2 %87 + OpStore %68 %72 +-%74 = OpAccessChain %70 %20 %69 %69 ++%74 = OpAccessChain %70 %14 %69 %69 + %75 = OpLoad %2 %74 + OpStore %73 %75 + %76 = OpFunctionCall %2 %48 %68 %73 + %77 = OpFAdd %2 %67 %76 +-%79 = OpAccessChain %70 %20 %78 %69 ++%79 = OpAccessChain %70 %14 %78 %69 + %80 = OpLoad %2 %79 + %81 = OpFAdd %2 %77 %80 + OpStore %22 %81 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +TEST(DiffTest, DifferentDecorationsFragmentIgnoreLocation) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 82 ++; Bound: 86 + ; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %63 "main" %4 %22 + OpExecutionMode %63 OriginUpperLeft + OpSource GLSL 450 + OpName %4 "_ue" + OpName %8 "_uf" + OpName %11 "_ug" + OpName %12 "_uA" + OpMemberName %12 0 "_ux" + OpName %14 "_uc" + OpName %15 "_uB" + OpMemberName %15 0 "_ux" + OpName %20 "_ud" + OpName %22 "_ucol" + OpName %26 "ANGLEDepthRangeParams" + OpMemberName %26 0 "near" + OpMemberName %26 1 "far" + OpMemberName %26 2 "diff" + OpMemberName %26 3 "reserved" + OpName %27 "ANGLEUniformBlock" + OpMemberName %27 0 "viewport" + OpMemberName %27 1 "clipDistancesEnabled" + OpMemberName %27 2 "xfbActiveUnpaused" + OpMemberName %27 3 "xfbVerticesPerInstance" + OpMemberName %27 4 "numSamples" + OpMemberName %27 5 "xfbBufferOffsets" + OpMemberName %27 6 "acbBufferOffsets" + OpMemberName %27 7 "depthRange" + OpName %29 "ANGLEUniforms" + OpName %33 "_uc" + OpName %32 "_uh" + OpName %49 "_ux" + OpName %50 "_uy" + OpName %48 "_ui" + OpName %63 "main" + OpName %65 "param" + OpName %68 "param" + OpName %73 "param" +-OpDecorate %4 Location 0 ++OpDecorate %4 Location 1 + OpDecorate %8 RelaxedPrecision +-OpDecorate %8 DescriptorSet 0 ++OpDecorate %8 DescriptorSet 2 + OpDecorate %8 Binding 0 +-OpDecorate %11 DescriptorSet 0 ++OpDecorate %11 DescriptorSet 3 +-OpDecorate %11 Binding 1 ++OpDecorate %11 Binding 0 + OpMemberDecorate %12 0 Offset 0 + OpMemberDecorate %12 0 RelaxedPrecision + OpDecorate %12 Block +-OpDecorate %14 DescriptorSet 0 ++OpDecorate %14 DescriptorSet 3 +-OpDecorate %14 Binding 2 ++OpDecorate %14 Binding 1 + OpMemberDecorate %15 0 Offset 0 + OpMemberDecorate %15 0 RelaxedPrecision + OpDecorate %15 BufferBlock +-OpDecorate %20 DescriptorSet 0 ++OpDecorate %20 DescriptorSet 3 +-OpDecorate %20 Binding 3 ++OpDecorate %20 Binding 2 + OpDecorate %22 RelaxedPrecision +-OpDecorate %22 Location 0 ++OpDecorate %22 Location 1 + OpMemberDecorate %26 0 Offset 0 + OpMemberDecorate %26 1 Offset 4 + OpMemberDecorate %26 2 Offset 8 + OpMemberDecorate %26 3 Offset 12 + OpMemberDecorate %27 0 Offset 0 + OpMemberDecorate %27 1 Offset 16 + OpMemberDecorate %27 2 Offset 20 + OpMemberDecorate %27 3 Offset 24 + OpMemberDecorate %27 4 Offset 28 + OpMemberDecorate %27 5 Offset 32 + OpMemberDecorate %27 6 Offset 48 + OpMemberDecorate %27 7 Offset 64 + OpMemberDecorate %27 2 RelaxedPrecision + OpMemberDecorate %27 4 RelaxedPrecision + OpDecorate %27 Block + OpDecorate %29 DescriptorSet 0 +-OpDecorate %29 Binding 4 ++OpDecorate %29 Binding 0 + OpDecorate %32 RelaxedPrecision + OpDecorate %33 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %38 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %43 RelaxedPrecision + OpDecorate %48 RelaxedPrecision + OpDecorate %49 RelaxedPrecision + OpDecorate %50 RelaxedPrecision + OpDecorate %52 RelaxedPrecision + OpDecorate %53 RelaxedPrecision + OpDecorate %54 RelaxedPrecision + OpDecorate %55 RelaxedPrecision + OpDecorate %56 RelaxedPrecision + OpDecorate %57 RelaxedPrecision + OpDecorate %58 RelaxedPrecision + OpDecorate %59 RelaxedPrecision + OpDecorate %60 RelaxedPrecision + OpDecorate %67 RelaxedPrecision + OpDecorate %68 RelaxedPrecision + OpDecorate %72 RelaxedPrecision + OpDecorate %73 RelaxedPrecision + OpDecorate %75 RelaxedPrecision + OpDecorate %76 RelaxedPrecision + OpDecorate %77 RelaxedPrecision + OpDecorate %80 RelaxedPrecision + OpDecorate %81 RelaxedPrecision + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %5 = OpTypeImage %1 2D 0 0 0 1 Unknown + %6 = OpTypeSampledImage %5 + %9 = OpTypeImage %1 2D 0 0 0 2 Rgba8 + %12 = OpTypeStruct %2 + %15 = OpTypeStruct %2 + %16 = OpTypeInt 32 0 + %17 = OpConstant %16 2 + %18 = OpTypeArray %15 %17 + %23 = OpTypeInt 32 1 + %24 = OpTypeVector %23 4 + %25 = OpTypeVector %16 4 + %26 = OpTypeStruct %1 %1 %1 %1 + %27 = OpTypeStruct %2 %16 %16 %23 %23 %24 %25 %26 + %35 = OpTypeVector %1 2 + %40 = OpTypeVector %23 2 + %61 = OpTypeVoid + %69 = OpConstant %16 0 + %78 = OpConstant %16 1 ++%82 = OpTypePointer Private %2 + %3 = OpTypePointer Input %2 + %7 = OpTypePointer UniformConstant %6 + %10 = OpTypePointer UniformConstant %9 + %13 = OpTypePointer Uniform %12 + %19 = OpTypePointer Uniform %18 ++%83 = OpTypePointer Private %2 + %21 = OpTypePointer Output %2 + %28 = OpTypePointer Uniform %27 + %30 = OpTypePointer Function %2 + %70 = OpTypePointer Uniform %2 + %31 = OpTypeFunction %2 %30 + %47 = OpTypeFunction %2 %30 %30 + %62 = OpTypeFunction %61 + %4 = OpVariable %3 Input + %8 = OpVariable %7 UniformConstant + %11 = OpVariable %10 UniformConstant + %14 = OpVariable %13 Uniform + %20 = OpVariable %19 Uniform + %22 = OpVariable %21 Output + %29 = OpVariable %28 Uniform ++%84 = OpConstant %23 0 ++%85 = OpConstant %1 0.5 + %32 = OpFunction %2 None %31 + %33 = OpFunctionParameter %30 + %34 = OpLabel + %36 = OpLoad %6 %8 + %37 = OpLoad %2 %33 + %38 = OpVectorShuffle %35 %37 %37 0 1 + %39 = OpImageSampleImplicitLod %2 %36 %38 + %41 = OpLoad %2 %33 + %42 = OpVectorShuffle %35 %41 %41 2 3 + %43 = OpConvertFToS %40 %42 + %44 = OpLoad %9 %11 + %45 = OpImageRead %2 %44 %43 + %46 = OpFAdd %2 %39 %45 + OpReturnValue %46 + OpFunctionEnd + %48 = OpFunction %2 None %47 + %49 = OpFunctionParameter %30 + %50 = OpFunctionParameter %30 + %51 = OpLabel + %52 = OpLoad %2 %49 + %53 = OpVectorShuffle %35 %52 %52 0 1 + %54 = OpLoad %2 %50 + %55 = OpVectorShuffle %35 %54 %54 2 3 + %56 = OpCompositeExtract %1 %53 0 + %57 = OpCompositeExtract %1 %53 1 + %58 = OpCompositeExtract %1 %55 0 + %59 = OpCompositeExtract %1 %55 1 + %60 = OpCompositeConstruct %2 %56 %57 %58 %59 + OpReturnValue %60 + OpFunctionEnd + %63 = OpFunction %61 None %62 + %64 = OpLabel + %65 = OpVariable %30 Function + %68 = OpVariable %30 Function + %73 = OpVariable %30 Function + %66 = OpLoad %2 %4 + OpStore %65 %66 + %67 = OpFunctionCall %2 %32 %65 + %71 = OpAccessChain %70 %14 %69 + %72 = OpLoad %2 %71 + OpStore %68 %72 + %74 = OpAccessChain %70 %20 %69 %69 + %75 = OpLoad %2 %74 + OpStore %73 %75 + %76 = OpFunctionCall %2 %48 %68 %73 + %77 = OpFAdd %2 %67 %76 + %79 = OpAccessChain %70 %20 %78 %69 + %80 = OpLoad %2 %79 + %81 = OpFAdd %2 %77 %80 + OpStore %22 %81 + OpReturn + OpFunctionEnd +)"; + Options options; + options.ignore_location = true; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, DifferentDecorationsFragmentIgnoreSetBindingLocation) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 82 ++; Bound: 86 + ; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %63 "main" %4 %22 + OpExecutionMode %63 OriginUpperLeft + OpSource GLSL 450 + OpName %4 "_ue" + OpName %8 "_uf" + OpName %11 "_ug" + OpName %12 "_uA" + OpMemberName %12 0 "_ux" + OpName %14 "_uc" + OpName %15 "_uB" + OpMemberName %15 0 "_ux" + OpName %20 "_ud" + OpName %22 "_ucol" + OpName %26 "ANGLEDepthRangeParams" + OpMemberName %26 0 "near" + OpMemberName %26 1 "far" + OpMemberName %26 2 "diff" + OpMemberName %26 3 "reserved" + OpName %27 "ANGLEUniformBlock" + OpMemberName %27 0 "viewport" + OpMemberName %27 1 "clipDistancesEnabled" + OpMemberName %27 2 "xfbActiveUnpaused" + OpMemberName %27 3 "xfbVerticesPerInstance" + OpMemberName %27 4 "numSamples" + OpMemberName %27 5 "xfbBufferOffsets" + OpMemberName %27 6 "acbBufferOffsets" + OpMemberName %27 7 "depthRange" + OpName %29 "ANGLEUniforms" + OpName %33 "_uc" + OpName %32 "_uh" + OpName %49 "_ux" + OpName %50 "_uy" + OpName %48 "_ui" + OpName %63 "main" + OpName %65 "param" + OpName %68 "param" + OpName %73 "param" +-OpDecorate %4 Location 0 ++OpDecorate %4 Location 1 + OpDecorate %8 RelaxedPrecision +-OpDecorate %8 DescriptorSet 0 ++OpDecorate %8 DescriptorSet 2 + OpDecorate %8 Binding 0 +-OpDecorate %11 DescriptorSet 0 ++OpDecorate %11 DescriptorSet 3 +-OpDecorate %11 Binding 1 ++OpDecorate %11 Binding 0 + OpMemberDecorate %12 0 Offset 0 + OpMemberDecorate %12 0 RelaxedPrecision + OpDecorate %12 Block +-OpDecorate %14 DescriptorSet 0 ++OpDecorate %14 DescriptorSet 3 +-OpDecorate %14 Binding 2 ++OpDecorate %14 Binding 1 + OpMemberDecorate %15 0 Offset 0 + OpMemberDecorate %15 0 RelaxedPrecision + OpDecorate %15 BufferBlock +-OpDecorate %20 DescriptorSet 0 ++OpDecorate %20 DescriptorSet 3 +-OpDecorate %20 Binding 3 ++OpDecorate %20 Binding 2 + OpDecorate %22 RelaxedPrecision +-OpDecorate %22 Location 0 ++OpDecorate %22 Location 1 + OpMemberDecorate %26 0 Offset 0 + OpMemberDecorate %26 1 Offset 4 + OpMemberDecorate %26 2 Offset 8 + OpMemberDecorate %26 3 Offset 12 + OpMemberDecorate %27 0 Offset 0 + OpMemberDecorate %27 1 Offset 16 + OpMemberDecorate %27 2 Offset 20 + OpMemberDecorate %27 3 Offset 24 + OpMemberDecorate %27 4 Offset 28 + OpMemberDecorate %27 5 Offset 32 + OpMemberDecorate %27 6 Offset 48 + OpMemberDecorate %27 7 Offset 64 + OpMemberDecorate %27 2 RelaxedPrecision + OpMemberDecorate %27 4 RelaxedPrecision + OpDecorate %27 Block + OpDecorate %29 DescriptorSet 0 +-OpDecorate %29 Binding 4 ++OpDecorate %29 Binding 0 + OpDecorate %32 RelaxedPrecision + OpDecorate %33 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %38 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %43 RelaxedPrecision + OpDecorate %48 RelaxedPrecision + OpDecorate %49 RelaxedPrecision + OpDecorate %50 RelaxedPrecision + OpDecorate %52 RelaxedPrecision + OpDecorate %53 RelaxedPrecision + OpDecorate %54 RelaxedPrecision + OpDecorate %55 RelaxedPrecision + OpDecorate %56 RelaxedPrecision + OpDecorate %57 RelaxedPrecision + OpDecorate %58 RelaxedPrecision + OpDecorate %59 RelaxedPrecision + OpDecorate %60 RelaxedPrecision + OpDecorate %67 RelaxedPrecision + OpDecorate %68 RelaxedPrecision + OpDecorate %72 RelaxedPrecision + OpDecorate %73 RelaxedPrecision + OpDecorate %75 RelaxedPrecision + OpDecorate %76 RelaxedPrecision + OpDecorate %77 RelaxedPrecision + OpDecorate %80 RelaxedPrecision + OpDecorate %81 RelaxedPrecision + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %5 = OpTypeImage %1 2D 0 0 0 1 Unknown + %6 = OpTypeSampledImage %5 + %9 = OpTypeImage %1 2D 0 0 0 2 Rgba8 + %12 = OpTypeStruct %2 + %15 = OpTypeStruct %2 + %16 = OpTypeInt 32 0 + %17 = OpConstant %16 2 + %18 = OpTypeArray %15 %17 + %23 = OpTypeInt 32 1 + %24 = OpTypeVector %23 4 + %25 = OpTypeVector %16 4 + %26 = OpTypeStruct %1 %1 %1 %1 + %27 = OpTypeStruct %2 %16 %16 %23 %23 %24 %25 %26 + %35 = OpTypeVector %1 2 + %40 = OpTypeVector %23 2 + %61 = OpTypeVoid + %69 = OpConstant %16 0 + %78 = OpConstant %16 1 ++%82 = OpTypePointer Private %2 + %3 = OpTypePointer Input %2 + %7 = OpTypePointer UniformConstant %6 + %10 = OpTypePointer UniformConstant %9 + %13 = OpTypePointer Uniform %12 + %19 = OpTypePointer Uniform %18 ++%83 = OpTypePointer Private %2 + %21 = OpTypePointer Output %2 + %28 = OpTypePointer Uniform %27 + %30 = OpTypePointer Function %2 + %70 = OpTypePointer Uniform %2 + %31 = OpTypeFunction %2 %30 + %47 = OpTypeFunction %2 %30 %30 + %62 = OpTypeFunction %61 + %4 = OpVariable %3 Input + %8 = OpVariable %7 UniformConstant + %11 = OpVariable %10 UniformConstant + %14 = OpVariable %13 Uniform + %20 = OpVariable %19 Uniform + %22 = OpVariable %21 Output + %29 = OpVariable %28 Uniform ++%84 = OpConstant %23 0 ++%85 = OpConstant %1 0.5 + %32 = OpFunction %2 None %31 + %33 = OpFunctionParameter %30 + %34 = OpLabel + %36 = OpLoad %6 %8 + %37 = OpLoad %2 %33 + %38 = OpVectorShuffle %35 %37 %37 0 1 + %39 = OpImageSampleImplicitLod %2 %36 %38 + %41 = OpLoad %2 %33 + %42 = OpVectorShuffle %35 %41 %41 2 3 + %43 = OpConvertFToS %40 %42 + %44 = OpLoad %9 %11 + %45 = OpImageRead %2 %44 %43 + %46 = OpFAdd %2 %39 %45 + OpReturnValue %46 + OpFunctionEnd + %48 = OpFunction %2 None %47 + %49 = OpFunctionParameter %30 + %50 = OpFunctionParameter %30 + %51 = OpLabel + %52 = OpLoad %2 %49 + %53 = OpVectorShuffle %35 %52 %52 0 1 + %54 = OpLoad %2 %50 + %55 = OpVectorShuffle %35 %54 %54 2 3 + %56 = OpCompositeExtract %1 %53 0 + %57 = OpCompositeExtract %1 %53 1 + %58 = OpCompositeExtract %1 %55 0 + %59 = OpCompositeExtract %1 %55 1 + %60 = OpCompositeConstruct %2 %56 %57 %58 %59 + OpReturnValue %60 + OpFunctionEnd + %63 = OpFunction %61 None %62 + %64 = OpLabel + %65 = OpVariable %30 Function + %68 = OpVariable %30 Function + %73 = OpVariable %30 Function + %66 = OpLoad %2 %4 + OpStore %65 %66 + %67 = OpFunctionCall %2 %32 %65 + %71 = OpAccessChain %70 %14 %69 + %72 = OpLoad %2 %71 + OpStore %68 %72 + %74 = OpAccessChain %70 %20 %69 %69 + %75 = OpLoad %2 %74 + OpStore %73 %75 + %76 = OpFunctionCall %2 %48 %68 %73 + %77 = OpFAdd %2 %67 %76 + %79 = OpAccessChain %70 %20 %78 %69 + %80 = OpLoad %2 %79 + %81 = OpFAdd %2 %77 %80 + OpStore %22 %81 + OpReturn + OpFunctionEnd +)"; + Options options; + options.ignore_set_binding = true; + options.ignore_location = true; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/different_decorations_fragment_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/different_decorations_fragment_dst.spvasm new file mode 100644 index 0000000000..b5d1c9f7b3 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/different_decorations_fragment_dst.spvasm @@ -0,0 +1,199 @@ +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %63 "main" %4 %22 +OpExecutionMode %63 OriginUpperLeft +OpSource GLSL 450 +OpName %4 "_ue" +OpName %8 "_uf" +OpName %11 "_ug" +OpName %12 "_uA" +OpMemberName %12 0 "_ux" +OpName %14 "_uc" +OpName %15 "_uB" +OpMemberName %15 0 "_ux" +OpName %20 "_ud" +OpName %22 "_ucol" +OpName %26 "ANGLEDepthRangeParams" +OpMemberName %26 0 "near" +OpMemberName %26 1 "far" +OpMemberName %26 2 "diff" +OpMemberName %26 3 "reserved" +OpName %27 "ANGLEUniformBlock" +OpMemberName %27 0 "viewport" +OpMemberName %27 1 "clipDistancesEnabled" +OpMemberName %27 2 "xfbActiveUnpaused" +OpMemberName %27 3 "xfbVerticesPerInstance" +OpMemberName %27 4 "numSamples" +OpMemberName %27 5 "xfbBufferOffsets" +OpMemberName %27 6 "acbBufferOffsets" +OpMemberName %27 7 "depthRange" +OpName %29 "ANGLEUniforms" +OpName %33 "_uc" +OpName %32 "_uh" +OpName %49 "_ux" +OpName %50 "_uy" +OpName %48 "_ui" +OpName %63 "main" +OpName %65 "param" +OpName %68 "param" +OpName %73 "param" +OpDecorate %4 Location 1 +OpDecorate %8 RelaxedPrecision +OpDecorate %8 DescriptorSet 2 +OpDecorate %8 Binding 0 +OpDecorate %11 DescriptorSet 3 +OpDecorate %11 Binding 0 +OpMemberDecorate %12 0 Offset 0 +OpMemberDecorate %12 0 RelaxedPrecision +OpDecorate %12 Block +OpDecorate %14 DescriptorSet 3 +OpDecorate %14 Binding 1 +OpMemberDecorate %15 0 Offset 0 +OpMemberDecorate %15 0 RelaxedPrecision +OpDecorate %15 BufferBlock +OpDecorate %20 DescriptorSet 3 +OpDecorate %20 Binding 2 +OpDecorate %22 RelaxedPrecision +OpDecorate %22 Location 1 +OpMemberDecorate %26 0 Offset 0 +OpMemberDecorate %26 1 Offset 4 +OpMemberDecorate %26 2 Offset 8 +OpMemberDecorate %26 3 Offset 12 +OpMemberDecorate %27 0 Offset 0 +OpMemberDecorate %27 1 Offset 16 +OpMemberDecorate %27 2 Offset 20 +OpMemberDecorate %27 3 Offset 24 +OpMemberDecorate %27 4 Offset 28 +OpMemberDecorate %27 5 Offset 32 +OpMemberDecorate %27 6 Offset 48 +OpMemberDecorate %27 7 Offset 64 +OpMemberDecorate %27 2 RelaxedPrecision +OpMemberDecorate %27 4 RelaxedPrecision +OpDecorate %27 Block +OpDecorate %29 DescriptorSet 0 +OpDecorate %29 Binding 0 +OpDecorate %32 RelaxedPrecision +OpDecorate %33 RelaxedPrecision +OpDecorate %36 RelaxedPrecision +OpDecorate %37 RelaxedPrecision +OpDecorate %38 RelaxedPrecision +OpDecorate %39 RelaxedPrecision +OpDecorate %41 RelaxedPrecision +OpDecorate %42 RelaxedPrecision +OpDecorate %43 RelaxedPrecision +OpDecorate %48 RelaxedPrecision +OpDecorate %49 RelaxedPrecision +OpDecorate %50 RelaxedPrecision +OpDecorate %52 RelaxedPrecision +OpDecorate %53 RelaxedPrecision +OpDecorate %54 RelaxedPrecision +OpDecorate %55 RelaxedPrecision +OpDecorate %56 RelaxedPrecision +OpDecorate %57 RelaxedPrecision +OpDecorate %58 RelaxedPrecision +OpDecorate %59 RelaxedPrecision +OpDecorate %60 RelaxedPrecision +OpDecorate %67 RelaxedPrecision +OpDecorate %68 RelaxedPrecision +OpDecorate %72 RelaxedPrecision +OpDecorate %73 RelaxedPrecision +OpDecorate %75 RelaxedPrecision +OpDecorate %76 RelaxedPrecision +OpDecorate %77 RelaxedPrecision +OpDecorate %80 RelaxedPrecision +OpDecorate %81 RelaxedPrecision +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeImage %1 2D 0 0 0 1 Unknown +%6 = OpTypeSampledImage %5 +%9 = OpTypeImage %1 2D 0 0 0 2 Rgba8 +%12 = OpTypeStruct %2 +%15 = OpTypeStruct %2 +%16 = OpTypeInt 32 0 +%17 = OpConstant %16 2 +%18 = OpTypeArray %15 %17 +%23 = OpTypeInt 32 1 +%24 = OpTypeVector %23 4 +%25 = OpTypeVector %16 4 +%26 = OpTypeStruct %1 %1 %1 %1 +%27 = OpTypeStruct %2 %16 %16 %23 %23 %24 %25 %26 +%35 = OpTypeVector %1 2 +%40 = OpTypeVector %23 2 +%61 = OpTypeVoid +%69 = OpConstant %16 0 +%78 = OpConstant %16 1 +%82 = OpTypePointer Private %2 +%3 = OpTypePointer Input %2 +%7 = OpTypePointer UniformConstant %6 +%10 = OpTypePointer UniformConstant %9 +%13 = OpTypePointer Uniform %12 +%19 = OpTypePointer Uniform %18 +%83 = OpTypePointer Private %2 +%21 = OpTypePointer Output %2 +%28 = OpTypePointer Uniform %27 +%30 = OpTypePointer Function %2 +%70 = OpTypePointer Uniform %2 +%31 = OpTypeFunction %2 %30 +%47 = OpTypeFunction %2 %30 %30 +%62 = OpTypeFunction %61 +%4 = OpVariable %3 Input +%8 = OpVariable %7 UniformConstant +%11 = OpVariable %10 UniformConstant +%14 = OpVariable %13 Uniform +%20 = OpVariable %19 Uniform +%22 = OpVariable %21 Output +%29 = OpVariable %28 Uniform +%84 = OpConstant %23 0 +%85 = OpConstant %1 0.5 +%32 = OpFunction %2 None %31 +%33 = OpFunctionParameter %30 +%34 = OpLabel +%36 = OpLoad %6 %8 +%37 = OpLoad %2 %33 +%38 = OpVectorShuffle %35 %37 %37 0 1 +%39 = OpImageSampleImplicitLod %2 %36 %38 +%41 = OpLoad %2 %33 +%42 = OpVectorShuffle %35 %41 %41 2 3 +%43 = OpConvertFToS %40 %42 +%44 = OpLoad %9 %11 +%45 = OpImageRead %2 %44 %43 +%46 = OpFAdd %2 %39 %45 +OpReturnValue %46 +OpFunctionEnd +%48 = OpFunction %2 None %47 +%49 = OpFunctionParameter %30 +%50 = OpFunctionParameter %30 +%51 = OpLabel +%52 = OpLoad %2 %49 +%53 = OpVectorShuffle %35 %52 %52 0 1 +%54 = OpLoad %2 %50 +%55 = OpVectorShuffle %35 %54 %54 2 3 +%56 = OpCompositeExtract %1 %53 0 +%57 = OpCompositeExtract %1 %53 1 +%58 = OpCompositeExtract %1 %55 0 +%59 = OpCompositeExtract %1 %55 1 +%60 = OpCompositeConstruct %2 %56 %57 %58 %59 +OpReturnValue %60 +OpFunctionEnd +%63 = OpFunction %61 None %62 +%64 = OpLabel +%65 = OpVariable %30 Function +%68 = OpVariable %30 Function +%73 = OpVariable %30 Function +%66 = OpLoad %2 %4 +OpStore %65 %66 +%67 = OpFunctionCall %2 %32 %65 +%71 = OpAccessChain %70 %14 %69 +%72 = OpLoad %2 %71 +OpStore %68 %72 +%74 = OpAccessChain %70 %20 %69 %69 +%75 = OpLoad %2 %74 +OpStore %73 %75 +%76 = OpFunctionCall %2 %48 %68 %73 +%77 = OpFAdd %2 %67 %76 +%79 = OpAccessChain %70 %20 %78 %69 +%80 = OpLoad %2 %79 +%81 = OpFAdd %2 %77 %80 +OpStore %22 %81 +OpReturn +OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/different_decorations_fragment_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/different_decorations_fragment_src.spvasm new file mode 100644 index 0000000000..2c8cd644f6 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/different_decorations_fragment_src.spvasm @@ -0,0 +1,198 @@ +;; Test where variable set/binding/location decorations are different between +;; src and dst fragment shaders. +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %63 "main" %4 %22 +OpExecutionMode %63 OriginUpperLeft +OpSource GLSL 450 +OpName %4 "_ue" +OpName %8 "_uf" +OpName %11 "_ug" +OpName %12 "_uA" +OpMemberName %12 0 "_ux" +OpName %14 "_uc" +OpName %15 "_uB" +OpMemberName %15 0 "_ux" +OpName %20 "_ud" +OpName %22 "_ucol" +OpName %26 "ANGLEDepthRangeParams" +OpMemberName %26 0 "near" +OpMemberName %26 1 "far" +OpMemberName %26 2 "diff" +OpMemberName %26 3 "reserved" +OpName %27 "ANGLEUniformBlock" +OpMemberName %27 0 "viewport" +OpMemberName %27 1 "clipDistancesEnabled" +OpMemberName %27 2 "xfbActiveUnpaused" +OpMemberName %27 3 "xfbVerticesPerInstance" +OpMemberName %27 4 "numSamples" +OpMemberName %27 5 "xfbBufferOffsets" +OpMemberName %27 6 "acbBufferOffsets" +OpMemberName %27 7 "depthRange" +OpName %29 "ANGLEUniforms" +OpName %33 "_uc" +OpName %32 "_uh" +OpName %49 "_ux" +OpName %50 "_uy" +OpName %48 "_ui" +OpName %63 "main" +OpName %65 "param" +OpName %68 "param" +OpName %73 "param" +OpDecorate %4 Location 0 +OpDecorate %8 RelaxedPrecision +OpDecorate %8 DescriptorSet 0 +OpDecorate %8 Binding 0 +OpDecorate %11 DescriptorSet 0 +OpDecorate %11 Binding 1 +OpMemberDecorate %12 0 Offset 0 +OpMemberDecorate %12 0 RelaxedPrecision +OpDecorate %12 Block +OpDecorate %14 DescriptorSet 0 +OpDecorate %14 Binding 2 +OpMemberDecorate %15 0 Offset 0 +OpMemberDecorate %15 0 RelaxedPrecision +OpDecorate %15 BufferBlock +OpDecorate %20 DescriptorSet 0 +OpDecorate %20 Binding 3 +OpDecorate %22 RelaxedPrecision +OpDecorate %22 Location 0 +OpMemberDecorate %26 0 Offset 0 +OpMemberDecorate %26 1 Offset 4 +OpMemberDecorate %26 2 Offset 8 +OpMemberDecorate %26 3 Offset 12 +OpMemberDecorate %27 0 Offset 0 +OpMemberDecorate %27 1 Offset 16 +OpMemberDecorate %27 2 Offset 20 +OpMemberDecorate %27 3 Offset 24 +OpMemberDecorate %27 4 Offset 28 +OpMemberDecorate %27 5 Offset 32 +OpMemberDecorate %27 6 Offset 48 +OpMemberDecorate %27 7 Offset 64 +OpMemberDecorate %27 2 RelaxedPrecision +OpMemberDecorate %27 4 RelaxedPrecision +OpDecorate %27 Block +OpDecorate %29 DescriptorSet 0 +OpDecorate %29 Binding 4 +OpDecorate %32 RelaxedPrecision +OpDecorate %33 RelaxedPrecision +OpDecorate %36 RelaxedPrecision +OpDecorate %37 RelaxedPrecision +OpDecorate %38 RelaxedPrecision +OpDecorate %39 RelaxedPrecision +OpDecorate %41 RelaxedPrecision +OpDecorate %42 RelaxedPrecision +OpDecorate %43 RelaxedPrecision +OpDecorate %48 RelaxedPrecision +OpDecorate %49 RelaxedPrecision +OpDecorate %50 RelaxedPrecision +OpDecorate %52 RelaxedPrecision +OpDecorate %53 RelaxedPrecision +OpDecorate %54 RelaxedPrecision +OpDecorate %55 RelaxedPrecision +OpDecorate %56 RelaxedPrecision +OpDecorate %57 RelaxedPrecision +OpDecorate %58 RelaxedPrecision +OpDecorate %59 RelaxedPrecision +OpDecorate %60 RelaxedPrecision +OpDecorate %67 RelaxedPrecision +OpDecorate %68 RelaxedPrecision +OpDecorate %72 RelaxedPrecision +OpDecorate %73 RelaxedPrecision +OpDecorate %75 RelaxedPrecision +OpDecorate %76 RelaxedPrecision +OpDecorate %77 RelaxedPrecision +OpDecorate %80 RelaxedPrecision +OpDecorate %81 RelaxedPrecision +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeImage %1 2D 0 0 0 1 Unknown +%6 = OpTypeSampledImage %5 +%9 = OpTypeImage %1 2D 0 0 0 2 Rgba8 +%12 = OpTypeStruct %2 +%15 = OpTypeStruct %2 +%16 = OpTypeInt 32 0 +%17 = OpConstant %16 2 +%18 = OpTypeArray %15 %17 +%23 = OpTypeInt 32 1 +%24 = OpTypeVector %23 4 +%25 = OpTypeVector %16 4 +%26 = OpTypeStruct %1 %1 %1 %1 +%27 = OpTypeStruct %2 %16 %16 %23 %23 %24 %25 %26 +%35 = OpTypeVector %1 2 +%40 = OpTypeVector %23 2 +%61 = OpTypeVoid +%69 = OpConstant %16 0 +%78 = OpConstant %16 1 +%3 = OpTypePointer Input %2 +%7 = OpTypePointer UniformConstant %6 +%10 = OpTypePointer UniformConstant %9 +%13 = OpTypePointer Uniform %12 +%19 = OpTypePointer Uniform %18 +%21 = OpTypePointer Output %2 +%28 = OpTypePointer Uniform %27 +%30 = OpTypePointer Function %2 +%70 = OpTypePointer Uniform %2 +%31 = OpTypeFunction %2 %30 +%47 = OpTypeFunction %2 %30 %30 +%62 = OpTypeFunction %61 +%4 = OpVariable %3 Input +%8 = OpVariable %7 UniformConstant +%11 = OpVariable %10 UniformConstant +%14 = OpVariable %13 Uniform +%20 = OpVariable %19 Uniform +%22 = OpVariable %21 Output +%29 = OpVariable %28 Uniform +%32 = OpFunction %2 None %31 +%33 = OpFunctionParameter %30 +%34 = OpLabel +%36 = OpLoad %6 %8 +%37 = OpLoad %2 %33 +%38 = OpVectorShuffle %35 %37 %37 0 1 +%39 = OpImageSampleImplicitLod %2 %36 %38 +%41 = OpLoad %2 %33 +%42 = OpVectorShuffle %35 %41 %41 2 3 +%43 = OpConvertFToS %40 %42 +%44 = OpLoad %9 %11 +%45 = OpImageRead %2 %44 %43 +%46 = OpFAdd %2 %39 %45 +OpReturnValue %46 +OpFunctionEnd +%48 = OpFunction %2 None %47 +%49 = OpFunctionParameter %30 +%50 = OpFunctionParameter %30 +%51 = OpLabel +%52 = OpLoad %2 %49 +%53 = OpVectorShuffle %35 %52 %52 0 1 +%54 = OpLoad %2 %50 +%55 = OpVectorShuffle %35 %54 %54 2 3 +%56 = OpCompositeExtract %1 %53 0 +%57 = OpCompositeExtract %1 %53 1 +%58 = OpCompositeExtract %1 %55 0 +%59 = OpCompositeExtract %1 %55 1 +%60 = OpCompositeConstruct %2 %56 %57 %58 %59 +OpReturnValue %60 +OpFunctionEnd +%63 = OpFunction %61 None %62 +%64 = OpLabel +%65 = OpVariable %30 Function +%68 = OpVariable %30 Function +%73 = OpVariable %30 Function +%66 = OpLoad %2 %4 +OpStore %65 %66 +%67 = OpFunctionCall %2 %32 %65 +%71 = OpAccessChain %70 %14 %69 +%72 = OpLoad %2 %71 +OpStore %68 %72 +%74 = OpAccessChain %70 %20 %69 %69 +%75 = OpLoad %2 %74 +OpStore %73 %75 +%76 = OpFunctionCall %2 %48 %68 %73 +%77 = OpFAdd %2 %67 %76 +%79 = OpAccessChain %70 %20 %78 %69 +%80 = OpLoad %2 %79 +%81 = OpFAdd %2 %77 %80 +OpStore %22 %81 +OpReturn +OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/different_decorations_vertex_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/different_decorations_vertex_autogen.cpp new file mode 100644 index 0000000000..f65ee5a198 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/different_decorations_vertex_autogen.cpp @@ -0,0 +1,1322 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Test where variable set/binding/location decorations are different between +// src and dst vertex shaders. +constexpr char kSrc[] = R"(OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %20 %25 +OpSource GLSL 450 +OpName %4 "_ub" +OpName %5 "_uc" +OpName %6 "_ud" +OpName %8 "_ue" +OpName %9 "defaultUniformsVS" +OpMemberName %9 0 "_ua" +OpName %11 "" +OpName %16 "ANGLEDepthRangeParams" +OpMemberName %16 0 "near" +OpMemberName %16 1 "far" +OpMemberName %16 2 "diff" +OpMemberName %16 3 "reserved" +OpName %17 "ANGLEUniformBlock" +OpMemberName %17 0 "viewport" +OpMemberName %17 1 "clipDistancesEnabled" +OpMemberName %17 2 "xfbActiveUnpaused" +OpMemberName %17 3 "xfbVerticesPerInstance" +OpMemberName %17 4 "numSamples" +OpMemberName %17 5 "xfbBufferOffsets" +OpMemberName %17 6 "acbBufferOffsets" +OpMemberName %17 7 "depthRange" +OpName %19 "ANGLEUniforms" +OpName %20 "ANGLEXfbPosition" +OpName %23 "gl_PerVertex" +OpMemberName %23 0 "gl_Position" +OpMemberName %23 1 "gl_PointSize" +OpMemberName %23 2 "gl_ClipDistance" +OpMemberName %23 3 "gl_CullDistance" +OpName %25 "" +OpName %29 "_ua" +OpName %28 "_uf" +OpName %33 "_uf" +OpName %32 "_ug" +OpName %40 "main" +OpName %42 "param" +OpName %50 "param" +OpName %53 "param" +OpDecorate %4 Location 0 +OpDecorate %5 Location 1 +OpDecorate %6 Location 2 +OpDecorate %8 Location 0 +OpMemberDecorate %9 0 Offset 0 +OpDecorate %9 Block +OpDecorate %11 DescriptorSet 0 +OpDecorate %11 Binding 0 +OpMemberDecorate %16 0 Offset 0 +OpMemberDecorate %16 1 Offset 4 +OpMemberDecorate %16 2 Offset 8 +OpMemberDecorate %16 3 Offset 12 +OpMemberDecorate %17 0 Offset 0 +OpMemberDecorate %17 1 Offset 16 +OpMemberDecorate %17 2 Offset 20 +OpMemberDecorate %17 3 Offset 24 +OpMemberDecorate %17 4 Offset 28 +OpMemberDecorate %17 5 Offset 32 +OpMemberDecorate %17 6 Offset 48 +OpMemberDecorate %17 7 Offset 64 +OpMemberDecorate %17 2 RelaxedPrecision +OpMemberDecorate %17 4 RelaxedPrecision +OpDecorate %17 Block +OpDecorate %19 DescriptorSet 0 +OpDecorate %19 Binding 1 +OpDecorate %20 Location 1 +OpMemberDecorate %23 0 BuiltIn Position +OpMemberDecorate %23 1 BuiltIn PointSize +OpMemberDecorate %23 2 BuiltIn ClipDistance +OpMemberDecorate %23 3 BuiltIn CullDistance +OpDecorate %23 Block +OpDecorate %28 RelaxedPrecision +OpDecorate %29 RelaxedPrecision +OpDecorate %31 RelaxedPrecision +OpDecorate %32 RelaxedPrecision +OpDecorate %33 RelaxedPrecision +OpDecorate %35 RelaxedPrecision +OpDecorate %36 RelaxedPrecision +OpDecorate %37 RelaxedPrecision +OpDecorate %44 RelaxedPrecision +OpDecorate %52 RelaxedPrecision +OpDecorate %55 RelaxedPrecision +OpDecorate %56 RelaxedPrecision +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%9 = OpTypeStruct %2 +%12 = OpTypeInt 32 0 +%13 = OpTypeInt 32 1 +%14 = OpTypeVector %13 4 +%15 = OpTypeVector %12 4 +%16 = OpTypeStruct %1 %1 %1 %1 +%17 = OpTypeStruct %2 %12 %12 %13 %13 %14 %15 %16 +%21 = OpConstant %12 8 +%22 = OpTypeArray %1 %21 +%23 = OpTypeStruct %2 %1 %22 %22 +%38 = OpTypeVoid +%45 = OpConstant %12 0 +%3 = OpTypePointer Input %2 +%7 = OpTypePointer Output %2 +%10 = OpTypePointer Uniform %9 +%18 = OpTypePointer Uniform %17 +%24 = OpTypePointer Output %23 +%26 = OpTypePointer Function %2 +%46 = OpTypePointer Uniform %2 +%27 = OpTypeFunction %2 %26 +%39 = OpTypeFunction %38 +%4 = OpVariable %3 Input +%5 = OpVariable %3 Input +%6 = OpVariable %3 Input +%8 = OpVariable %7 Output +%11 = OpVariable %10 Uniform +%19 = OpVariable %18 Uniform +%20 = OpVariable %7 Output +%25 = OpVariable %24 Output +%28 = OpFunction %2 None %27 +%29 = OpFunctionParameter %26 +%30 = OpLabel +%31 = OpLoad %2 %29 +OpReturnValue %31 +OpFunctionEnd +%32 = OpFunction %2 None %27 +%33 = OpFunctionParameter %26 +%34 = OpLabel +%35 = OpLoad %2 %33 +%36 = OpLoad %2 %33 +%37 = OpFAdd %2 %35 %36 +OpReturnValue %37 +OpFunctionEnd +%40 = OpFunction %38 None %39 +%41 = OpLabel +%42 = OpVariable %26 Function +%50 = OpVariable %26 Function +%53 = OpVariable %26 Function +%43 = OpLoad %2 %4 +OpStore %42 %43 +%44 = OpFunctionCall %2 %28 %42 +%47 = OpAccessChain %46 %11 %45 +%48 = OpLoad %2 %47 +%49 = OpFAdd %2 %44 %48 +OpStore %8 %49 +%51 = OpLoad %2 %5 +OpStore %50 %51 +%52 = OpFunctionCall %2 %32 %50 +%54 = OpLoad %2 %6 +OpStore %53 %54 +%55 = OpFunctionCall %2 %28 %53 +%56 = OpFAdd %2 %52 %55 +%57 = OpAccessChain %7 %25 %45 +OpStore %57 %56 +OpReturn +OpFunctionEnd +)"; +constexpr char kDst[] = R"(OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %25 +OpSource GLSL 450 +OpName %4 "_ub" +OpName %5 "_uc" +OpName %6 "_ud" +OpName %8 "_ue" +OpName %9 "defaultUniformsVS" +OpMemberName %9 0 "_ua" +OpName %11 "" +OpName %16 "ANGLEDepthRangeParams" +OpMemberName %16 0 "near" +OpMemberName %16 1 "far" +OpMemberName %16 2 "diff" +OpMemberName %16 3 "reserved" +OpName %17 "ANGLEUniformBlock" +OpMemberName %17 0 "viewport" +OpMemberName %17 1 "clipDistancesEnabled" +OpMemberName %17 2 "xfbActiveUnpaused" +OpMemberName %17 3 "xfbVerticesPerInstance" +OpMemberName %17 4 "numSamples" +OpMemberName %17 5 "xfbBufferOffsets" +OpMemberName %17 6 "acbBufferOffsets" +OpMemberName %17 7 "depthRange" +OpName %19 "ANGLEUniforms" +OpName %23 "gl_PerVertex" +OpMemberName %23 0 "gl_Position" +OpName %25 "" +OpName %29 "_ua" +OpName %28 "_uf" +OpName %33 "_uf" +OpName %32 "_ug" +OpName %40 "main" +OpName %42 "param" +OpName %50 "param" +OpName %53 "param" +OpDecorate %4 Location 1 +OpDecorate %5 Location 2 +OpDecorate %6 Location 0 +OpDecorate %8 Location 1 +OpMemberDecorate %9 0 Offset 0 +OpDecorate %9 Block +OpDecorate %11 DescriptorSet 0 +OpDecorate %11 Binding 1 +OpMemberDecorate %16 0 Offset 0 +OpMemberDecorate %16 1 Offset 4 +OpMemberDecorate %16 2 Offset 8 +OpMemberDecorate %16 3 Offset 12 +OpMemberDecorate %17 0 Offset 0 +OpMemberDecorate %17 1 Offset 16 +OpMemberDecorate %17 2 Offset 20 +OpMemberDecorate %17 3 Offset 24 +OpMemberDecorate %17 4 Offset 28 +OpMemberDecorate %17 5 Offset 32 +OpMemberDecorate %17 6 Offset 48 +OpMemberDecorate %17 7 Offset 64 +OpMemberDecorate %17 2 RelaxedPrecision +OpMemberDecorate %17 4 RelaxedPrecision +OpDecorate %17 Block +OpDecorate %19 DescriptorSet 2 +OpDecorate %19 Binding 0 +OpMemberDecorate %23 0 BuiltIn Position +OpDecorate %23 Block +OpDecorate %28 RelaxedPrecision +OpDecorate %29 RelaxedPrecision +OpDecorate %31 RelaxedPrecision +OpDecorate %32 RelaxedPrecision +OpDecorate %33 RelaxedPrecision +OpDecorate %35 RelaxedPrecision +OpDecorate %36 RelaxedPrecision +OpDecorate %37 RelaxedPrecision +OpDecorate %44 RelaxedPrecision +OpDecorate %52 RelaxedPrecision +OpDecorate %55 RelaxedPrecision +OpDecorate %56 RelaxedPrecision +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%9 = OpTypeStruct %2 +%12 = OpTypeInt 32 0 +%13 = OpTypeInt 32 1 +%14 = OpTypeVector %13 4 +%15 = OpTypeVector %12 4 +%16 = OpTypeStruct %1 %1 %1 %1 +%17 = OpTypeStruct %2 %12 %12 %13 %13 %14 %15 %16 +%21 = OpConstant %12 8 +%22 = OpTypeArray %1 %21 +%23 = OpTypeStruct %2 +%38 = OpTypeVoid +%45 = OpConstant %12 0 +%58 = OpTypePointer Private %2 +%3 = OpTypePointer Input %2 +%59 = OpTypePointer Private %2 +%7 = OpTypePointer Output %2 +%10 = OpTypePointer Uniform %9 +%18 = OpTypePointer Uniform %17 +%24 = OpTypePointer Output %23 +%26 = OpTypePointer Function %2 +%46 = OpTypePointer Uniform %2 +%27 = OpTypeFunction %2 %26 +%39 = OpTypeFunction %38 +%4 = OpVariable %3 Input +%5 = OpVariable %3 Input +%6 = OpVariable %3 Input +%8 = OpVariable %7 Output +%11 = OpVariable %10 Uniform +%19 = OpVariable %18 Uniform +%20 = OpVariable %59 Private +%25 = OpVariable %24 Output +%60 = OpConstant %13 0 +%61 = OpConstant %1 0.5 +%28 = OpFunction %2 None %27 +%29 = OpFunctionParameter %26 +%30 = OpLabel +%31 = OpLoad %2 %29 +OpReturnValue %31 +OpFunctionEnd +%32 = OpFunction %2 None %27 +%33 = OpFunctionParameter %26 +%34 = OpLabel +%35 = OpLoad %2 %33 +%36 = OpLoad %2 %33 +%37 = OpFAdd %2 %35 %36 +OpReturnValue %37 +OpFunctionEnd +%40 = OpFunction %38 None %39 +%41 = OpLabel +%42 = OpVariable %26 Function +%50 = OpVariable %26 Function +%53 = OpVariable %26 Function +%43 = OpLoad %2 %4 +OpStore %42 %43 +%44 = OpFunctionCall %2 %28 %42 +%47 = OpAccessChain %46 %11 %45 +%48 = OpLoad %2 %47 +%49 = OpFAdd %2 %44 %48 +OpStore %8 %49 +%51 = OpLoad %2 %5 +OpStore %50 %51 +%52 = OpFunctionCall %2 %32 %50 +%54 = OpLoad %2 %6 +OpStore %53 %54 +%55 = OpFunctionCall %2 %28 %53 +%56 = OpFAdd %2 %52 %55 +%57 = OpAccessChain %7 %25 %45 +OpStore %57 %56 +%62 = OpAccessChain %7 %25 %60 +%63 = OpLoad %2 %62 +%64 = OpCompositeExtract %1 %63 0 +%65 = OpCompositeExtract %1 %63 1 +%66 = OpCompositeExtract %1 %63 2 +%67 = OpCompositeExtract %1 %63 3 +%69 = OpFNegate %1 %64 +%70 = OpFAdd %1 %66 %67 +%71 = OpFMul %1 %70 %61 +%68 = OpCompositeConstruct %2 %65 %69 %71 %67 +OpStore %62 %68 +OpReturn +OpFunctionEnd +)"; + +TEST(DiffTest, DifferentDecorationsVertex) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 58 ++; Bound: 73 + ; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 +-OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %20 %25 ++OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %25 + OpSource GLSL 450 + OpName %4 "_ub" + OpName %5 "_uc" + OpName %6 "_ud" + OpName %8 "_ue" + OpName %9 "defaultUniformsVS" + OpMemberName %9 0 "_ua" + OpName %11 "" + OpName %16 "ANGLEDepthRangeParams" + OpMemberName %16 0 "near" + OpMemberName %16 1 "far" + OpMemberName %16 2 "diff" + OpMemberName %16 3 "reserved" + OpName %17 "ANGLEUniformBlock" + OpMemberName %17 0 "viewport" + OpMemberName %17 1 "clipDistancesEnabled" + OpMemberName %17 2 "xfbActiveUnpaused" + OpMemberName %17 3 "xfbVerticesPerInstance" + OpMemberName %17 4 "numSamples" + OpMemberName %17 5 "xfbBufferOffsets" + OpMemberName %17 6 "acbBufferOffsets" + OpMemberName %17 7 "depthRange" + OpName %19 "ANGLEUniforms" +-OpName %20 "ANGLEXfbPosition" + OpName %23 "gl_PerVertex" + OpMemberName %23 0 "gl_Position" +-OpMemberName %23 1 "gl_PointSize" +-OpMemberName %23 2 "gl_ClipDistance" +-OpMemberName %23 3 "gl_CullDistance" + OpName %25 "" + OpName %29 "_ua" + OpName %28 "_uf" + OpName %33 "_uf" + OpName %32 "_ug" + OpName %40 "main" + OpName %42 "param" + OpName %50 "param" + OpName %53 "param" +-OpDecorate %4 Location 0 ++OpDecorate %4 Location 1 +-OpDecorate %5 Location 1 ++OpDecorate %5 Location 2 +-OpDecorate %6 Location 2 ++OpDecorate %6 Location 0 +-OpDecorate %8 Location 0 ++OpDecorate %8 Location 1 + OpMemberDecorate %9 0 Offset 0 + OpDecorate %9 Block + OpDecorate %11 DescriptorSet 0 +-OpDecorate %11 Binding 0 ++OpDecorate %11 Binding 1 + OpMemberDecorate %16 0 Offset 0 + OpMemberDecorate %16 1 Offset 4 + OpMemberDecorate %16 2 Offset 8 + OpMemberDecorate %16 3 Offset 12 + OpMemberDecorate %17 0 Offset 0 + OpMemberDecorate %17 1 Offset 16 + OpMemberDecorate %17 2 Offset 20 + OpMemberDecorate %17 3 Offset 24 + OpMemberDecorate %17 4 Offset 28 + OpMemberDecorate %17 5 Offset 32 + OpMemberDecorate %17 6 Offset 48 + OpMemberDecorate %17 7 Offset 64 + OpMemberDecorate %17 2 RelaxedPrecision + OpMemberDecorate %17 4 RelaxedPrecision + OpDecorate %17 Block +-OpDecorate %19 DescriptorSet 0 ++OpDecorate %19 DescriptorSet 2 +-OpDecorate %19 Binding 1 ++OpDecorate %19 Binding 0 +-OpDecorate %20 Location 1 + OpMemberDecorate %23 0 BuiltIn Position +-OpMemberDecorate %23 1 BuiltIn PointSize +-OpMemberDecorate %23 2 BuiltIn ClipDistance +-OpMemberDecorate %23 3 BuiltIn CullDistance + OpDecorate %23 Block + OpDecorate %28 RelaxedPrecision + OpDecorate %29 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %32 RelaxedPrecision + OpDecorate %33 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %44 RelaxedPrecision + OpDecorate %52 RelaxedPrecision + OpDecorate %55 RelaxedPrecision + OpDecorate %56 RelaxedPrecision + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %9 = OpTypeStruct %2 + %12 = OpTypeInt 32 0 + %13 = OpTypeInt 32 1 + %14 = OpTypeVector %13 4 + %15 = OpTypeVector %12 4 + %16 = OpTypeStruct %1 %1 %1 %1 + %17 = OpTypeStruct %2 %12 %12 %13 %13 %14 %15 %16 + %21 = OpConstant %12 8 + %22 = OpTypeArray %1 %21 +-%23 = OpTypeStruct %2 %1 %22 %22 ++%23 = OpTypeStruct %2 + %38 = OpTypeVoid + %45 = OpConstant %12 0 ++%59 = OpTypePointer Private %2 + %3 = OpTypePointer Input %2 ++%60 = OpTypePointer Private %2 + %7 = OpTypePointer Output %2 + %10 = OpTypePointer Uniform %9 + %18 = OpTypePointer Uniform %17 + %24 = OpTypePointer Output %23 + %26 = OpTypePointer Function %2 + %46 = OpTypePointer Uniform %2 + %27 = OpTypeFunction %2 %26 + %39 = OpTypeFunction %38 + %4 = OpVariable %3 Input + %5 = OpVariable %3 Input + %6 = OpVariable %3 Input + %8 = OpVariable %7 Output + %11 = OpVariable %10 Uniform + %19 = OpVariable %18 Uniform +-%20 = OpVariable %7 Output ++%58 = OpVariable %60 Private + %25 = OpVariable %24 Output ++%61 = OpConstant %13 0 ++%62 = OpConstant %1 0.5 + %28 = OpFunction %2 None %27 + %29 = OpFunctionParameter %26 + %30 = OpLabel + %31 = OpLoad %2 %29 + OpReturnValue %31 + OpFunctionEnd + %32 = OpFunction %2 None %27 + %33 = OpFunctionParameter %26 + %34 = OpLabel + %35 = OpLoad %2 %33 + %36 = OpLoad %2 %33 + %37 = OpFAdd %2 %35 %36 + OpReturnValue %37 + OpFunctionEnd + %40 = OpFunction %38 None %39 + %41 = OpLabel + %42 = OpVariable %26 Function + %50 = OpVariable %26 Function + %53 = OpVariable %26 Function + %43 = OpLoad %2 %4 + OpStore %42 %43 + %44 = OpFunctionCall %2 %28 %42 + %47 = OpAccessChain %46 %11 %45 + %48 = OpLoad %2 %47 + %49 = OpFAdd %2 %44 %48 + OpStore %8 %49 + %51 = OpLoad %2 %5 + OpStore %50 %51 + %52 = OpFunctionCall %2 %32 %50 + %54 = OpLoad %2 %6 + OpStore %53 %54 + %55 = OpFunctionCall %2 %28 %53 + %56 = OpFAdd %2 %52 %55 + %57 = OpAccessChain %7 %25 %45 + OpStore %57 %56 ++%63 = OpAccessChain %7 %25 %61 ++%64 = OpLoad %2 %63 ++%65 = OpCompositeExtract %1 %64 0 ++%66 = OpCompositeExtract %1 %64 1 ++%67 = OpCompositeExtract %1 %64 2 ++%68 = OpCompositeExtract %1 %64 3 ++%70 = OpFNegate %1 %65 ++%71 = OpFAdd %1 %67 %68 ++%72 = OpFMul %1 %71 %62 ++%69 = OpCompositeConstruct %2 %66 %70 %72 %68 ++OpStore %63 %69 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, DifferentDecorationsVertexNoDebug) { + constexpr char kSrcNoDebug[] = R"(OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %20 %25 +OpSource GLSL 450 +OpDecorate %4 Location 0 +OpDecorate %5 Location 1 +OpDecorate %6 Location 2 +OpDecorate %8 Location 0 +OpMemberDecorate %9 0 Offset 0 +OpDecorate %9 Block +OpDecorate %11 DescriptorSet 0 +OpDecorate %11 Binding 0 +OpMemberDecorate %16 0 Offset 0 +OpMemberDecorate %16 1 Offset 4 +OpMemberDecorate %16 2 Offset 8 +OpMemberDecorate %16 3 Offset 12 +OpMemberDecorate %17 0 Offset 0 +OpMemberDecorate %17 1 Offset 16 +OpMemberDecorate %17 2 Offset 20 +OpMemberDecorate %17 3 Offset 24 +OpMemberDecorate %17 4 Offset 28 +OpMemberDecorate %17 5 Offset 32 +OpMemberDecorate %17 6 Offset 48 +OpMemberDecorate %17 7 Offset 64 +OpMemberDecorate %17 2 RelaxedPrecision +OpMemberDecorate %17 4 RelaxedPrecision +OpDecorate %17 Block +OpDecorate %19 DescriptorSet 0 +OpDecorate %19 Binding 1 +OpDecorate %20 Location 1 +OpMemberDecorate %23 0 BuiltIn Position +OpMemberDecorate %23 1 BuiltIn PointSize +OpMemberDecorate %23 2 BuiltIn ClipDistance +OpMemberDecorate %23 3 BuiltIn CullDistance +OpDecorate %23 Block +OpDecorate %28 RelaxedPrecision +OpDecorate %29 RelaxedPrecision +OpDecorate %31 RelaxedPrecision +OpDecorate %32 RelaxedPrecision +OpDecorate %33 RelaxedPrecision +OpDecorate %35 RelaxedPrecision +OpDecorate %36 RelaxedPrecision +OpDecorate %37 RelaxedPrecision +OpDecorate %44 RelaxedPrecision +OpDecorate %52 RelaxedPrecision +OpDecorate %55 RelaxedPrecision +OpDecorate %56 RelaxedPrecision +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%9 = OpTypeStruct %2 +%12 = OpTypeInt 32 0 +%13 = OpTypeInt 32 1 +%14 = OpTypeVector %13 4 +%15 = OpTypeVector %12 4 +%16 = OpTypeStruct %1 %1 %1 %1 +%17 = OpTypeStruct %2 %12 %12 %13 %13 %14 %15 %16 +%21 = OpConstant %12 8 +%22 = OpTypeArray %1 %21 +%23 = OpTypeStruct %2 %1 %22 %22 +%38 = OpTypeVoid +%45 = OpConstant %12 0 +%3 = OpTypePointer Input %2 +%7 = OpTypePointer Output %2 +%10 = OpTypePointer Uniform %9 +%18 = OpTypePointer Uniform %17 +%24 = OpTypePointer Output %23 +%26 = OpTypePointer Function %2 +%46 = OpTypePointer Uniform %2 +%27 = OpTypeFunction %2 %26 +%39 = OpTypeFunction %38 +%4 = OpVariable %3 Input +%5 = OpVariable %3 Input +%6 = OpVariable %3 Input +%8 = OpVariable %7 Output +%11 = OpVariable %10 Uniform +%19 = OpVariable %18 Uniform +%20 = OpVariable %7 Output +%25 = OpVariable %24 Output +%28 = OpFunction %2 None %27 +%29 = OpFunctionParameter %26 +%30 = OpLabel +%31 = OpLoad %2 %29 +OpReturnValue %31 +OpFunctionEnd +%32 = OpFunction %2 None %27 +%33 = OpFunctionParameter %26 +%34 = OpLabel +%35 = OpLoad %2 %33 +%36 = OpLoad %2 %33 +%37 = OpFAdd %2 %35 %36 +OpReturnValue %37 +OpFunctionEnd +%40 = OpFunction %38 None %39 +%41 = OpLabel +%42 = OpVariable %26 Function +%50 = OpVariable %26 Function +%53 = OpVariable %26 Function +%43 = OpLoad %2 %4 +OpStore %42 %43 +%44 = OpFunctionCall %2 %28 %42 +%47 = OpAccessChain %46 %11 %45 +%48 = OpLoad %2 %47 +%49 = OpFAdd %2 %44 %48 +OpStore %8 %49 +%51 = OpLoad %2 %5 +OpStore %50 %51 +%52 = OpFunctionCall %2 %32 %50 +%54 = OpLoad %2 %6 +OpStore %53 %54 +%55 = OpFunctionCall %2 %28 %53 +%56 = OpFAdd %2 %52 %55 +%57 = OpAccessChain %7 %25 %45 +OpStore %57 %56 +OpReturn +OpFunctionEnd + +)"; + constexpr char kDstNoDebug[] = R"(OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %25 +OpSource GLSL 450 +OpDecorate %4 Location 1 +OpDecorate %5 Location 2 +OpDecorate %6 Location 0 +OpDecorate %8 Location 1 +OpMemberDecorate %9 0 Offset 0 +OpDecorate %9 Block +OpDecorate %11 DescriptorSet 0 +OpDecorate %11 Binding 1 +OpMemberDecorate %16 0 Offset 0 +OpMemberDecorate %16 1 Offset 4 +OpMemberDecorate %16 2 Offset 8 +OpMemberDecorate %16 3 Offset 12 +OpMemberDecorate %17 0 Offset 0 +OpMemberDecorate %17 1 Offset 16 +OpMemberDecorate %17 2 Offset 20 +OpMemberDecorate %17 3 Offset 24 +OpMemberDecorate %17 4 Offset 28 +OpMemberDecorate %17 5 Offset 32 +OpMemberDecorate %17 6 Offset 48 +OpMemberDecorate %17 7 Offset 64 +OpMemberDecorate %17 2 RelaxedPrecision +OpMemberDecorate %17 4 RelaxedPrecision +OpDecorate %17 Block +OpDecorate %19 DescriptorSet 2 +OpDecorate %19 Binding 0 +OpMemberDecorate %23 0 BuiltIn Position +OpDecorate %23 Block +OpDecorate %28 RelaxedPrecision +OpDecorate %29 RelaxedPrecision +OpDecorate %31 RelaxedPrecision +OpDecorate %32 RelaxedPrecision +OpDecorate %33 RelaxedPrecision +OpDecorate %35 RelaxedPrecision +OpDecorate %36 RelaxedPrecision +OpDecorate %37 RelaxedPrecision +OpDecorate %44 RelaxedPrecision +OpDecorate %52 RelaxedPrecision +OpDecorate %55 RelaxedPrecision +OpDecorate %56 RelaxedPrecision +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%9 = OpTypeStruct %2 +%12 = OpTypeInt 32 0 +%13 = OpTypeInt 32 1 +%14 = OpTypeVector %13 4 +%15 = OpTypeVector %12 4 +%16 = OpTypeStruct %1 %1 %1 %1 +%17 = OpTypeStruct %2 %12 %12 %13 %13 %14 %15 %16 +%21 = OpConstant %12 8 +%22 = OpTypeArray %1 %21 +%23 = OpTypeStruct %2 +%38 = OpTypeVoid +%45 = OpConstant %12 0 +%58 = OpTypePointer Private %2 +%3 = OpTypePointer Input %2 +%59 = OpTypePointer Private %2 +%7 = OpTypePointer Output %2 +%10 = OpTypePointer Uniform %9 +%18 = OpTypePointer Uniform %17 +%24 = OpTypePointer Output %23 +%26 = OpTypePointer Function %2 +%46 = OpTypePointer Uniform %2 +%27 = OpTypeFunction %2 %26 +%39 = OpTypeFunction %38 +%4 = OpVariable %3 Input +%5 = OpVariable %3 Input +%6 = OpVariable %3 Input +%8 = OpVariable %7 Output +%11 = OpVariable %10 Uniform +%19 = OpVariable %18 Uniform +%20 = OpVariable %59 Private +%25 = OpVariable %24 Output +%60 = OpConstant %13 0 +%61 = OpConstant %1 0.5 +%28 = OpFunction %2 None %27 +%29 = OpFunctionParameter %26 +%30 = OpLabel +%31 = OpLoad %2 %29 +OpReturnValue %31 +OpFunctionEnd +%32 = OpFunction %2 None %27 +%33 = OpFunctionParameter %26 +%34 = OpLabel +%35 = OpLoad %2 %33 +%36 = OpLoad %2 %33 +%37 = OpFAdd %2 %35 %36 +OpReturnValue %37 +OpFunctionEnd +%40 = OpFunction %38 None %39 +%41 = OpLabel +%42 = OpVariable %26 Function +%50 = OpVariable %26 Function +%53 = OpVariable %26 Function +%43 = OpLoad %2 %4 +OpStore %42 %43 +%44 = OpFunctionCall %2 %28 %42 +%47 = OpAccessChain %46 %11 %45 +%48 = OpLoad %2 %47 +%49 = OpFAdd %2 %44 %48 +OpStore %8 %49 +%51 = OpLoad %2 %5 +OpStore %50 %51 +%52 = OpFunctionCall %2 %32 %50 +%54 = OpLoad %2 %6 +OpStore %53 %54 +%55 = OpFunctionCall %2 %28 %53 +%56 = OpFAdd %2 %52 %55 +%57 = OpAccessChain %7 %25 %45 +OpStore %57 %56 +%62 = OpAccessChain %7 %25 %60 +%63 = OpLoad %2 %62 +%64 = OpCompositeExtract %1 %63 0 +%65 = OpCompositeExtract %1 %63 1 +%66 = OpCompositeExtract %1 %63 2 +%67 = OpCompositeExtract %1 %63 3 +%69 = OpFNegate %1 %64 +%70 = OpFAdd %1 %66 %67 +%71 = OpFMul %1 %70 %61 +%68 = OpCompositeConstruct %2 %65 %69 %71 %67 +OpStore %62 %68 +OpReturn +OpFunctionEnd +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 58 ++; Bound: 79 + ; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 +-OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %20 %25 ++OpEntryPoint Vertex %40 "main" %5 %6 %4 %20 %25 + OpSource GLSL 450 + OpDecorate %4 Location 0 + OpDecorate %5 Location 1 + OpDecorate %6 Location 2 +-OpDecorate %8 Location 0 + OpMemberDecorate %9 0 Offset 0 + OpDecorate %9 Block +-OpDecorate %11 DescriptorSet 0 ++OpDecorate %11 DescriptorSet 2 + OpDecorate %11 Binding 0 + OpMemberDecorate %16 0 Offset 0 + OpMemberDecorate %16 1 Offset 4 + OpMemberDecorate %16 2 Offset 8 + OpMemberDecorate %16 3 Offset 12 + OpMemberDecorate %17 0 Offset 0 + OpMemberDecorate %17 1 Offset 16 + OpMemberDecorate %17 2 Offset 20 + OpMemberDecorate %17 3 Offset 24 + OpMemberDecorate %17 4 Offset 28 + OpMemberDecorate %17 5 Offset 32 + OpMemberDecorate %17 6 Offset 48 + OpMemberDecorate %17 7 Offset 64 + OpMemberDecorate %17 2 RelaxedPrecision + OpMemberDecorate %17 4 RelaxedPrecision + OpDecorate %17 Block + OpDecorate %19 DescriptorSet 0 + OpDecorate %19 Binding 1 + OpDecorate %20 Location 1 + OpMemberDecorate %23 0 BuiltIn Position +-OpMemberDecorate %23 1 BuiltIn PointSize +-OpMemberDecorate %23 2 BuiltIn ClipDistance +-OpMemberDecorate %23 3 BuiltIn CullDistance + OpDecorate %23 Block + OpDecorate %28 RelaxedPrecision +-OpDecorate %29 RelaxedPrecision ++OpDecorate %59 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %32 RelaxedPrecision +-OpDecorate %33 RelaxedPrecision ++OpDecorate %60 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %44 RelaxedPrecision + OpDecorate %52 RelaxedPrecision + OpDecorate %55 RelaxedPrecision + OpDecorate %56 RelaxedPrecision + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %9 = OpTypeStruct %2 + %12 = OpTypeInt 32 0 + %13 = OpTypeInt 32 1 + %14 = OpTypeVector %13 4 + %15 = OpTypeVector %12 4 + %16 = OpTypeStruct %1 %1 %1 %1 + %17 = OpTypeStruct %2 %12 %12 %13 %13 %14 %15 %16 + %21 = OpConstant %12 8 + %22 = OpTypeArray %1 %21 +-%23 = OpTypeStruct %2 %1 %22 %22 ++%23 = OpTypeStruct %2 + %38 = OpTypeVoid + %45 = OpConstant %12 0 ++%65 = OpTypePointer Private %2 + %3 = OpTypePointer Input %2 ++%66 = OpTypePointer Private %2 + %7 = OpTypePointer Output %2 + %10 = OpTypePointer Uniform %9 + %18 = OpTypePointer Uniform %17 + %24 = OpTypePointer Output %23 + %26 = OpTypePointer Function %2 + %46 = OpTypePointer Uniform %2 + %27 = OpTypeFunction %2 %26 + %39 = OpTypeFunction %38 + %4 = OpVariable %3 Input + %5 = OpVariable %3 Input + %6 = OpVariable %3 Input +-%8 = OpVariable %7 Output +-%11 = OpVariable %10 Uniform ++%11 = OpVariable %18 Uniform +-%19 = OpVariable %18 Uniform ++%19 = OpVariable %10 Uniform + %20 = OpVariable %7 Output ++%58 = OpVariable %66 Private + %25 = OpVariable %24 Output ++%67 = OpConstant %13 0 ++%68 = OpConstant %1 0.5 + %28 = OpFunction %2 None %27 +-%29 = OpFunctionParameter %26 ++%59 = OpFunctionParameter %26 + %30 = OpLabel +-%31 = OpLoad %2 %29 ++%31 = OpLoad %2 %59 + OpReturnValue %31 + OpFunctionEnd + %32 = OpFunction %2 None %27 +-%33 = OpFunctionParameter %26 ++%60 = OpFunctionParameter %26 + %34 = OpLabel +-%35 = OpLoad %2 %33 ++%35 = OpLoad %2 %60 +-%36 = OpLoad %2 %33 ++%36 = OpLoad %2 %60 + %37 = OpFAdd %2 %35 %36 + OpReturnValue %37 + OpFunctionEnd + %40 = OpFunction %38 None %39 + %41 = OpLabel + %42 = OpVariable %26 Function + %50 = OpVariable %26 Function + %53 = OpVariable %26 Function +-%43 = OpLoad %2 %4 ++%61 = OpLoad %2 %5 +-OpStore %42 %43 ++OpStore %42 %61 + %44 = OpFunctionCall %2 %28 %42 +-%47 = OpAccessChain %46 %11 %45 ++%62 = OpAccessChain %46 %19 %45 +-%48 = OpLoad %2 %47 ++%48 = OpLoad %2 %62 + %49 = OpFAdd %2 %44 %48 +-OpStore %8 %49 ++OpStore %20 %49 +-%51 = OpLoad %2 %5 ++%63 = OpLoad %2 %6 +-OpStore %50 %51 ++OpStore %50 %63 + %52 = OpFunctionCall %2 %32 %50 +-%54 = OpLoad %2 %6 ++%64 = OpLoad %2 %4 +-OpStore %53 %54 ++OpStore %53 %64 + %55 = OpFunctionCall %2 %28 %53 + %56 = OpFAdd %2 %52 %55 + %57 = OpAccessChain %7 %25 %45 + OpStore %57 %56 ++%69 = OpAccessChain %7 %25 %67 ++%70 = OpLoad %2 %69 ++%71 = OpCompositeExtract %1 %70 0 ++%72 = OpCompositeExtract %1 %70 1 ++%73 = OpCompositeExtract %1 %70 2 ++%74 = OpCompositeExtract %1 %70 3 ++%76 = OpFNegate %1 %71 ++%77 = OpFAdd %1 %73 %74 ++%78 = OpFMul %1 %77 %68 ++%75 = OpCompositeConstruct %2 %72 %76 %78 %74 ++OpStore %69 %75 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +TEST(DiffTest, DifferentDecorationsVertexIgnoreSetBinding) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 58 ++; Bound: 73 + ; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 +-OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %20 %25 ++OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %25 + OpSource GLSL 450 + OpName %4 "_ub" + OpName %5 "_uc" + OpName %6 "_ud" + OpName %8 "_ue" + OpName %9 "defaultUniformsVS" + OpMemberName %9 0 "_ua" + OpName %11 "" + OpName %16 "ANGLEDepthRangeParams" + OpMemberName %16 0 "near" + OpMemberName %16 1 "far" + OpMemberName %16 2 "diff" + OpMemberName %16 3 "reserved" + OpName %17 "ANGLEUniformBlock" + OpMemberName %17 0 "viewport" + OpMemberName %17 1 "clipDistancesEnabled" + OpMemberName %17 2 "xfbActiveUnpaused" + OpMemberName %17 3 "xfbVerticesPerInstance" + OpMemberName %17 4 "numSamples" + OpMemberName %17 5 "xfbBufferOffsets" + OpMemberName %17 6 "acbBufferOffsets" + OpMemberName %17 7 "depthRange" + OpName %19 "ANGLEUniforms" +-OpName %20 "ANGLEXfbPosition" + OpName %23 "gl_PerVertex" + OpMemberName %23 0 "gl_Position" +-OpMemberName %23 1 "gl_PointSize" +-OpMemberName %23 2 "gl_ClipDistance" +-OpMemberName %23 3 "gl_CullDistance" + OpName %25 "" + OpName %29 "_ua" + OpName %28 "_uf" + OpName %33 "_uf" + OpName %32 "_ug" + OpName %40 "main" + OpName %42 "param" + OpName %50 "param" + OpName %53 "param" +-OpDecorate %4 Location 0 ++OpDecorate %4 Location 1 +-OpDecorate %5 Location 1 ++OpDecorate %5 Location 2 +-OpDecorate %6 Location 2 ++OpDecorate %6 Location 0 +-OpDecorate %8 Location 0 ++OpDecorate %8 Location 1 + OpMemberDecorate %9 0 Offset 0 + OpDecorate %9 Block + OpDecorate %11 DescriptorSet 0 +-OpDecorate %11 Binding 0 ++OpDecorate %11 Binding 1 + OpMemberDecorate %16 0 Offset 0 + OpMemberDecorate %16 1 Offset 4 + OpMemberDecorate %16 2 Offset 8 + OpMemberDecorate %16 3 Offset 12 + OpMemberDecorate %17 0 Offset 0 + OpMemberDecorate %17 1 Offset 16 + OpMemberDecorate %17 2 Offset 20 + OpMemberDecorate %17 3 Offset 24 + OpMemberDecorate %17 4 Offset 28 + OpMemberDecorate %17 5 Offset 32 + OpMemberDecorate %17 6 Offset 48 + OpMemberDecorate %17 7 Offset 64 + OpMemberDecorate %17 2 RelaxedPrecision + OpMemberDecorate %17 4 RelaxedPrecision + OpDecorate %17 Block +-OpDecorate %19 DescriptorSet 0 ++OpDecorate %19 DescriptorSet 2 +-OpDecorate %19 Binding 1 ++OpDecorate %19 Binding 0 +-OpDecorate %20 Location 1 + OpMemberDecorate %23 0 BuiltIn Position +-OpMemberDecorate %23 1 BuiltIn PointSize +-OpMemberDecorate %23 2 BuiltIn ClipDistance +-OpMemberDecorate %23 3 BuiltIn CullDistance + OpDecorate %23 Block + OpDecorate %28 RelaxedPrecision + OpDecorate %29 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %32 RelaxedPrecision + OpDecorate %33 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %44 RelaxedPrecision + OpDecorate %52 RelaxedPrecision + OpDecorate %55 RelaxedPrecision + OpDecorate %56 RelaxedPrecision + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %9 = OpTypeStruct %2 + %12 = OpTypeInt 32 0 + %13 = OpTypeInt 32 1 + %14 = OpTypeVector %13 4 + %15 = OpTypeVector %12 4 + %16 = OpTypeStruct %1 %1 %1 %1 + %17 = OpTypeStruct %2 %12 %12 %13 %13 %14 %15 %16 + %21 = OpConstant %12 8 + %22 = OpTypeArray %1 %21 +-%23 = OpTypeStruct %2 %1 %22 %22 ++%23 = OpTypeStruct %2 + %38 = OpTypeVoid + %45 = OpConstant %12 0 ++%59 = OpTypePointer Private %2 + %3 = OpTypePointer Input %2 ++%60 = OpTypePointer Private %2 + %7 = OpTypePointer Output %2 + %10 = OpTypePointer Uniform %9 + %18 = OpTypePointer Uniform %17 + %24 = OpTypePointer Output %23 + %26 = OpTypePointer Function %2 + %46 = OpTypePointer Uniform %2 + %27 = OpTypeFunction %2 %26 + %39 = OpTypeFunction %38 + %4 = OpVariable %3 Input + %5 = OpVariable %3 Input + %6 = OpVariable %3 Input + %8 = OpVariable %7 Output + %11 = OpVariable %10 Uniform + %19 = OpVariable %18 Uniform +-%20 = OpVariable %7 Output ++%58 = OpVariable %60 Private + %25 = OpVariable %24 Output ++%61 = OpConstant %13 0 ++%62 = OpConstant %1 0.5 + %28 = OpFunction %2 None %27 + %29 = OpFunctionParameter %26 + %30 = OpLabel + %31 = OpLoad %2 %29 + OpReturnValue %31 + OpFunctionEnd + %32 = OpFunction %2 None %27 + %33 = OpFunctionParameter %26 + %34 = OpLabel + %35 = OpLoad %2 %33 + %36 = OpLoad %2 %33 + %37 = OpFAdd %2 %35 %36 + OpReturnValue %37 + OpFunctionEnd + %40 = OpFunction %38 None %39 + %41 = OpLabel + %42 = OpVariable %26 Function + %50 = OpVariable %26 Function + %53 = OpVariable %26 Function + %43 = OpLoad %2 %4 + OpStore %42 %43 + %44 = OpFunctionCall %2 %28 %42 + %47 = OpAccessChain %46 %11 %45 + %48 = OpLoad %2 %47 + %49 = OpFAdd %2 %44 %48 + OpStore %8 %49 + %51 = OpLoad %2 %5 + OpStore %50 %51 + %52 = OpFunctionCall %2 %32 %50 + %54 = OpLoad %2 %6 + OpStore %53 %54 + %55 = OpFunctionCall %2 %28 %53 + %56 = OpFAdd %2 %52 %55 + %57 = OpAccessChain %7 %25 %45 + OpStore %57 %56 ++%63 = OpAccessChain %7 %25 %61 ++%64 = OpLoad %2 %63 ++%65 = OpCompositeExtract %1 %64 0 ++%66 = OpCompositeExtract %1 %64 1 ++%67 = OpCompositeExtract %1 %64 2 ++%68 = OpCompositeExtract %1 %64 3 ++%70 = OpFNegate %1 %65 ++%71 = OpFAdd %1 %67 %68 ++%72 = OpFMul %1 %71 %62 ++%69 = OpCompositeConstruct %2 %66 %70 %72 %68 ++OpStore %63 %69 + OpReturn + OpFunctionEnd +)"; + Options options; + options.ignore_set_binding = true; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, DifferentDecorationsVertexIgnoreSetBindingLocation) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 58 ++; Bound: 73 + ; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 +-OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %20 %25 ++OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %25 + OpSource GLSL 450 + OpName %4 "_ub" + OpName %5 "_uc" + OpName %6 "_ud" + OpName %8 "_ue" + OpName %9 "defaultUniformsVS" + OpMemberName %9 0 "_ua" + OpName %11 "" + OpName %16 "ANGLEDepthRangeParams" + OpMemberName %16 0 "near" + OpMemberName %16 1 "far" + OpMemberName %16 2 "diff" + OpMemberName %16 3 "reserved" + OpName %17 "ANGLEUniformBlock" + OpMemberName %17 0 "viewport" + OpMemberName %17 1 "clipDistancesEnabled" + OpMemberName %17 2 "xfbActiveUnpaused" + OpMemberName %17 3 "xfbVerticesPerInstance" + OpMemberName %17 4 "numSamples" + OpMemberName %17 5 "xfbBufferOffsets" + OpMemberName %17 6 "acbBufferOffsets" + OpMemberName %17 7 "depthRange" + OpName %19 "ANGLEUniforms" +-OpName %20 "ANGLEXfbPosition" + OpName %23 "gl_PerVertex" + OpMemberName %23 0 "gl_Position" +-OpMemberName %23 1 "gl_PointSize" +-OpMemberName %23 2 "gl_ClipDistance" +-OpMemberName %23 3 "gl_CullDistance" + OpName %25 "" + OpName %29 "_ua" + OpName %28 "_uf" + OpName %33 "_uf" + OpName %32 "_ug" + OpName %40 "main" + OpName %42 "param" + OpName %50 "param" + OpName %53 "param" +-OpDecorate %4 Location 0 ++OpDecorate %4 Location 1 +-OpDecorate %5 Location 1 ++OpDecorate %5 Location 2 +-OpDecorate %6 Location 2 ++OpDecorate %6 Location 0 +-OpDecorate %8 Location 0 ++OpDecorate %8 Location 1 + OpMemberDecorate %9 0 Offset 0 + OpDecorate %9 Block + OpDecorate %11 DescriptorSet 0 +-OpDecorate %11 Binding 0 ++OpDecorate %11 Binding 1 + OpMemberDecorate %16 0 Offset 0 + OpMemberDecorate %16 1 Offset 4 + OpMemberDecorate %16 2 Offset 8 + OpMemberDecorate %16 3 Offset 12 + OpMemberDecorate %17 0 Offset 0 + OpMemberDecorate %17 1 Offset 16 + OpMemberDecorate %17 2 Offset 20 + OpMemberDecorate %17 3 Offset 24 + OpMemberDecorate %17 4 Offset 28 + OpMemberDecorate %17 5 Offset 32 + OpMemberDecorate %17 6 Offset 48 + OpMemberDecorate %17 7 Offset 64 + OpMemberDecorate %17 2 RelaxedPrecision + OpMemberDecorate %17 4 RelaxedPrecision + OpDecorate %17 Block +-OpDecorate %19 DescriptorSet 0 ++OpDecorate %19 DescriptorSet 2 +-OpDecorate %19 Binding 1 ++OpDecorate %19 Binding 0 +-OpDecorate %20 Location 1 + OpMemberDecorate %23 0 BuiltIn Position +-OpMemberDecorate %23 1 BuiltIn PointSize +-OpMemberDecorate %23 2 BuiltIn ClipDistance +-OpMemberDecorate %23 3 BuiltIn CullDistance + OpDecorate %23 Block + OpDecorate %28 RelaxedPrecision + OpDecorate %29 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %32 RelaxedPrecision + OpDecorate %33 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %44 RelaxedPrecision + OpDecorate %52 RelaxedPrecision + OpDecorate %55 RelaxedPrecision + OpDecorate %56 RelaxedPrecision + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %9 = OpTypeStruct %2 + %12 = OpTypeInt 32 0 + %13 = OpTypeInt 32 1 + %14 = OpTypeVector %13 4 + %15 = OpTypeVector %12 4 + %16 = OpTypeStruct %1 %1 %1 %1 + %17 = OpTypeStruct %2 %12 %12 %13 %13 %14 %15 %16 + %21 = OpConstant %12 8 + %22 = OpTypeArray %1 %21 +-%23 = OpTypeStruct %2 %1 %22 %22 ++%23 = OpTypeStruct %2 + %38 = OpTypeVoid + %45 = OpConstant %12 0 ++%59 = OpTypePointer Private %2 + %3 = OpTypePointer Input %2 ++%60 = OpTypePointer Private %2 + %7 = OpTypePointer Output %2 + %10 = OpTypePointer Uniform %9 + %18 = OpTypePointer Uniform %17 + %24 = OpTypePointer Output %23 + %26 = OpTypePointer Function %2 + %46 = OpTypePointer Uniform %2 + %27 = OpTypeFunction %2 %26 + %39 = OpTypeFunction %38 + %4 = OpVariable %3 Input + %5 = OpVariable %3 Input + %6 = OpVariable %3 Input + %8 = OpVariable %7 Output + %11 = OpVariable %10 Uniform + %19 = OpVariable %18 Uniform +-%20 = OpVariable %7 Output ++%58 = OpVariable %60 Private + %25 = OpVariable %24 Output ++%61 = OpConstant %13 0 ++%62 = OpConstant %1 0.5 + %28 = OpFunction %2 None %27 + %29 = OpFunctionParameter %26 + %30 = OpLabel + %31 = OpLoad %2 %29 + OpReturnValue %31 + OpFunctionEnd + %32 = OpFunction %2 None %27 + %33 = OpFunctionParameter %26 + %34 = OpLabel + %35 = OpLoad %2 %33 + %36 = OpLoad %2 %33 + %37 = OpFAdd %2 %35 %36 + OpReturnValue %37 + OpFunctionEnd + %40 = OpFunction %38 None %39 + %41 = OpLabel + %42 = OpVariable %26 Function + %50 = OpVariable %26 Function + %53 = OpVariable %26 Function + %43 = OpLoad %2 %4 + OpStore %42 %43 + %44 = OpFunctionCall %2 %28 %42 + %47 = OpAccessChain %46 %11 %45 + %48 = OpLoad %2 %47 + %49 = OpFAdd %2 %44 %48 + OpStore %8 %49 + %51 = OpLoad %2 %5 + OpStore %50 %51 + %52 = OpFunctionCall %2 %32 %50 + %54 = OpLoad %2 %6 + OpStore %53 %54 + %55 = OpFunctionCall %2 %28 %53 + %56 = OpFAdd %2 %52 %55 + %57 = OpAccessChain %7 %25 %45 + OpStore %57 %56 ++%63 = OpAccessChain %7 %25 %61 ++%64 = OpLoad %2 %63 ++%65 = OpCompositeExtract %1 %64 0 ++%66 = OpCompositeExtract %1 %64 1 ++%67 = OpCompositeExtract %1 %64 2 ++%68 = OpCompositeExtract %1 %64 3 ++%70 = OpFNegate %1 %65 ++%71 = OpFAdd %1 %67 %68 ++%72 = OpFMul %1 %71 %62 ++%69 = OpCompositeConstruct %2 %66 %70 %72 %68 ++OpStore %63 %69 + OpReturn + OpFunctionEnd +)"; + Options options; + options.ignore_set_binding = true; + options.ignore_location = true; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/different_decorations_vertex_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/different_decorations_vertex_dst.spvasm new file mode 100644 index 0000000000..33c6a9c125 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/different_decorations_vertex_dst.spvasm @@ -0,0 +1,159 @@ +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %25 +OpSource GLSL 450 +OpName %4 "_ub" +OpName %5 "_uc" +OpName %6 "_ud" +OpName %8 "_ue" +OpName %9 "defaultUniformsVS" +OpMemberName %9 0 "_ua" +OpName %11 "" +OpName %16 "ANGLEDepthRangeParams" +OpMemberName %16 0 "near" +OpMemberName %16 1 "far" +OpMemberName %16 2 "diff" +OpMemberName %16 3 "reserved" +OpName %17 "ANGLEUniformBlock" +OpMemberName %17 0 "viewport" +OpMemberName %17 1 "clipDistancesEnabled" +OpMemberName %17 2 "xfbActiveUnpaused" +OpMemberName %17 3 "xfbVerticesPerInstance" +OpMemberName %17 4 "numSamples" +OpMemberName %17 5 "xfbBufferOffsets" +OpMemberName %17 6 "acbBufferOffsets" +OpMemberName %17 7 "depthRange" +OpName %19 "ANGLEUniforms" +OpName %23 "gl_PerVertex" +OpMemberName %23 0 "gl_Position" +OpName %25 "" +OpName %29 "_ua" +OpName %28 "_uf" +OpName %33 "_uf" +OpName %32 "_ug" +OpName %40 "main" +OpName %42 "param" +OpName %50 "param" +OpName %53 "param" +OpDecorate %4 Location 1 +OpDecorate %5 Location 2 +OpDecorate %6 Location 0 +OpDecorate %8 Location 1 +OpMemberDecorate %9 0 Offset 0 +OpDecorate %9 Block +OpDecorate %11 DescriptorSet 0 +OpDecorate %11 Binding 1 +OpMemberDecorate %16 0 Offset 0 +OpMemberDecorate %16 1 Offset 4 +OpMemberDecorate %16 2 Offset 8 +OpMemberDecorate %16 3 Offset 12 +OpMemberDecorate %17 0 Offset 0 +OpMemberDecorate %17 1 Offset 16 +OpMemberDecorate %17 2 Offset 20 +OpMemberDecorate %17 3 Offset 24 +OpMemberDecorate %17 4 Offset 28 +OpMemberDecorate %17 5 Offset 32 +OpMemberDecorate %17 6 Offset 48 +OpMemberDecorate %17 7 Offset 64 +OpMemberDecorate %17 2 RelaxedPrecision +OpMemberDecorate %17 4 RelaxedPrecision +OpDecorate %17 Block +OpDecorate %19 DescriptorSet 2 +OpDecorate %19 Binding 0 +OpMemberDecorate %23 0 BuiltIn Position +OpDecorate %23 Block +OpDecorate %28 RelaxedPrecision +OpDecorate %29 RelaxedPrecision +OpDecorate %31 RelaxedPrecision +OpDecorate %32 RelaxedPrecision +OpDecorate %33 RelaxedPrecision +OpDecorate %35 RelaxedPrecision +OpDecorate %36 RelaxedPrecision +OpDecorate %37 RelaxedPrecision +OpDecorate %44 RelaxedPrecision +OpDecorate %52 RelaxedPrecision +OpDecorate %55 RelaxedPrecision +OpDecorate %56 RelaxedPrecision +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%9 = OpTypeStruct %2 +%12 = OpTypeInt 32 0 +%13 = OpTypeInt 32 1 +%14 = OpTypeVector %13 4 +%15 = OpTypeVector %12 4 +%16 = OpTypeStruct %1 %1 %1 %1 +%17 = OpTypeStruct %2 %12 %12 %13 %13 %14 %15 %16 +%21 = OpConstant %12 8 +%22 = OpTypeArray %1 %21 +%23 = OpTypeStruct %2 +%38 = OpTypeVoid +%45 = OpConstant %12 0 +%58 = OpTypePointer Private %2 +%3 = OpTypePointer Input %2 +%59 = OpTypePointer Private %2 +%7 = OpTypePointer Output %2 +%10 = OpTypePointer Uniform %9 +%18 = OpTypePointer Uniform %17 +%24 = OpTypePointer Output %23 +%26 = OpTypePointer Function %2 +%46 = OpTypePointer Uniform %2 +%27 = OpTypeFunction %2 %26 +%39 = OpTypeFunction %38 +%4 = OpVariable %3 Input +%5 = OpVariable %3 Input +%6 = OpVariable %3 Input +%8 = OpVariable %7 Output +%11 = OpVariable %10 Uniform +%19 = OpVariable %18 Uniform +%20 = OpVariable %59 Private +%25 = OpVariable %24 Output +%60 = OpConstant %13 0 +%61 = OpConstant %1 0.5 +%28 = OpFunction %2 None %27 +%29 = OpFunctionParameter %26 +%30 = OpLabel +%31 = OpLoad %2 %29 +OpReturnValue %31 +OpFunctionEnd +%32 = OpFunction %2 None %27 +%33 = OpFunctionParameter %26 +%34 = OpLabel +%35 = OpLoad %2 %33 +%36 = OpLoad %2 %33 +%37 = OpFAdd %2 %35 %36 +OpReturnValue %37 +OpFunctionEnd +%40 = OpFunction %38 None %39 +%41 = OpLabel +%42 = OpVariable %26 Function +%50 = OpVariable %26 Function +%53 = OpVariable %26 Function +%43 = OpLoad %2 %4 +OpStore %42 %43 +%44 = OpFunctionCall %2 %28 %42 +%47 = OpAccessChain %46 %11 %45 +%48 = OpLoad %2 %47 +%49 = OpFAdd %2 %44 %48 +OpStore %8 %49 +%51 = OpLoad %2 %5 +OpStore %50 %51 +%52 = OpFunctionCall %2 %32 %50 +%54 = OpLoad %2 %6 +OpStore %53 %54 +%55 = OpFunctionCall %2 %28 %53 +%56 = OpFAdd %2 %52 %55 +%57 = OpAccessChain %7 %25 %45 +OpStore %57 %56 +%62 = OpAccessChain %7 %25 %60 +%63 = OpLoad %2 %62 +%64 = OpCompositeExtract %1 %63 0 +%65 = OpCompositeExtract %1 %63 1 +%66 = OpCompositeExtract %1 %63 2 +%67 = OpCompositeExtract %1 %63 3 +%69 = OpFNegate %1 %64 +%70 = OpFAdd %1 %66 %67 +%71 = OpFMul %1 %70 %61 +%68 = OpCompositeConstruct %2 %65 %69 %71 %67 +OpStore %62 %68 +OpReturn +OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/different_decorations_vertex_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/different_decorations_vertex_src.spvasm new file mode 100644 index 0000000000..ce1680cb4f --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/different_decorations_vertex_src.spvasm @@ -0,0 +1,155 @@ +;; Test where variable set/binding/location decorations are different between +;; src and dst vertex shaders. +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %20 %25 +OpSource GLSL 450 +OpName %4 "_ub" +OpName %5 "_uc" +OpName %6 "_ud" +OpName %8 "_ue" +OpName %9 "defaultUniformsVS" +OpMemberName %9 0 "_ua" +OpName %11 "" +OpName %16 "ANGLEDepthRangeParams" +OpMemberName %16 0 "near" +OpMemberName %16 1 "far" +OpMemberName %16 2 "diff" +OpMemberName %16 3 "reserved" +OpName %17 "ANGLEUniformBlock" +OpMemberName %17 0 "viewport" +OpMemberName %17 1 "clipDistancesEnabled" +OpMemberName %17 2 "xfbActiveUnpaused" +OpMemberName %17 3 "xfbVerticesPerInstance" +OpMemberName %17 4 "numSamples" +OpMemberName %17 5 "xfbBufferOffsets" +OpMemberName %17 6 "acbBufferOffsets" +OpMemberName %17 7 "depthRange" +OpName %19 "ANGLEUniforms" +OpName %20 "ANGLEXfbPosition" +OpName %23 "gl_PerVertex" +OpMemberName %23 0 "gl_Position" +OpMemberName %23 1 "gl_PointSize" +OpMemberName %23 2 "gl_ClipDistance" +OpMemberName %23 3 "gl_CullDistance" +OpName %25 "" +OpName %29 "_ua" +OpName %28 "_uf" +OpName %33 "_uf" +OpName %32 "_ug" +OpName %40 "main" +OpName %42 "param" +OpName %50 "param" +OpName %53 "param" +OpDecorate %4 Location 0 +OpDecorate %5 Location 1 +OpDecorate %6 Location 2 +OpDecorate %8 Location 0 +OpMemberDecorate %9 0 Offset 0 +OpDecorate %9 Block +OpDecorate %11 DescriptorSet 0 +OpDecorate %11 Binding 0 +OpMemberDecorate %16 0 Offset 0 +OpMemberDecorate %16 1 Offset 4 +OpMemberDecorate %16 2 Offset 8 +OpMemberDecorate %16 3 Offset 12 +OpMemberDecorate %17 0 Offset 0 +OpMemberDecorate %17 1 Offset 16 +OpMemberDecorate %17 2 Offset 20 +OpMemberDecorate %17 3 Offset 24 +OpMemberDecorate %17 4 Offset 28 +OpMemberDecorate %17 5 Offset 32 +OpMemberDecorate %17 6 Offset 48 +OpMemberDecorate %17 7 Offset 64 +OpMemberDecorate %17 2 RelaxedPrecision +OpMemberDecorate %17 4 RelaxedPrecision +OpDecorate %17 Block +OpDecorate %19 DescriptorSet 0 +OpDecorate %19 Binding 1 +OpDecorate %20 Location 1 +OpMemberDecorate %23 0 BuiltIn Position +OpMemberDecorate %23 1 BuiltIn PointSize +OpMemberDecorate %23 2 BuiltIn ClipDistance +OpMemberDecorate %23 3 BuiltIn CullDistance +OpDecorate %23 Block +OpDecorate %28 RelaxedPrecision +OpDecorate %29 RelaxedPrecision +OpDecorate %31 RelaxedPrecision +OpDecorate %32 RelaxedPrecision +OpDecorate %33 RelaxedPrecision +OpDecorate %35 RelaxedPrecision +OpDecorate %36 RelaxedPrecision +OpDecorate %37 RelaxedPrecision +OpDecorate %44 RelaxedPrecision +OpDecorate %52 RelaxedPrecision +OpDecorate %55 RelaxedPrecision +OpDecorate %56 RelaxedPrecision +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%9 = OpTypeStruct %2 +%12 = OpTypeInt 32 0 +%13 = OpTypeInt 32 1 +%14 = OpTypeVector %13 4 +%15 = OpTypeVector %12 4 +%16 = OpTypeStruct %1 %1 %1 %1 +%17 = OpTypeStruct %2 %12 %12 %13 %13 %14 %15 %16 +%21 = OpConstant %12 8 +%22 = OpTypeArray %1 %21 +%23 = OpTypeStruct %2 %1 %22 %22 +%38 = OpTypeVoid +%45 = OpConstant %12 0 +%3 = OpTypePointer Input %2 +%7 = OpTypePointer Output %2 +%10 = OpTypePointer Uniform %9 +%18 = OpTypePointer Uniform %17 +%24 = OpTypePointer Output %23 +%26 = OpTypePointer Function %2 +%46 = OpTypePointer Uniform %2 +%27 = OpTypeFunction %2 %26 +%39 = OpTypeFunction %38 +%4 = OpVariable %3 Input +%5 = OpVariable %3 Input +%6 = OpVariable %3 Input +%8 = OpVariable %7 Output +%11 = OpVariable %10 Uniform +%19 = OpVariable %18 Uniform +%20 = OpVariable %7 Output +%25 = OpVariable %24 Output +%28 = OpFunction %2 None %27 +%29 = OpFunctionParameter %26 +%30 = OpLabel +%31 = OpLoad %2 %29 +OpReturnValue %31 +OpFunctionEnd +%32 = OpFunction %2 None %27 +%33 = OpFunctionParameter %26 +%34 = OpLabel +%35 = OpLoad %2 %33 +%36 = OpLoad %2 %33 +%37 = OpFAdd %2 %35 %36 +OpReturnValue %37 +OpFunctionEnd +%40 = OpFunction %38 None %39 +%41 = OpLabel +%42 = OpVariable %26 Function +%50 = OpVariable %26 Function +%53 = OpVariable %26 Function +%43 = OpLoad %2 %4 +OpStore %42 %43 +%44 = OpFunctionCall %2 %28 %42 +%47 = OpAccessChain %46 %11 %45 +%48 = OpLoad %2 %47 +%49 = OpFAdd %2 %44 %48 +OpStore %8 %49 +%51 = OpLoad %2 %5 +OpStore %50 %51 +%52 = OpFunctionCall %2 %32 %50 +%54 = OpLoad %2 %6 +OpStore %53 %54 +%55 = OpFunctionCall %2 %28 %53 +%56 = OpFAdd %2 %52 %55 +%57 = OpAccessChain %7 %25 %45 +OpStore %57 %56 +OpReturn +OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/different_function_parameter_count_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/different_function_parameter_count_autogen.cpp new file mode 100644 index 0000000000..3a077fb0eb --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/different_function_parameter_count_autogen.cpp @@ -0,0 +1,339 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Test where src and dst have a function with different parameter count. +constexpr char kSrc[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 25 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %20 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 320 + OpName %4 "main" + OpName %11 "f(vf2;" + OpName %10 "v" + OpName %20 "o" + OpName %23 "param" + OpDecorate %20 RelaxedPrecision + OpDecorate %20 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 2 + %8 = OpTypePointer Function %7 + %9 = OpTypeFunction %7 %8 + %14 = OpConstant %6 0.5 + %15 = OpConstantComposite %7 %14 %14 + %19 = OpTypePointer Output %7 + %20 = OpVariable %19 Output + %21 = OpConstant %6 0 + %22 = OpConstantComposite %7 %21 %21 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %23 = OpVariable %8 Function + OpStore %23 %22 + %24 = OpFunctionCall %7 %11 %23 + OpStore %20 %24 + OpReturn + OpFunctionEnd + %11 = OpFunction %7 None %9 + %10 = OpFunctionParameter %8 + %12 = OpLabel + %13 = OpLoad %7 %10 + %16 = OpFAdd %7 %13 %15 + OpReturnValue %16 + OpFunctionEnd)"; +constexpr char kDst[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 28 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %20 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 320 + OpName %4 "main" + OpName %12 "f(vf2;vf2;" + OpName %10 "v" + OpName %11 "v2" + OpName %20 "o" + OpName %25 "param" + OpName %26 "param" + OpDecorate %20 RelaxedPrecision + OpDecorate %20 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 2 + %8 = OpTypePointer Function %7 + %9 = OpTypeFunction %7 %8 %8 + %19 = OpTypePointer Output %7 + %20 = OpVariable %19 Output + %21 = OpConstant %6 0 + %22 = OpConstantComposite %7 %21 %21 + %23 = OpConstant %6 0.5 + %24 = OpConstantComposite %7 %23 %23 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %25 = OpVariable %8 Function + %26 = OpVariable %8 Function + OpStore %25 %22 + OpStore %26 %24 + %27 = OpFunctionCall %7 %12 %25 %26 + OpStore %20 %27 + OpReturn + OpFunctionEnd + %12 = OpFunction %7 None %9 + %10 = OpFunctionParameter %8 + %11 = OpFunctionParameter %8 + %13 = OpLabel + %14 = OpLoad %7 %10 + %15 = OpLoad %7 %11 + %16 = OpFAdd %7 %14 %15 + OpReturnValue %16 + OpFunctionEnd + +)"; + +TEST(DiffTest, DifferentFunctionParameterCount) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 25 ++; Bound: 33 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %20 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 320 + OpName %4 "main" +-OpName %11 "f(vf2;" ++OpName %11 "f(vf2;vf2;" + OpName %10 "v" ++OpName %26 "v2" + OpName %20 "o" + OpName %23 "param" ++OpName %31 "param" + OpDecorate %20 RelaxedPrecision + OpDecorate %20 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 2 + %8 = OpTypePointer Function %7 +-%9 = OpTypeFunction %7 %8 ++%25 = OpTypeFunction %7 %8 %8 + %14 = OpConstant %6 0.5 + %15 = OpConstantComposite %7 %14 %14 + %19 = OpTypePointer Output %7 + %20 = OpVariable %19 Output + %21 = OpConstant %6 0 + %22 = OpConstantComposite %7 %21 %21 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %23 = OpVariable %8 Function ++%31 = OpVariable %8 Function + OpStore %23 %22 +-%24 = OpFunctionCall %7 %11 %23 ++OpStore %31 %15 ++%32 = OpFunctionCall %7 %11 %23 %31 +-OpStore %20 %24 ++OpStore %20 %32 + OpReturn + OpFunctionEnd +-%11 = OpFunction %7 None %9 ++%11 = OpFunction %7 None %25 + %10 = OpFunctionParameter %8 ++%26 = OpFunctionParameter %8 + %12 = OpLabel + %13 = OpLoad %7 %10 +-%16 = OpFAdd %7 %13 %15 ++%27 = OpLoad %7 %26 ++%28 = OpFAdd %7 %13 %27 +-OpReturnValue %16 ++OpReturnValue %28 + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, DifferentFunctionParameterCountNoDebug) { + constexpr char kSrcNoDebug[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 25 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %20 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 320 + OpDecorate %20 RelaxedPrecision + OpDecorate %20 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 2 + %8 = OpTypePointer Function %7 + %9 = OpTypeFunction %7 %8 + %14 = OpConstant %6 0.5 + %15 = OpConstantComposite %7 %14 %14 + %19 = OpTypePointer Output %7 + %20 = OpVariable %19 Output + %21 = OpConstant %6 0 + %22 = OpConstantComposite %7 %21 %21 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %23 = OpVariable %8 Function + OpStore %23 %22 + %24 = OpFunctionCall %7 %11 %23 + OpStore %20 %24 + OpReturn + OpFunctionEnd + %11 = OpFunction %7 None %9 + %10 = OpFunctionParameter %8 + %12 = OpLabel + %13 = OpLoad %7 %10 + %16 = OpFAdd %7 %13 %15 + OpReturnValue %16 + OpFunctionEnd +)"; + constexpr char kDstNoDebug[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 28 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %20 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 320 + OpDecorate %20 RelaxedPrecision + OpDecorate %20 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 2 + %8 = OpTypePointer Function %7 + %9 = OpTypeFunction %7 %8 %8 + %19 = OpTypePointer Output %7 + %20 = OpVariable %19 Output + %21 = OpConstant %6 0 + %22 = OpConstantComposite %7 %21 %21 + %23 = OpConstant %6 0.5 + %24 = OpConstantComposite %7 %23 %23 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %25 = OpVariable %8 Function + %26 = OpVariable %8 Function + OpStore %25 %22 + OpStore %26 %24 + %27 = OpFunctionCall %7 %12 %25 %26 + OpStore %20 %27 + OpReturn + OpFunctionEnd + %12 = OpFunction %7 None %9 + %10 = OpFunctionParameter %8 + %11 = OpFunctionParameter %8 + %13 = OpLabel + %14 = OpLoad %7 %10 + %15 = OpLoad %7 %11 + %16 = OpFAdd %7 %14 %15 + OpReturnValue %16 + OpFunctionEnd + +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 25 ++; Bound: 34 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %20 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 320 + OpDecorate %20 RelaxedPrecision + OpDecorate %20 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 2 + %8 = OpTypePointer Function %7 +-%9 = OpTypeFunction %7 %8 ++%25 = OpTypeFunction %7 %8 %8 + %14 = OpConstant %6 0.5 + %15 = OpConstantComposite %7 %14 %14 + %19 = OpTypePointer Output %7 + %20 = OpVariable %19 Output + %21 = OpConstant %6 0 + %22 = OpConstantComposite %7 %21 %21 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %23 = OpVariable %8 Function ++%32 = OpVariable %8 Function + OpStore %23 %22 +-%24 = OpFunctionCall %7 %11 %23 ++OpStore %32 %15 ++%33 = OpFunctionCall %7 %11 %23 %32 +-OpStore %20 %24 ++OpStore %20 %33 + OpReturn + OpFunctionEnd +-%11 = OpFunction %7 None %9 ++%11 = OpFunction %7 None %25 +-%10 = OpFunctionParameter %8 ++%26 = OpFunctionParameter %8 ++%27 = OpFunctionParameter %8 + %12 = OpLabel +-%13 = OpLoad %7 %10 ++%13 = OpLoad %7 %26 +-%16 = OpFAdd %7 %13 %15 ++%28 = OpLoad %7 %27 ++%29 = OpFAdd %7 %13 %28 +-OpReturnValue %16 ++OpReturnValue %29 + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/different_function_parameter_count_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/different_function_parameter_count_dst.spvasm new file mode 100644 index 0000000000..9244260125 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/different_function_parameter_count_dst.spvasm @@ -0,0 +1,52 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 28 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %20 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 320 + OpName %4 "main" + OpName %12 "f(vf2;vf2;" + OpName %10 "v" + OpName %11 "v2" + OpName %20 "o" + OpName %25 "param" + OpName %26 "param" + OpDecorate %20 RelaxedPrecision + OpDecorate %20 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 2 + %8 = OpTypePointer Function %7 + %9 = OpTypeFunction %7 %8 %8 + %19 = OpTypePointer Output %7 + %20 = OpVariable %19 Output + %21 = OpConstant %6 0 + %22 = OpConstantComposite %7 %21 %21 + %23 = OpConstant %6 0.5 + %24 = OpConstantComposite %7 %23 %23 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %25 = OpVariable %8 Function + %26 = OpVariable %8 Function + OpStore %25 %22 + OpStore %26 %24 + %27 = OpFunctionCall %7 %12 %25 %26 + OpStore %20 %27 + OpReturn + OpFunctionEnd + %12 = OpFunction %7 None %9 + %10 = OpFunctionParameter %8 + %11 = OpFunctionParameter %8 + %13 = OpLabel + %14 = OpLoad %7 %10 + %15 = OpLoad %7 %11 + %16 = OpFAdd %7 %14 %15 + OpReturnValue %16 + OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/different_function_parameter_count_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/different_function_parameter_count_src.spvasm new file mode 100644 index 0000000000..6ee2408a79 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/different_function_parameter_count_src.spvasm @@ -0,0 +1,46 @@ +;; Test where src and dst have a function with different parameter count. +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 25 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %20 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 320 + OpName %4 "main" + OpName %11 "f(vf2;" + OpName %10 "v" + OpName %20 "o" + OpName %23 "param" + OpDecorate %20 RelaxedPrecision + OpDecorate %20 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 2 + %8 = OpTypePointer Function %7 + %9 = OpTypeFunction %7 %8 + %14 = OpConstant %6 0.5 + %15 = OpConstantComposite %7 %14 %14 + %19 = OpTypePointer Output %7 + %20 = OpVariable %19 Output + %21 = OpConstant %6 0 + %22 = OpConstantComposite %7 %21 %21 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %23 = OpVariable %8 Function + OpStore %23 %22 + %24 = OpFunctionCall %7 %11 %23 + OpStore %20 %24 + OpReturn + OpFunctionEnd + %11 = OpFunction %7 None %9 + %10 = OpFunctionParameter %8 + %12 = OpLabel + %13 = OpLoad %7 %10 + %16 = OpFAdd %7 %13 %15 + OpReturnValue %16 + OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/extra_if_block_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/extra_if_block_autogen.cpp new file mode 100644 index 0000000000..4f91319871 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/extra_if_block_autogen.cpp @@ -0,0 +1,867 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Test where src has an extra if block in one function, and dst has an extra +// if block in another function. +constexpr char kSrc[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %63 %68 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %8 "f1(" + OpName %10 "f2(" + OpName %13 "v" + OpName %16 "Buffer" + OpMemberName %16 0 "flag1" + OpMemberName %16 1 "flag2" + OpName %18 "" + OpName %45 "v" + OpName %63 "color" + OpName %68 "v" + OpDecorate %8 RelaxedPrecision + OpDecorate %10 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + OpMemberDecorate %16 0 RelaxedPrecision + OpMemberDecorate %16 0 Offset 0 + OpMemberDecorate %16 1 RelaxedPrecision + OpMemberDecorate %16 1 Offset 4 + OpDecorate %16 Block + OpDecorate %18 DescriptorSet 0 + OpDecorate %18 Binding 0 + OpDecorate %23 RelaxedPrecision + OpDecorate %30 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %38 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %45 RelaxedPrecision + OpDecorate %47 RelaxedPrecision + OpDecorate %48 RelaxedPrecision + OpDecorate %50 RelaxedPrecision + OpDecorate %51 RelaxedPrecision + OpDecorate %54 RelaxedPrecision + OpDecorate %55 RelaxedPrecision + OpDecorate %56 RelaxedPrecision + OpDecorate %57 RelaxedPrecision + OpDecorate %58 RelaxedPrecision + OpDecorate %63 RelaxedPrecision + OpDecorate %63 Location 0 + OpDecorate %64 RelaxedPrecision + OpDecorate %65 RelaxedPrecision + OpDecorate %66 RelaxedPrecision + OpDecorate %68 RelaxedPrecision + OpDecorate %68 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeFunction %6 + %12 = OpTypePointer Function %6 + %14 = OpConstant %6 0 + %15 = OpTypeInt 32 0 + %16 = OpTypeStruct %15 %15 + %17 = OpTypePointer Uniform %16 + %18 = OpVariable %17 Uniform + %19 = OpTypeInt 32 1 + %20 = OpConstant %19 0 + %21 = OpTypePointer Uniform %15 + %24 = OpConstant %15 0 + %25 = OpTypeBool + %29 = OpConstant %6 1 + %32 = OpConstant %19 1 + %49 = OpConstant %6 10 + %52 = OpConstant %6 0.5 + %53 = OpConstant %6 0.699999988 + %61 = OpTypeVector %6 4 + %62 = OpTypePointer Output %61 + %63 = OpVariable %62 Output + %67 = OpTypePointer Input %6 + %68 = OpVariable %67 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %64 = OpFunctionCall %6 %8 + %65 = OpFunctionCall %6 %10 + %66 = OpCompositeConstruct %61 %64 %65 %14 %29 + OpStore %63 %66 + OpReturn + OpFunctionEnd + %8 = OpFunction %6 None %7 + %9 = OpLabel + %13 = OpVariable %12 Function + OpStore %13 %14 + %22 = OpAccessChain %21 %18 %20 + %23 = OpLoad %15 %22 + %26 = OpINotEqual %25 %23 %24 + OpSelectionMerge %28 None + OpBranchConditional %26 %27 %28 + %27 = OpLabel + %30 = OpLoad %6 %13 + %31 = OpFAdd %6 %30 %29 + OpStore %13 %31 + OpBranch %28 + %28 = OpLabel + %33 = OpAccessChain %21 %18 %32 + %34 = OpLoad %15 %33 + %35 = OpConvertUToF %6 %34 + %36 = OpExtInst %6 %1 Log2 %35 + %37 = OpLoad %6 %13 + %38 = OpFAdd %6 %37 %36 + OpStore %13 %38 + %39 = OpLoad %6 %13 + %40 = OpLoad %6 %13 + %41 = OpExtInst %6 %1 Sqrt %40 + %42 = OpFSub %6 %39 %41 + OpReturnValue %42 + OpFunctionEnd + %10 = OpFunction %6 None %7 + %11 = OpLabel + %45 = OpVariable %12 Function + %46 = OpAccessChain %21 %18 %20 + %47 = OpLoad %15 %46 + %48 = OpConvertUToF %6 %47 + %50 = OpFDiv %6 %48 %49 + OpStore %45 %50 + %51 = OpLoad %6 %45 + %54 = OpExtInst %6 %1 FClamp %51 %52 %53 + %55 = OpLoad %6 %45 + %56 = OpFMul %6 %55 %54 + OpStore %45 %56 + %57 = OpLoad %6 %45 + %58 = OpExtInst %6 %1 Exp %57 + OpReturnValue %58 + OpFunctionEnd +)"; +constexpr char kDst[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %63 %69 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %8 "f1(" + OpName %10 "f2(" + OpName %13 "v" + OpName %16 "Buffer" + OpMemberName %16 0 "flag1" + OpMemberName %16 1 "flag2" + OpName %18 "" + OpName %34 "v" + OpName %63 "color" + OpName %69 "v" + OpDecorate %8 RelaxedPrecision + OpDecorate %10 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + OpMemberDecorate %16 0 RelaxedPrecision + OpMemberDecorate %16 0 Offset 0 + OpMemberDecorate %16 1 RelaxedPrecision + OpMemberDecorate %16 1 Offset 4 + OpDecorate %16 Block + OpDecorate %18 DescriptorSet 0 + OpDecorate %18 Binding 0 + OpDecorate %23 RelaxedPrecision + OpDecorate %24 RelaxedPrecision + OpDecorate %25 RelaxedPrecision + OpDecorate %26 RelaxedPrecision + OpDecorate %27 RelaxedPrecision + OpDecorate %28 RelaxedPrecision + OpDecorate %29 RelaxedPrecision + OpDecorate %30 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %38 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %44 RelaxedPrecision + OpDecorate %45 RelaxedPrecision + OpDecorate %46 RelaxedPrecision + OpDecorate %48 RelaxedPrecision + OpDecorate %55 RelaxedPrecision + OpDecorate %56 RelaxedPrecision + OpDecorate %57 RelaxedPrecision + OpDecorate %58 RelaxedPrecision + OpDecorate %63 RelaxedPrecision + OpDecorate %63 Location 0 + OpDecorate %64 RelaxedPrecision + OpDecorate %65 RelaxedPrecision + OpDecorate %67 RelaxedPrecision + OpDecorate %69 RelaxedPrecision + OpDecorate %69 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeFunction %6 + %12 = OpTypePointer Function %6 + %14 = OpConstant %6 0 + %15 = OpTypeInt 32 0 + %16 = OpTypeStruct %15 %15 + %17 = OpTypePointer Uniform %16 + %18 = OpVariable %17 Uniform + %19 = OpTypeInt 32 1 + %20 = OpConstant %19 1 + %21 = OpTypePointer Uniform %15 + %35 = OpConstant %19 0 + %39 = OpConstant %6 10 + %42 = OpConstant %6 0.5 + %43 = OpConstant %6 0.699999988 + %49 = OpConstant %15 0 + %50 = OpTypeBool + %54 = OpConstant %6 0.100000001 + %61 = OpTypeVector %6 4 + %62 = OpTypePointer Output %61 + %63 = OpVariable %62 Output + %66 = OpConstant %6 1 + %68 = OpTypePointer Input %6 + %69 = OpVariable %68 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %64 = OpFunctionCall %6 %8 + %65 = OpFunctionCall %6 %10 + %67 = OpCompositeConstruct %61 %64 %65 %14 %66 + OpStore %63 %67 + OpReturn + OpFunctionEnd + %8 = OpFunction %6 None %7 + %9 = OpLabel + %13 = OpVariable %12 Function + OpStore %13 %14 + %22 = OpAccessChain %21 %18 %20 + %23 = OpLoad %15 %22 + %24 = OpConvertUToF %6 %23 + %25 = OpExtInst %6 %1 Log2 %24 + %26 = OpLoad %6 %13 + %27 = OpFAdd %6 %26 %25 + OpStore %13 %27 + %28 = OpLoad %6 %13 + %29 = OpLoad %6 %13 + %30 = OpExtInst %6 %1 Sqrt %29 + %31 = OpFSub %6 %28 %30 + OpReturnValue %31 + OpFunctionEnd + %10 = OpFunction %6 None %7 + %11 = OpLabel + %34 = OpVariable %12 Function + %36 = OpAccessChain %21 %18 %35 + %37 = OpLoad %15 %36 + %38 = OpConvertUToF %6 %37 + %40 = OpFDiv %6 %38 %39 + OpStore %34 %40 + %41 = OpLoad %6 %34 + %44 = OpExtInst %6 %1 FClamp %41 %42 %43 + %45 = OpLoad %6 %34 + %46 = OpFMul %6 %45 %44 + OpStore %34 %46 + %47 = OpAccessChain %21 %18 %20 + %48 = OpLoad %15 %47 + %51 = OpINotEqual %50 %48 %49 + OpSelectionMerge %53 None + OpBranchConditional %51 %52 %53 + %52 = OpLabel + %55 = OpLoad %6 %34 + %56 = OpFSub %6 %55 %54 + OpStore %34 %56 + OpBranch %53 + %53 = OpLabel + %57 = OpLoad %6 %34 + %58 = OpExtInst %6 %1 Exp %57 + OpReturnValue %58 + OpFunctionEnd + +)"; + +TEST(DiffTest, ExtraIfBlock) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 69 ++; Bound: 81 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %63 %68 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %8 "f1(" + OpName %10 "f2(" + OpName %13 "v" + OpName %16 "Buffer" + OpMemberName %16 0 "flag1" + OpMemberName %16 1 "flag2" + OpName %18 "" + OpName %45 "v" + OpName %63 "color" + OpName %68 "v" + OpDecorate %8 RelaxedPrecision + OpDecorate %10 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + OpMemberDecorate %16 0 RelaxedPrecision + OpMemberDecorate %16 0 Offset 0 + OpMemberDecorate %16 1 RelaxedPrecision + OpMemberDecorate %16 1 Offset 4 + OpDecorate %16 Block + OpDecorate %18 DescriptorSet 0 + OpDecorate %18 Binding 0 +-OpDecorate %23 RelaxedPrecision +-OpDecorate %30 RelaxedPrecision +-OpDecorate %31 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %38 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %45 RelaxedPrecision + OpDecorate %47 RelaxedPrecision + OpDecorate %48 RelaxedPrecision + OpDecorate %50 RelaxedPrecision + OpDecorate %51 RelaxedPrecision + OpDecorate %54 RelaxedPrecision + OpDecorate %55 RelaxedPrecision + OpDecorate %56 RelaxedPrecision ++OpDecorate %72 RelaxedPrecision + OpDecorate %57 RelaxedPrecision ++OpDecorate %77 RelaxedPrecision ++OpDecorate %78 RelaxedPrecision + OpDecorate %58 RelaxedPrecision + OpDecorate %63 RelaxedPrecision + OpDecorate %63 Location 0 + OpDecorate %64 RelaxedPrecision + OpDecorate %65 RelaxedPrecision + OpDecorate %66 RelaxedPrecision + OpDecorate %68 RelaxedPrecision + OpDecorate %68 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeFunction %6 + %12 = OpTypePointer Function %6 + %14 = OpConstant %6 0 + %15 = OpTypeInt 32 0 + %16 = OpTypeStruct %15 %15 + %17 = OpTypePointer Uniform %16 + %18 = OpVariable %17 Uniform + %19 = OpTypeInt 32 1 + %20 = OpConstant %19 0 + %21 = OpTypePointer Uniform %15 + %24 = OpConstant %15 0 + %25 = OpTypeBool + %29 = OpConstant %6 1 + %32 = OpConstant %19 1 + %49 = OpConstant %6 10 + %52 = OpConstant %6 0.5 ++%76 = OpConstant %6 0.100000001 + %53 = OpConstant %6 0.699999988 + %61 = OpTypeVector %6 4 + %62 = OpTypePointer Output %61 + %63 = OpVariable %62 Output + %67 = OpTypePointer Input %6 + %68 = OpVariable %67 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %64 = OpFunctionCall %6 %8 + %65 = OpFunctionCall %6 %10 + %66 = OpCompositeConstruct %61 %64 %65 %14 %29 + OpStore %63 %66 + OpReturn + OpFunctionEnd + %8 = OpFunction %6 None %7 + %9 = OpLabel + %13 = OpVariable %12 Function + OpStore %13 %14 +-%22 = OpAccessChain %21 %18 %20 +-%23 = OpLoad %15 %22 +-%26 = OpINotEqual %25 %23 %24 +-OpSelectionMerge %28 None +-OpBranchConditional %26 %27 %28 +-%27 = OpLabel +-%30 = OpLoad %6 %13 +-%31 = OpFAdd %6 %30 %29 +-OpStore %13 %31 +-OpBranch %28 +-%28 = OpLabel + %33 = OpAccessChain %21 %18 %32 + %34 = OpLoad %15 %33 + %35 = OpConvertUToF %6 %34 + %36 = OpExtInst %6 %1 Log2 %35 + %37 = OpLoad %6 %13 + %38 = OpFAdd %6 %37 %36 + OpStore %13 %38 + %39 = OpLoad %6 %13 + %40 = OpLoad %6 %13 + %41 = OpExtInst %6 %1 Sqrt %40 + %42 = OpFSub %6 %39 %41 + OpReturnValue %42 + OpFunctionEnd + %10 = OpFunction %6 None %7 + %11 = OpLabel + %45 = OpVariable %12 Function + %46 = OpAccessChain %21 %18 %20 + %47 = OpLoad %15 %46 + %48 = OpConvertUToF %6 %47 + %50 = OpFDiv %6 %48 %49 + OpStore %45 %50 + %51 = OpLoad %6 %45 + %54 = OpExtInst %6 %1 FClamp %51 %52 %53 + %55 = OpLoad %6 %45 + %56 = OpFMul %6 %55 %54 + OpStore %45 %56 ++%71 = OpAccessChain %21 %18 %32 ++%72 = OpLoad %15 %71 ++%73 = OpINotEqual %25 %72 %24 ++OpSelectionMerge %75 None ++OpBranchConditional %73 %74 %75 ++%74 = OpLabel + %57 = OpLoad %6 %45 ++%77 = OpFSub %6 %57 %76 ++OpStore %45 %77 ++OpBranch %75 ++%75 = OpLabel ++%78 = OpLoad %6 %45 +-%58 = OpExtInst %6 %1 Exp %57 ++%58 = OpExtInst %6 %1 Exp %78 + OpReturnValue %58 + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, ExtraIfBlockNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %63 %68 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpDecorate %8 RelaxedPrecision + OpDecorate %10 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + OpMemberDecorate %16 0 RelaxedPrecision + OpMemberDecorate %16 0 Offset 0 + OpMemberDecorate %16 1 RelaxedPrecision + OpMemberDecorate %16 1 Offset 4 + OpDecorate %16 Block + OpDecorate %18 DescriptorSet 0 + OpDecorate %18 Binding 0 + OpDecorate %23 RelaxedPrecision + OpDecorate %30 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %38 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %45 RelaxedPrecision + OpDecorate %47 RelaxedPrecision + OpDecorate %48 RelaxedPrecision + OpDecorate %50 RelaxedPrecision + OpDecorate %51 RelaxedPrecision + OpDecorate %54 RelaxedPrecision + OpDecorate %55 RelaxedPrecision + OpDecorate %56 RelaxedPrecision + OpDecorate %57 RelaxedPrecision + OpDecorate %58 RelaxedPrecision + OpDecorate %63 RelaxedPrecision + OpDecorate %63 Location 0 + OpDecorate %64 RelaxedPrecision + OpDecorate %65 RelaxedPrecision + OpDecorate %66 RelaxedPrecision + OpDecorate %68 RelaxedPrecision + OpDecorate %68 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeFunction %6 + %12 = OpTypePointer Function %6 + %14 = OpConstant %6 0 + %15 = OpTypeInt 32 0 + %16 = OpTypeStruct %15 %15 + %17 = OpTypePointer Uniform %16 + %18 = OpVariable %17 Uniform + %19 = OpTypeInt 32 1 + %20 = OpConstant %19 0 + %21 = OpTypePointer Uniform %15 + %24 = OpConstant %15 0 + %25 = OpTypeBool + %29 = OpConstant %6 1 + %32 = OpConstant %19 1 + %49 = OpConstant %6 10 + %52 = OpConstant %6 0.5 + %53 = OpConstant %6 0.699999988 + %61 = OpTypeVector %6 4 + %62 = OpTypePointer Output %61 + %63 = OpVariable %62 Output + %67 = OpTypePointer Input %6 + %68 = OpVariable %67 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %64 = OpFunctionCall %6 %8 + %65 = OpFunctionCall %6 %10 + %66 = OpCompositeConstruct %61 %64 %65 %14 %29 + OpStore %63 %66 + OpReturn + OpFunctionEnd + %8 = OpFunction %6 None %7 + %9 = OpLabel + %13 = OpVariable %12 Function + OpStore %13 %14 + %22 = OpAccessChain %21 %18 %20 + %23 = OpLoad %15 %22 + %26 = OpINotEqual %25 %23 %24 + OpSelectionMerge %28 None + OpBranchConditional %26 %27 %28 + %27 = OpLabel + %30 = OpLoad %6 %13 + %31 = OpFAdd %6 %30 %29 + OpStore %13 %31 + OpBranch %28 + %28 = OpLabel + %33 = OpAccessChain %21 %18 %32 + %34 = OpLoad %15 %33 + %35 = OpConvertUToF %6 %34 + %36 = OpExtInst %6 %1 Log2 %35 + %37 = OpLoad %6 %13 + %38 = OpFAdd %6 %37 %36 + OpStore %13 %38 + %39 = OpLoad %6 %13 + %40 = OpLoad %6 %13 + %41 = OpExtInst %6 %1 Sqrt %40 + %42 = OpFSub %6 %39 %41 + OpReturnValue %42 + OpFunctionEnd + %10 = OpFunction %6 None %7 + %11 = OpLabel + %45 = OpVariable %12 Function + %46 = OpAccessChain %21 %18 %20 + %47 = OpLoad %15 %46 + %48 = OpConvertUToF %6 %47 + %50 = OpFDiv %6 %48 %49 + OpStore %45 %50 + %51 = OpLoad %6 %45 + %54 = OpExtInst %6 %1 FClamp %51 %52 %53 + %55 = OpLoad %6 %45 + %56 = OpFMul %6 %55 %54 + OpStore %45 %56 + %57 = OpLoad %6 %45 + %58 = OpExtInst %6 %1 Exp %57 + OpReturnValue %58 + OpFunctionEnd + +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %63 %69 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpDecorate %8 RelaxedPrecision + OpDecorate %10 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + OpMemberDecorate %16 0 RelaxedPrecision + OpMemberDecorate %16 0 Offset 0 + OpMemberDecorate %16 1 RelaxedPrecision + OpMemberDecorate %16 1 Offset 4 + OpDecorate %16 Block + OpDecorate %18 DescriptorSet 0 + OpDecorate %18 Binding 0 + OpDecorate %23 RelaxedPrecision + OpDecorate %24 RelaxedPrecision + OpDecorate %25 RelaxedPrecision + OpDecorate %26 RelaxedPrecision + OpDecorate %27 RelaxedPrecision + OpDecorate %28 RelaxedPrecision + OpDecorate %29 RelaxedPrecision + OpDecorate %30 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %38 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %44 RelaxedPrecision + OpDecorate %45 RelaxedPrecision + OpDecorate %46 RelaxedPrecision + OpDecorate %48 RelaxedPrecision + OpDecorate %55 RelaxedPrecision + OpDecorate %56 RelaxedPrecision + OpDecorate %57 RelaxedPrecision + OpDecorate %58 RelaxedPrecision + OpDecorate %63 RelaxedPrecision + OpDecorate %63 Location 0 + OpDecorate %64 RelaxedPrecision + OpDecorate %65 RelaxedPrecision + OpDecorate %67 RelaxedPrecision + OpDecorate %69 RelaxedPrecision + OpDecorate %69 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeFunction %6 + %12 = OpTypePointer Function %6 + %14 = OpConstant %6 0 + %15 = OpTypeInt 32 0 + %16 = OpTypeStruct %15 %15 + %17 = OpTypePointer Uniform %16 + %18 = OpVariable %17 Uniform + %19 = OpTypeInt 32 1 + %20 = OpConstant %19 1 + %21 = OpTypePointer Uniform %15 + %35 = OpConstant %19 0 + %39 = OpConstant %6 10 + %42 = OpConstant %6 0.5 + %43 = OpConstant %6 0.699999988 + %49 = OpConstant %15 0 + %50 = OpTypeBool + %54 = OpConstant %6 0.100000001 + %61 = OpTypeVector %6 4 + %62 = OpTypePointer Output %61 + %63 = OpVariable %62 Output + %66 = OpConstant %6 1 + %68 = OpTypePointer Input %6 + %69 = OpVariable %68 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %64 = OpFunctionCall %6 %8 + %65 = OpFunctionCall %6 %10 + %67 = OpCompositeConstruct %61 %64 %65 %14 %66 + OpStore %63 %67 + OpReturn + OpFunctionEnd + %8 = OpFunction %6 None %7 + %9 = OpLabel + %13 = OpVariable %12 Function + OpStore %13 %14 + %22 = OpAccessChain %21 %18 %20 + %23 = OpLoad %15 %22 + %24 = OpConvertUToF %6 %23 + %25 = OpExtInst %6 %1 Log2 %24 + %26 = OpLoad %6 %13 + %27 = OpFAdd %6 %26 %25 + OpStore %13 %27 + %28 = OpLoad %6 %13 + %29 = OpLoad %6 %13 + %30 = OpExtInst %6 %1 Sqrt %29 + %31 = OpFSub %6 %28 %30 + OpReturnValue %31 + OpFunctionEnd + %10 = OpFunction %6 None %7 + %11 = OpLabel + %34 = OpVariable %12 Function + %36 = OpAccessChain %21 %18 %35 + %37 = OpLoad %15 %36 + %38 = OpConvertUToF %6 %37 + %40 = OpFDiv %6 %38 %39 + OpStore %34 %40 + %41 = OpLoad %6 %34 + %44 = OpExtInst %6 %1 FClamp %41 %42 %43 + %45 = OpLoad %6 %34 + %46 = OpFMul %6 %45 %44 + OpStore %34 %46 + %47 = OpAccessChain %21 %18 %20 + %48 = OpLoad %15 %47 + %51 = OpINotEqual %50 %48 %49 + OpSelectionMerge %53 None + OpBranchConditional %51 %52 %53 + %52 = OpLabel + %55 = OpLoad %6 %34 + %56 = OpFSub %6 %55 %54 + OpStore %34 %56 + OpBranch %53 + %53 = OpLabel + %57 = OpLoad %6 %34 + %58 = OpExtInst %6 %1 Exp %57 + OpReturnValue %58 + OpFunctionEnd + +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 69 ++; Bound: 81 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %63 %68 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpDecorate %8 RelaxedPrecision + OpDecorate %10 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + OpMemberDecorate %16 0 RelaxedPrecision + OpMemberDecorate %16 0 Offset 0 + OpMemberDecorate %16 1 RelaxedPrecision + OpMemberDecorate %16 1 Offset 4 + OpDecorate %16 Block + OpDecorate %18 DescriptorSet 0 + OpDecorate %18 Binding 0 +-OpDecorate %23 RelaxedPrecision +-OpDecorate %30 RelaxedPrecision +-OpDecorate %31 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %38 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %45 RelaxedPrecision + OpDecorate %47 RelaxedPrecision + OpDecorate %48 RelaxedPrecision + OpDecorate %50 RelaxedPrecision + OpDecorate %51 RelaxedPrecision + OpDecorate %54 RelaxedPrecision + OpDecorate %55 RelaxedPrecision + OpDecorate %56 RelaxedPrecision ++OpDecorate %72 RelaxedPrecision + OpDecorate %57 RelaxedPrecision ++OpDecorate %77 RelaxedPrecision ++OpDecorate %78 RelaxedPrecision + OpDecorate %58 RelaxedPrecision + OpDecorate %63 RelaxedPrecision + OpDecorate %63 Location 0 + OpDecorate %64 RelaxedPrecision + OpDecorate %65 RelaxedPrecision + OpDecorate %66 RelaxedPrecision + OpDecorate %68 RelaxedPrecision + OpDecorate %68 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeFunction %6 + %12 = OpTypePointer Function %6 + %14 = OpConstant %6 0 + %15 = OpTypeInt 32 0 + %16 = OpTypeStruct %15 %15 + %17 = OpTypePointer Uniform %16 + %18 = OpVariable %17 Uniform + %19 = OpTypeInt 32 1 + %20 = OpConstant %19 0 + %21 = OpTypePointer Uniform %15 + %24 = OpConstant %15 0 + %25 = OpTypeBool + %29 = OpConstant %6 1 + %32 = OpConstant %19 1 + %49 = OpConstant %6 10 + %52 = OpConstant %6 0.5 ++%76 = OpConstant %6 0.100000001 + %53 = OpConstant %6 0.699999988 + %61 = OpTypeVector %6 4 + %62 = OpTypePointer Output %61 + %63 = OpVariable %62 Output + %67 = OpTypePointer Input %6 + %68 = OpVariable %67 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %64 = OpFunctionCall %6 %8 + %65 = OpFunctionCall %6 %10 + %66 = OpCompositeConstruct %61 %64 %65 %14 %29 + OpStore %63 %66 + OpReturn + OpFunctionEnd + %8 = OpFunction %6 None %7 + %9 = OpLabel + %13 = OpVariable %12 Function + OpStore %13 %14 +-%22 = OpAccessChain %21 %18 %20 +-%23 = OpLoad %15 %22 +-%26 = OpINotEqual %25 %23 %24 +-OpSelectionMerge %28 None +-OpBranchConditional %26 %27 %28 +-%27 = OpLabel +-%30 = OpLoad %6 %13 +-%31 = OpFAdd %6 %30 %29 +-OpStore %13 %31 +-OpBranch %28 +-%28 = OpLabel + %33 = OpAccessChain %21 %18 %32 + %34 = OpLoad %15 %33 + %35 = OpConvertUToF %6 %34 + %36 = OpExtInst %6 %1 Log2 %35 + %37 = OpLoad %6 %13 + %38 = OpFAdd %6 %37 %36 + OpStore %13 %38 + %39 = OpLoad %6 %13 + %40 = OpLoad %6 %13 + %41 = OpExtInst %6 %1 Sqrt %40 + %42 = OpFSub %6 %39 %41 + OpReturnValue %42 + OpFunctionEnd + %10 = OpFunction %6 None %7 + %11 = OpLabel + %45 = OpVariable %12 Function + %46 = OpAccessChain %21 %18 %20 + %47 = OpLoad %15 %46 + %48 = OpConvertUToF %6 %47 + %50 = OpFDiv %6 %48 %49 + OpStore %45 %50 + %51 = OpLoad %6 %45 + %54 = OpExtInst %6 %1 FClamp %51 %52 %53 + %55 = OpLoad %6 %45 + %56 = OpFMul %6 %55 %54 + OpStore %45 %56 ++%71 = OpAccessChain %21 %18 %32 ++%72 = OpLoad %15 %71 ++%73 = OpINotEqual %25 %72 %24 ++OpSelectionMerge %75 None ++OpBranchConditional %73 %74 %75 ++%74 = OpLabel + %57 = OpLoad %6 %45 ++%77 = OpFSub %6 %57 %76 ++OpStore %45 %77 ++OpBranch %75 ++%75 = OpLabel ++%78 = OpLoad %6 %45 +-%58 = OpExtInst %6 %1 Exp %57 ++%58 = OpExtInst %6 %1 Exp %78 + OpReturnValue %58 + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/extra_if_block_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/extra_if_block_dst.spvasm new file mode 100644 index 0000000000..79bda83047 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/extra_if_block_dst.spvasm @@ -0,0 +1,136 @@ + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %63 %69 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %8 "f1(" + OpName %10 "f2(" + OpName %13 "v" + OpName %16 "Buffer" + OpMemberName %16 0 "flag1" + OpMemberName %16 1 "flag2" + OpName %18 "" + OpName %34 "v" + OpName %63 "color" + OpName %69 "v" + OpDecorate %8 RelaxedPrecision + OpDecorate %10 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + OpMemberDecorate %16 0 RelaxedPrecision + OpMemberDecorate %16 0 Offset 0 + OpMemberDecorate %16 1 RelaxedPrecision + OpMemberDecorate %16 1 Offset 4 + OpDecorate %16 Block + OpDecorate %18 DescriptorSet 0 + OpDecorate %18 Binding 0 + OpDecorate %23 RelaxedPrecision + OpDecorate %24 RelaxedPrecision + OpDecorate %25 RelaxedPrecision + OpDecorate %26 RelaxedPrecision + OpDecorate %27 RelaxedPrecision + OpDecorate %28 RelaxedPrecision + OpDecorate %29 RelaxedPrecision + OpDecorate %30 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %38 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %44 RelaxedPrecision + OpDecorate %45 RelaxedPrecision + OpDecorate %46 RelaxedPrecision + OpDecorate %48 RelaxedPrecision + OpDecorate %55 RelaxedPrecision + OpDecorate %56 RelaxedPrecision + OpDecorate %57 RelaxedPrecision + OpDecorate %58 RelaxedPrecision + OpDecorate %63 RelaxedPrecision + OpDecorate %63 Location 0 + OpDecorate %64 RelaxedPrecision + OpDecorate %65 RelaxedPrecision + OpDecorate %67 RelaxedPrecision + OpDecorate %69 RelaxedPrecision + OpDecorate %69 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeFunction %6 + %12 = OpTypePointer Function %6 + %14 = OpConstant %6 0 + %15 = OpTypeInt 32 0 + %16 = OpTypeStruct %15 %15 + %17 = OpTypePointer Uniform %16 + %18 = OpVariable %17 Uniform + %19 = OpTypeInt 32 1 + %20 = OpConstant %19 1 + %21 = OpTypePointer Uniform %15 + %35 = OpConstant %19 0 + %39 = OpConstant %6 10 + %42 = OpConstant %6 0.5 + %43 = OpConstant %6 0.699999988 + %49 = OpConstant %15 0 + %50 = OpTypeBool + %54 = OpConstant %6 0.100000001 + %61 = OpTypeVector %6 4 + %62 = OpTypePointer Output %61 + %63 = OpVariable %62 Output + %66 = OpConstant %6 1 + %68 = OpTypePointer Input %6 + %69 = OpVariable %68 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %64 = OpFunctionCall %6 %8 + %65 = OpFunctionCall %6 %10 + %67 = OpCompositeConstruct %61 %64 %65 %14 %66 + OpStore %63 %67 + OpReturn + OpFunctionEnd + %8 = OpFunction %6 None %7 + %9 = OpLabel + %13 = OpVariable %12 Function + OpStore %13 %14 + %22 = OpAccessChain %21 %18 %20 + %23 = OpLoad %15 %22 + %24 = OpConvertUToF %6 %23 + %25 = OpExtInst %6 %1 Log2 %24 + %26 = OpLoad %6 %13 + %27 = OpFAdd %6 %26 %25 + OpStore %13 %27 + %28 = OpLoad %6 %13 + %29 = OpLoad %6 %13 + %30 = OpExtInst %6 %1 Sqrt %29 + %31 = OpFSub %6 %28 %30 + OpReturnValue %31 + OpFunctionEnd + %10 = OpFunction %6 None %7 + %11 = OpLabel + %34 = OpVariable %12 Function + %36 = OpAccessChain %21 %18 %35 + %37 = OpLoad %15 %36 + %38 = OpConvertUToF %6 %37 + %40 = OpFDiv %6 %38 %39 + OpStore %34 %40 + %41 = OpLoad %6 %34 + %44 = OpExtInst %6 %1 FClamp %41 %42 %43 + %45 = OpLoad %6 %34 + %46 = OpFMul %6 %45 %44 + OpStore %34 %46 + %47 = OpAccessChain %21 %18 %20 + %48 = OpLoad %15 %47 + %51 = OpINotEqual %50 %48 %49 + OpSelectionMerge %53 None + OpBranchConditional %51 %52 %53 + %52 = OpLabel + %55 = OpLoad %6 %34 + %56 = OpFSub %6 %55 %54 + OpStore %34 %56 + OpBranch %53 + %53 = OpLabel + %57 = OpLoad %6 %34 + %58 = OpExtInst %6 %1 Exp %57 + OpReturnValue %58 + OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/extra_if_block_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/extra_if_block_src.spvasm new file mode 100644 index 0000000000..1b43ccb186 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/extra_if_block_src.spvasm @@ -0,0 +1,137 @@ +;; Test where src has an extra if block in one function, and dst has an extra +;; if block in another function. + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %63 %68 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %8 "f1(" + OpName %10 "f2(" + OpName %13 "v" + OpName %16 "Buffer" + OpMemberName %16 0 "flag1" + OpMemberName %16 1 "flag2" + OpName %18 "" + OpName %45 "v" + OpName %63 "color" + OpName %68 "v" + OpDecorate %8 RelaxedPrecision + OpDecorate %10 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + OpMemberDecorate %16 0 RelaxedPrecision + OpMemberDecorate %16 0 Offset 0 + OpMemberDecorate %16 1 RelaxedPrecision + OpMemberDecorate %16 1 Offset 4 + OpDecorate %16 Block + OpDecorate %18 DescriptorSet 0 + OpDecorate %18 Binding 0 + OpDecorate %23 RelaxedPrecision + OpDecorate %30 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %38 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %45 RelaxedPrecision + OpDecorate %47 RelaxedPrecision + OpDecorate %48 RelaxedPrecision + OpDecorate %50 RelaxedPrecision + OpDecorate %51 RelaxedPrecision + OpDecorate %54 RelaxedPrecision + OpDecorate %55 RelaxedPrecision + OpDecorate %56 RelaxedPrecision + OpDecorate %57 RelaxedPrecision + OpDecorate %58 RelaxedPrecision + OpDecorate %63 RelaxedPrecision + OpDecorate %63 Location 0 + OpDecorate %64 RelaxedPrecision + OpDecorate %65 RelaxedPrecision + OpDecorate %66 RelaxedPrecision + OpDecorate %68 RelaxedPrecision + OpDecorate %68 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeFunction %6 + %12 = OpTypePointer Function %6 + %14 = OpConstant %6 0 + %15 = OpTypeInt 32 0 + %16 = OpTypeStruct %15 %15 + %17 = OpTypePointer Uniform %16 + %18 = OpVariable %17 Uniform + %19 = OpTypeInt 32 1 + %20 = OpConstant %19 0 + %21 = OpTypePointer Uniform %15 + %24 = OpConstant %15 0 + %25 = OpTypeBool + %29 = OpConstant %6 1 + %32 = OpConstant %19 1 + %49 = OpConstant %6 10 + %52 = OpConstant %6 0.5 + %53 = OpConstant %6 0.699999988 + %61 = OpTypeVector %6 4 + %62 = OpTypePointer Output %61 + %63 = OpVariable %62 Output + %67 = OpTypePointer Input %6 + %68 = OpVariable %67 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %64 = OpFunctionCall %6 %8 + %65 = OpFunctionCall %6 %10 + %66 = OpCompositeConstruct %61 %64 %65 %14 %29 + OpStore %63 %66 + OpReturn + OpFunctionEnd + %8 = OpFunction %6 None %7 + %9 = OpLabel + %13 = OpVariable %12 Function + OpStore %13 %14 + %22 = OpAccessChain %21 %18 %20 + %23 = OpLoad %15 %22 + %26 = OpINotEqual %25 %23 %24 + OpSelectionMerge %28 None + OpBranchConditional %26 %27 %28 + %27 = OpLabel + %30 = OpLoad %6 %13 + %31 = OpFAdd %6 %30 %29 + OpStore %13 %31 + OpBranch %28 + %28 = OpLabel + %33 = OpAccessChain %21 %18 %32 + %34 = OpLoad %15 %33 + %35 = OpConvertUToF %6 %34 + %36 = OpExtInst %6 %1 Log2 %35 + %37 = OpLoad %6 %13 + %38 = OpFAdd %6 %37 %36 + OpStore %13 %38 + %39 = OpLoad %6 %13 + %40 = OpLoad %6 %13 + %41 = OpExtInst %6 %1 Sqrt %40 + %42 = OpFSub %6 %39 %41 + OpReturnValue %42 + OpFunctionEnd + %10 = OpFunction %6 None %7 + %11 = OpLabel + %45 = OpVariable %12 Function + %46 = OpAccessChain %21 %18 %20 + %47 = OpLoad %15 %46 + %48 = OpConvertUToF %6 %47 + %50 = OpFDiv %6 %48 %49 + OpStore %45 %50 + %51 = OpLoad %6 %45 + %54 = OpExtInst %6 %1 FClamp %51 %52 %53 + %55 = OpLoad %6 %45 + %56 = OpFMul %6 %55 %54 + OpStore %45 %56 + %57 = OpLoad %6 %45 + %58 = OpExtInst %6 %1 Exp %57 + OpReturnValue %58 + OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/generate_tests.py b/third_party/spirv-tools/test/diff/diff_files/generate_tests.py new file mode 100755 index 0000000000..cc3175d345 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/generate_tests.py @@ -0,0 +1,304 @@ +#! /usr/bin/python3 +# +# Copyright (c) 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import glob +import os +import subprocess +import sys + +# A handful of relevant tests are hand-picked to generate extra unit tests with +# specific options of spirv-diff. +IGNORE_SET_BINDING_TESTS = ['different_decorations_vertex'] +IGNORE_LOCATION_TESTS = ['different_decorations_fragment'] +IGNORE_DECORATIONS_TESTS = ['different_decorations_vertex', 'different_decorations_fragment'] +DUMP_IDS_TESTS = ['basic', 'int_vs_uint_constants', 'multiple_same_entry_points', 'small_functions_small_diffs'] + +LICENSE = u"""Copyright (c) 2022 Google LLC. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +""" + +TEMPLATE_TEST_FILE = u"""// GENERATED FILE - DO NOT EDIT. +// Generated by {script_name} +// +{license} + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools {{ +namespace diff {{ +namespace {{ + +{test_comment} +constexpr char kSrc[] = R"({src_spirv})"; +constexpr char kDst[] = R"({dst_spirv})"; + +TEST(DiffTest, {test_name}) {{ + constexpr char kDiff[] = R"({diff_spirv})"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +}} + +TEST(DiffTest, {test_name}NoDebug) {{ + constexpr char kSrcNoDebug[] = R"({src_spirv_no_debug})"; + constexpr char kDstNoDebug[] = R"({dst_spirv_no_debug})"; + constexpr char kDiff[] = R"({diff_spirv_no_debug})"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +}} +{extra_tests} +}} // namespace +}} // namespace diff +}} // namespace spvtools +""" + +TEMPLATE_TEST_FUNC = u""" +TEST(DiffTest, {test_name}{test_tag}) {{ + constexpr char kDiff[] = R"({diff_spirv})"; + Options options; + {test_options} + DoStringDiffTest(kSrc, kDst, kDiff, options); +}} +""" + +TEMPLATE_TEST_FILES_CMAKE = u"""# GENERATED FILE - DO NOT EDIT. +# Generated by {script_name} +# +{license} + +list(APPEND DIFF_TEST_FILES +{test_files} +) +""" + +VARIANT_NONE = 0 +VARIANT_IGNORE_SET_BINDING = 1 +VARIANT_IGNORE_LOCATION = 2 +VARIANT_IGNORE_DECORATIONS = 3 +VARIANT_DUMP_IDS = 4 + +def print_usage(): + print("Usage: {} ".format(sys.argv[0])) + +def remove_debug_info(in_path): + tmp_dir = '.no_dbg' + + if not os.path.exists(tmp_dir): + os.makedirs(tmp_dir) + + (in_basename, in_ext) = os.path.splitext(in_path) + out_name = in_basename + '_no_dbg' + in_ext + out_path = os.path.join(tmp_dir, out_name) + + with open(in_path, 'r') as fin: + with open(out_path, 'w') as fout: + for line in fin: + ops = line.strip().split() + op = ops[0] if len(ops) > 0 else '' + if (op != ';;' and op != 'OpName' and op != 'OpMemberName' and op != 'OpString' and + op != 'OpLine' and op != 'OpNoLine' and op != 'OpModuleProcessed'): + fout.write(line) + + return out_path + +def make_src_file(test_name): + return '{}_src.spvasm'.format(test_name) + +def make_dst_file(test_name): + return '{}_dst.spvasm'.format(test_name) + +def make_cpp_file(test_name): + return '{}_autogen.cpp'.format(test_name) + +def make_camel_case(test_name): + return test_name.replace('_', ' ').title().replace(' ', '') + +def make_comment(text, comment_prefix): + return '\n'.join([comment_prefix + (' ' if line.strip() else '') + line for line in text.splitlines()]) + +def read_file(file_name): + with open(file_name, 'r') as f: + content = f.read() + + # Use unix line endings. + content = content.replace('\r\n', '\n') + + return content + +def parse_test_comment(src_spirv_file_name, src_spirv): + src_spirv_lines = src_spirv.splitlines() + comment_line_count = 0 + while comment_line_count < len(src_spirv_lines): + if not src_spirv_lines[comment_line_count].strip().startswith(';;'): + break + comment_line_count += 1 + + if comment_line_count == 0: + print("Expected comment on test file '{}'. See README.md next to this file.".format(src_spirv_file_name)) + sys.exit(1) + + comment_block = src_spirv_lines[:comment_line_count] + spirv_block = src_spirv_lines[comment_line_count:] + + comment_block = ['// ' + line.replace(';;', '').strip() for line in comment_block] + + return '\n'.join(spirv_block), '\n'.join(comment_block) + +def run_diff_tool(diff_tool, src_file, dst_file, variant): + args = [diff_tool] + + if variant == VARIANT_IGNORE_SET_BINDING or variant == VARIANT_IGNORE_DECORATIONS: + args.append('--ignore-set-binding') + + if variant == VARIANT_IGNORE_LOCATION or variant == VARIANT_IGNORE_DECORATIONS: + args.append('--ignore-location') + + if variant == VARIANT_DUMP_IDS: + args.append('--with-id-map') + + args.append('--no-color') + args.append('--no-indent') + + args.append(src_file) + args.append(dst_file) + + success = True + print(' '.join(args)) + process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + out, err = process.communicate() + + if process.returncode != 0: + print(err) + sys.exit(process.returncode) + + # Use unix line endings. + out = out.replace('\r\n', '\n') + + return out + +def generate_extra_test(diff_tool, src_file, dst_file, variant, test_name_camel_case, test_tag, test_options): + diff = run_diff_tool(diff_tool, src_file, dst_file, variant) + return TEMPLATE_TEST_FUNC.format( + test_name = test_name_camel_case, + test_tag = test_tag, + test_options = test_options, + diff_spirv = diff) + +def generate_test(diff_tool, test_name): + src_file = make_src_file(test_name) + dst_file = make_dst_file(test_name) + src_file_no_debug = remove_debug_info(src_file) + dst_file_no_debug = remove_debug_info(dst_file) + + src_spirv = read_file(src_file) + dst_spirv = read_file(dst_file) + src_spirv_no_debug = read_file(src_file_no_debug) + dst_spirv_no_debug = read_file(dst_file_no_debug) + + test_name_camel_case = make_camel_case(test_name) + + diff_spirv = run_diff_tool(diff_tool, src_file, dst_file, VARIANT_NONE) + diff_spirv_no_debug = run_diff_tool(diff_tool, src_file_no_debug, dst_file_no_debug, VARIANT_NONE) + + extra_tests = [] + + if test_name in IGNORE_SET_BINDING_TESTS: + extra_tests.append(generate_extra_test(diff_tool, src_file, dst_file, VARIANT_IGNORE_SET_BINDING, + test_name_camel_case, 'IgnoreSetBinding', 'options.ignore_set_binding = true;')) + + if test_name in IGNORE_LOCATION_TESTS: + extra_tests.append(generate_extra_test(diff_tool, src_file, dst_file, VARIANT_IGNORE_LOCATION, + test_name_camel_case, 'IgnoreLocation', 'options.ignore_location = true;')) + + if test_name in IGNORE_DECORATIONS_TESTS: + extra_tests.append(generate_extra_test(diff_tool, src_file, dst_file, VARIANT_IGNORE_DECORATIONS, + test_name_camel_case, 'IgnoreSetBindingLocation', + '\n '.join(['options.ignore_set_binding = true;', 'options.ignore_location = true;']))) + + if test_name in DUMP_IDS_TESTS: + extra_tests.append(generate_extra_test(diff_tool, src_file, dst_file, VARIANT_DUMP_IDS, + test_name_camel_case, 'DumpIds', 'options.dump_id_map = true;')) + + src_spirv, test_comment = parse_test_comment(src_file, src_spirv) + + test_file = TEMPLATE_TEST_FILE.format( + script_name = os.path.basename(__file__), + license = make_comment(LICENSE, '//'), + test_comment = test_comment, + test_name = test_name_camel_case, + src_spirv = src_spirv, + dst_spirv = dst_spirv, + diff_spirv = diff_spirv, + src_spirv_no_debug = src_spirv_no_debug, + dst_spirv_no_debug = dst_spirv_no_debug, + diff_spirv_no_debug = diff_spirv_no_debug, + extra_tests = ''.join(extra_tests)) + + test_file_name = make_cpp_file(test_name) + with open(test_file_name, 'wb') as fout: + fout.write(str.encode(test_file)) + + return test_file_name + +def generate_tests(diff_tool, test_names): + return [generate_test(diff_tool, test_name) for test_name in test_names] + +def generate_cmake(test_files): + cmake = TEMPLATE_TEST_FILES_CMAKE.format( + script_name = os.path.basename(__file__), + license = make_comment(LICENSE, '#'), + test_files = '\n'.join(['"diff_files/{}"'.format(f) for f in test_files])) + + with open('diff_test_files_autogen.cmake', 'wb') as fout: + fout.write(str.encode(cmake)) + +def main(): + + if len(sys.argv) != 2: + print_usage() + return 1 + + diff_tool = sys.argv[1] + if not os.path.exists(diff_tool): + print("No such file: {}".format(diff_tool)) + print_usage() + return 1 + + diff_tool = os.path.realpath(diff_tool) + os.chdir(os.path.dirname(__file__)) + + test_names = sorted([f[:-11] for f in glob.glob("*_src.spvasm")]) + + test_files = generate_tests(diff_tool, test_names) + + generate_cmake(test_files) + + return 0 + +if __name__ == '__main__': + sys.exit(main()) diff --git a/third_party/spirv-tools/test/diff/diff_files/index_signedness_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/index_signedness_autogen.cpp new file mode 100644 index 0000000000..ab650be1ea --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/index_signedness_autogen.cpp @@ -0,0 +1,733 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Test where signedness of indices are different between src and dst. +constexpr char kSrc[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %13 "BufferOut" + OpMemberName %13 0 "o1" + OpMemberName %13 1 "o2" + OpMemberName %13 2 "o3" + OpName %15 "" + OpName %22 "BufferIn" + OpMemberName %22 0 "i1" + OpMemberName %22 1 "i2" + OpName %24 "" + OpDecorate %8 ArrayStride 4 + OpDecorate %9 ArrayStride 4 + OpDecorate %11 ArrayStride 4 + OpDecorate %12 ArrayStride 8 + OpMemberDecorate %13 0 Offset 0 + OpMemberDecorate %13 1 Offset 12 + OpMemberDecorate %13 2 Offset 24 + OpDecorate %13 BufferBlock + OpDecorate %15 DescriptorSet 0 + OpDecorate %15 Binding 1 + OpDecorate %18 ArrayStride 16 + OpDecorate %19 ArrayStride 48 + OpDecorate %21 ArrayStride 16 + OpMemberDecorate %22 0 Offset 0 + OpMemberDecorate %22 1 Offset 96 + OpDecorate %22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeInt 32 0 + %7 = OpConstant %6 3 + %8 = OpTypeArray %6 %7 + %9 = OpTypeArray %6 %7 + %10 = OpConstant %6 2 + %11 = OpTypeArray %6 %10 + %12 = OpTypeArray %11 %10 + %13 = OpTypeStruct %8 %9 %12 + %14 = OpTypePointer Uniform %13 + %15 = OpVariable %14 Uniform + %16 = OpTypeInt 32 1 + %17 = OpConstant %16 0 + %18 = OpTypeArray %6 %7 + %19 = OpTypeArray %18 %10 + %20 = OpConstant %6 4 + %21 = OpTypeArray %6 %20 + %22 = OpTypeStruct %19 %21 + %23 = OpTypePointer Uniform %22 + %24 = OpVariable %23 Uniform + %25 = OpTypePointer Uniform %6 + %28 = OpConstant %6 1 + %31 = OpConstant %16 1 + %34 = OpConstant %6 0 + %37 = OpConstant %16 2 + %61 = OpConstant %16 3 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %26 = OpAccessChain %25 %24 %17 %17 %17 + %27 = OpLoad %6 %26 + %29 = OpIAdd %6 %27 %28 + %30 = OpAccessChain %25 %15 %17 %17 + OpStore %30 %29 + %32 = OpAccessChain %25 %24 %17 %31 %17 + %33 = OpLoad %6 %32 + %35 = OpIAdd %6 %33 %34 + %36 = OpAccessChain %25 %15 %17 %31 + OpStore %36 %35 + %38 = OpAccessChain %25 %24 %17 %31 %31 + %39 = OpLoad %6 %38 + %40 = OpIAdd %6 %39 %10 + %41 = OpAccessChain %25 %15 %17 %37 + OpStore %41 %40 + %42 = OpAccessChain %25 %24 %17 %17 %37 + %43 = OpLoad %6 %42 + %44 = OpAccessChain %25 %15 %31 %17 + OpStore %44 %43 + %45 = OpAccessChain %25 %24 %17 %17 %31 + %46 = OpLoad %6 %45 + %47 = OpIMul %6 %46 %7 + %48 = OpAccessChain %25 %15 %31 %31 + OpStore %48 %47 + %49 = OpAccessChain %25 %24 %17 %31 %37 + %50 = OpLoad %6 %49 + %51 = OpAccessChain %25 %15 %31 %37 + OpStore %51 %50 + %52 = OpAccessChain %25 %24 %31 %17 + %53 = OpLoad %6 %52 + %54 = OpAccessChain %25 %15 %37 %17 %17 + OpStore %54 %53 + %55 = OpAccessChain %25 %24 %31 %31 + %56 = OpLoad %6 %55 + %57 = OpAccessChain %25 %15 %37 %17 %31 + OpStore %57 %56 + %58 = OpAccessChain %25 %24 %31 %37 + %59 = OpLoad %6 %58 + %60 = OpAccessChain %25 %15 %37 %31 %17 + OpStore %60 %59 + %62 = OpAccessChain %25 %24 %31 %61 + %63 = OpLoad %6 %62 + %64 = OpAccessChain %25 %15 %37 %31 %31 + OpStore %64 %63 + OpReturn + OpFunctionEnd +)"; +constexpr char kDst[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %13 "BufferOut" + OpMemberName %13 0 "o1" + OpMemberName %13 1 "o2" + OpMemberName %13 2 "o3" + OpName %15 "" + OpName %22 "BufferIn" + OpMemberName %22 0 "i1" + OpMemberName %22 1 "i2" + OpName %24 "" + OpDecorate %8 ArrayStride 4 + OpDecorate %9 ArrayStride 4 + OpDecorate %11 ArrayStride 4 + OpDecorate %12 ArrayStride 8 + OpMemberDecorate %13 0 Offset 0 + OpMemberDecorate %13 1 Offset 12 + OpMemberDecorate %13 2 Offset 24 + OpDecorate %13 BufferBlock + OpDecorate %15 DescriptorSet 0 + OpDecorate %15 Binding 1 + OpDecorate %18 ArrayStride 16 + OpDecorate %19 ArrayStride 48 + OpDecorate %21 ArrayStride 16 + OpMemberDecorate %22 0 Offset 0 + OpMemberDecorate %22 1 Offset 96 + OpDecorate %22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeInt 32 0 + %16 = OpTypeInt 32 1 + %7 = OpConstant %16 3 + %8 = OpTypeArray %6 %7 + %9 = OpTypeArray %6 %7 + %10 = OpConstant %16 2 + %11 = OpTypeArray %6 %10 + %12 = OpTypeArray %11 %10 + %13 = OpTypeStruct %8 %9 %12 + %14 = OpTypePointer Uniform %13 + %15 = OpVariable %14 Uniform + %18 = OpTypeArray %6 %7 + %19 = OpTypeArray %18 %10 + %20 = OpConstant %16 4 + %21 = OpTypeArray %6 %20 + %22 = OpTypeStruct %19 %21 + %23 = OpTypePointer Uniform %22 + %24 = OpVariable %23 Uniform + %25 = OpTypePointer Uniform %6 + %17 = OpConstant %16 0 + %28 = OpConstant %16 1 + %31 = OpConstant %6 1 + %34 = OpConstant %6 0 + %37 = OpConstant %6 2 + %61 = OpConstant %6 3 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %26 = OpAccessChain %25 %24 %17 %17 %17 + %27 = OpLoad %6 %26 + %29 = OpIAdd %6 %27 %28 + %30 = OpAccessChain %25 %15 %17 %17 + OpStore %30 %29 + %32 = OpAccessChain %25 %24 %17 %31 %17 + %33 = OpLoad %6 %32 + %35 = OpIAdd %6 %33 %34 + %36 = OpAccessChain %25 %15 %17 %31 + OpStore %36 %35 + %38 = OpAccessChain %25 %24 %17 %31 %31 + %39 = OpLoad %6 %38 + %40 = OpIAdd %6 %39 %37 + %41 = OpAccessChain %25 %15 %17 %10 + OpStore %41 %40 + %42 = OpAccessChain %25 %24 %17 %17 %10 + %43 = OpLoad %6 %42 + %44 = OpAccessChain %25 %15 %31 %17 + OpStore %44 %43 + %45 = OpAccessChain %25 %24 %17 %17 %31 + %46 = OpLoad %6 %45 + %47 = OpIMul %6 %46 %7 + %48 = OpAccessChain %25 %15 %31 %31 + OpStore %48 %47 + %49 = OpAccessChain %25 %24 %17 %31 %10 + %50 = OpLoad %6 %49 + %51 = OpAccessChain %25 %15 %31 %10 + OpStore %51 %50 + %52 = OpAccessChain %25 %24 %31 %17 + %53 = OpLoad %6 %52 + %54 = OpAccessChain %25 %15 %37 %17 %17 + OpStore %54 %53 + %55 = OpAccessChain %25 %24 %31 %31 + %56 = OpLoad %6 %55 + %57 = OpAccessChain %25 %15 %37 %17 %31 + OpStore %57 %56 + %58 = OpAccessChain %25 %24 %31 %37 + %59 = OpLoad %6 %58 + %60 = OpAccessChain %25 %15 %37 %31 %17 + OpStore %60 %59 + %62 = OpAccessChain %25 %24 %31 %61 + %63 = OpLoad %6 %62 + %64 = OpAccessChain %25 %15 %37 %31 %31 + OpStore %64 %63 + OpReturn + OpFunctionEnd + +)"; + +TEST(DiffTest, IndexSignedness) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 + ; Bound: 65 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %13 "BufferOut" + OpMemberName %13 0 "o1" + OpMemberName %13 1 "o2" + OpMemberName %13 2 "o3" + OpName %15 "" + OpName %22 "BufferIn" + OpMemberName %22 0 "i1" + OpMemberName %22 1 "i2" + OpName %24 "" + OpDecorate %8 ArrayStride 4 + OpDecorate %9 ArrayStride 4 + OpDecorate %11 ArrayStride 4 + OpDecorate %12 ArrayStride 8 + OpMemberDecorate %13 0 Offset 0 + OpMemberDecorate %13 1 Offset 12 + OpMemberDecorate %13 2 Offset 24 + OpDecorate %13 BufferBlock + OpDecorate %15 DescriptorSet 0 + OpDecorate %15 Binding 1 + OpDecorate %18 ArrayStride 16 + OpDecorate %19 ArrayStride 48 + OpDecorate %21 ArrayStride 16 + OpMemberDecorate %22 0 Offset 0 + OpMemberDecorate %22 1 Offset 96 + OpDecorate %22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeInt 32 0 + %7 = OpConstant %6 3 +-%8 = OpTypeArray %6 %7 ++%8 = OpTypeArray %6 %61 +-%9 = OpTypeArray %6 %7 ++%9 = OpTypeArray %6 %61 + %10 = OpConstant %6 2 +-%11 = OpTypeArray %6 %10 ++%11 = OpTypeArray %6 %37 +-%12 = OpTypeArray %11 %10 ++%12 = OpTypeArray %11 %37 + %13 = OpTypeStruct %8 %9 %12 + %14 = OpTypePointer Uniform %13 + %15 = OpVariable %14 Uniform + %16 = OpTypeInt 32 1 + %17 = OpConstant %16 0 +-%18 = OpTypeArray %6 %7 ++%18 = OpTypeArray %6 %61 +-%19 = OpTypeArray %18 %10 ++%19 = OpTypeArray %18 %37 +-%20 = OpConstant %6 4 ++%20 = OpConstant %16 4 + %21 = OpTypeArray %6 %20 + %22 = OpTypeStruct %19 %21 + %23 = OpTypePointer Uniform %22 + %24 = OpVariable %23 Uniform + %25 = OpTypePointer Uniform %6 + %28 = OpConstant %6 1 + %31 = OpConstant %16 1 + %34 = OpConstant %6 0 + %37 = OpConstant %16 2 + %61 = OpConstant %16 3 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %26 = OpAccessChain %25 %24 %17 %17 %17 + %27 = OpLoad %6 %26 +-%29 = OpIAdd %6 %27 %28 ++%29 = OpIAdd %6 %27 %31 + %30 = OpAccessChain %25 %15 %17 %17 + OpStore %30 %29 +-%32 = OpAccessChain %25 %24 %17 %31 %17 ++%32 = OpAccessChain %25 %24 %17 %28 %17 + %33 = OpLoad %6 %32 + %35 = OpIAdd %6 %33 %34 +-%36 = OpAccessChain %25 %15 %17 %31 ++%36 = OpAccessChain %25 %15 %17 %28 + OpStore %36 %35 +-%38 = OpAccessChain %25 %24 %17 %31 %31 ++%38 = OpAccessChain %25 %24 %17 %28 %28 + %39 = OpLoad %6 %38 + %40 = OpIAdd %6 %39 %10 + %41 = OpAccessChain %25 %15 %17 %37 + OpStore %41 %40 + %42 = OpAccessChain %25 %24 %17 %17 %37 + %43 = OpLoad %6 %42 +-%44 = OpAccessChain %25 %15 %31 %17 ++%44 = OpAccessChain %25 %15 %28 %17 + OpStore %44 %43 +-%45 = OpAccessChain %25 %24 %17 %17 %31 ++%45 = OpAccessChain %25 %24 %17 %17 %28 + %46 = OpLoad %6 %45 +-%47 = OpIMul %6 %46 %7 ++%47 = OpIMul %6 %46 %61 +-%48 = OpAccessChain %25 %15 %31 %31 ++%48 = OpAccessChain %25 %15 %28 %28 + OpStore %48 %47 +-%49 = OpAccessChain %25 %24 %17 %31 %37 ++%49 = OpAccessChain %25 %24 %17 %28 %37 + %50 = OpLoad %6 %49 +-%51 = OpAccessChain %25 %15 %31 %37 ++%51 = OpAccessChain %25 %15 %28 %37 + OpStore %51 %50 +-%52 = OpAccessChain %25 %24 %31 %17 ++%52 = OpAccessChain %25 %24 %28 %17 + %53 = OpLoad %6 %52 +-%54 = OpAccessChain %25 %15 %37 %17 %17 ++%54 = OpAccessChain %25 %15 %10 %17 %17 + OpStore %54 %53 +-%55 = OpAccessChain %25 %24 %31 %31 ++%55 = OpAccessChain %25 %24 %28 %28 + %56 = OpLoad %6 %55 +-%57 = OpAccessChain %25 %15 %37 %17 %31 ++%57 = OpAccessChain %25 %15 %10 %17 %28 + OpStore %57 %56 +-%58 = OpAccessChain %25 %24 %31 %37 ++%58 = OpAccessChain %25 %24 %28 %10 + %59 = OpLoad %6 %58 +-%60 = OpAccessChain %25 %15 %37 %31 %17 ++%60 = OpAccessChain %25 %15 %10 %28 %17 + OpStore %60 %59 +-%62 = OpAccessChain %25 %24 %31 %61 ++%62 = OpAccessChain %25 %24 %28 %7 + %63 = OpLoad %6 %62 +-%64 = OpAccessChain %25 %15 %37 %31 %31 ++%64 = OpAccessChain %25 %15 %10 %28 %28 + OpStore %64 %63 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, IndexSignednessNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpDecorate %8 ArrayStride 4 + OpDecorate %9 ArrayStride 4 + OpDecorate %11 ArrayStride 4 + OpDecorate %12 ArrayStride 8 + OpMemberDecorate %13 0 Offset 0 + OpMemberDecorate %13 1 Offset 12 + OpMemberDecorate %13 2 Offset 24 + OpDecorate %13 BufferBlock + OpDecorate %15 DescriptorSet 0 + OpDecorate %15 Binding 1 + OpDecorate %18 ArrayStride 16 + OpDecorate %19 ArrayStride 48 + OpDecorate %21 ArrayStride 16 + OpMemberDecorate %22 0 Offset 0 + OpMemberDecorate %22 1 Offset 96 + OpDecorate %22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeInt 32 0 + %7 = OpConstant %6 3 + %8 = OpTypeArray %6 %7 + %9 = OpTypeArray %6 %7 + %10 = OpConstant %6 2 + %11 = OpTypeArray %6 %10 + %12 = OpTypeArray %11 %10 + %13 = OpTypeStruct %8 %9 %12 + %14 = OpTypePointer Uniform %13 + %15 = OpVariable %14 Uniform + %16 = OpTypeInt 32 1 + %17 = OpConstant %16 0 + %18 = OpTypeArray %6 %7 + %19 = OpTypeArray %18 %10 + %20 = OpConstant %6 4 + %21 = OpTypeArray %6 %20 + %22 = OpTypeStruct %19 %21 + %23 = OpTypePointer Uniform %22 + %24 = OpVariable %23 Uniform + %25 = OpTypePointer Uniform %6 + %28 = OpConstant %6 1 + %31 = OpConstant %16 1 + %34 = OpConstant %6 0 + %37 = OpConstant %16 2 + %61 = OpConstant %16 3 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %26 = OpAccessChain %25 %24 %17 %17 %17 + %27 = OpLoad %6 %26 + %29 = OpIAdd %6 %27 %28 + %30 = OpAccessChain %25 %15 %17 %17 + OpStore %30 %29 + %32 = OpAccessChain %25 %24 %17 %31 %17 + %33 = OpLoad %6 %32 + %35 = OpIAdd %6 %33 %34 + %36 = OpAccessChain %25 %15 %17 %31 + OpStore %36 %35 + %38 = OpAccessChain %25 %24 %17 %31 %31 + %39 = OpLoad %6 %38 + %40 = OpIAdd %6 %39 %10 + %41 = OpAccessChain %25 %15 %17 %37 + OpStore %41 %40 + %42 = OpAccessChain %25 %24 %17 %17 %37 + %43 = OpLoad %6 %42 + %44 = OpAccessChain %25 %15 %31 %17 + OpStore %44 %43 + %45 = OpAccessChain %25 %24 %17 %17 %31 + %46 = OpLoad %6 %45 + %47 = OpIMul %6 %46 %7 + %48 = OpAccessChain %25 %15 %31 %31 + OpStore %48 %47 + %49 = OpAccessChain %25 %24 %17 %31 %37 + %50 = OpLoad %6 %49 + %51 = OpAccessChain %25 %15 %31 %37 + OpStore %51 %50 + %52 = OpAccessChain %25 %24 %31 %17 + %53 = OpLoad %6 %52 + %54 = OpAccessChain %25 %15 %37 %17 %17 + OpStore %54 %53 + %55 = OpAccessChain %25 %24 %31 %31 + %56 = OpLoad %6 %55 + %57 = OpAccessChain %25 %15 %37 %17 %31 + OpStore %57 %56 + %58 = OpAccessChain %25 %24 %31 %37 + %59 = OpLoad %6 %58 + %60 = OpAccessChain %25 %15 %37 %31 %17 + OpStore %60 %59 + %62 = OpAccessChain %25 %24 %31 %61 + %63 = OpLoad %6 %62 + %64 = OpAccessChain %25 %15 %37 %31 %31 + OpStore %64 %63 + OpReturn + OpFunctionEnd + +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpDecorate %8 ArrayStride 4 + OpDecorate %9 ArrayStride 4 + OpDecorate %11 ArrayStride 4 + OpDecorate %12 ArrayStride 8 + OpMemberDecorate %13 0 Offset 0 + OpMemberDecorate %13 1 Offset 12 + OpMemberDecorate %13 2 Offset 24 + OpDecorate %13 BufferBlock + OpDecorate %15 DescriptorSet 0 + OpDecorate %15 Binding 1 + OpDecorate %18 ArrayStride 16 + OpDecorate %19 ArrayStride 48 + OpDecorate %21 ArrayStride 16 + OpMemberDecorate %22 0 Offset 0 + OpMemberDecorate %22 1 Offset 96 + OpDecorate %22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeInt 32 0 + %16 = OpTypeInt 32 1 + %7 = OpConstant %16 3 + %8 = OpTypeArray %6 %7 + %9 = OpTypeArray %6 %7 + %10 = OpConstant %16 2 + %11 = OpTypeArray %6 %10 + %12 = OpTypeArray %11 %10 + %13 = OpTypeStruct %8 %9 %12 + %14 = OpTypePointer Uniform %13 + %15 = OpVariable %14 Uniform + %18 = OpTypeArray %6 %7 + %19 = OpTypeArray %18 %10 + %20 = OpConstant %16 4 + %21 = OpTypeArray %6 %20 + %22 = OpTypeStruct %19 %21 + %23 = OpTypePointer Uniform %22 + %24 = OpVariable %23 Uniform + %25 = OpTypePointer Uniform %6 + %17 = OpConstant %16 0 + %28 = OpConstant %16 1 + %31 = OpConstant %6 1 + %34 = OpConstant %6 0 + %37 = OpConstant %6 2 + %61 = OpConstant %6 3 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %26 = OpAccessChain %25 %24 %17 %17 %17 + %27 = OpLoad %6 %26 + %29 = OpIAdd %6 %27 %28 + %30 = OpAccessChain %25 %15 %17 %17 + OpStore %30 %29 + %32 = OpAccessChain %25 %24 %17 %31 %17 + %33 = OpLoad %6 %32 + %35 = OpIAdd %6 %33 %34 + %36 = OpAccessChain %25 %15 %17 %31 + OpStore %36 %35 + %38 = OpAccessChain %25 %24 %17 %31 %31 + %39 = OpLoad %6 %38 + %40 = OpIAdd %6 %39 %37 + %41 = OpAccessChain %25 %15 %17 %10 + OpStore %41 %40 + %42 = OpAccessChain %25 %24 %17 %17 %10 + %43 = OpLoad %6 %42 + %44 = OpAccessChain %25 %15 %31 %17 + OpStore %44 %43 + %45 = OpAccessChain %25 %24 %17 %17 %31 + %46 = OpLoad %6 %45 + %47 = OpIMul %6 %46 %7 + %48 = OpAccessChain %25 %15 %31 %31 + OpStore %48 %47 + %49 = OpAccessChain %25 %24 %17 %31 %10 + %50 = OpLoad %6 %49 + %51 = OpAccessChain %25 %15 %31 %10 + OpStore %51 %50 + %52 = OpAccessChain %25 %24 %31 %17 + %53 = OpLoad %6 %52 + %54 = OpAccessChain %25 %15 %37 %17 %17 + OpStore %54 %53 + %55 = OpAccessChain %25 %24 %31 %31 + %56 = OpLoad %6 %55 + %57 = OpAccessChain %25 %15 %37 %17 %31 + OpStore %57 %56 + %58 = OpAccessChain %25 %24 %31 %37 + %59 = OpLoad %6 %58 + %60 = OpAccessChain %25 %15 %37 %31 %17 + OpStore %60 %59 + %62 = OpAccessChain %25 %24 %31 %61 + %63 = OpLoad %6 %62 + %64 = OpAccessChain %25 %15 %37 %31 %31 + OpStore %64 %63 + OpReturn + OpFunctionEnd + +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 + ; Bound: 65 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpDecorate %8 ArrayStride 4 + OpDecorate %9 ArrayStride 4 + OpDecorate %11 ArrayStride 4 + OpDecorate %12 ArrayStride 8 + OpMemberDecorate %13 0 Offset 0 + OpMemberDecorate %13 1 Offset 12 + OpMemberDecorate %13 2 Offset 24 + OpDecorate %13 BufferBlock + OpDecorate %15 DescriptorSet 0 + OpDecorate %15 Binding 1 + OpDecorate %18 ArrayStride 16 + OpDecorate %19 ArrayStride 48 + OpDecorate %21 ArrayStride 16 + OpMemberDecorate %22 0 Offset 0 + OpMemberDecorate %22 1 Offset 96 + OpDecorate %22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeInt 32 0 + %7 = OpConstant %6 3 +-%8 = OpTypeArray %6 %7 ++%8 = OpTypeArray %6 %61 +-%9 = OpTypeArray %6 %7 ++%9 = OpTypeArray %6 %61 + %10 = OpConstant %6 2 +-%11 = OpTypeArray %6 %10 ++%11 = OpTypeArray %6 %37 +-%12 = OpTypeArray %11 %10 ++%12 = OpTypeArray %11 %37 + %13 = OpTypeStruct %8 %9 %12 + %14 = OpTypePointer Uniform %13 + %15 = OpVariable %14 Uniform + %16 = OpTypeInt 32 1 + %17 = OpConstant %16 0 +-%18 = OpTypeArray %6 %7 ++%18 = OpTypeArray %6 %61 +-%19 = OpTypeArray %18 %10 ++%19 = OpTypeArray %18 %37 +-%20 = OpConstant %6 4 ++%20 = OpConstant %16 4 + %21 = OpTypeArray %6 %20 + %22 = OpTypeStruct %19 %21 + %23 = OpTypePointer Uniform %22 + %24 = OpVariable %23 Uniform + %25 = OpTypePointer Uniform %6 + %28 = OpConstant %6 1 + %31 = OpConstant %16 1 + %34 = OpConstant %6 0 + %37 = OpConstant %16 2 + %61 = OpConstant %16 3 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %26 = OpAccessChain %25 %24 %17 %17 %17 + %27 = OpLoad %6 %26 +-%29 = OpIAdd %6 %27 %28 ++%29 = OpIAdd %6 %27 %31 + %30 = OpAccessChain %25 %15 %17 %17 + OpStore %30 %29 +-%32 = OpAccessChain %25 %24 %17 %31 %17 ++%32 = OpAccessChain %25 %24 %17 %28 %17 + %33 = OpLoad %6 %32 + %35 = OpIAdd %6 %33 %34 +-%36 = OpAccessChain %25 %15 %17 %31 ++%36 = OpAccessChain %25 %15 %17 %28 + OpStore %36 %35 +-%38 = OpAccessChain %25 %24 %17 %31 %31 ++%38 = OpAccessChain %25 %24 %17 %28 %28 + %39 = OpLoad %6 %38 + %40 = OpIAdd %6 %39 %10 + %41 = OpAccessChain %25 %15 %17 %37 + OpStore %41 %40 + %42 = OpAccessChain %25 %24 %17 %17 %37 + %43 = OpLoad %6 %42 +-%44 = OpAccessChain %25 %15 %31 %17 ++%44 = OpAccessChain %25 %15 %28 %17 + OpStore %44 %43 +-%45 = OpAccessChain %25 %24 %17 %17 %31 ++%45 = OpAccessChain %25 %24 %17 %17 %28 + %46 = OpLoad %6 %45 +-%47 = OpIMul %6 %46 %7 ++%47 = OpIMul %6 %46 %61 +-%48 = OpAccessChain %25 %15 %31 %31 ++%48 = OpAccessChain %25 %15 %28 %28 + OpStore %48 %47 +-%49 = OpAccessChain %25 %24 %17 %31 %37 ++%49 = OpAccessChain %25 %24 %17 %28 %37 + %50 = OpLoad %6 %49 +-%51 = OpAccessChain %25 %15 %31 %37 ++%51 = OpAccessChain %25 %15 %28 %37 + OpStore %51 %50 +-%52 = OpAccessChain %25 %24 %31 %17 ++%52 = OpAccessChain %25 %24 %28 %17 + %53 = OpLoad %6 %52 +-%54 = OpAccessChain %25 %15 %37 %17 %17 ++%54 = OpAccessChain %25 %15 %10 %17 %17 + OpStore %54 %53 +-%55 = OpAccessChain %25 %24 %31 %31 ++%55 = OpAccessChain %25 %24 %28 %28 + %56 = OpLoad %6 %55 +-%57 = OpAccessChain %25 %15 %37 %17 %31 ++%57 = OpAccessChain %25 %15 %10 %17 %28 + OpStore %57 %56 +-%58 = OpAccessChain %25 %24 %31 %37 ++%58 = OpAccessChain %25 %24 %28 %10 + %59 = OpLoad %6 %58 +-%60 = OpAccessChain %25 %15 %37 %31 %17 ++%60 = OpAccessChain %25 %15 %10 %28 %17 + OpStore %60 %59 +-%62 = OpAccessChain %25 %24 %31 %61 ++%62 = OpAccessChain %25 %24 %28 %7 + %63 = OpLoad %6 %62 +-%64 = OpAccessChain %25 %15 %37 %31 %31 ++%64 = OpAccessChain %25 %15 %10 %28 %28 + OpStore %64 %63 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/index_signedness_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/index_signedness_dst.spvasm new file mode 100644 index 0000000000..08c1939b2d --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/index_signedness_dst.spvasm @@ -0,0 +1,110 @@ + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %13 "BufferOut" + OpMemberName %13 0 "o1" + OpMemberName %13 1 "o2" + OpMemberName %13 2 "o3" + OpName %15 "" + OpName %22 "BufferIn" + OpMemberName %22 0 "i1" + OpMemberName %22 1 "i2" + OpName %24 "" + OpDecorate %8 ArrayStride 4 + OpDecorate %9 ArrayStride 4 + OpDecorate %11 ArrayStride 4 + OpDecorate %12 ArrayStride 8 + OpMemberDecorate %13 0 Offset 0 + OpMemberDecorate %13 1 Offset 12 + OpMemberDecorate %13 2 Offset 24 + OpDecorate %13 BufferBlock + OpDecorate %15 DescriptorSet 0 + OpDecorate %15 Binding 1 + OpDecorate %18 ArrayStride 16 + OpDecorate %19 ArrayStride 48 + OpDecorate %21 ArrayStride 16 + OpMemberDecorate %22 0 Offset 0 + OpMemberDecorate %22 1 Offset 96 + OpDecorate %22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeInt 32 0 + %16 = OpTypeInt 32 1 + %7 = OpConstant %16 3 + %8 = OpTypeArray %6 %7 + %9 = OpTypeArray %6 %7 + %10 = OpConstant %16 2 + %11 = OpTypeArray %6 %10 + %12 = OpTypeArray %11 %10 + %13 = OpTypeStruct %8 %9 %12 + %14 = OpTypePointer Uniform %13 + %15 = OpVariable %14 Uniform + %18 = OpTypeArray %6 %7 + %19 = OpTypeArray %18 %10 + %20 = OpConstant %16 4 + %21 = OpTypeArray %6 %20 + %22 = OpTypeStruct %19 %21 + %23 = OpTypePointer Uniform %22 + %24 = OpVariable %23 Uniform + %25 = OpTypePointer Uniform %6 + %17 = OpConstant %16 0 + %28 = OpConstant %16 1 + %31 = OpConstant %6 1 + %34 = OpConstant %6 0 + %37 = OpConstant %6 2 + %61 = OpConstant %6 3 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %26 = OpAccessChain %25 %24 %17 %17 %17 + %27 = OpLoad %6 %26 + %29 = OpIAdd %6 %27 %28 + %30 = OpAccessChain %25 %15 %17 %17 + OpStore %30 %29 + %32 = OpAccessChain %25 %24 %17 %31 %17 + %33 = OpLoad %6 %32 + %35 = OpIAdd %6 %33 %34 + %36 = OpAccessChain %25 %15 %17 %31 + OpStore %36 %35 + %38 = OpAccessChain %25 %24 %17 %31 %31 + %39 = OpLoad %6 %38 + %40 = OpIAdd %6 %39 %37 + %41 = OpAccessChain %25 %15 %17 %10 + OpStore %41 %40 + %42 = OpAccessChain %25 %24 %17 %17 %10 + %43 = OpLoad %6 %42 + %44 = OpAccessChain %25 %15 %31 %17 + OpStore %44 %43 + %45 = OpAccessChain %25 %24 %17 %17 %31 + %46 = OpLoad %6 %45 + %47 = OpIMul %6 %46 %7 + %48 = OpAccessChain %25 %15 %31 %31 + OpStore %48 %47 + %49 = OpAccessChain %25 %24 %17 %31 %10 + %50 = OpLoad %6 %49 + %51 = OpAccessChain %25 %15 %31 %10 + OpStore %51 %50 + %52 = OpAccessChain %25 %24 %31 %17 + %53 = OpLoad %6 %52 + %54 = OpAccessChain %25 %15 %37 %17 %17 + OpStore %54 %53 + %55 = OpAccessChain %25 %24 %31 %31 + %56 = OpLoad %6 %55 + %57 = OpAccessChain %25 %15 %37 %17 %31 + OpStore %57 %56 + %58 = OpAccessChain %25 %24 %31 %37 + %59 = OpLoad %6 %58 + %60 = OpAccessChain %25 %15 %37 %31 %17 + OpStore %60 %59 + %62 = OpAccessChain %25 %24 %31 %61 + %63 = OpLoad %6 %62 + %64 = OpAccessChain %25 %15 %37 %31 %31 + OpStore %64 %63 + OpReturn + OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/index_signedness_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/index_signedness_src.spvasm new file mode 100644 index 0000000000..06dfd18bad --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/index_signedness_src.spvasm @@ -0,0 +1,111 @@ +;; Test where signedness of indices are different between src and dst. + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %13 "BufferOut" + OpMemberName %13 0 "o1" + OpMemberName %13 1 "o2" + OpMemberName %13 2 "o3" + OpName %15 "" + OpName %22 "BufferIn" + OpMemberName %22 0 "i1" + OpMemberName %22 1 "i2" + OpName %24 "" + OpDecorate %8 ArrayStride 4 + OpDecorate %9 ArrayStride 4 + OpDecorate %11 ArrayStride 4 + OpDecorate %12 ArrayStride 8 + OpMemberDecorate %13 0 Offset 0 + OpMemberDecorate %13 1 Offset 12 + OpMemberDecorate %13 2 Offset 24 + OpDecorate %13 BufferBlock + OpDecorate %15 DescriptorSet 0 + OpDecorate %15 Binding 1 + OpDecorate %18 ArrayStride 16 + OpDecorate %19 ArrayStride 48 + OpDecorate %21 ArrayStride 16 + OpMemberDecorate %22 0 Offset 0 + OpMemberDecorate %22 1 Offset 96 + OpDecorate %22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeInt 32 0 + %7 = OpConstant %6 3 + %8 = OpTypeArray %6 %7 + %9 = OpTypeArray %6 %7 + %10 = OpConstant %6 2 + %11 = OpTypeArray %6 %10 + %12 = OpTypeArray %11 %10 + %13 = OpTypeStruct %8 %9 %12 + %14 = OpTypePointer Uniform %13 + %15 = OpVariable %14 Uniform + %16 = OpTypeInt 32 1 + %17 = OpConstant %16 0 + %18 = OpTypeArray %6 %7 + %19 = OpTypeArray %18 %10 + %20 = OpConstant %6 4 + %21 = OpTypeArray %6 %20 + %22 = OpTypeStruct %19 %21 + %23 = OpTypePointer Uniform %22 + %24 = OpVariable %23 Uniform + %25 = OpTypePointer Uniform %6 + %28 = OpConstant %6 1 + %31 = OpConstant %16 1 + %34 = OpConstant %6 0 + %37 = OpConstant %16 2 + %61 = OpConstant %16 3 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %26 = OpAccessChain %25 %24 %17 %17 %17 + %27 = OpLoad %6 %26 + %29 = OpIAdd %6 %27 %28 + %30 = OpAccessChain %25 %15 %17 %17 + OpStore %30 %29 + %32 = OpAccessChain %25 %24 %17 %31 %17 + %33 = OpLoad %6 %32 + %35 = OpIAdd %6 %33 %34 + %36 = OpAccessChain %25 %15 %17 %31 + OpStore %36 %35 + %38 = OpAccessChain %25 %24 %17 %31 %31 + %39 = OpLoad %6 %38 + %40 = OpIAdd %6 %39 %10 + %41 = OpAccessChain %25 %15 %17 %37 + OpStore %41 %40 + %42 = OpAccessChain %25 %24 %17 %17 %37 + %43 = OpLoad %6 %42 + %44 = OpAccessChain %25 %15 %31 %17 + OpStore %44 %43 + %45 = OpAccessChain %25 %24 %17 %17 %31 + %46 = OpLoad %6 %45 + %47 = OpIMul %6 %46 %7 + %48 = OpAccessChain %25 %15 %31 %31 + OpStore %48 %47 + %49 = OpAccessChain %25 %24 %17 %31 %37 + %50 = OpLoad %6 %49 + %51 = OpAccessChain %25 %15 %31 %37 + OpStore %51 %50 + %52 = OpAccessChain %25 %24 %31 %17 + %53 = OpLoad %6 %52 + %54 = OpAccessChain %25 %15 %37 %17 %17 + OpStore %54 %53 + %55 = OpAccessChain %25 %24 %31 %31 + %56 = OpLoad %6 %55 + %57 = OpAccessChain %25 %15 %37 %17 %31 + OpStore %57 %56 + %58 = OpAccessChain %25 %24 %31 %37 + %59 = OpLoad %6 %58 + %60 = OpAccessChain %25 %15 %37 %31 %17 + OpStore %60 %59 + %62 = OpAccessChain %25 %24 %31 %61 + %63 = OpLoad %6 %62 + %64 = OpAccessChain %25 %15 %37 %31 %31 + OpStore %64 %63 + OpReturn + OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/int_vs_uint_constants_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/int_vs_uint_constants_autogen.cpp new file mode 100644 index 0000000000..187722e891 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/int_vs_uint_constants_autogen.cpp @@ -0,0 +1,396 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Tests that identical integer constants are matched, regardless of int or +// uint. This helps compare output from different generators that default to +// int or uint for constants such as those passed to OpAccessChain. +constexpr char kSrc[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Google ANGLE Shader Compiler; 0 +; Bound: 27 +; Schema: 0 +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %22 "main" %4 %19 +OpSource GLSL 450 +OpName %4 "_ua_position" +OpName %17 "gl_PerVertex" +OpMemberName %17 0 "gl_Position" +OpMemberName %17 1 "gl_PointSize" +OpMemberName %17 2 "gl_ClipDistance" +OpMemberName %17 3 "gl_CullDistance" +OpName %19 "" +OpName %22 "main" +OpDecorate %4 Location 0 +OpMemberDecorate %17 1 RelaxedPrecision +OpMemberDecorate %17 0 BuiltIn Position +OpMemberDecorate %17 1 BuiltIn PointSize +OpMemberDecorate %17 2 BuiltIn ClipDistance +OpMemberDecorate %17 3 BuiltIn CullDistance +OpDecorate %17 Block +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeInt 32 0 +%8 = OpTypeVector %5 4 +%15 = OpConstant %5 8 +%16 = OpTypeArray %1 %15 +%17 = OpTypeStruct %2 %1 %16 %16 +%20 = OpTypeVoid +%25 = OpConstant %5 0 +%3 = OpTypePointer Input %2 +%13 = OpTypePointer Output %2 +%18 = OpTypePointer Output %17 +%21 = OpTypeFunction %20 +%4 = OpVariable %3 Input +%19 = OpVariable %18 Output +%22 = OpFunction %20 None %21 +%23 = OpLabel +%24 = OpLoad %2 %4 +%26 = OpAccessChain %13 %19 %25 +OpStore %26 %24 +OpReturn +OpFunctionEnd)"; +constexpr char kDst[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 28 +; Schema: 0 +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %4 "main" %13 %17 +OpSource GLSL 450 +OpName %4 "main" +OpName %11 "gl_PerVertex" +OpMemberName %11 0 "gl_Position" +OpMemberName %11 1 "gl_PointSize" +OpMemberName %11 2 "gl_ClipDistance" +OpMemberName %11 3 "gl_CullDistance" +OpName %13 "" +OpName %17 "_ua_position" +OpMemberDecorate %11 0 BuiltIn Position +OpMemberDecorate %11 1 BuiltIn PointSize +OpMemberDecorate %11 2 BuiltIn ClipDistance +OpMemberDecorate %11 3 BuiltIn CullDistance +OpDecorate %11 Block +OpDecorate %17 Location 0 +%2 = OpTypeVoid +%3 = OpTypeFunction %2 +%6 = OpTypeFloat 32 +%7 = OpTypeVector %6 4 +%8 = OpTypeInt 32 0 +%9 = OpConstant %8 1 +%10 = OpTypeArray %6 %9 +%11 = OpTypeStruct %7 %6 %10 %10 +%12 = OpTypePointer Output %11 +%13 = OpVariable %12 Output +%14 = OpTypeInt 32 1 +%15 = OpConstant %14 0 +%16 = OpTypePointer Input %7 +%17 = OpVariable %16 Input +%19 = OpTypePointer Output %7 +%4 = OpFunction %2 None %3 +%5 = OpLabel +%18 = OpLoad %7 %17 +%20 = OpAccessChain %19 %13 %15 +OpStore %20 %18 +OpReturn +OpFunctionEnd +)"; + +TEST(DiffTest, IntVsUintConstants) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 27 ++; Bound: 31 + ; Schema: 0 + OpCapability Shader ++%27 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 +-OpEntryPoint Vertex %22 "main" %4 %19 ++OpEntryPoint Vertex %22 "main" %19 %4 + OpSource GLSL 450 + OpName %4 "_ua_position" + OpName %17 "gl_PerVertex" + OpMemberName %17 0 "gl_Position" + OpMemberName %17 1 "gl_PointSize" + OpMemberName %17 2 "gl_ClipDistance" + OpMemberName %17 3 "gl_CullDistance" + OpName %19 "" + OpName %22 "main" + OpDecorate %4 Location 0 +-OpMemberDecorate %17 1 RelaxedPrecision + OpMemberDecorate %17 0 BuiltIn Position + OpMemberDecorate %17 1 BuiltIn PointSize + OpMemberDecorate %17 2 BuiltIn ClipDistance + OpMemberDecorate %17 3 BuiltIn CullDistance + OpDecorate %17 Block + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %5 = OpTypeInt 32 0 +-%8 = OpTypeVector %5 4 +-%15 = OpConstant %5 8 +-%16 = OpTypeArray %1 %15 +-%17 = OpTypeStruct %2 %1 %16 %16 ++%17 = OpTypeStruct %2 %1 %29 %29 + %20 = OpTypeVoid ++%28 = OpConstant %5 1 ++%29 = OpTypeArray %1 %28 +-%25 = OpConstant %5 0 ++%25 = OpConstant %30 0 + %3 = OpTypePointer Input %2 + %13 = OpTypePointer Output %2 ++%30 = OpTypeInt 32 1 + %18 = OpTypePointer Output %17 + %21 = OpTypeFunction %20 + %4 = OpVariable %3 Input + %19 = OpVariable %18 Output + %22 = OpFunction %20 None %21 + %23 = OpLabel + %24 = OpLoad %2 %4 + %26 = OpAccessChain %13 %19 %25 + OpStore %26 %24 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, IntVsUintConstantsNoDebug) { + constexpr char kSrcNoDebug[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Google ANGLE Shader Compiler; 0 +; Bound: 27 +; Schema: 0 +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %22 "main" %4 %19 +OpSource GLSL 450 +OpDecorate %4 Location 0 +OpMemberDecorate %17 1 RelaxedPrecision +OpMemberDecorate %17 0 BuiltIn Position +OpMemberDecorate %17 1 BuiltIn PointSize +OpMemberDecorate %17 2 BuiltIn ClipDistance +OpMemberDecorate %17 3 BuiltIn CullDistance +OpDecorate %17 Block +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeInt 32 0 +%8 = OpTypeVector %5 4 +%15 = OpConstant %5 8 +%16 = OpTypeArray %1 %15 +%17 = OpTypeStruct %2 %1 %16 %16 +%20 = OpTypeVoid +%25 = OpConstant %5 0 +%3 = OpTypePointer Input %2 +%13 = OpTypePointer Output %2 +%18 = OpTypePointer Output %17 +%21 = OpTypeFunction %20 +%4 = OpVariable %3 Input +%19 = OpVariable %18 Output +%22 = OpFunction %20 None %21 +%23 = OpLabel +%24 = OpLoad %2 %4 +%26 = OpAccessChain %13 %19 %25 +OpStore %26 %24 +OpReturn +OpFunctionEnd +)"; + constexpr char kDstNoDebug[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 28 +; Schema: 0 +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %4 "main" %13 %17 +OpSource GLSL 450 +OpMemberDecorate %11 0 BuiltIn Position +OpMemberDecorate %11 1 BuiltIn PointSize +OpMemberDecorate %11 2 BuiltIn ClipDistance +OpMemberDecorate %11 3 BuiltIn CullDistance +OpDecorate %11 Block +OpDecorate %17 Location 0 +%2 = OpTypeVoid +%3 = OpTypeFunction %2 +%6 = OpTypeFloat 32 +%7 = OpTypeVector %6 4 +%8 = OpTypeInt 32 0 +%9 = OpConstant %8 1 +%10 = OpTypeArray %6 %9 +%11 = OpTypeStruct %7 %6 %10 %10 +%12 = OpTypePointer Output %11 +%13 = OpVariable %12 Output +%14 = OpTypeInt 32 1 +%15 = OpConstant %14 0 +%16 = OpTypePointer Input %7 +%17 = OpVariable %16 Input +%19 = OpTypePointer Output %7 +%4 = OpFunction %2 None %3 +%5 = OpLabel +%18 = OpLoad %7 %17 +%20 = OpAccessChain %19 %13 %15 +OpStore %20 %18 +OpReturn +OpFunctionEnd +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 27 ++; Bound: 31 + ; Schema: 0 + OpCapability Shader ++%27 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 +-OpEntryPoint Vertex %22 "main" %4 %19 ++OpEntryPoint Vertex %22 "main" %19 %4 + OpSource GLSL 450 + OpDecorate %4 Location 0 +-OpMemberDecorate %17 1 RelaxedPrecision + OpMemberDecorate %17 0 BuiltIn Position + OpMemberDecorate %17 1 BuiltIn PointSize + OpMemberDecorate %17 2 BuiltIn ClipDistance + OpMemberDecorate %17 3 BuiltIn CullDistance + OpDecorate %17 Block + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %5 = OpTypeInt 32 0 +-%8 = OpTypeVector %5 4 +-%15 = OpConstant %5 8 +-%16 = OpTypeArray %1 %15 +-%17 = OpTypeStruct %2 %1 %16 %16 ++%17 = OpTypeStruct %2 %1 %29 %29 + %20 = OpTypeVoid ++%28 = OpConstant %5 1 ++%29 = OpTypeArray %1 %28 +-%25 = OpConstant %5 0 ++%25 = OpConstant %30 0 + %3 = OpTypePointer Input %2 + %13 = OpTypePointer Output %2 ++%30 = OpTypeInt 32 1 + %18 = OpTypePointer Output %17 + %21 = OpTypeFunction %20 + %4 = OpVariable %3 Input + %19 = OpVariable %18 Output + %22 = OpFunction %20 None %21 + %23 = OpLabel + %24 = OpLoad %2 %4 + %26 = OpAccessChain %13 %19 %25 + OpStore %26 %24 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +TEST(DiffTest, IntVsUintConstantsDumpIds) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 27 ++; Bound: 31 + ; Schema: 0 + OpCapability Shader ++%27 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 +-OpEntryPoint Vertex %22 "main" %4 %19 ++OpEntryPoint Vertex %22 "main" %19 %4 + OpSource GLSL 450 + OpName %4 "_ua_position" + OpName %17 "gl_PerVertex" + OpMemberName %17 0 "gl_Position" + OpMemberName %17 1 "gl_PointSize" + OpMemberName %17 2 "gl_ClipDistance" + OpMemberName %17 3 "gl_CullDistance" + OpName %19 "" + OpName %22 "main" + OpDecorate %4 Location 0 +-OpMemberDecorate %17 1 RelaxedPrecision + OpMemberDecorate %17 0 BuiltIn Position + OpMemberDecorate %17 1 BuiltIn PointSize + OpMemberDecorate %17 2 BuiltIn ClipDistance + OpMemberDecorate %17 3 BuiltIn CullDistance + OpDecorate %17 Block + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %5 = OpTypeInt 32 0 +-%8 = OpTypeVector %5 4 +-%15 = OpConstant %5 8 +-%16 = OpTypeArray %1 %15 +-%17 = OpTypeStruct %2 %1 %16 %16 ++%17 = OpTypeStruct %2 %1 %29 %29 + %20 = OpTypeVoid ++%28 = OpConstant %5 1 ++%29 = OpTypeArray %1 %28 +-%25 = OpConstant %5 0 ++%25 = OpConstant %30 0 + %3 = OpTypePointer Input %2 + %13 = OpTypePointer Output %2 ++%30 = OpTypeInt 32 1 + %18 = OpTypePointer Output %17 + %21 = OpTypeFunction %20 + %4 = OpVariable %3 Input + %19 = OpVariable %18 Output + %22 = OpFunction %20 None %21 + %23 = OpLabel + %24 = OpLoad %2 %4 + %26 = OpAccessChain %13 %19 %25 + OpStore %26 %24 + OpReturn + OpFunctionEnd + Src -> Dst + 1 -> 6 [TypeFloat] + 2 -> 7 [TypeVector] + 3 -> 16 [TypePointer] + 4 -> 17 [Variable] + 5 -> 8 [TypeInt] + 8 -> 23 [TypeVector] + 13 -> 19 [TypePointer] + 15 -> 29 [Constant] + 16 -> 30 [TypeArray] + 17 -> 11 [TypeStruct] + 18 -> 12 [TypePointer] + 19 -> 13 [Variable] + 20 -> 2 [TypeVoid] + 21 -> 3 [TypeFunction] + 22 -> 4 [Function] + 23 -> 5 [Label] + 24 -> 18 [Load] + 25 -> 15 [Constant] + 26 -> 20 [AccessChain] +)"; + Options options; + options.dump_id_map = true; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/int_vs_uint_constants_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/int_vs_uint_constants_dst.spvasm new file mode 100644 index 0000000000..da2618b293 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/int_vs_uint_constants_dst.spvasm @@ -0,0 +1,46 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 28 +; Schema: 0 +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %4 "main" %13 %17 +OpSource GLSL 450 +OpName %4 "main" +OpName %11 "gl_PerVertex" +OpMemberName %11 0 "gl_Position" +OpMemberName %11 1 "gl_PointSize" +OpMemberName %11 2 "gl_ClipDistance" +OpMemberName %11 3 "gl_CullDistance" +OpName %13 "" +OpName %17 "_ua_position" +OpMemberDecorate %11 0 BuiltIn Position +OpMemberDecorate %11 1 BuiltIn PointSize +OpMemberDecorate %11 2 BuiltIn ClipDistance +OpMemberDecorate %11 3 BuiltIn CullDistance +OpDecorate %11 Block +OpDecorate %17 Location 0 +%2 = OpTypeVoid +%3 = OpTypeFunction %2 +%6 = OpTypeFloat 32 +%7 = OpTypeVector %6 4 +%8 = OpTypeInt 32 0 +%9 = OpConstant %8 1 +%10 = OpTypeArray %6 %9 +%11 = OpTypeStruct %7 %6 %10 %10 +%12 = OpTypePointer Output %11 +%13 = OpVariable %12 Output +%14 = OpTypeInt 32 1 +%15 = OpConstant %14 0 +%16 = OpTypePointer Input %7 +%17 = OpVariable %16 Input +%19 = OpTypePointer Output %7 +%4 = OpFunction %2 None %3 +%5 = OpLabel +%18 = OpLoad %7 %17 +%20 = OpAccessChain %19 %13 %15 +OpStore %20 %18 +OpReturn +OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/int_vs_uint_constants_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/int_vs_uint_constants_src.spvasm new file mode 100644 index 0000000000..214b49bd28 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/int_vs_uint_constants_src.spvasm @@ -0,0 +1,49 @@ +;; Tests that identical integer constants are matched, regardless of int or +;; uint. This helps compare output from different generators that default to +;; int or uint for constants such as those passed to OpAccessChain. +; SPIR-V +; Version: 1.0 +; Generator: Google ANGLE Shader Compiler; 0 +; Bound: 27 +; Schema: 0 +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %22 "main" %4 %19 +OpSource GLSL 450 +OpName %4 "_ua_position" +OpName %17 "gl_PerVertex" +OpMemberName %17 0 "gl_Position" +OpMemberName %17 1 "gl_PointSize" +OpMemberName %17 2 "gl_ClipDistance" +OpMemberName %17 3 "gl_CullDistance" +OpName %19 "" +OpName %22 "main" +OpDecorate %4 Location 0 +OpMemberDecorate %17 1 RelaxedPrecision +OpMemberDecorate %17 0 BuiltIn Position +OpMemberDecorate %17 1 BuiltIn PointSize +OpMemberDecorate %17 2 BuiltIn ClipDistance +OpMemberDecorate %17 3 BuiltIn CullDistance +OpDecorate %17 Block +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeInt 32 0 +%8 = OpTypeVector %5 4 +%15 = OpConstant %5 8 +%16 = OpTypeArray %1 %15 +%17 = OpTypeStruct %2 %1 %16 %16 +%20 = OpTypeVoid +%25 = OpConstant %5 0 +%3 = OpTypePointer Input %2 +%13 = OpTypePointer Output %2 +%18 = OpTypePointer Output %17 +%21 = OpTypeFunction %20 +%4 = OpVariable %3 Input +%19 = OpVariable %18 Output +%22 = OpFunction %20 None %21 +%23 = OpLabel +%24 = OpLoad %2 %4 +%26 = OpAccessChain %13 %19 %25 +OpStore %26 %24 +OpReturn +OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/large_functions_large_diffs_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/large_functions_large_diffs_autogen.cpp new file mode 100644 index 0000000000..12cb6219c9 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/large_functions_large_diffs_autogen.cpp @@ -0,0 +1,1534 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Test where src and dst have a few large functions with large differences. +constexpr char kSrc[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" %15 + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %6 "f1(" + OpName %8 "f2(" + OpName %12 "x" + OpName %15 "gl_LocalInvocationID" + OpName %20 "y" + OpName %27 "image" + OpName %44 "sum" + OpName %46 "i" + OpName %56 "j" + OpName %80 "BufferOut" + OpMemberName %80 0 "o_uv4" + OpMemberName %80 1 "o_v3" + OpMemberName %80 2 "o_i" + OpName %82 "" + OpName %88 "BufferIn" + OpMemberName %88 0 "i_u" + OpMemberName %88 1 "i_v4" + OpMemberName %88 2 "i_f" + OpName %90 "" + OpName %101 "i" + OpName %128 "image2" + OpDecorate %15 BuiltIn LocalInvocationId + OpDecorate %27 DescriptorSet 0 + OpDecorate %27 Binding 2 + OpMemberDecorate %80 0 Offset 0 + OpMemberDecorate %80 1 Offset 16 + OpMemberDecorate %80 2 Offset 28 + OpDecorate %80 BufferBlock + OpDecorate %82 DescriptorSet 0 + OpDecorate %82 Binding 1 + OpMemberDecorate %88 0 Offset 0 + OpMemberDecorate %88 1 RowMajor + OpMemberDecorate %88 1 Offset 16 + OpMemberDecorate %88 1 MatrixStride 16 + OpMemberDecorate %88 2 Offset 80 + OpDecorate %88 Block + OpDecorate %90 DescriptorSet 0 + OpDecorate %90 Binding 0 + OpDecorate %128 DescriptorSet 0 + OpDecorate %128 Binding 3 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %10 = OpTypeInt 32 0 + %11 = OpTypePointer Function %10 + %13 = OpTypeVector %10 3 + %14 = OpTypePointer Input %13 + %15 = OpVariable %14 Input + %16 = OpConstant %10 0 + %17 = OpTypePointer Input %10 + %21 = OpConstant %10 1 + %24 = OpTypeInt 32 1 + %25 = OpTypeImage %24 2D 0 0 0 2 R32i + %26 = OpTypePointer UniformConstant %25 + %27 = OpVariable %26 UniformConstant + %29 = OpTypeVector %10 2 + %32 = OpTypeVector %24 2 + %38 = OpTypeVector %24 4 + %40 = OpConstant %10 2 + %41 = OpConstant %10 3400 + %42 = OpConstant %10 264 + %43 = OpTypePointer Function %24 + %45 = OpConstant %24 0 + %53 = OpConstant %24 2 + %54 = OpTypeBool + %73 = OpConstant %24 1 + %77 = OpTypeVector %10 4 + %78 = OpTypeFloat 32 + %79 = OpTypeVector %78 3 + %80 = OpTypeStruct %77 %79 %24 + %81 = OpTypePointer Uniform %80 + %82 = OpVariable %81 Uniform + %84 = OpTypePointer Uniform %24 + %86 = OpTypeVector %78 4 + %87 = OpTypeMatrix %86 4 + %88 = OpTypeStruct %10 %87 %78 + %89 = OpTypePointer Uniform %88 + %90 = OpVariable %89 Uniform + %91 = OpTypePointer Uniform %87 + %94 = OpTypePointer Uniform %77 + %108 = OpConstant %24 3 + %110 = OpTypePointer Uniform %79 + %113 = OpTypePointer Uniform %78 + %128 = OpVariable %26 UniformConstant + %130 = OpConstantComposite %32 %45 %45 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %136 = OpFunctionCall %2 %6 + %137 = OpFunctionCall %2 %8 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %12 = OpVariable %11 Function + %20 = OpVariable %11 Function + %44 = OpVariable %43 Function + %46 = OpVariable %43 Function + %56 = OpVariable %43 Function + %18 = OpAccessChain %17 %15 %16 + %19 = OpLoad %10 %18 + OpStore %12 %19 + %22 = OpAccessChain %17 %15 %21 + %23 = OpLoad %10 %22 + OpStore %20 %23 + %28 = OpLoad %25 %27 + %30 = OpLoad %13 %15 + %31 = OpVectorShuffle %29 %30 %30 0 1 + %33 = OpBitcast %32 %31 + %34 = OpLoad %10 %12 + %35 = OpLoad %10 %20 + %36 = OpIAdd %10 %34 %35 + %37 = OpBitcast %24 %36 + %39 = OpCompositeConstruct %38 %37 %37 %37 %37 + OpImageWrite %28 %33 %39 + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + OpStore %44 %45 + OpStore %46 %45 + OpBranch %47 + %47 = OpLabel + OpLoopMerge %49 %50 None + OpBranch %51 + %51 = OpLabel + %52 = OpLoad %24 %46 + %55 = OpSLessThan %54 %52 %53 + OpBranchConditional %55 %48 %49 + %48 = OpLabel + OpStore %56 %45 + OpBranch %57 + %57 = OpLabel + OpLoopMerge %59 %60 None + OpBranch %61 + %61 = OpLabel + %62 = OpLoad %24 %56 + %63 = OpSLessThan %54 %62 %53 + OpBranchConditional %63 %58 %59 + %58 = OpLabel + %64 = OpLoad %25 %27 + %65 = OpLoad %24 %46 + %66 = OpLoad %24 %56 + %67 = OpCompositeConstruct %32 %65 %66 + %68 = OpImageRead %38 %64 %67 + %69 = OpCompositeExtract %24 %68 0 + %70 = OpLoad %24 %44 + %71 = OpIMul %24 %70 %69 + OpStore %44 %71 + OpBranch %60 + %60 = OpLabel + %72 = OpLoad %24 %56 + %74 = OpIAdd %24 %72 %73 + OpStore %56 %74 + OpBranch %57 + %59 = OpLabel + OpBranch %50 + %50 = OpLabel + %75 = OpLoad %24 %46 + %76 = OpIAdd %24 %75 %73 + OpStore %46 %76 + OpBranch %47 + %49 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %83 = OpLoad %24 %44 + %85 = OpAccessChain %84 %82 %53 + OpStore %85 %83 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %101 = OpVariable %43 Function + %92 = OpAccessChain %91 %90 %73 + %93 = OpLoad %87 %92 + %95 = OpAccessChain %94 %82 %45 + %96 = OpLoad %77 %95 + %97 = OpConvertUToF %86 %96 + %98 = OpMatrixTimesVector %86 %93 %97 + %99 = OpConvertFToU %77 %98 + %100 = OpAccessChain %94 %82 %45 + OpStore %100 %99 + OpStore %101 %45 + OpBranch %102 + %102 = OpLabel + OpLoopMerge %104 %105 None + OpBranch %106 + %106 = OpLabel + %107 = OpLoad %24 %101 + %109 = OpSLessThan %54 %107 %108 + OpBranchConditional %109 %103 %104 + %103 = OpLabel + %111 = OpAccessChain %110 %82 %73 + %112 = OpLoad %79 %111 + %114 = OpAccessChain %113 %90 %53 + %115 = OpLoad %78 %114 + %116 = OpVectorTimesScalar %79 %112 %115 + %117 = OpConvertFToU %13 %116 + %118 = OpCompositeExtract %10 %117 0 + %119 = OpCompositeExtract %10 %117 1 + %120 = OpCompositeExtract %10 %117 2 + %121 = OpCompositeConstruct %77 %118 %119 %120 %16 + %122 = OpAccessChain %94 %82 %45 + %123 = OpLoad %77 %122 + %124 = OpIAdd %77 %123 %121 + %125 = OpAccessChain %94 %82 %45 + OpStore %125 %124 + OpBranch %105 + %105 = OpLabel + %126 = OpLoad %24 %101 + %127 = OpIAdd %24 %126 %73 + OpStore %101 %127 + OpBranch %102 + %104 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %129 = OpLoad %25 %128 + %131 = OpImageRead %38 %129 %130 + %132 = OpCompositeExtract %24 %131 0 + %133 = OpConvertSToF %78 %132 + %134 = OpCompositeConstruct %79 %133 %133 %133 + %135 = OpAccessChain %110 %82 %73 + OpStore %135 %134 + OpReturn + OpFunctionEnd +)"; +constexpr char kDst[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" %15 %110 + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %6 "f1(" + OpName %8 "f2(" + OpName %12 "x" + OpName %15 "gl_GlobalInvocationID" + OpName %20 "z" + OpName %26 "i" + OpName %40 "BufferOut" + OpMemberName %40 0 "o_uv4" + OpMemberName %40 1 "o_v3" + OpMemberName %40 2 "o_i" + OpName %42 "" + OpName %63 "image2" + OpName %79 "image" + OpName %89 "i" + OpName %110 "gl_LocalInvocationID" + OpName %127 "BufferIn" + OpMemberName %127 0 "i_u" + OpMemberName %127 1 "i_v4" + OpMemberName %127 2 "i_f" + OpName %129 "" + OpDecorate %15 BuiltIn GlobalInvocationId + OpMemberDecorate %40 0 Offset 0 + OpMemberDecorate %40 1 Offset 16 + OpMemberDecorate %40 2 Offset 28 + OpDecorate %40 BufferBlock + OpDecorate %42 DescriptorSet 0 + OpDecorate %42 Binding 1 + OpDecorate %63 DescriptorSet 0 + OpDecorate %63 Binding 3 + OpDecorate %79 DescriptorSet 0 + OpDecorate %79 Binding 2 + OpDecorate %110 BuiltIn LocalInvocationId + OpMemberDecorate %127 0 Offset 0 + OpMemberDecorate %127 1 RowMajor + OpMemberDecorate %127 1 Offset 16 + OpMemberDecorate %127 1 MatrixStride 16 + OpMemberDecorate %127 2 Offset 80 + OpDecorate %127 Block + OpDecorate %129 DescriptorSet 0 + OpDecorate %129 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %10 = OpTypeInt 32 0 + %11 = OpTypePointer Function %10 + %13 = OpTypeVector %10 3 + %14 = OpTypePointer Input %13 + %15 = OpVariable %14 Input + %16 = OpConstant %10 0 + %17 = OpTypePointer Input %10 + %21 = OpConstant %10 1 + %24 = OpTypeInt 32 1 + %25 = OpTypePointer Function %24 + %27 = OpConstant %24 0 + %34 = OpConstant %24 2 + %35 = OpTypeBool + %37 = OpTypeVector %10 4 + %38 = OpTypeFloat 32 + %39 = OpTypeVector %38 3 + %40 = OpTypeStruct %37 %39 %24 + %41 = OpTypePointer Uniform %40 + %42 = OpVariable %41 Uniform + %46 = OpTypeVector %10 2 + %48 = OpTypePointer Uniform %37 + %53 = OpTypePointer Uniform %10 + %59 = OpConstant %24 1 + %61 = OpTypeImage %24 2D 0 0 0 2 R32i + %62 = OpTypePointer UniformConstant %61 + %63 = OpVariable %62 UniformConstant + %69 = OpTypeVector %24 2 + %71 = OpTypeVector %24 4 + %74 = OpTypePointer Uniform %24 + %76 = OpConstant %10 2 + %77 = OpConstant %10 3400 + %78 = OpConstant %10 264 + %79 = OpVariable %62 UniformConstant + %96 = OpConstant %24 3 + %103 = OpConstantComposite %69 %27 %27 + %107 = OpTypePointer Uniform %38 + %110 = OpVariable %14 Input + %113 = OpTypeVector %38 2 + %125 = OpTypeVector %38 4 + %126 = OpTypeMatrix %125 4 + %127 = OpTypeStruct %10 %126 %38 + %128 = OpTypePointer Uniform %127 + %129 = OpVariable %128 Uniform + %4 = OpFunction %2 None %3 + %5 = OpLabel + %123 = OpFunctionCall %2 %8 + %124 = OpFunctionCall %2 %6 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %12 = OpVariable %11 Function + %20 = OpVariable %11 Function + %26 = OpVariable %25 Function + %18 = OpAccessChain %17 %15 %16 + %19 = OpLoad %10 %18 + OpStore %12 %19 + %22 = OpAccessChain %17 %15 %21 + %23 = OpLoad %10 %22 + OpStore %20 %23 + OpStore %26 %27 + OpBranch %28 + %28 = OpLabel + OpLoopMerge %30 %31 None + OpBranch %32 + %32 = OpLabel + %33 = OpLoad %24 %26 + %36 = OpSLessThan %35 %33 %34 + OpBranchConditional %36 %29 %30 + %29 = OpLabel + %43 = OpLoad %10 %12 + %44 = OpLoad %10 %20 + %45 = OpIAdd %10 %43 %44 + %47 = OpCompositeConstruct %46 %45 %45 + %49 = OpAccessChain %48 %42 %27 + %50 = OpLoad %37 %49 + %51 = OpVectorShuffle %46 %50 %50 0 1 + %52 = OpIAdd %46 %51 %47 + %54 = OpAccessChain %53 %42 %27 %16 + %55 = OpCompositeExtract %10 %52 0 + OpStore %54 %55 + %56 = OpAccessChain %53 %42 %27 %21 + %57 = OpCompositeExtract %10 %52 1 + OpStore %56 %57 + OpBranch %31 + %31 = OpLabel + %58 = OpLoad %24 %26 + %60 = OpIAdd %24 %58 %59 + OpStore %26 %60 + OpBranch %28 + %30 = OpLabel + %64 = OpLoad %61 %63 + %65 = OpLoad %10 %12 + %66 = OpBitcast %24 %65 + %67 = OpLoad %10 %20 + %68 = OpBitcast %24 %67 + %70 = OpCompositeConstruct %69 %66 %68 + %72 = OpImageRead %71 %64 %70 + %73 = OpCompositeExtract %24 %72 1 + %75 = OpAccessChain %74 %42 %34 + OpStore %75 %73 + OpMemoryBarrier %76 %77 + OpControlBarrier %76 %76 %78 + %80 = OpLoad %61 %79 + %81 = OpLoad %10 %20 + %82 = OpBitcast %24 %81 + %83 = OpLoad %10 %12 + %84 = OpBitcast %24 %83 + %85 = OpCompositeConstruct %69 %82 %84 + %86 = OpAccessChain %74 %42 %34 + %87 = OpLoad %24 %86 + %88 = OpCompositeConstruct %71 %87 %27 %27 %27 + OpImageWrite %80 %85 %88 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %89 = OpVariable %25 Function + OpStore %89 %27 + OpBranch %90 + %90 = OpLabel + OpLoopMerge %92 %93 None + OpBranch %94 + %94 = OpLabel + %95 = OpLoad %24 %89 + %97 = OpSLessThan %35 %95 %96 + OpBranchConditional %97 %91 %92 + %91 = OpLabel + %98 = OpLoad %24 %89 + %99 = OpIEqual %35 %98 %27 + OpSelectionMerge %101 None + OpBranchConditional %99 %100 %109 + %100 = OpLabel + %102 = OpLoad %61 %63 + %104 = OpImageRead %71 %102 %103 + %105 = OpCompositeExtract %24 %104 0 + %106 = OpConvertSToF %38 %105 + %108 = OpAccessChain %107 %42 %59 %16 + OpStore %108 %106 + OpBranch %101 + %109 = OpLabel + %111 = OpLoad %13 %110 + %112 = OpConvertUToF %39 %111 + %114 = OpCompositeExtract %38 %112 0 + %115 = OpCompositeExtract %38 %112 1 + %116 = OpCompositeConstruct %113 %114 %115 + %117 = OpAccessChain %107 %42 %59 %21 + %118 = OpCompositeExtract %38 %116 0 + OpStore %117 %118 + %119 = OpAccessChain %107 %42 %59 %76 + %120 = OpCompositeExtract %38 %116 1 + OpStore %119 %120 + OpBranch %101 + %101 = OpLabel + OpBranch %93 + %93 = OpLabel + %121 = OpLoad %24 %89 + %122 = OpIAdd %24 %121 %59 + OpStore %89 %122 + OpBranch %90 + %92 = OpLabel + OpReturn + OpFunctionEnd + +)"; + +TEST(DiffTest, LargeFunctionsLargeDiffs) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 138 ++; Bound: 190 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 +-OpEntryPoint GLCompute %4 "main" %15 ++OpEntryPoint GLCompute %4 "main" %138 %15 + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %6 "f1(" + OpName %8 "f2(" + OpName %12 "x" ++OpName %138 "gl_GlobalInvocationID" + OpName %15 "gl_LocalInvocationID" +-OpName %20 "y" ++OpName %20 "z" + OpName %27 "image" +-OpName %44 "sum" ++OpName %44 "i" +-OpName %46 "i" +-OpName %56 "j" + OpName %80 "BufferOut" + OpMemberName %80 0 "o_uv4" + OpMemberName %80 1 "o_v3" + OpMemberName %80 2 "o_i" + OpName %82 "" + OpName %88 "BufferIn" + OpMemberName %88 0 "i_u" + OpMemberName %88 1 "i_v4" + OpMemberName %88 2 "i_f" + OpName %90 "" + OpName %101 "i" + OpName %128 "image2" ++OpDecorate %138 BuiltIn GlobalInvocationId + OpDecorate %15 BuiltIn LocalInvocationId + OpDecorate %27 DescriptorSet 0 + OpDecorate %27 Binding 2 + OpMemberDecorate %80 0 Offset 0 + OpMemberDecorate %80 1 Offset 16 + OpMemberDecorate %80 2 Offset 28 + OpDecorate %80 BufferBlock + OpDecorate %82 DescriptorSet 0 + OpDecorate %82 Binding 1 + OpMemberDecorate %88 0 Offset 0 + OpMemberDecorate %88 1 RowMajor + OpMemberDecorate %88 1 Offset 16 + OpMemberDecorate %88 1 MatrixStride 16 + OpMemberDecorate %88 2 Offset 80 + OpDecorate %88 Block + OpDecorate %90 DescriptorSet 0 + OpDecorate %90 Binding 0 + OpDecorate %128 DescriptorSet 0 + OpDecorate %128 Binding 3 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %10 = OpTypeInt 32 0 + %11 = OpTypePointer Function %10 + %13 = OpTypeVector %10 3 + %14 = OpTypePointer Input %13 ++%138 = OpVariable %14 Input + %15 = OpVariable %14 Input + %16 = OpConstant %10 0 + %17 = OpTypePointer Input %10 + %21 = OpConstant %10 1 + %24 = OpTypeInt 32 1 + %25 = OpTypeImage %24 2D 0 0 0 2 R32i + %26 = OpTypePointer UniformConstant %25 + %27 = OpVariable %26 UniformConstant + %29 = OpTypeVector %10 2 + %32 = OpTypeVector %24 2 + %38 = OpTypeVector %24 4 + %40 = OpConstant %10 2 + %41 = OpConstant %10 3400 + %42 = OpConstant %10 264 + %43 = OpTypePointer Function %24 + %45 = OpConstant %24 0 ++%149 = OpTypePointer Uniform %10 + %53 = OpConstant %24 2 + %54 = OpTypeBool + %73 = OpConstant %24 1 + %77 = OpTypeVector %10 4 + %78 = OpTypeFloat 32 + %79 = OpTypeVector %78 3 + %80 = OpTypeStruct %77 %79 %24 + %81 = OpTypePointer Uniform %80 + %82 = OpVariable %81 Uniform + %84 = OpTypePointer Uniform %24 + %86 = OpTypeVector %78 4 + %87 = OpTypeMatrix %86 4 + %88 = OpTypeStruct %10 %87 %78 + %89 = OpTypePointer Uniform %88 + %90 = OpVariable %89 Uniform +-%91 = OpTypePointer Uniform %87 ++%179 = OpTypeVector %78 2 + %94 = OpTypePointer Uniform %77 + %108 = OpConstant %24 3 +-%110 = OpTypePointer Uniform %79 + %113 = OpTypePointer Uniform %78 + %128 = OpVariable %26 UniformConstant + %130 = OpConstantComposite %32 %45 %45 + %4 = OpFunction %2 None %3 + %5 = OpLabel +-%136 = OpFunctionCall %2 %6 + %137 = OpFunctionCall %2 %8 ++%189 = OpFunctionCall %2 %6 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %12 = OpVariable %11 Function + %20 = OpVariable %11 Function + %44 = OpVariable %43 Function +-%46 = OpVariable %43 Function +-%56 = OpVariable %43 Function +-%18 = OpAccessChain %17 %15 %16 ++%139 = OpAccessChain %17 %138 %16 +-%19 = OpLoad %10 %18 ++%19 = OpLoad %10 %139 + OpStore %12 %19 +-%22 = OpAccessChain %17 %15 %21 ++%140 = OpAccessChain %17 %138 %21 +-%23 = OpLoad %10 %22 ++%23 = OpLoad %10 %140 + OpStore %20 %23 +-%28 = OpLoad %25 %27 +-%30 = OpLoad %13 %15 +-%31 = OpVectorShuffle %29 %30 %30 0 1 +-%33 = OpBitcast %32 %31 +-%34 = OpLoad %10 %12 +-%35 = OpLoad %10 %20 +-%36 = OpIAdd %10 %34 %35 +-%37 = OpBitcast %24 %36 +-%39 = OpCompositeConstruct %38 %37 %37 %37 %37 +-OpImageWrite %28 %33 %39 +-OpMemoryBarrier %40 %41 +-OpControlBarrier %40 %40 %42 + OpStore %44 %45 +-OpStore %46 %45 + OpBranch %47 + %47 = OpLabel +-OpLoopMerge %49 %50 None ++OpLoopMerge %49 %59 None + OpBranch %51 + %51 = OpLabel +-%52 = OpLoad %24 %46 ++%52 = OpLoad %24 %44 + %55 = OpSLessThan %54 %52 %53 + OpBranchConditional %55 %48 %49 + %48 = OpLabel +-OpStore %56 %45 +-OpBranch %57 +-%57 = OpLabel +-OpLoopMerge %59 %60 None +-OpBranch %61 +-%61 = OpLabel +-%62 = OpLoad %24 %56 +-%63 = OpSLessThan %54 %62 %53 +-OpBranchConditional %63 %58 %59 +-%58 = OpLabel +-%64 = OpLoad %25 %27 +-%65 = OpLoad %24 %46 +-%66 = OpLoad %24 %56 +-%67 = OpCompositeConstruct %32 %65 %66 +-%68 = OpImageRead %38 %64 %67 +-%69 = OpCompositeExtract %24 %68 0 +-%70 = OpLoad %24 %44 +-%71 = OpIMul %24 %70 %69 ++%141 = OpLoad %10 %12 ++%142 = OpLoad %10 %20 ++%143 = OpIAdd %10 %141 %142 ++%144 = OpCompositeConstruct %29 %143 %143 ++%145 = OpAccessChain %94 %82 %45 ++%146 = OpLoad %77 %145 ++%147 = OpVectorShuffle %29 %146 %146 0 1 ++%148 = OpIAdd %29 %147 %144 ++%150 = OpAccessChain %149 %82 %45 %16 ++%151 = OpCompositeExtract %10 %148 0 +-OpStore %44 %71 ++OpStore %150 %151 +-OpBranch %60 +-%60 = OpLabel +-%72 = OpLoad %24 %56 +-%74 = OpIAdd %24 %72 %73 ++%152 = OpAccessChain %149 %82 %45 %21 ++%153 = OpCompositeExtract %10 %148 1 +-OpStore %56 %74 ++OpStore %152 %153 +-OpBranch %57 ++OpBranch %59 + %59 = OpLabel +-OpBranch %50 +-%50 = OpLabel +-%75 = OpLoad %24 %46 ++%75 = OpLoad %24 %44 + %76 = OpIAdd %24 %75 %73 +-OpStore %46 %76 ++OpStore %44 %76 + OpBranch %47 + %49 = OpLabel ++%154 = OpLoad %25 %128 ++%155 = OpLoad %10 %12 ++%156 = OpBitcast %24 %155 ++%157 = OpLoad %10 %20 ++%158 = OpBitcast %24 %157 ++%159 = OpCompositeConstruct %32 %156 %158 ++%160 = OpImageRead %38 %154 %159 ++%161 = OpCompositeExtract %24 %160 1 ++%162 = OpAccessChain %84 %82 %53 ++OpStore %162 %161 + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 +-%83 = OpLoad %24 %44 ++%163 = OpLoad %25 %27 ++%164 = OpLoad %10 %20 ++%165 = OpBitcast %24 %164 ++%166 = OpLoad %10 %12 ++%167 = OpBitcast %24 %166 ++%168 = OpCompositeConstruct %32 %165 %167 + %85 = OpAccessChain %84 %82 %53 +-OpStore %85 %83 ++%169 = OpLoad %24 %85 ++%170 = OpCompositeConstruct %38 %169 %45 %45 %45 ++OpImageWrite %163 %168 %170 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %101 = OpVariable %43 Function +-%92 = OpAccessChain %91 %90 %73 +-%93 = OpLoad %87 %92 +-%95 = OpAccessChain %94 %82 %45 +-%96 = OpLoad %77 %95 +-%97 = OpConvertUToF %86 %96 +-%98 = OpMatrixTimesVector %86 %93 %97 +-%99 = OpConvertFToU %77 %98 +-%100 = OpAccessChain %94 %82 %45 +-OpStore %100 %99 ++OpStore %101 %45 +-OpStore %101 %45 + OpBranch %102 + %102 = OpLabel +-OpLoopMerge %104 %105 None ++OpLoopMerge %171 %172 None + OpBranch %106 + %106 = OpLabel + %107 = OpLoad %24 %101 + %109 = OpSLessThan %54 %107 %108 +-OpBranchConditional %109 %103 %104 ++OpBranchConditional %109 %103 %171 + %103 = OpLabel +-%111 = OpAccessChain %110 %82 %73 +-%112 = OpLoad %79 %111 +-%114 = OpAccessChain %113 %90 %53 +-%115 = OpLoad %78 %114 +-%116 = OpVectorTimesScalar %79 %112 %115 +-%117 = OpConvertFToU %13 %116 +-%118 = OpCompositeExtract %10 %117 0 +-%119 = OpCompositeExtract %10 %117 1 +-%120 = OpCompositeExtract %10 %117 2 +-%121 = OpCompositeConstruct %77 %118 %119 %120 %16 +-%122 = OpAccessChain %94 %82 %45 +-%123 = OpLoad %77 %122 +-%124 = OpIAdd %77 %123 %121 +-%125 = OpAccessChain %94 %82 %45 +-OpStore %125 %124 +-OpBranch %105 +-%105 = OpLabel + %126 = OpLoad %24 %101 +-%127 = OpIAdd %24 %126 %73 ++%173 = OpIEqual %54 %126 %45 ++OpSelectionMerge %174 None ++OpBranchConditional %173 %104 %176 ++%176 = OpLabel ++%177 = OpLoad %13 %15 ++%178 = OpConvertUToF %79 %177 ++%180 = OpCompositeExtract %78 %178 0 ++%181 = OpCompositeExtract %78 %178 1 ++%182 = OpCompositeConstruct %179 %180 %181 ++%183 = OpAccessChain %113 %82 %73 %21 ++%184 = OpCompositeExtract %78 %182 0 +-OpStore %101 %127 ++OpStore %183 %184 ++%185 = OpAccessChain %113 %82 %73 %40 ++%186 = OpCompositeExtract %78 %182 1 ++OpStore %185 %186 +-OpBranch %102 ++OpBranch %174 + %104 = OpLabel +-OpMemoryBarrier %40 %41 +-OpControlBarrier %40 %40 %42 + %129 = OpLoad %25 %128 + %131 = OpImageRead %38 %129 %130 + %132 = OpCompositeExtract %24 %131 0 + %133 = OpConvertSToF %78 %132 +-%134 = OpCompositeConstruct %79 %133 %133 %133 +-%135 = OpAccessChain %110 %82 %73 ++%175 = OpAccessChain %113 %82 %73 %16 +-OpStore %135 %134 ++OpStore %175 %133 ++OpBranch %174 ++%174 = OpLabel ++OpBranch %172 ++%172 = OpLabel ++%187 = OpLoad %24 %101 ++%188 = OpIAdd %24 %187 %73 ++OpStore %101 %188 ++OpBranch %102 ++%171 = OpLabel + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, LargeFunctionsLargeDiffsNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" %15 + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpDecorate %15 BuiltIn LocalInvocationId + OpDecorate %27 DescriptorSet 0 + OpDecorate %27 Binding 2 + OpMemberDecorate %80 0 Offset 0 + OpMemberDecorate %80 1 Offset 16 + OpMemberDecorate %80 2 Offset 28 + OpDecorate %80 BufferBlock + OpDecorate %82 DescriptorSet 0 + OpDecorate %82 Binding 1 + OpMemberDecorate %88 0 Offset 0 + OpMemberDecorate %88 1 RowMajor + OpMemberDecorate %88 1 Offset 16 + OpMemberDecorate %88 1 MatrixStride 16 + OpMemberDecorate %88 2 Offset 80 + OpDecorate %88 Block + OpDecorate %90 DescriptorSet 0 + OpDecorate %90 Binding 0 + OpDecorate %128 DescriptorSet 0 + OpDecorate %128 Binding 3 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %10 = OpTypeInt 32 0 + %11 = OpTypePointer Function %10 + %13 = OpTypeVector %10 3 + %14 = OpTypePointer Input %13 + %15 = OpVariable %14 Input + %16 = OpConstant %10 0 + %17 = OpTypePointer Input %10 + %21 = OpConstant %10 1 + %24 = OpTypeInt 32 1 + %25 = OpTypeImage %24 2D 0 0 0 2 R32i + %26 = OpTypePointer UniformConstant %25 + %27 = OpVariable %26 UniformConstant + %29 = OpTypeVector %10 2 + %32 = OpTypeVector %24 2 + %38 = OpTypeVector %24 4 + %40 = OpConstant %10 2 + %41 = OpConstant %10 3400 + %42 = OpConstant %10 264 + %43 = OpTypePointer Function %24 + %45 = OpConstant %24 0 + %53 = OpConstant %24 2 + %54 = OpTypeBool + %73 = OpConstant %24 1 + %77 = OpTypeVector %10 4 + %78 = OpTypeFloat 32 + %79 = OpTypeVector %78 3 + %80 = OpTypeStruct %77 %79 %24 + %81 = OpTypePointer Uniform %80 + %82 = OpVariable %81 Uniform + %84 = OpTypePointer Uniform %24 + %86 = OpTypeVector %78 4 + %87 = OpTypeMatrix %86 4 + %88 = OpTypeStruct %10 %87 %78 + %89 = OpTypePointer Uniform %88 + %90 = OpVariable %89 Uniform + %91 = OpTypePointer Uniform %87 + %94 = OpTypePointer Uniform %77 + %108 = OpConstant %24 3 + %110 = OpTypePointer Uniform %79 + %113 = OpTypePointer Uniform %78 + %128 = OpVariable %26 UniformConstant + %130 = OpConstantComposite %32 %45 %45 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %136 = OpFunctionCall %2 %6 + %137 = OpFunctionCall %2 %8 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %12 = OpVariable %11 Function + %20 = OpVariable %11 Function + %44 = OpVariable %43 Function + %46 = OpVariable %43 Function + %56 = OpVariable %43 Function + %18 = OpAccessChain %17 %15 %16 + %19 = OpLoad %10 %18 + OpStore %12 %19 + %22 = OpAccessChain %17 %15 %21 + %23 = OpLoad %10 %22 + OpStore %20 %23 + %28 = OpLoad %25 %27 + %30 = OpLoad %13 %15 + %31 = OpVectorShuffle %29 %30 %30 0 1 + %33 = OpBitcast %32 %31 + %34 = OpLoad %10 %12 + %35 = OpLoad %10 %20 + %36 = OpIAdd %10 %34 %35 + %37 = OpBitcast %24 %36 + %39 = OpCompositeConstruct %38 %37 %37 %37 %37 + OpImageWrite %28 %33 %39 + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + OpStore %44 %45 + OpStore %46 %45 + OpBranch %47 + %47 = OpLabel + OpLoopMerge %49 %50 None + OpBranch %51 + %51 = OpLabel + %52 = OpLoad %24 %46 + %55 = OpSLessThan %54 %52 %53 + OpBranchConditional %55 %48 %49 + %48 = OpLabel + OpStore %56 %45 + OpBranch %57 + %57 = OpLabel + OpLoopMerge %59 %60 None + OpBranch %61 + %61 = OpLabel + %62 = OpLoad %24 %56 + %63 = OpSLessThan %54 %62 %53 + OpBranchConditional %63 %58 %59 + %58 = OpLabel + %64 = OpLoad %25 %27 + %65 = OpLoad %24 %46 + %66 = OpLoad %24 %56 + %67 = OpCompositeConstruct %32 %65 %66 + %68 = OpImageRead %38 %64 %67 + %69 = OpCompositeExtract %24 %68 0 + %70 = OpLoad %24 %44 + %71 = OpIMul %24 %70 %69 + OpStore %44 %71 + OpBranch %60 + %60 = OpLabel + %72 = OpLoad %24 %56 + %74 = OpIAdd %24 %72 %73 + OpStore %56 %74 + OpBranch %57 + %59 = OpLabel + OpBranch %50 + %50 = OpLabel + %75 = OpLoad %24 %46 + %76 = OpIAdd %24 %75 %73 + OpStore %46 %76 + OpBranch %47 + %49 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %83 = OpLoad %24 %44 + %85 = OpAccessChain %84 %82 %53 + OpStore %85 %83 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %101 = OpVariable %43 Function + %92 = OpAccessChain %91 %90 %73 + %93 = OpLoad %87 %92 + %95 = OpAccessChain %94 %82 %45 + %96 = OpLoad %77 %95 + %97 = OpConvertUToF %86 %96 + %98 = OpMatrixTimesVector %86 %93 %97 + %99 = OpConvertFToU %77 %98 + %100 = OpAccessChain %94 %82 %45 + OpStore %100 %99 + OpStore %101 %45 + OpBranch %102 + %102 = OpLabel + OpLoopMerge %104 %105 None + OpBranch %106 + %106 = OpLabel + %107 = OpLoad %24 %101 + %109 = OpSLessThan %54 %107 %108 + OpBranchConditional %109 %103 %104 + %103 = OpLabel + %111 = OpAccessChain %110 %82 %73 + %112 = OpLoad %79 %111 + %114 = OpAccessChain %113 %90 %53 + %115 = OpLoad %78 %114 + %116 = OpVectorTimesScalar %79 %112 %115 + %117 = OpConvertFToU %13 %116 + %118 = OpCompositeExtract %10 %117 0 + %119 = OpCompositeExtract %10 %117 1 + %120 = OpCompositeExtract %10 %117 2 + %121 = OpCompositeConstruct %77 %118 %119 %120 %16 + %122 = OpAccessChain %94 %82 %45 + %123 = OpLoad %77 %122 + %124 = OpIAdd %77 %123 %121 + %125 = OpAccessChain %94 %82 %45 + OpStore %125 %124 + OpBranch %105 + %105 = OpLabel + %126 = OpLoad %24 %101 + %127 = OpIAdd %24 %126 %73 + OpStore %101 %127 + OpBranch %102 + %104 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %129 = OpLoad %25 %128 + %131 = OpImageRead %38 %129 %130 + %132 = OpCompositeExtract %24 %131 0 + %133 = OpConvertSToF %78 %132 + %134 = OpCompositeConstruct %79 %133 %133 %133 + %135 = OpAccessChain %110 %82 %73 + OpStore %135 %134 + OpReturn + OpFunctionEnd + +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" %15 %110 + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpDecorate %15 BuiltIn GlobalInvocationId + OpMemberDecorate %40 0 Offset 0 + OpMemberDecorate %40 1 Offset 16 + OpMemberDecorate %40 2 Offset 28 + OpDecorate %40 BufferBlock + OpDecorate %42 DescriptorSet 0 + OpDecorate %42 Binding 1 + OpDecorate %63 DescriptorSet 0 + OpDecorate %63 Binding 3 + OpDecorate %79 DescriptorSet 0 + OpDecorate %79 Binding 2 + OpDecorate %110 BuiltIn LocalInvocationId + OpMemberDecorate %127 0 Offset 0 + OpMemberDecorate %127 1 RowMajor + OpMemberDecorate %127 1 Offset 16 + OpMemberDecorate %127 1 MatrixStride 16 + OpMemberDecorate %127 2 Offset 80 + OpDecorate %127 Block + OpDecorate %129 DescriptorSet 0 + OpDecorate %129 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %10 = OpTypeInt 32 0 + %11 = OpTypePointer Function %10 + %13 = OpTypeVector %10 3 + %14 = OpTypePointer Input %13 + %15 = OpVariable %14 Input + %16 = OpConstant %10 0 + %17 = OpTypePointer Input %10 + %21 = OpConstant %10 1 + %24 = OpTypeInt 32 1 + %25 = OpTypePointer Function %24 + %27 = OpConstant %24 0 + %34 = OpConstant %24 2 + %35 = OpTypeBool + %37 = OpTypeVector %10 4 + %38 = OpTypeFloat 32 + %39 = OpTypeVector %38 3 + %40 = OpTypeStruct %37 %39 %24 + %41 = OpTypePointer Uniform %40 + %42 = OpVariable %41 Uniform + %46 = OpTypeVector %10 2 + %48 = OpTypePointer Uniform %37 + %53 = OpTypePointer Uniform %10 + %59 = OpConstant %24 1 + %61 = OpTypeImage %24 2D 0 0 0 2 R32i + %62 = OpTypePointer UniformConstant %61 + %63 = OpVariable %62 UniformConstant + %69 = OpTypeVector %24 2 + %71 = OpTypeVector %24 4 + %74 = OpTypePointer Uniform %24 + %76 = OpConstant %10 2 + %77 = OpConstant %10 3400 + %78 = OpConstant %10 264 + %79 = OpVariable %62 UniformConstant + %96 = OpConstant %24 3 + %103 = OpConstantComposite %69 %27 %27 + %107 = OpTypePointer Uniform %38 + %110 = OpVariable %14 Input + %113 = OpTypeVector %38 2 + %125 = OpTypeVector %38 4 + %126 = OpTypeMatrix %125 4 + %127 = OpTypeStruct %10 %126 %38 + %128 = OpTypePointer Uniform %127 + %129 = OpVariable %128 Uniform + %4 = OpFunction %2 None %3 + %5 = OpLabel + %123 = OpFunctionCall %2 %8 + %124 = OpFunctionCall %2 %6 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %12 = OpVariable %11 Function + %20 = OpVariable %11 Function + %26 = OpVariable %25 Function + %18 = OpAccessChain %17 %15 %16 + %19 = OpLoad %10 %18 + OpStore %12 %19 + %22 = OpAccessChain %17 %15 %21 + %23 = OpLoad %10 %22 + OpStore %20 %23 + OpStore %26 %27 + OpBranch %28 + %28 = OpLabel + OpLoopMerge %30 %31 None + OpBranch %32 + %32 = OpLabel + %33 = OpLoad %24 %26 + %36 = OpSLessThan %35 %33 %34 + OpBranchConditional %36 %29 %30 + %29 = OpLabel + %43 = OpLoad %10 %12 + %44 = OpLoad %10 %20 + %45 = OpIAdd %10 %43 %44 + %47 = OpCompositeConstruct %46 %45 %45 + %49 = OpAccessChain %48 %42 %27 + %50 = OpLoad %37 %49 + %51 = OpVectorShuffle %46 %50 %50 0 1 + %52 = OpIAdd %46 %51 %47 + %54 = OpAccessChain %53 %42 %27 %16 + %55 = OpCompositeExtract %10 %52 0 + OpStore %54 %55 + %56 = OpAccessChain %53 %42 %27 %21 + %57 = OpCompositeExtract %10 %52 1 + OpStore %56 %57 + OpBranch %31 + %31 = OpLabel + %58 = OpLoad %24 %26 + %60 = OpIAdd %24 %58 %59 + OpStore %26 %60 + OpBranch %28 + %30 = OpLabel + %64 = OpLoad %61 %63 + %65 = OpLoad %10 %12 + %66 = OpBitcast %24 %65 + %67 = OpLoad %10 %20 + %68 = OpBitcast %24 %67 + %70 = OpCompositeConstruct %69 %66 %68 + %72 = OpImageRead %71 %64 %70 + %73 = OpCompositeExtract %24 %72 1 + %75 = OpAccessChain %74 %42 %34 + OpStore %75 %73 + OpMemoryBarrier %76 %77 + OpControlBarrier %76 %76 %78 + %80 = OpLoad %61 %79 + %81 = OpLoad %10 %20 + %82 = OpBitcast %24 %81 + %83 = OpLoad %10 %12 + %84 = OpBitcast %24 %83 + %85 = OpCompositeConstruct %69 %82 %84 + %86 = OpAccessChain %74 %42 %34 + %87 = OpLoad %24 %86 + %88 = OpCompositeConstruct %71 %87 %27 %27 %27 + OpImageWrite %80 %85 %88 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %89 = OpVariable %25 Function + OpStore %89 %27 + OpBranch %90 + %90 = OpLabel + OpLoopMerge %92 %93 None + OpBranch %94 + %94 = OpLabel + %95 = OpLoad %24 %89 + %97 = OpSLessThan %35 %95 %96 + OpBranchConditional %97 %91 %92 + %91 = OpLabel + %98 = OpLoad %24 %89 + %99 = OpIEqual %35 %98 %27 + OpSelectionMerge %101 None + OpBranchConditional %99 %100 %109 + %100 = OpLabel + %102 = OpLoad %61 %63 + %104 = OpImageRead %71 %102 %103 + %105 = OpCompositeExtract %24 %104 0 + %106 = OpConvertSToF %38 %105 + %108 = OpAccessChain %107 %42 %59 %16 + OpStore %108 %106 + OpBranch %101 + %109 = OpLabel + %111 = OpLoad %13 %110 + %112 = OpConvertUToF %39 %111 + %114 = OpCompositeExtract %38 %112 0 + %115 = OpCompositeExtract %38 %112 1 + %116 = OpCompositeConstruct %113 %114 %115 + %117 = OpAccessChain %107 %42 %59 %21 + %118 = OpCompositeExtract %38 %116 0 + OpStore %117 %118 + %119 = OpAccessChain %107 %42 %59 %76 + %120 = OpCompositeExtract %38 %116 1 + OpStore %119 %120 + OpBranch %101 + %101 = OpLabel + OpBranch %93 + %93 = OpLabel + %121 = OpLoad %24 %89 + %122 = OpIAdd %24 %121 %59 + OpStore %89 %122 + OpBranch %90 + %92 = OpLabel + OpReturn + OpFunctionEnd + +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 138 ++; Bound: 220 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 +-OpEntryPoint GLCompute %4 "main" %15 ++OpEntryPoint GLCompute %4 "main" %143 %15 + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 ++OpDecorate %143 BuiltIn GlobalInvocationId + OpDecorate %15 BuiltIn LocalInvocationId + OpDecorate %27 DescriptorSet 0 + OpDecorate %27 Binding 2 + OpMemberDecorate %80 0 Offset 0 + OpMemberDecorate %80 1 Offset 16 + OpMemberDecorate %80 2 Offset 28 + OpDecorate %80 BufferBlock + OpDecorate %82 DescriptorSet 0 + OpDecorate %82 Binding 1 + OpMemberDecorate %88 0 Offset 0 + OpMemberDecorate %88 1 RowMajor + OpMemberDecorate %88 1 Offset 16 + OpMemberDecorate %88 1 MatrixStride 16 + OpMemberDecorate %88 2 Offset 80 + OpDecorate %88 Block + OpDecorate %90 DescriptorSet 0 + OpDecorate %90 Binding 0 + OpDecorate %128 DescriptorSet 0 + OpDecorate %128 Binding 3 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %10 = OpTypeInt 32 0 + %11 = OpTypePointer Function %10 + %13 = OpTypeVector %10 3 + %14 = OpTypePointer Input %13 ++%143 = OpVariable %14 Input + %15 = OpVariable %14 Input + %16 = OpConstant %10 0 + %17 = OpTypePointer Input %10 + %21 = OpConstant %10 1 + %24 = OpTypeInt 32 1 + %25 = OpTypeImage %24 2D 0 0 0 2 R32i + %26 = OpTypePointer UniformConstant %25 + %27 = OpVariable %26 UniformConstant + %29 = OpTypeVector %10 2 + %32 = OpTypeVector %24 2 + %38 = OpTypeVector %24 4 + %40 = OpConstant %10 2 + %41 = OpConstant %10 3400 + %42 = OpConstant %10 264 + %43 = OpTypePointer Function %24 + %45 = OpConstant %24 0 ++%165 = OpTypePointer Uniform %10 + %53 = OpConstant %24 2 + %54 = OpTypeBool + %73 = OpConstant %24 1 + %77 = OpTypeVector %10 4 + %78 = OpTypeFloat 32 + %79 = OpTypeVector %78 3 + %80 = OpTypeStruct %77 %79 %24 + %81 = OpTypePointer Uniform %80 + %82 = OpVariable %81 Uniform + %84 = OpTypePointer Uniform %24 + %86 = OpTypeVector %78 4 + %87 = OpTypeMatrix %86 4 + %88 = OpTypeStruct %10 %87 %78 + %89 = OpTypePointer Uniform %88 + %90 = OpVariable %89 Uniform +-%91 = OpTypePointer Uniform %87 ++%210 = OpTypeVector %78 2 + %94 = OpTypePointer Uniform %77 + %108 = OpConstant %24 3 +-%110 = OpTypePointer Uniform %79 + %113 = OpTypePointer Uniform %78 + %128 = OpVariable %26 UniformConstant + %130 = OpConstantComposite %32 %45 %45 + %4 = OpFunction %2 None %3 + %5 = OpLabel +-%136 = OpFunctionCall %2 %6 ++%136 = OpFunctionCall %2 %140 +-%137 = OpFunctionCall %2 %8 ++%137 = OpFunctionCall %2 %138 + OpReturn + OpFunctionEnd +-%6 = OpFunction %2 None %3 +-%7 = OpLabel +-%12 = OpVariable %11 Function +-%20 = OpVariable %11 Function +-%44 = OpVariable %43 Function +-%46 = OpVariable %43 Function +-%56 = OpVariable %43 Function +-%18 = OpAccessChain %17 %15 %16 +-%19 = OpLoad %10 %18 +-OpStore %12 %19 +-%22 = OpAccessChain %17 %15 %21 +-%23 = OpLoad %10 %22 +-OpStore %20 %23 +-%28 = OpLoad %25 %27 +-%30 = OpLoad %13 %15 +-%31 = OpVectorShuffle %29 %30 %30 0 1 +-%33 = OpBitcast %32 %31 +-%34 = OpLoad %10 %12 +-%35 = OpLoad %10 %20 +-%36 = OpIAdd %10 %34 %35 +-%37 = OpBitcast %24 %36 +-%39 = OpCompositeConstruct %38 %37 %37 %37 %37 +-OpImageWrite %28 %33 %39 +-OpMemoryBarrier %40 %41 +-OpControlBarrier %40 %40 %42 +-OpStore %44 %45 +-OpStore %46 %45 +-OpBranch %47 +-%47 = OpLabel +-OpLoopMerge %49 %50 None +-OpBranch %51 +-%51 = OpLabel +-%52 = OpLoad %24 %46 +-%55 = OpSLessThan %54 %52 %53 +-OpBranchConditional %55 %48 %49 +-%48 = OpLabel +-OpStore %56 %45 +-OpBranch %57 +-%57 = OpLabel +-OpLoopMerge %59 %60 None +-OpBranch %61 +-%61 = OpLabel +-%62 = OpLoad %24 %56 +-%63 = OpSLessThan %54 %62 %53 +-OpBranchConditional %63 %58 %59 +-%58 = OpLabel +-%64 = OpLoad %25 %27 +-%65 = OpLoad %24 %46 +-%66 = OpLoad %24 %56 +-%67 = OpCompositeConstruct %32 %65 %66 +-%68 = OpImageRead %38 %64 %67 +-%69 = OpCompositeExtract %24 %68 0 +-%70 = OpLoad %24 %44 +-%71 = OpIMul %24 %70 %69 +-OpStore %44 %71 +-OpBranch %60 +-%60 = OpLabel +-%72 = OpLoad %24 %56 +-%74 = OpIAdd %24 %72 %73 +-OpStore %56 %74 +-OpBranch %57 +-%59 = OpLabel +-OpBranch %50 +-%50 = OpLabel +-%75 = OpLoad %24 %46 +-%76 = OpIAdd %24 %75 %73 +-OpStore %46 %76 +-OpBranch %47 +-%49 = OpLabel +-OpMemoryBarrier %40 %41 +-OpControlBarrier %40 %40 %42 +-%83 = OpLoad %24 %44 +-%85 = OpAccessChain %84 %82 %53 +-OpStore %85 %83 +-OpReturn +-OpFunctionEnd +-%8 = OpFunction %2 None %3 +-%9 = OpLabel +-%101 = OpVariable %43 Function +-%92 = OpAccessChain %91 %90 %73 +-%93 = OpLoad %87 %92 +-%95 = OpAccessChain %94 %82 %45 +-%96 = OpLoad %77 %95 +-%97 = OpConvertUToF %86 %96 +-%98 = OpMatrixTimesVector %86 %93 %97 +-%99 = OpConvertFToU %77 %98 +-%100 = OpAccessChain %94 %82 %45 +-OpStore %100 %99 +-OpStore %101 %45 +-OpBranch %102 +-%102 = OpLabel +-OpLoopMerge %104 %105 None +-OpBranch %106 +-%106 = OpLabel +-%107 = OpLoad %24 %101 +-%109 = OpSLessThan %54 %107 %108 +-OpBranchConditional %109 %103 %104 +-%103 = OpLabel +-%111 = OpAccessChain %110 %82 %73 +-%112 = OpLoad %79 %111 +-%114 = OpAccessChain %113 %90 %53 +-%115 = OpLoad %78 %114 +-%116 = OpVectorTimesScalar %79 %112 %115 +-%117 = OpConvertFToU %13 %116 +-%118 = OpCompositeExtract %10 %117 0 +-%119 = OpCompositeExtract %10 %117 1 +-%120 = OpCompositeExtract %10 %117 2 +-%121 = OpCompositeConstruct %77 %118 %119 %120 %16 +-%122 = OpAccessChain %94 %82 %45 +-%123 = OpLoad %77 %122 +-%124 = OpIAdd %77 %123 %121 +-%125 = OpAccessChain %94 %82 %45 +-OpStore %125 %124 +-OpBranch %105 +-%105 = OpLabel +-%126 = OpLoad %24 %101 +-%127 = OpIAdd %24 %126 %73 +-OpStore %101 %127 +-OpBranch %102 +-%104 = OpLabel +-OpMemoryBarrier %40 %41 +-OpControlBarrier %40 %40 %42 +-%129 = OpLoad %25 %128 +-%131 = OpImageRead %38 %129 %130 +-%132 = OpCompositeExtract %24 %131 0 +-%133 = OpConvertSToF %78 %132 +-%134 = OpCompositeConstruct %79 %133 %133 %133 +-%135 = OpAccessChain %110 %82 %73 +-OpStore %135 %134 +-OpReturn +-OpFunctionEnd ++%138 = OpFunction %2 None %3 ++%139 = OpLabel ++%142 = OpVariable %11 Function ++%146 = OpVariable %11 Function ++%149 = OpVariable %43 Function ++%144 = OpAccessChain %17 %143 %16 ++%145 = OpLoad %10 %144 ++OpStore %142 %145 ++%147 = OpAccessChain %17 %143 %21 ++%148 = OpLoad %10 %147 ++OpStore %146 %148 ++OpStore %149 %45 ++OpBranch %150 ++%150 = OpLabel ++OpLoopMerge %152 %153 None ++OpBranch %154 ++%154 = OpLabel ++%155 = OpLoad %24 %149 ++%156 = OpSLessThan %54 %155 %53 ++OpBranchConditional %156 %151 %152 ++%151 = OpLabel ++%157 = OpLoad %10 %142 ++%158 = OpLoad %10 %146 ++%159 = OpIAdd %10 %157 %158 ++%160 = OpCompositeConstruct %29 %159 %159 ++%161 = OpAccessChain %94 %82 %45 ++%162 = OpLoad %77 %161 ++%163 = OpVectorShuffle %29 %162 %162 0 1 ++%164 = OpIAdd %29 %163 %160 ++%166 = OpAccessChain %165 %82 %45 %16 ++%167 = OpCompositeExtract %10 %164 0 ++OpStore %166 %167 ++%168 = OpAccessChain %165 %82 %45 %21 ++%169 = OpCompositeExtract %10 %164 1 ++OpStore %168 %169 ++OpBranch %153 ++%153 = OpLabel ++%170 = OpLoad %24 %149 ++%171 = OpIAdd %24 %170 %73 ++OpStore %149 %171 ++OpBranch %150 ++%152 = OpLabel ++%172 = OpLoad %25 %128 ++%173 = OpLoad %10 %142 ++%174 = OpBitcast %24 %173 ++%175 = OpLoad %10 %146 ++%176 = OpBitcast %24 %175 ++%177 = OpCompositeConstruct %32 %174 %176 ++%178 = OpImageRead %38 %172 %177 ++%179 = OpCompositeExtract %24 %178 1 ++%180 = OpAccessChain %84 %82 %53 ++OpStore %180 %179 ++OpMemoryBarrier %40 %41 ++OpControlBarrier %40 %40 %42 ++%181 = OpLoad %25 %27 ++%182 = OpLoad %10 %146 ++%183 = OpBitcast %24 %182 ++%184 = OpLoad %10 %142 ++%185 = OpBitcast %24 %184 ++%186 = OpCompositeConstruct %32 %183 %185 ++%187 = OpAccessChain %84 %82 %53 ++%188 = OpLoad %24 %187 ++%189 = OpCompositeConstruct %38 %188 %45 %45 %45 ++OpImageWrite %181 %186 %189 ++OpReturn ++OpFunctionEnd ++%140 = OpFunction %2 None %3 ++%141 = OpLabel ++%190 = OpVariable %43 Function ++OpStore %190 %45 ++OpBranch %191 ++%191 = OpLabel ++OpLoopMerge %193 %194 None ++OpBranch %195 ++%195 = OpLabel ++%196 = OpLoad %24 %190 ++%197 = OpSLessThan %54 %196 %108 ++OpBranchConditional %197 %192 %193 ++%192 = OpLabel ++%198 = OpLoad %24 %190 ++%199 = OpIEqual %54 %198 %45 ++OpSelectionMerge %201 None ++OpBranchConditional %199 %200 %207 ++%207 = OpLabel ++%208 = OpLoad %13 %15 ++%209 = OpConvertUToF %79 %208 ++%211 = OpCompositeExtract %78 %209 0 ++%212 = OpCompositeExtract %78 %209 1 ++%213 = OpCompositeConstruct %210 %211 %212 ++%214 = OpAccessChain %113 %82 %73 %21 ++%215 = OpCompositeExtract %78 %213 0 ++OpStore %214 %215 ++%216 = OpAccessChain %113 %82 %73 %40 ++%217 = OpCompositeExtract %78 %213 1 ++OpStore %216 %217 ++OpBranch %201 ++%200 = OpLabel ++%202 = OpLoad %25 %128 ++%203 = OpImageRead %38 %202 %130 ++%204 = OpCompositeExtract %24 %203 0 ++%205 = OpConvertSToF %78 %204 ++%206 = OpAccessChain %113 %82 %73 %16 ++OpStore %206 %205 ++OpBranch %201 ++%201 = OpLabel ++OpBranch %194 ++%194 = OpLabel ++%218 = OpLoad %24 %190 ++%219 = OpIAdd %24 %218 %73 ++OpStore %190 %219 ++OpBranch %191 ++%193 = OpLabel ++OpReturn ++OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/large_functions_large_diffs_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/large_functions_large_diffs_dst.spvasm new file mode 100644 index 0000000000..be7c1d5f64 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/large_functions_large_diffs_dst.spvasm @@ -0,0 +1,213 @@ + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" %15 %110 + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %6 "f1(" + OpName %8 "f2(" + OpName %12 "x" + OpName %15 "gl_GlobalInvocationID" + OpName %20 "z" + OpName %26 "i" + OpName %40 "BufferOut" + OpMemberName %40 0 "o_uv4" + OpMemberName %40 1 "o_v3" + OpMemberName %40 2 "o_i" + OpName %42 "" + OpName %63 "image2" + OpName %79 "image" + OpName %89 "i" + OpName %110 "gl_LocalInvocationID" + OpName %127 "BufferIn" + OpMemberName %127 0 "i_u" + OpMemberName %127 1 "i_v4" + OpMemberName %127 2 "i_f" + OpName %129 "" + OpDecorate %15 BuiltIn GlobalInvocationId + OpMemberDecorate %40 0 Offset 0 + OpMemberDecorate %40 1 Offset 16 + OpMemberDecorate %40 2 Offset 28 + OpDecorate %40 BufferBlock + OpDecorate %42 DescriptorSet 0 + OpDecorate %42 Binding 1 + OpDecorate %63 DescriptorSet 0 + OpDecorate %63 Binding 3 + OpDecorate %79 DescriptorSet 0 + OpDecorate %79 Binding 2 + OpDecorate %110 BuiltIn LocalInvocationId + OpMemberDecorate %127 0 Offset 0 + OpMemberDecorate %127 1 RowMajor + OpMemberDecorate %127 1 Offset 16 + OpMemberDecorate %127 1 MatrixStride 16 + OpMemberDecorate %127 2 Offset 80 + OpDecorate %127 Block + OpDecorate %129 DescriptorSet 0 + OpDecorate %129 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %10 = OpTypeInt 32 0 + %11 = OpTypePointer Function %10 + %13 = OpTypeVector %10 3 + %14 = OpTypePointer Input %13 + %15 = OpVariable %14 Input + %16 = OpConstant %10 0 + %17 = OpTypePointer Input %10 + %21 = OpConstant %10 1 + %24 = OpTypeInt 32 1 + %25 = OpTypePointer Function %24 + %27 = OpConstant %24 0 + %34 = OpConstant %24 2 + %35 = OpTypeBool + %37 = OpTypeVector %10 4 + %38 = OpTypeFloat 32 + %39 = OpTypeVector %38 3 + %40 = OpTypeStruct %37 %39 %24 + %41 = OpTypePointer Uniform %40 + %42 = OpVariable %41 Uniform + %46 = OpTypeVector %10 2 + %48 = OpTypePointer Uniform %37 + %53 = OpTypePointer Uniform %10 + %59 = OpConstant %24 1 + %61 = OpTypeImage %24 2D 0 0 0 2 R32i + %62 = OpTypePointer UniformConstant %61 + %63 = OpVariable %62 UniformConstant + %69 = OpTypeVector %24 2 + %71 = OpTypeVector %24 4 + %74 = OpTypePointer Uniform %24 + %76 = OpConstant %10 2 + %77 = OpConstant %10 3400 + %78 = OpConstant %10 264 + %79 = OpVariable %62 UniformConstant + %96 = OpConstant %24 3 + %103 = OpConstantComposite %69 %27 %27 + %107 = OpTypePointer Uniform %38 + %110 = OpVariable %14 Input + %113 = OpTypeVector %38 2 + %125 = OpTypeVector %38 4 + %126 = OpTypeMatrix %125 4 + %127 = OpTypeStruct %10 %126 %38 + %128 = OpTypePointer Uniform %127 + %129 = OpVariable %128 Uniform + %4 = OpFunction %2 None %3 + %5 = OpLabel + %123 = OpFunctionCall %2 %8 + %124 = OpFunctionCall %2 %6 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %12 = OpVariable %11 Function + %20 = OpVariable %11 Function + %26 = OpVariable %25 Function + %18 = OpAccessChain %17 %15 %16 + %19 = OpLoad %10 %18 + OpStore %12 %19 + %22 = OpAccessChain %17 %15 %21 + %23 = OpLoad %10 %22 + OpStore %20 %23 + OpStore %26 %27 + OpBranch %28 + %28 = OpLabel + OpLoopMerge %30 %31 None + OpBranch %32 + %32 = OpLabel + %33 = OpLoad %24 %26 + %36 = OpSLessThan %35 %33 %34 + OpBranchConditional %36 %29 %30 + %29 = OpLabel + %43 = OpLoad %10 %12 + %44 = OpLoad %10 %20 + %45 = OpIAdd %10 %43 %44 + %47 = OpCompositeConstruct %46 %45 %45 + %49 = OpAccessChain %48 %42 %27 + %50 = OpLoad %37 %49 + %51 = OpVectorShuffle %46 %50 %50 0 1 + %52 = OpIAdd %46 %51 %47 + %54 = OpAccessChain %53 %42 %27 %16 + %55 = OpCompositeExtract %10 %52 0 + OpStore %54 %55 + %56 = OpAccessChain %53 %42 %27 %21 + %57 = OpCompositeExtract %10 %52 1 + OpStore %56 %57 + OpBranch %31 + %31 = OpLabel + %58 = OpLoad %24 %26 + %60 = OpIAdd %24 %58 %59 + OpStore %26 %60 + OpBranch %28 + %30 = OpLabel + %64 = OpLoad %61 %63 + %65 = OpLoad %10 %12 + %66 = OpBitcast %24 %65 + %67 = OpLoad %10 %20 + %68 = OpBitcast %24 %67 + %70 = OpCompositeConstruct %69 %66 %68 + %72 = OpImageRead %71 %64 %70 + %73 = OpCompositeExtract %24 %72 1 + %75 = OpAccessChain %74 %42 %34 + OpStore %75 %73 + OpMemoryBarrier %76 %77 + OpControlBarrier %76 %76 %78 + %80 = OpLoad %61 %79 + %81 = OpLoad %10 %20 + %82 = OpBitcast %24 %81 + %83 = OpLoad %10 %12 + %84 = OpBitcast %24 %83 + %85 = OpCompositeConstruct %69 %82 %84 + %86 = OpAccessChain %74 %42 %34 + %87 = OpLoad %24 %86 + %88 = OpCompositeConstruct %71 %87 %27 %27 %27 + OpImageWrite %80 %85 %88 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %89 = OpVariable %25 Function + OpStore %89 %27 + OpBranch %90 + %90 = OpLabel + OpLoopMerge %92 %93 None + OpBranch %94 + %94 = OpLabel + %95 = OpLoad %24 %89 + %97 = OpSLessThan %35 %95 %96 + OpBranchConditional %97 %91 %92 + %91 = OpLabel + %98 = OpLoad %24 %89 + %99 = OpIEqual %35 %98 %27 + OpSelectionMerge %101 None + OpBranchConditional %99 %100 %109 + %100 = OpLabel + %102 = OpLoad %61 %63 + %104 = OpImageRead %71 %102 %103 + %105 = OpCompositeExtract %24 %104 0 + %106 = OpConvertSToF %38 %105 + %108 = OpAccessChain %107 %42 %59 %16 + OpStore %108 %106 + OpBranch %101 + %109 = OpLabel + %111 = OpLoad %13 %110 + %112 = OpConvertUToF %39 %111 + %114 = OpCompositeExtract %38 %112 0 + %115 = OpCompositeExtract %38 %112 1 + %116 = OpCompositeConstruct %113 %114 %115 + %117 = OpAccessChain %107 %42 %59 %21 + %118 = OpCompositeExtract %38 %116 0 + OpStore %117 %118 + %119 = OpAccessChain %107 %42 %59 %76 + %120 = OpCompositeExtract %38 %116 1 + OpStore %119 %120 + OpBranch %101 + %101 = OpLabel + OpBranch %93 + %93 = OpLabel + %121 = OpLoad %24 %89 + %122 = OpIAdd %24 %121 %59 + OpStore %89 %122 + OpBranch %90 + %92 = OpLabel + OpReturn + OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/large_functions_large_diffs_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/large_functions_large_diffs_src.spvasm new file mode 100644 index 0000000000..8f0aa614b1 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/large_functions_large_diffs_src.spvasm @@ -0,0 +1,230 @@ +;; Test where src and dst have a few large functions with large differences. + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" %15 + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %6 "f1(" + OpName %8 "f2(" + OpName %12 "x" + OpName %15 "gl_LocalInvocationID" + OpName %20 "y" + OpName %27 "image" + OpName %44 "sum" + OpName %46 "i" + OpName %56 "j" + OpName %80 "BufferOut" + OpMemberName %80 0 "o_uv4" + OpMemberName %80 1 "o_v3" + OpMemberName %80 2 "o_i" + OpName %82 "" + OpName %88 "BufferIn" + OpMemberName %88 0 "i_u" + OpMemberName %88 1 "i_v4" + OpMemberName %88 2 "i_f" + OpName %90 "" + OpName %101 "i" + OpName %128 "image2" + OpDecorate %15 BuiltIn LocalInvocationId + OpDecorate %27 DescriptorSet 0 + OpDecorate %27 Binding 2 + OpMemberDecorate %80 0 Offset 0 + OpMemberDecorate %80 1 Offset 16 + OpMemberDecorate %80 2 Offset 28 + OpDecorate %80 BufferBlock + OpDecorate %82 DescriptorSet 0 + OpDecorate %82 Binding 1 + OpMemberDecorate %88 0 Offset 0 + OpMemberDecorate %88 1 RowMajor + OpMemberDecorate %88 1 Offset 16 + OpMemberDecorate %88 1 MatrixStride 16 + OpMemberDecorate %88 2 Offset 80 + OpDecorate %88 Block + OpDecorate %90 DescriptorSet 0 + OpDecorate %90 Binding 0 + OpDecorate %128 DescriptorSet 0 + OpDecorate %128 Binding 3 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %10 = OpTypeInt 32 0 + %11 = OpTypePointer Function %10 + %13 = OpTypeVector %10 3 + %14 = OpTypePointer Input %13 + %15 = OpVariable %14 Input + %16 = OpConstant %10 0 + %17 = OpTypePointer Input %10 + %21 = OpConstant %10 1 + %24 = OpTypeInt 32 1 + %25 = OpTypeImage %24 2D 0 0 0 2 R32i + %26 = OpTypePointer UniformConstant %25 + %27 = OpVariable %26 UniformConstant + %29 = OpTypeVector %10 2 + %32 = OpTypeVector %24 2 + %38 = OpTypeVector %24 4 + %40 = OpConstant %10 2 + %41 = OpConstant %10 3400 + %42 = OpConstant %10 264 + %43 = OpTypePointer Function %24 + %45 = OpConstant %24 0 + %53 = OpConstant %24 2 + %54 = OpTypeBool + %73 = OpConstant %24 1 + %77 = OpTypeVector %10 4 + %78 = OpTypeFloat 32 + %79 = OpTypeVector %78 3 + %80 = OpTypeStruct %77 %79 %24 + %81 = OpTypePointer Uniform %80 + %82 = OpVariable %81 Uniform + %84 = OpTypePointer Uniform %24 + %86 = OpTypeVector %78 4 + %87 = OpTypeMatrix %86 4 + %88 = OpTypeStruct %10 %87 %78 + %89 = OpTypePointer Uniform %88 + %90 = OpVariable %89 Uniform + %91 = OpTypePointer Uniform %87 + %94 = OpTypePointer Uniform %77 + %108 = OpConstant %24 3 + %110 = OpTypePointer Uniform %79 + %113 = OpTypePointer Uniform %78 + %128 = OpVariable %26 UniformConstant + %130 = OpConstantComposite %32 %45 %45 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %136 = OpFunctionCall %2 %6 + %137 = OpFunctionCall %2 %8 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %12 = OpVariable %11 Function + %20 = OpVariable %11 Function + %44 = OpVariable %43 Function + %46 = OpVariable %43 Function + %56 = OpVariable %43 Function + %18 = OpAccessChain %17 %15 %16 + %19 = OpLoad %10 %18 + OpStore %12 %19 + %22 = OpAccessChain %17 %15 %21 + %23 = OpLoad %10 %22 + OpStore %20 %23 + %28 = OpLoad %25 %27 + %30 = OpLoad %13 %15 + %31 = OpVectorShuffle %29 %30 %30 0 1 + %33 = OpBitcast %32 %31 + %34 = OpLoad %10 %12 + %35 = OpLoad %10 %20 + %36 = OpIAdd %10 %34 %35 + %37 = OpBitcast %24 %36 + %39 = OpCompositeConstruct %38 %37 %37 %37 %37 + OpImageWrite %28 %33 %39 + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + OpStore %44 %45 + OpStore %46 %45 + OpBranch %47 + %47 = OpLabel + OpLoopMerge %49 %50 None + OpBranch %51 + %51 = OpLabel + %52 = OpLoad %24 %46 + %55 = OpSLessThan %54 %52 %53 + OpBranchConditional %55 %48 %49 + %48 = OpLabel + OpStore %56 %45 + OpBranch %57 + %57 = OpLabel + OpLoopMerge %59 %60 None + OpBranch %61 + %61 = OpLabel + %62 = OpLoad %24 %56 + %63 = OpSLessThan %54 %62 %53 + OpBranchConditional %63 %58 %59 + %58 = OpLabel + %64 = OpLoad %25 %27 + %65 = OpLoad %24 %46 + %66 = OpLoad %24 %56 + %67 = OpCompositeConstruct %32 %65 %66 + %68 = OpImageRead %38 %64 %67 + %69 = OpCompositeExtract %24 %68 0 + %70 = OpLoad %24 %44 + %71 = OpIMul %24 %70 %69 + OpStore %44 %71 + OpBranch %60 + %60 = OpLabel + %72 = OpLoad %24 %56 + %74 = OpIAdd %24 %72 %73 + OpStore %56 %74 + OpBranch %57 + %59 = OpLabel + OpBranch %50 + %50 = OpLabel + %75 = OpLoad %24 %46 + %76 = OpIAdd %24 %75 %73 + OpStore %46 %76 + OpBranch %47 + %49 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %83 = OpLoad %24 %44 + %85 = OpAccessChain %84 %82 %53 + OpStore %85 %83 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %101 = OpVariable %43 Function + %92 = OpAccessChain %91 %90 %73 + %93 = OpLoad %87 %92 + %95 = OpAccessChain %94 %82 %45 + %96 = OpLoad %77 %95 + %97 = OpConvertUToF %86 %96 + %98 = OpMatrixTimesVector %86 %93 %97 + %99 = OpConvertFToU %77 %98 + %100 = OpAccessChain %94 %82 %45 + OpStore %100 %99 + OpStore %101 %45 + OpBranch %102 + %102 = OpLabel + OpLoopMerge %104 %105 None + OpBranch %106 + %106 = OpLabel + %107 = OpLoad %24 %101 + %109 = OpSLessThan %54 %107 %108 + OpBranchConditional %109 %103 %104 + %103 = OpLabel + %111 = OpAccessChain %110 %82 %73 + %112 = OpLoad %79 %111 + %114 = OpAccessChain %113 %90 %53 + %115 = OpLoad %78 %114 + %116 = OpVectorTimesScalar %79 %112 %115 + %117 = OpConvertFToU %13 %116 + %118 = OpCompositeExtract %10 %117 0 + %119 = OpCompositeExtract %10 %117 1 + %120 = OpCompositeExtract %10 %117 2 + %121 = OpCompositeConstruct %77 %118 %119 %120 %16 + %122 = OpAccessChain %94 %82 %45 + %123 = OpLoad %77 %122 + %124 = OpIAdd %77 %123 %121 + %125 = OpAccessChain %94 %82 %45 + OpStore %125 %124 + OpBranch %105 + %105 = OpLabel + %126 = OpLoad %24 %101 + %127 = OpIAdd %24 %126 %73 + OpStore %101 %127 + OpBranch %102 + %104 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %129 = OpLoad %25 %128 + %131 = OpImageRead %38 %129 %130 + %132 = OpCompositeExtract %24 %131 0 + %133 = OpConvertSToF %78 %132 + %134 = OpCompositeConstruct %79 %133 %133 %133 + %135 = OpAccessChain %110 %82 %73 + OpStore %135 %134 + OpReturn + OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/large_functions_small_diffs_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/large_functions_small_diffs_autogen.cpp new file mode 100644 index 0000000000..02838d9ad0 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/large_functions_small_diffs_autogen.cpp @@ -0,0 +1,1364 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Test where src and dst have a few large functions with small differences. +constexpr char kSrc[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" %15 + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %6 "f1(" + OpName %8 "f2(" + OpName %12 "x" + OpName %15 "gl_LocalInvocationID" + OpName %20 "y" + OpName %27 "image" + OpName %44 "sum" + OpName %46 "i" + OpName %56 "j" + OpName %80 "BufferOut" + OpMemberName %80 0 "o_uv4" + OpMemberName %80 1 "o_v3" + OpMemberName %80 2 "o_i" + OpName %82 "" + OpName %88 "BufferIn" + OpMemberName %88 0 "i_u" + OpMemberName %88 1 "i_v4" + OpMemberName %88 2 "i_f" + OpName %90 "" + OpName %101 "i" + OpDecorate %15 BuiltIn LocalInvocationId + OpDecorate %27 DescriptorSet 0 + OpDecorate %27 Binding 2 + OpMemberDecorate %80 0 Offset 0 + OpMemberDecorate %80 1 Offset 16 + OpMemberDecorate %80 2 Offset 28 + OpDecorate %80 BufferBlock + OpDecorate %82 DescriptorSet 0 + OpDecorate %82 Binding 1 + OpMemberDecorate %88 0 Offset 0 + OpMemberDecorate %88 1 RowMajor + OpMemberDecorate %88 1 Offset 16 + OpMemberDecorate %88 1 MatrixStride 16 + OpMemberDecorate %88 2 Offset 80 + OpDecorate %88 Block + OpDecorate %90 DescriptorSet 0 + OpDecorate %90 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %10 = OpTypeInt 32 0 + %11 = OpTypePointer Function %10 + %13 = OpTypeVector %10 3 + %14 = OpTypePointer Input %13 + %15 = OpVariable %14 Input + %16 = OpConstant %10 0 + %17 = OpTypePointer Input %10 + %21 = OpConstant %10 1 + %24 = OpTypeInt 32 1 + %25 = OpTypeImage %24 2D 0 0 0 2 R32i + %26 = OpTypePointer UniformConstant %25 + %27 = OpVariable %26 UniformConstant + %29 = OpTypeVector %10 2 + %32 = OpTypeVector %24 2 + %38 = OpTypeVector %24 4 + %40 = OpConstant %10 2 + %41 = OpConstant %10 3400 + %42 = OpConstant %10 264 + %43 = OpTypePointer Function %24 + %45 = OpConstant %24 0 + %53 = OpConstant %24 2 + %54 = OpTypeBool + %73 = OpConstant %24 1 + %77 = OpTypeVector %10 4 + %78 = OpTypeFloat 32 + %79 = OpTypeVector %78 3 + %80 = OpTypeStruct %77 %79 %24 + %81 = OpTypePointer Uniform %80 + %82 = OpVariable %81 Uniform + %84 = OpTypePointer Uniform %24 + %86 = OpTypeVector %78 4 + %87 = OpTypeMatrix %86 4 + %88 = OpTypeStruct %10 %87 %78 + %89 = OpTypePointer Uniform %88 + %90 = OpVariable %89 Uniform + %91 = OpTypePointer Uniform %87 + %94 = OpTypePointer Uniform %77 + %108 = OpConstant %24 3 + %110 = OpTypePointer Uniform %79 + %113 = OpTypePointer Uniform %78 + %129 = OpConstantComposite %32 %45 %45 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %135 = OpFunctionCall %2 %6 + %136 = OpFunctionCall %2 %8 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %12 = OpVariable %11 Function + %20 = OpVariable %11 Function + %44 = OpVariable %43 Function + %46 = OpVariable %43 Function + %56 = OpVariable %43 Function + %18 = OpAccessChain %17 %15 %16 + %19 = OpLoad %10 %18 + OpStore %12 %19 + %22 = OpAccessChain %17 %15 %21 + %23 = OpLoad %10 %22 + OpStore %20 %23 + %28 = OpLoad %25 %27 + %30 = OpLoad %13 %15 + %31 = OpVectorShuffle %29 %30 %30 0 1 + %33 = OpBitcast %32 %31 + %34 = OpLoad %10 %12 + %35 = OpLoad %10 %20 + %36 = OpIAdd %10 %34 %35 + %37 = OpBitcast %24 %36 + %39 = OpCompositeConstruct %38 %37 %37 %37 %37 + OpImageWrite %28 %33 %39 + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + OpStore %44 %45 + OpStore %46 %45 + OpBranch %47 + %47 = OpLabel + OpLoopMerge %49 %50 None + OpBranch %51 + %51 = OpLabel + %52 = OpLoad %24 %46 + %55 = OpSLessThan %54 %52 %53 + OpBranchConditional %55 %48 %49 + %48 = OpLabel + OpStore %56 %45 + OpBranch %57 + %57 = OpLabel + OpLoopMerge %59 %60 None + OpBranch %61 + %61 = OpLabel + %62 = OpLoad %24 %56 + %63 = OpSLessThan %54 %62 %53 + OpBranchConditional %63 %58 %59 + %58 = OpLabel + %64 = OpLoad %25 %27 + %65 = OpLoad %24 %46 + %66 = OpLoad %24 %56 + %67 = OpCompositeConstruct %32 %65 %66 + %68 = OpImageRead %38 %64 %67 + %69 = OpCompositeExtract %24 %68 0 + %70 = OpLoad %24 %44 + %71 = OpIAdd %24 %70 %69 + OpStore %44 %71 + OpBranch %60 + %60 = OpLabel + %72 = OpLoad %24 %56 + %74 = OpIAdd %24 %72 %73 + OpStore %56 %74 + OpBranch %57 + %59 = OpLabel + OpBranch %50 + %50 = OpLabel + %75 = OpLoad %24 %46 + %76 = OpIAdd %24 %75 %73 + OpStore %46 %76 + OpBranch %47 + %49 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %83 = OpLoad %24 %44 + %85 = OpAccessChain %84 %82 %53 + OpStore %85 %83 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %101 = OpVariable %43 Function + %92 = OpAccessChain %91 %90 %73 + %93 = OpLoad %87 %92 + %95 = OpAccessChain %94 %82 %45 + %96 = OpLoad %77 %95 + %97 = OpConvertUToF %86 %96 + %98 = OpMatrixTimesVector %86 %93 %97 + %99 = OpConvertFToU %77 %98 + %100 = OpAccessChain %94 %82 %45 + OpStore %100 %99 + OpStore %101 %45 + OpBranch %102 + %102 = OpLabel + OpLoopMerge %104 %105 None + OpBranch %106 + %106 = OpLabel + %107 = OpLoad %24 %101 + %109 = OpSLessThan %54 %107 %108 + OpBranchConditional %109 %103 %104 + %103 = OpLabel + %111 = OpAccessChain %110 %82 %73 + %112 = OpLoad %79 %111 + %114 = OpAccessChain %113 %90 %53 + %115 = OpLoad %78 %114 + %116 = OpVectorTimesScalar %79 %112 %115 + %117 = OpConvertFToU %13 %116 + %118 = OpCompositeExtract %10 %117 0 + %119 = OpCompositeExtract %10 %117 1 + %120 = OpCompositeExtract %10 %117 2 + %121 = OpCompositeConstruct %77 %118 %119 %120 %16 + %122 = OpAccessChain %94 %82 %45 + %123 = OpLoad %77 %122 + %124 = OpIAdd %77 %123 %121 + %125 = OpAccessChain %94 %82 %45 + OpStore %125 %124 + OpBranch %105 + %105 = OpLabel + %126 = OpLoad %24 %101 + %127 = OpIAdd %24 %126 %73 + OpStore %101 %127 + OpBranch %102 + %104 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %128 = OpLoad %25 %27 + %130 = OpImageRead %38 %128 %129 + %131 = OpCompositeExtract %24 %130 0 + %132 = OpConvertSToF %78 %131 + %133 = OpCompositeConstruct %79 %132 %132 %132 + %134 = OpAccessChain %110 %82 %73 + OpStore %134 %133 + OpReturn + OpFunctionEnd +)"; +constexpr char kDst[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" %15 + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %6 "f1(" + OpName %8 "f2(" + OpName %12 "x" + OpName %15 "gl_LocalInvocationID" + OpName %20 "y" + OpName %27 "image" + OpName %44 "sum" + OpName %46 "i" + OpName %56 "j" + OpName %80 "BufferOut" + OpMemberName %80 0 "o_uv4" + OpMemberName %80 1 "o_v3" + OpMemberName %80 2 "o_i" + OpName %82 "" + OpName %88 "BufferIn" + OpMemberName %88 0 "i_u" + OpMemberName %88 1 "i_v4" + OpMemberName %88 2 "i_f" + OpName %90 "" + OpName %101 "i" + OpName %128 "image2" + OpDecorate %15 BuiltIn LocalInvocationId + OpDecorate %27 DescriptorSet 0 + OpDecorate %27 Binding 2 + OpMemberDecorate %80 0 Offset 0 + OpMemberDecorate %80 1 Offset 16 + OpMemberDecorate %80 2 Offset 28 + OpDecorate %80 BufferBlock + OpDecorate %82 DescriptorSet 0 + OpDecorate %82 Binding 1 + OpMemberDecorate %88 0 Offset 0 + OpMemberDecorate %88 1 RowMajor + OpMemberDecorate %88 1 Offset 16 + OpMemberDecorate %88 1 MatrixStride 16 + OpMemberDecorate %88 2 Offset 80 + OpDecorate %88 Block + OpDecorate %90 DescriptorSet 0 + OpDecorate %90 Binding 0 + OpDecorate %128 DescriptorSet 0 + OpDecorate %128 Binding 3 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %10 = OpTypeInt 32 0 + %11 = OpTypePointer Function %10 + %13 = OpTypeVector %10 3 + %14 = OpTypePointer Input %13 + %15 = OpVariable %14 Input + %16 = OpConstant %10 0 + %17 = OpTypePointer Input %10 + %21 = OpConstant %10 1 + %24 = OpTypeInt 32 1 + %25 = OpTypeImage %24 2D 0 0 0 2 R32i + %26 = OpTypePointer UniformConstant %25 + %27 = OpVariable %26 UniformConstant + %29 = OpTypeVector %10 2 + %32 = OpTypeVector %24 2 + %38 = OpTypeVector %24 4 + %40 = OpConstant %10 2 + %41 = OpConstant %10 3400 + %42 = OpConstant %10 264 + %43 = OpTypePointer Function %24 + %45 = OpConstant %24 0 + %53 = OpConstant %24 2 + %54 = OpTypeBool + %73 = OpConstant %24 1 + %77 = OpTypeVector %10 4 + %78 = OpTypeFloat 32 + %79 = OpTypeVector %78 3 + %80 = OpTypeStruct %77 %79 %24 + %81 = OpTypePointer Uniform %80 + %82 = OpVariable %81 Uniform + %84 = OpTypePointer Uniform %24 + %86 = OpTypeVector %78 4 + %87 = OpTypeMatrix %86 4 + %88 = OpTypeStruct %10 %87 %78 + %89 = OpTypePointer Uniform %88 + %90 = OpVariable %89 Uniform + %91 = OpTypePointer Uniform %87 + %94 = OpTypePointer Uniform %77 + %108 = OpConstant %24 3 + %110 = OpTypePointer Uniform %79 + %113 = OpTypePointer Uniform %78 + %128 = OpVariable %26 UniformConstant + %130 = OpConstantComposite %32 %45 %45 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %136 = OpFunctionCall %2 %6 + %137 = OpFunctionCall %2 %8 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %12 = OpVariable %11 Function + %20 = OpVariable %11 Function + %44 = OpVariable %43 Function + %46 = OpVariable %43 Function + %56 = OpVariable %43 Function + %18 = OpAccessChain %17 %15 %16 + %19 = OpLoad %10 %18 + OpStore %12 %19 + %22 = OpAccessChain %17 %15 %21 + %23 = OpLoad %10 %22 + OpStore %20 %23 + %28 = OpLoad %25 %27 + %30 = OpLoad %13 %15 + %31 = OpVectorShuffle %29 %30 %30 0 1 + %33 = OpBitcast %32 %31 + %34 = OpLoad %10 %12 + %35 = OpLoad %10 %20 + %36 = OpIAdd %10 %34 %35 + %37 = OpBitcast %24 %36 + %39 = OpCompositeConstruct %38 %37 %37 %37 %37 + OpImageWrite %28 %33 %39 + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + OpStore %44 %45 + OpStore %46 %45 + OpBranch %47 + %47 = OpLabel + OpLoopMerge %49 %50 None + OpBranch %51 + %51 = OpLabel + %52 = OpLoad %24 %46 + %55 = OpSLessThan %54 %52 %53 + OpBranchConditional %55 %48 %49 + %48 = OpLabel + OpStore %56 %45 + OpBranch %57 + %57 = OpLabel + OpLoopMerge %59 %60 None + OpBranch %61 + %61 = OpLabel + %62 = OpLoad %24 %56 + %63 = OpSLessThan %54 %62 %53 + OpBranchConditional %63 %58 %59 + %58 = OpLabel + %64 = OpLoad %25 %27 + %65 = OpLoad %24 %46 + %66 = OpLoad %24 %56 + %67 = OpCompositeConstruct %32 %65 %66 + %68 = OpImageRead %38 %64 %67 + %69 = OpCompositeExtract %24 %68 0 + %70 = OpLoad %24 %44 + %71 = OpIMul %24 %70 %69 + OpStore %44 %71 + OpBranch %60 + %60 = OpLabel + %72 = OpLoad %24 %56 + %74 = OpIAdd %24 %72 %73 + OpStore %56 %74 + OpBranch %57 + %59 = OpLabel + OpBranch %50 + %50 = OpLabel + %75 = OpLoad %24 %46 + %76 = OpIAdd %24 %75 %73 + OpStore %46 %76 + OpBranch %47 + %49 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %83 = OpLoad %24 %44 + %85 = OpAccessChain %84 %82 %53 + OpStore %85 %83 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %101 = OpVariable %43 Function + %92 = OpAccessChain %91 %90 %73 + %93 = OpLoad %87 %92 + %95 = OpAccessChain %94 %82 %45 + %96 = OpLoad %77 %95 + %97 = OpConvertUToF %86 %96 + %98 = OpMatrixTimesVector %86 %93 %97 + %99 = OpConvertFToU %77 %98 + %100 = OpAccessChain %94 %82 %45 + OpStore %100 %99 + OpStore %101 %45 + OpBranch %102 + %102 = OpLabel + OpLoopMerge %104 %105 None + OpBranch %106 + %106 = OpLabel + %107 = OpLoad %24 %101 + %109 = OpSLessThan %54 %107 %108 + OpBranchConditional %109 %103 %104 + %103 = OpLabel + %111 = OpAccessChain %110 %82 %73 + %112 = OpLoad %79 %111 + %114 = OpAccessChain %113 %90 %53 + %115 = OpLoad %78 %114 + %116 = OpVectorTimesScalar %79 %112 %115 + %117 = OpConvertFToU %13 %116 + %118 = OpCompositeExtract %10 %117 0 + %119 = OpCompositeExtract %10 %117 1 + %120 = OpCompositeExtract %10 %117 2 + %121 = OpCompositeConstruct %77 %118 %119 %120 %16 + %122 = OpAccessChain %94 %82 %45 + %123 = OpLoad %77 %122 + %124 = OpIAdd %77 %123 %121 + %125 = OpAccessChain %94 %82 %45 + OpStore %125 %124 + OpBranch %105 + %105 = OpLabel + %126 = OpLoad %24 %101 + %127 = OpIAdd %24 %126 %73 + OpStore %101 %127 + OpBranch %102 + %104 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %129 = OpLoad %25 %128 + %131 = OpImageRead %38 %129 %130 + %132 = OpCompositeExtract %24 %131 0 + %133 = OpConvertSToF %78 %132 + %134 = OpCompositeConstruct %79 %133 %133 %133 + %135 = OpAccessChain %110 %82 %73 + OpStore %135 %134 + OpReturn + OpFunctionEnd + +)"; + +TEST(DiffTest, LargeFunctionsSmallDiffs) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 137 ++; Bound: 140 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" %15 + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %6 "f1(" + OpName %8 "f2(" + OpName %12 "x" + OpName %15 "gl_LocalInvocationID" + OpName %20 "y" + OpName %27 "image" + OpName %44 "sum" + OpName %46 "i" + OpName %56 "j" + OpName %80 "BufferOut" + OpMemberName %80 0 "o_uv4" + OpMemberName %80 1 "o_v3" + OpMemberName %80 2 "o_i" + OpName %82 "" + OpName %88 "BufferIn" + OpMemberName %88 0 "i_u" + OpMemberName %88 1 "i_v4" + OpMemberName %88 2 "i_f" + OpName %90 "" + OpName %101 "i" ++OpName %138 "image2" + OpDecorate %15 BuiltIn LocalInvocationId + OpDecorate %27 DescriptorSet 0 + OpDecorate %27 Binding 2 + OpMemberDecorate %80 0 Offset 0 + OpMemberDecorate %80 1 Offset 16 + OpMemberDecorate %80 2 Offset 28 + OpDecorate %80 BufferBlock + OpDecorate %82 DescriptorSet 0 + OpDecorate %82 Binding 1 + OpMemberDecorate %88 0 Offset 0 + OpMemberDecorate %88 1 RowMajor + OpMemberDecorate %88 1 Offset 16 + OpMemberDecorate %88 1 MatrixStride 16 + OpMemberDecorate %88 2 Offset 80 + OpDecorate %88 Block + OpDecorate %90 DescriptorSet 0 + OpDecorate %90 Binding 0 ++OpDecorate %138 DescriptorSet 0 ++OpDecorate %138 Binding 3 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %10 = OpTypeInt 32 0 + %11 = OpTypePointer Function %10 + %13 = OpTypeVector %10 3 + %14 = OpTypePointer Input %13 + %15 = OpVariable %14 Input + %16 = OpConstant %10 0 + %17 = OpTypePointer Input %10 + %21 = OpConstant %10 1 + %24 = OpTypeInt 32 1 + %25 = OpTypeImage %24 2D 0 0 0 2 R32i + %26 = OpTypePointer UniformConstant %25 + %27 = OpVariable %26 UniformConstant + %29 = OpTypeVector %10 2 + %32 = OpTypeVector %24 2 + %38 = OpTypeVector %24 4 + %40 = OpConstant %10 2 + %41 = OpConstant %10 3400 + %42 = OpConstant %10 264 + %43 = OpTypePointer Function %24 + %45 = OpConstant %24 0 + %53 = OpConstant %24 2 + %54 = OpTypeBool + %73 = OpConstant %24 1 + %77 = OpTypeVector %10 4 + %78 = OpTypeFloat 32 + %79 = OpTypeVector %78 3 + %80 = OpTypeStruct %77 %79 %24 + %81 = OpTypePointer Uniform %80 + %82 = OpVariable %81 Uniform + %84 = OpTypePointer Uniform %24 + %86 = OpTypeVector %78 4 + %87 = OpTypeMatrix %86 4 + %88 = OpTypeStruct %10 %87 %78 + %89 = OpTypePointer Uniform %88 + %90 = OpVariable %89 Uniform + %91 = OpTypePointer Uniform %87 + %94 = OpTypePointer Uniform %77 + %108 = OpConstant %24 3 + %110 = OpTypePointer Uniform %79 + %113 = OpTypePointer Uniform %78 ++%138 = OpVariable %26 UniformConstant + %129 = OpConstantComposite %32 %45 %45 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %135 = OpFunctionCall %2 %6 + %136 = OpFunctionCall %2 %8 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %12 = OpVariable %11 Function + %20 = OpVariable %11 Function + %44 = OpVariable %43 Function + %46 = OpVariable %43 Function + %56 = OpVariable %43 Function + %18 = OpAccessChain %17 %15 %16 + %19 = OpLoad %10 %18 + OpStore %12 %19 + %22 = OpAccessChain %17 %15 %21 + %23 = OpLoad %10 %22 + OpStore %20 %23 + %28 = OpLoad %25 %27 + %30 = OpLoad %13 %15 + %31 = OpVectorShuffle %29 %30 %30 0 1 + %33 = OpBitcast %32 %31 + %34 = OpLoad %10 %12 + %35 = OpLoad %10 %20 + %36 = OpIAdd %10 %34 %35 + %37 = OpBitcast %24 %36 + %39 = OpCompositeConstruct %38 %37 %37 %37 %37 + OpImageWrite %28 %33 %39 + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + OpStore %44 %45 + OpStore %46 %45 + OpBranch %47 + %47 = OpLabel + OpLoopMerge %49 %50 None + OpBranch %51 + %51 = OpLabel + %52 = OpLoad %24 %46 + %55 = OpSLessThan %54 %52 %53 + OpBranchConditional %55 %48 %49 + %48 = OpLabel + OpStore %56 %45 + OpBranch %57 + %57 = OpLabel + OpLoopMerge %59 %60 None + OpBranch %61 + %61 = OpLabel + %62 = OpLoad %24 %56 + %63 = OpSLessThan %54 %62 %53 + OpBranchConditional %63 %58 %59 + %58 = OpLabel + %64 = OpLoad %25 %27 + %65 = OpLoad %24 %46 + %66 = OpLoad %24 %56 + %67 = OpCompositeConstruct %32 %65 %66 + %68 = OpImageRead %38 %64 %67 + %69 = OpCompositeExtract %24 %68 0 + %70 = OpLoad %24 %44 +-%71 = OpIAdd %24 %70 %69 ++%137 = OpIMul %24 %70 %69 +-OpStore %44 %71 ++OpStore %44 %137 + OpBranch %60 + %60 = OpLabel + %72 = OpLoad %24 %56 + %74 = OpIAdd %24 %72 %73 + OpStore %56 %74 + OpBranch %57 + %59 = OpLabel + OpBranch %50 + %50 = OpLabel + %75 = OpLoad %24 %46 + %76 = OpIAdd %24 %75 %73 + OpStore %46 %76 + OpBranch %47 + %49 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %83 = OpLoad %24 %44 + %85 = OpAccessChain %84 %82 %53 + OpStore %85 %83 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %101 = OpVariable %43 Function + %92 = OpAccessChain %91 %90 %73 + %93 = OpLoad %87 %92 + %95 = OpAccessChain %94 %82 %45 + %96 = OpLoad %77 %95 + %97 = OpConvertUToF %86 %96 + %98 = OpMatrixTimesVector %86 %93 %97 + %99 = OpConvertFToU %77 %98 + %100 = OpAccessChain %94 %82 %45 + OpStore %100 %99 + OpStore %101 %45 + OpBranch %102 + %102 = OpLabel + OpLoopMerge %104 %105 None + OpBranch %106 + %106 = OpLabel + %107 = OpLoad %24 %101 + %109 = OpSLessThan %54 %107 %108 + OpBranchConditional %109 %103 %104 + %103 = OpLabel + %111 = OpAccessChain %110 %82 %73 + %112 = OpLoad %79 %111 + %114 = OpAccessChain %113 %90 %53 + %115 = OpLoad %78 %114 + %116 = OpVectorTimesScalar %79 %112 %115 + %117 = OpConvertFToU %13 %116 + %118 = OpCompositeExtract %10 %117 0 + %119 = OpCompositeExtract %10 %117 1 + %120 = OpCompositeExtract %10 %117 2 + %121 = OpCompositeConstruct %77 %118 %119 %120 %16 + %122 = OpAccessChain %94 %82 %45 + %123 = OpLoad %77 %122 + %124 = OpIAdd %77 %123 %121 + %125 = OpAccessChain %94 %82 %45 + OpStore %125 %124 + OpBranch %105 + %105 = OpLabel + %126 = OpLoad %24 %101 + %127 = OpIAdd %24 %126 %73 + OpStore %101 %127 + OpBranch %102 + %104 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 +-%128 = OpLoad %25 %27 ++%139 = OpLoad %25 %138 +-%130 = OpImageRead %38 %128 %129 ++%130 = OpImageRead %38 %139 %129 + %131 = OpCompositeExtract %24 %130 0 + %132 = OpConvertSToF %78 %131 + %133 = OpCompositeConstruct %79 %132 %132 %132 + %134 = OpAccessChain %110 %82 %73 + OpStore %134 %133 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, LargeFunctionsSmallDiffsNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" %15 + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpDecorate %15 BuiltIn LocalInvocationId + OpDecorate %27 DescriptorSet 0 + OpDecorate %27 Binding 2 + OpMemberDecorate %80 0 Offset 0 + OpMemberDecorate %80 1 Offset 16 + OpMemberDecorate %80 2 Offset 28 + OpDecorate %80 BufferBlock + OpDecorate %82 DescriptorSet 0 + OpDecorate %82 Binding 1 + OpMemberDecorate %88 0 Offset 0 + OpMemberDecorate %88 1 RowMajor + OpMemberDecorate %88 1 Offset 16 + OpMemberDecorate %88 1 MatrixStride 16 + OpMemberDecorate %88 2 Offset 80 + OpDecorate %88 Block + OpDecorate %90 DescriptorSet 0 + OpDecorate %90 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %10 = OpTypeInt 32 0 + %11 = OpTypePointer Function %10 + %13 = OpTypeVector %10 3 + %14 = OpTypePointer Input %13 + %15 = OpVariable %14 Input + %16 = OpConstant %10 0 + %17 = OpTypePointer Input %10 + %21 = OpConstant %10 1 + %24 = OpTypeInt 32 1 + %25 = OpTypeImage %24 2D 0 0 0 2 R32i + %26 = OpTypePointer UniformConstant %25 + %27 = OpVariable %26 UniformConstant + %29 = OpTypeVector %10 2 + %32 = OpTypeVector %24 2 + %38 = OpTypeVector %24 4 + %40 = OpConstant %10 2 + %41 = OpConstant %10 3400 + %42 = OpConstant %10 264 + %43 = OpTypePointer Function %24 + %45 = OpConstant %24 0 + %53 = OpConstant %24 2 + %54 = OpTypeBool + %73 = OpConstant %24 1 + %77 = OpTypeVector %10 4 + %78 = OpTypeFloat 32 + %79 = OpTypeVector %78 3 + %80 = OpTypeStruct %77 %79 %24 + %81 = OpTypePointer Uniform %80 + %82 = OpVariable %81 Uniform + %84 = OpTypePointer Uniform %24 + %86 = OpTypeVector %78 4 + %87 = OpTypeMatrix %86 4 + %88 = OpTypeStruct %10 %87 %78 + %89 = OpTypePointer Uniform %88 + %90 = OpVariable %89 Uniform + %91 = OpTypePointer Uniform %87 + %94 = OpTypePointer Uniform %77 + %108 = OpConstant %24 3 + %110 = OpTypePointer Uniform %79 + %113 = OpTypePointer Uniform %78 + %129 = OpConstantComposite %32 %45 %45 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %135 = OpFunctionCall %2 %6 + %136 = OpFunctionCall %2 %8 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %12 = OpVariable %11 Function + %20 = OpVariable %11 Function + %44 = OpVariable %43 Function + %46 = OpVariable %43 Function + %56 = OpVariable %43 Function + %18 = OpAccessChain %17 %15 %16 + %19 = OpLoad %10 %18 + OpStore %12 %19 + %22 = OpAccessChain %17 %15 %21 + %23 = OpLoad %10 %22 + OpStore %20 %23 + %28 = OpLoad %25 %27 + %30 = OpLoad %13 %15 + %31 = OpVectorShuffle %29 %30 %30 0 1 + %33 = OpBitcast %32 %31 + %34 = OpLoad %10 %12 + %35 = OpLoad %10 %20 + %36 = OpIAdd %10 %34 %35 + %37 = OpBitcast %24 %36 + %39 = OpCompositeConstruct %38 %37 %37 %37 %37 + OpImageWrite %28 %33 %39 + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + OpStore %44 %45 + OpStore %46 %45 + OpBranch %47 + %47 = OpLabel + OpLoopMerge %49 %50 None + OpBranch %51 + %51 = OpLabel + %52 = OpLoad %24 %46 + %55 = OpSLessThan %54 %52 %53 + OpBranchConditional %55 %48 %49 + %48 = OpLabel + OpStore %56 %45 + OpBranch %57 + %57 = OpLabel + OpLoopMerge %59 %60 None + OpBranch %61 + %61 = OpLabel + %62 = OpLoad %24 %56 + %63 = OpSLessThan %54 %62 %53 + OpBranchConditional %63 %58 %59 + %58 = OpLabel + %64 = OpLoad %25 %27 + %65 = OpLoad %24 %46 + %66 = OpLoad %24 %56 + %67 = OpCompositeConstruct %32 %65 %66 + %68 = OpImageRead %38 %64 %67 + %69 = OpCompositeExtract %24 %68 0 + %70 = OpLoad %24 %44 + %71 = OpIAdd %24 %70 %69 + OpStore %44 %71 + OpBranch %60 + %60 = OpLabel + %72 = OpLoad %24 %56 + %74 = OpIAdd %24 %72 %73 + OpStore %56 %74 + OpBranch %57 + %59 = OpLabel + OpBranch %50 + %50 = OpLabel + %75 = OpLoad %24 %46 + %76 = OpIAdd %24 %75 %73 + OpStore %46 %76 + OpBranch %47 + %49 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %83 = OpLoad %24 %44 + %85 = OpAccessChain %84 %82 %53 + OpStore %85 %83 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %101 = OpVariable %43 Function + %92 = OpAccessChain %91 %90 %73 + %93 = OpLoad %87 %92 + %95 = OpAccessChain %94 %82 %45 + %96 = OpLoad %77 %95 + %97 = OpConvertUToF %86 %96 + %98 = OpMatrixTimesVector %86 %93 %97 + %99 = OpConvertFToU %77 %98 + %100 = OpAccessChain %94 %82 %45 + OpStore %100 %99 + OpStore %101 %45 + OpBranch %102 + %102 = OpLabel + OpLoopMerge %104 %105 None + OpBranch %106 + %106 = OpLabel + %107 = OpLoad %24 %101 + %109 = OpSLessThan %54 %107 %108 + OpBranchConditional %109 %103 %104 + %103 = OpLabel + %111 = OpAccessChain %110 %82 %73 + %112 = OpLoad %79 %111 + %114 = OpAccessChain %113 %90 %53 + %115 = OpLoad %78 %114 + %116 = OpVectorTimesScalar %79 %112 %115 + %117 = OpConvertFToU %13 %116 + %118 = OpCompositeExtract %10 %117 0 + %119 = OpCompositeExtract %10 %117 1 + %120 = OpCompositeExtract %10 %117 2 + %121 = OpCompositeConstruct %77 %118 %119 %120 %16 + %122 = OpAccessChain %94 %82 %45 + %123 = OpLoad %77 %122 + %124 = OpIAdd %77 %123 %121 + %125 = OpAccessChain %94 %82 %45 + OpStore %125 %124 + OpBranch %105 + %105 = OpLabel + %126 = OpLoad %24 %101 + %127 = OpIAdd %24 %126 %73 + OpStore %101 %127 + OpBranch %102 + %104 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %128 = OpLoad %25 %27 + %130 = OpImageRead %38 %128 %129 + %131 = OpCompositeExtract %24 %130 0 + %132 = OpConvertSToF %78 %131 + %133 = OpCompositeConstruct %79 %132 %132 %132 + %134 = OpAccessChain %110 %82 %73 + OpStore %134 %133 + OpReturn + OpFunctionEnd + +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" %15 + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpDecorate %15 BuiltIn LocalInvocationId + OpDecorate %27 DescriptorSet 0 + OpDecorate %27 Binding 2 + OpMemberDecorate %80 0 Offset 0 + OpMemberDecorate %80 1 Offset 16 + OpMemberDecorate %80 2 Offset 28 + OpDecorate %80 BufferBlock + OpDecorate %82 DescriptorSet 0 + OpDecorate %82 Binding 1 + OpMemberDecorate %88 0 Offset 0 + OpMemberDecorate %88 1 RowMajor + OpMemberDecorate %88 1 Offset 16 + OpMemberDecorate %88 1 MatrixStride 16 + OpMemberDecorate %88 2 Offset 80 + OpDecorate %88 Block + OpDecorate %90 DescriptorSet 0 + OpDecorate %90 Binding 0 + OpDecorate %128 DescriptorSet 0 + OpDecorate %128 Binding 3 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %10 = OpTypeInt 32 0 + %11 = OpTypePointer Function %10 + %13 = OpTypeVector %10 3 + %14 = OpTypePointer Input %13 + %15 = OpVariable %14 Input + %16 = OpConstant %10 0 + %17 = OpTypePointer Input %10 + %21 = OpConstant %10 1 + %24 = OpTypeInt 32 1 + %25 = OpTypeImage %24 2D 0 0 0 2 R32i + %26 = OpTypePointer UniformConstant %25 + %27 = OpVariable %26 UniformConstant + %29 = OpTypeVector %10 2 + %32 = OpTypeVector %24 2 + %38 = OpTypeVector %24 4 + %40 = OpConstant %10 2 + %41 = OpConstant %10 3400 + %42 = OpConstant %10 264 + %43 = OpTypePointer Function %24 + %45 = OpConstant %24 0 + %53 = OpConstant %24 2 + %54 = OpTypeBool + %73 = OpConstant %24 1 + %77 = OpTypeVector %10 4 + %78 = OpTypeFloat 32 + %79 = OpTypeVector %78 3 + %80 = OpTypeStruct %77 %79 %24 + %81 = OpTypePointer Uniform %80 + %82 = OpVariable %81 Uniform + %84 = OpTypePointer Uniform %24 + %86 = OpTypeVector %78 4 + %87 = OpTypeMatrix %86 4 + %88 = OpTypeStruct %10 %87 %78 + %89 = OpTypePointer Uniform %88 + %90 = OpVariable %89 Uniform + %91 = OpTypePointer Uniform %87 + %94 = OpTypePointer Uniform %77 + %108 = OpConstant %24 3 + %110 = OpTypePointer Uniform %79 + %113 = OpTypePointer Uniform %78 + %128 = OpVariable %26 UniformConstant + %130 = OpConstantComposite %32 %45 %45 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %136 = OpFunctionCall %2 %6 + %137 = OpFunctionCall %2 %8 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %12 = OpVariable %11 Function + %20 = OpVariable %11 Function + %44 = OpVariable %43 Function + %46 = OpVariable %43 Function + %56 = OpVariable %43 Function + %18 = OpAccessChain %17 %15 %16 + %19 = OpLoad %10 %18 + OpStore %12 %19 + %22 = OpAccessChain %17 %15 %21 + %23 = OpLoad %10 %22 + OpStore %20 %23 + %28 = OpLoad %25 %27 + %30 = OpLoad %13 %15 + %31 = OpVectorShuffle %29 %30 %30 0 1 + %33 = OpBitcast %32 %31 + %34 = OpLoad %10 %12 + %35 = OpLoad %10 %20 + %36 = OpIAdd %10 %34 %35 + %37 = OpBitcast %24 %36 + %39 = OpCompositeConstruct %38 %37 %37 %37 %37 + OpImageWrite %28 %33 %39 + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + OpStore %44 %45 + OpStore %46 %45 + OpBranch %47 + %47 = OpLabel + OpLoopMerge %49 %50 None + OpBranch %51 + %51 = OpLabel + %52 = OpLoad %24 %46 + %55 = OpSLessThan %54 %52 %53 + OpBranchConditional %55 %48 %49 + %48 = OpLabel + OpStore %56 %45 + OpBranch %57 + %57 = OpLabel + OpLoopMerge %59 %60 None + OpBranch %61 + %61 = OpLabel + %62 = OpLoad %24 %56 + %63 = OpSLessThan %54 %62 %53 + OpBranchConditional %63 %58 %59 + %58 = OpLabel + %64 = OpLoad %25 %27 + %65 = OpLoad %24 %46 + %66 = OpLoad %24 %56 + %67 = OpCompositeConstruct %32 %65 %66 + %68 = OpImageRead %38 %64 %67 + %69 = OpCompositeExtract %24 %68 0 + %70 = OpLoad %24 %44 + %71 = OpIMul %24 %70 %69 + OpStore %44 %71 + OpBranch %60 + %60 = OpLabel + %72 = OpLoad %24 %56 + %74 = OpIAdd %24 %72 %73 + OpStore %56 %74 + OpBranch %57 + %59 = OpLabel + OpBranch %50 + %50 = OpLabel + %75 = OpLoad %24 %46 + %76 = OpIAdd %24 %75 %73 + OpStore %46 %76 + OpBranch %47 + %49 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %83 = OpLoad %24 %44 + %85 = OpAccessChain %84 %82 %53 + OpStore %85 %83 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %101 = OpVariable %43 Function + %92 = OpAccessChain %91 %90 %73 + %93 = OpLoad %87 %92 + %95 = OpAccessChain %94 %82 %45 + %96 = OpLoad %77 %95 + %97 = OpConvertUToF %86 %96 + %98 = OpMatrixTimesVector %86 %93 %97 + %99 = OpConvertFToU %77 %98 + %100 = OpAccessChain %94 %82 %45 + OpStore %100 %99 + OpStore %101 %45 + OpBranch %102 + %102 = OpLabel + OpLoopMerge %104 %105 None + OpBranch %106 + %106 = OpLabel + %107 = OpLoad %24 %101 + %109 = OpSLessThan %54 %107 %108 + OpBranchConditional %109 %103 %104 + %103 = OpLabel + %111 = OpAccessChain %110 %82 %73 + %112 = OpLoad %79 %111 + %114 = OpAccessChain %113 %90 %53 + %115 = OpLoad %78 %114 + %116 = OpVectorTimesScalar %79 %112 %115 + %117 = OpConvertFToU %13 %116 + %118 = OpCompositeExtract %10 %117 0 + %119 = OpCompositeExtract %10 %117 1 + %120 = OpCompositeExtract %10 %117 2 + %121 = OpCompositeConstruct %77 %118 %119 %120 %16 + %122 = OpAccessChain %94 %82 %45 + %123 = OpLoad %77 %122 + %124 = OpIAdd %77 %123 %121 + %125 = OpAccessChain %94 %82 %45 + OpStore %125 %124 + OpBranch %105 + %105 = OpLabel + %126 = OpLoad %24 %101 + %127 = OpIAdd %24 %126 %73 + OpStore %101 %127 + OpBranch %102 + %104 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %129 = OpLoad %25 %128 + %131 = OpImageRead %38 %129 %130 + %132 = OpCompositeExtract %24 %131 0 + %133 = OpConvertSToF %78 %132 + %134 = OpCompositeConstruct %79 %133 %133 %133 + %135 = OpAccessChain %110 %82 %73 + OpStore %135 %134 + OpReturn + OpFunctionEnd + +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 137 ++; Bound: 140 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" %15 + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpDecorate %15 BuiltIn LocalInvocationId + OpDecorate %27 DescriptorSet 0 + OpDecorate %27 Binding 2 + OpMemberDecorate %80 0 Offset 0 + OpMemberDecorate %80 1 Offset 16 + OpMemberDecorate %80 2 Offset 28 + OpDecorate %80 BufferBlock + OpDecorate %82 DescriptorSet 0 + OpDecorate %82 Binding 1 + OpMemberDecorate %88 0 Offset 0 + OpMemberDecorate %88 1 RowMajor + OpMemberDecorate %88 1 Offset 16 + OpMemberDecorate %88 1 MatrixStride 16 + OpMemberDecorate %88 2 Offset 80 + OpDecorate %88 Block + OpDecorate %90 DescriptorSet 0 + OpDecorate %90 Binding 0 ++OpDecorate %138 DescriptorSet 0 ++OpDecorate %138 Binding 3 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %10 = OpTypeInt 32 0 + %11 = OpTypePointer Function %10 + %13 = OpTypeVector %10 3 + %14 = OpTypePointer Input %13 + %15 = OpVariable %14 Input + %16 = OpConstant %10 0 + %17 = OpTypePointer Input %10 + %21 = OpConstant %10 1 + %24 = OpTypeInt 32 1 + %25 = OpTypeImage %24 2D 0 0 0 2 R32i + %26 = OpTypePointer UniformConstant %25 + %27 = OpVariable %26 UniformConstant + %29 = OpTypeVector %10 2 + %32 = OpTypeVector %24 2 + %38 = OpTypeVector %24 4 + %40 = OpConstant %10 2 + %41 = OpConstant %10 3400 + %42 = OpConstant %10 264 + %43 = OpTypePointer Function %24 + %45 = OpConstant %24 0 + %53 = OpConstant %24 2 + %54 = OpTypeBool + %73 = OpConstant %24 1 + %77 = OpTypeVector %10 4 + %78 = OpTypeFloat 32 + %79 = OpTypeVector %78 3 + %80 = OpTypeStruct %77 %79 %24 + %81 = OpTypePointer Uniform %80 + %82 = OpVariable %81 Uniform + %84 = OpTypePointer Uniform %24 + %86 = OpTypeVector %78 4 + %87 = OpTypeMatrix %86 4 + %88 = OpTypeStruct %10 %87 %78 + %89 = OpTypePointer Uniform %88 + %90 = OpVariable %89 Uniform + %91 = OpTypePointer Uniform %87 + %94 = OpTypePointer Uniform %77 + %108 = OpConstant %24 3 + %110 = OpTypePointer Uniform %79 + %113 = OpTypePointer Uniform %78 ++%138 = OpVariable %26 UniformConstant + %129 = OpConstantComposite %32 %45 %45 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %135 = OpFunctionCall %2 %6 + %136 = OpFunctionCall %2 %8 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %12 = OpVariable %11 Function + %20 = OpVariable %11 Function + %44 = OpVariable %43 Function + %46 = OpVariable %43 Function + %56 = OpVariable %43 Function + %18 = OpAccessChain %17 %15 %16 + %19 = OpLoad %10 %18 + OpStore %12 %19 + %22 = OpAccessChain %17 %15 %21 + %23 = OpLoad %10 %22 + OpStore %20 %23 + %28 = OpLoad %25 %27 + %30 = OpLoad %13 %15 + %31 = OpVectorShuffle %29 %30 %30 0 1 + %33 = OpBitcast %32 %31 + %34 = OpLoad %10 %12 + %35 = OpLoad %10 %20 + %36 = OpIAdd %10 %34 %35 + %37 = OpBitcast %24 %36 + %39 = OpCompositeConstruct %38 %37 %37 %37 %37 + OpImageWrite %28 %33 %39 + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + OpStore %44 %45 + OpStore %46 %45 + OpBranch %47 + %47 = OpLabel + OpLoopMerge %49 %50 None + OpBranch %51 + %51 = OpLabel + %52 = OpLoad %24 %46 + %55 = OpSLessThan %54 %52 %53 + OpBranchConditional %55 %48 %49 + %48 = OpLabel + OpStore %56 %45 + OpBranch %57 + %57 = OpLabel + OpLoopMerge %59 %60 None + OpBranch %61 + %61 = OpLabel + %62 = OpLoad %24 %56 + %63 = OpSLessThan %54 %62 %53 + OpBranchConditional %63 %58 %59 + %58 = OpLabel + %64 = OpLoad %25 %27 + %65 = OpLoad %24 %46 + %66 = OpLoad %24 %56 + %67 = OpCompositeConstruct %32 %65 %66 + %68 = OpImageRead %38 %64 %67 + %69 = OpCompositeExtract %24 %68 0 + %70 = OpLoad %24 %44 +-%71 = OpIAdd %24 %70 %69 ++%137 = OpIMul %24 %70 %69 +-OpStore %44 %71 ++OpStore %44 %137 + OpBranch %60 + %60 = OpLabel + %72 = OpLoad %24 %56 + %74 = OpIAdd %24 %72 %73 + OpStore %56 %74 + OpBranch %57 + %59 = OpLabel + OpBranch %50 + %50 = OpLabel + %75 = OpLoad %24 %46 + %76 = OpIAdd %24 %75 %73 + OpStore %46 %76 + OpBranch %47 + %49 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %83 = OpLoad %24 %44 + %85 = OpAccessChain %84 %82 %53 + OpStore %85 %83 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %101 = OpVariable %43 Function + %92 = OpAccessChain %91 %90 %73 + %93 = OpLoad %87 %92 + %95 = OpAccessChain %94 %82 %45 + %96 = OpLoad %77 %95 + %97 = OpConvertUToF %86 %96 + %98 = OpMatrixTimesVector %86 %93 %97 + %99 = OpConvertFToU %77 %98 + %100 = OpAccessChain %94 %82 %45 + OpStore %100 %99 + OpStore %101 %45 + OpBranch %102 + %102 = OpLabel + OpLoopMerge %104 %105 None + OpBranch %106 + %106 = OpLabel + %107 = OpLoad %24 %101 + %109 = OpSLessThan %54 %107 %108 + OpBranchConditional %109 %103 %104 + %103 = OpLabel + %111 = OpAccessChain %110 %82 %73 + %112 = OpLoad %79 %111 + %114 = OpAccessChain %113 %90 %53 + %115 = OpLoad %78 %114 + %116 = OpVectorTimesScalar %79 %112 %115 + %117 = OpConvertFToU %13 %116 + %118 = OpCompositeExtract %10 %117 0 + %119 = OpCompositeExtract %10 %117 1 + %120 = OpCompositeExtract %10 %117 2 + %121 = OpCompositeConstruct %77 %118 %119 %120 %16 + %122 = OpAccessChain %94 %82 %45 + %123 = OpLoad %77 %122 + %124 = OpIAdd %77 %123 %121 + %125 = OpAccessChain %94 %82 %45 + OpStore %125 %124 + OpBranch %105 + %105 = OpLabel + %126 = OpLoad %24 %101 + %127 = OpIAdd %24 %126 %73 + OpStore %101 %127 + OpBranch %102 + %104 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 +-%128 = OpLoad %25 %27 ++%139 = OpLoad %25 %138 +-%130 = OpImageRead %38 %128 %129 ++%130 = OpImageRead %38 %139 %129 + %131 = OpCompositeExtract %24 %130 0 + %132 = OpConvertSToF %78 %131 + %133 = OpCompositeConstruct %79 %132 %132 %132 + %134 = OpAccessChain %110 %82 %73 + OpStore %134 %133 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/large_functions_small_diffs_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/large_functions_small_diffs_dst.spvasm new file mode 100644 index 0000000000..f788e0b6db --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/large_functions_small_diffs_dst.spvasm @@ -0,0 +1,229 @@ + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" %15 + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %6 "f1(" + OpName %8 "f2(" + OpName %12 "x" + OpName %15 "gl_LocalInvocationID" + OpName %20 "y" + OpName %27 "image" + OpName %44 "sum" + OpName %46 "i" + OpName %56 "j" + OpName %80 "BufferOut" + OpMemberName %80 0 "o_uv4" + OpMemberName %80 1 "o_v3" + OpMemberName %80 2 "o_i" + OpName %82 "" + OpName %88 "BufferIn" + OpMemberName %88 0 "i_u" + OpMemberName %88 1 "i_v4" + OpMemberName %88 2 "i_f" + OpName %90 "" + OpName %101 "i" + OpName %128 "image2" + OpDecorate %15 BuiltIn LocalInvocationId + OpDecorate %27 DescriptorSet 0 + OpDecorate %27 Binding 2 + OpMemberDecorate %80 0 Offset 0 + OpMemberDecorate %80 1 Offset 16 + OpMemberDecorate %80 2 Offset 28 + OpDecorate %80 BufferBlock + OpDecorate %82 DescriptorSet 0 + OpDecorate %82 Binding 1 + OpMemberDecorate %88 0 Offset 0 + OpMemberDecorate %88 1 RowMajor + OpMemberDecorate %88 1 Offset 16 + OpMemberDecorate %88 1 MatrixStride 16 + OpMemberDecorate %88 2 Offset 80 + OpDecorate %88 Block + OpDecorate %90 DescriptorSet 0 + OpDecorate %90 Binding 0 + OpDecorate %128 DescriptorSet 0 + OpDecorate %128 Binding 3 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %10 = OpTypeInt 32 0 + %11 = OpTypePointer Function %10 + %13 = OpTypeVector %10 3 + %14 = OpTypePointer Input %13 + %15 = OpVariable %14 Input + %16 = OpConstant %10 0 + %17 = OpTypePointer Input %10 + %21 = OpConstant %10 1 + %24 = OpTypeInt 32 1 + %25 = OpTypeImage %24 2D 0 0 0 2 R32i + %26 = OpTypePointer UniformConstant %25 + %27 = OpVariable %26 UniformConstant + %29 = OpTypeVector %10 2 + %32 = OpTypeVector %24 2 + %38 = OpTypeVector %24 4 + %40 = OpConstant %10 2 + %41 = OpConstant %10 3400 + %42 = OpConstant %10 264 + %43 = OpTypePointer Function %24 + %45 = OpConstant %24 0 + %53 = OpConstant %24 2 + %54 = OpTypeBool + %73 = OpConstant %24 1 + %77 = OpTypeVector %10 4 + %78 = OpTypeFloat 32 + %79 = OpTypeVector %78 3 + %80 = OpTypeStruct %77 %79 %24 + %81 = OpTypePointer Uniform %80 + %82 = OpVariable %81 Uniform + %84 = OpTypePointer Uniform %24 + %86 = OpTypeVector %78 4 + %87 = OpTypeMatrix %86 4 + %88 = OpTypeStruct %10 %87 %78 + %89 = OpTypePointer Uniform %88 + %90 = OpVariable %89 Uniform + %91 = OpTypePointer Uniform %87 + %94 = OpTypePointer Uniform %77 + %108 = OpConstant %24 3 + %110 = OpTypePointer Uniform %79 + %113 = OpTypePointer Uniform %78 + %128 = OpVariable %26 UniformConstant + %130 = OpConstantComposite %32 %45 %45 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %136 = OpFunctionCall %2 %6 + %137 = OpFunctionCall %2 %8 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %12 = OpVariable %11 Function + %20 = OpVariable %11 Function + %44 = OpVariable %43 Function + %46 = OpVariable %43 Function + %56 = OpVariable %43 Function + %18 = OpAccessChain %17 %15 %16 + %19 = OpLoad %10 %18 + OpStore %12 %19 + %22 = OpAccessChain %17 %15 %21 + %23 = OpLoad %10 %22 + OpStore %20 %23 + %28 = OpLoad %25 %27 + %30 = OpLoad %13 %15 + %31 = OpVectorShuffle %29 %30 %30 0 1 + %33 = OpBitcast %32 %31 + %34 = OpLoad %10 %12 + %35 = OpLoad %10 %20 + %36 = OpIAdd %10 %34 %35 + %37 = OpBitcast %24 %36 + %39 = OpCompositeConstruct %38 %37 %37 %37 %37 + OpImageWrite %28 %33 %39 + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + OpStore %44 %45 + OpStore %46 %45 + OpBranch %47 + %47 = OpLabel + OpLoopMerge %49 %50 None + OpBranch %51 + %51 = OpLabel + %52 = OpLoad %24 %46 + %55 = OpSLessThan %54 %52 %53 + OpBranchConditional %55 %48 %49 + %48 = OpLabel + OpStore %56 %45 + OpBranch %57 + %57 = OpLabel + OpLoopMerge %59 %60 None + OpBranch %61 + %61 = OpLabel + %62 = OpLoad %24 %56 + %63 = OpSLessThan %54 %62 %53 + OpBranchConditional %63 %58 %59 + %58 = OpLabel + %64 = OpLoad %25 %27 + %65 = OpLoad %24 %46 + %66 = OpLoad %24 %56 + %67 = OpCompositeConstruct %32 %65 %66 + %68 = OpImageRead %38 %64 %67 + %69 = OpCompositeExtract %24 %68 0 + %70 = OpLoad %24 %44 + %71 = OpIMul %24 %70 %69 + OpStore %44 %71 + OpBranch %60 + %60 = OpLabel + %72 = OpLoad %24 %56 + %74 = OpIAdd %24 %72 %73 + OpStore %56 %74 + OpBranch %57 + %59 = OpLabel + OpBranch %50 + %50 = OpLabel + %75 = OpLoad %24 %46 + %76 = OpIAdd %24 %75 %73 + OpStore %46 %76 + OpBranch %47 + %49 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %83 = OpLoad %24 %44 + %85 = OpAccessChain %84 %82 %53 + OpStore %85 %83 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %101 = OpVariable %43 Function + %92 = OpAccessChain %91 %90 %73 + %93 = OpLoad %87 %92 + %95 = OpAccessChain %94 %82 %45 + %96 = OpLoad %77 %95 + %97 = OpConvertUToF %86 %96 + %98 = OpMatrixTimesVector %86 %93 %97 + %99 = OpConvertFToU %77 %98 + %100 = OpAccessChain %94 %82 %45 + OpStore %100 %99 + OpStore %101 %45 + OpBranch %102 + %102 = OpLabel + OpLoopMerge %104 %105 None + OpBranch %106 + %106 = OpLabel + %107 = OpLoad %24 %101 + %109 = OpSLessThan %54 %107 %108 + OpBranchConditional %109 %103 %104 + %103 = OpLabel + %111 = OpAccessChain %110 %82 %73 + %112 = OpLoad %79 %111 + %114 = OpAccessChain %113 %90 %53 + %115 = OpLoad %78 %114 + %116 = OpVectorTimesScalar %79 %112 %115 + %117 = OpConvertFToU %13 %116 + %118 = OpCompositeExtract %10 %117 0 + %119 = OpCompositeExtract %10 %117 1 + %120 = OpCompositeExtract %10 %117 2 + %121 = OpCompositeConstruct %77 %118 %119 %120 %16 + %122 = OpAccessChain %94 %82 %45 + %123 = OpLoad %77 %122 + %124 = OpIAdd %77 %123 %121 + %125 = OpAccessChain %94 %82 %45 + OpStore %125 %124 + OpBranch %105 + %105 = OpLabel + %126 = OpLoad %24 %101 + %127 = OpIAdd %24 %126 %73 + OpStore %101 %127 + OpBranch %102 + %104 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %129 = OpLoad %25 %128 + %131 = OpImageRead %38 %129 %130 + %132 = OpCompositeExtract %24 %131 0 + %133 = OpConvertSToF %78 %132 + %134 = OpCompositeConstruct %79 %133 %133 %133 + %135 = OpAccessChain %110 %82 %73 + OpStore %135 %134 + OpReturn + OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/large_functions_small_diffs_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/large_functions_small_diffs_src.spvasm new file mode 100644 index 0000000000..78a92785c5 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/large_functions_small_diffs_src.spvasm @@ -0,0 +1,226 @@ +;; Test where src and dst have a few large functions with small differences. + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" %15 + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %6 "f1(" + OpName %8 "f2(" + OpName %12 "x" + OpName %15 "gl_LocalInvocationID" + OpName %20 "y" + OpName %27 "image" + OpName %44 "sum" + OpName %46 "i" + OpName %56 "j" + OpName %80 "BufferOut" + OpMemberName %80 0 "o_uv4" + OpMemberName %80 1 "o_v3" + OpMemberName %80 2 "o_i" + OpName %82 "" + OpName %88 "BufferIn" + OpMemberName %88 0 "i_u" + OpMemberName %88 1 "i_v4" + OpMemberName %88 2 "i_f" + OpName %90 "" + OpName %101 "i" + OpDecorate %15 BuiltIn LocalInvocationId + OpDecorate %27 DescriptorSet 0 + OpDecorate %27 Binding 2 + OpMemberDecorate %80 0 Offset 0 + OpMemberDecorate %80 1 Offset 16 + OpMemberDecorate %80 2 Offset 28 + OpDecorate %80 BufferBlock + OpDecorate %82 DescriptorSet 0 + OpDecorate %82 Binding 1 + OpMemberDecorate %88 0 Offset 0 + OpMemberDecorate %88 1 RowMajor + OpMemberDecorate %88 1 Offset 16 + OpMemberDecorate %88 1 MatrixStride 16 + OpMemberDecorate %88 2 Offset 80 + OpDecorate %88 Block + OpDecorate %90 DescriptorSet 0 + OpDecorate %90 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %10 = OpTypeInt 32 0 + %11 = OpTypePointer Function %10 + %13 = OpTypeVector %10 3 + %14 = OpTypePointer Input %13 + %15 = OpVariable %14 Input + %16 = OpConstant %10 0 + %17 = OpTypePointer Input %10 + %21 = OpConstant %10 1 + %24 = OpTypeInt 32 1 + %25 = OpTypeImage %24 2D 0 0 0 2 R32i + %26 = OpTypePointer UniformConstant %25 + %27 = OpVariable %26 UniformConstant + %29 = OpTypeVector %10 2 + %32 = OpTypeVector %24 2 + %38 = OpTypeVector %24 4 + %40 = OpConstant %10 2 + %41 = OpConstant %10 3400 + %42 = OpConstant %10 264 + %43 = OpTypePointer Function %24 + %45 = OpConstant %24 0 + %53 = OpConstant %24 2 + %54 = OpTypeBool + %73 = OpConstant %24 1 + %77 = OpTypeVector %10 4 + %78 = OpTypeFloat 32 + %79 = OpTypeVector %78 3 + %80 = OpTypeStruct %77 %79 %24 + %81 = OpTypePointer Uniform %80 + %82 = OpVariable %81 Uniform + %84 = OpTypePointer Uniform %24 + %86 = OpTypeVector %78 4 + %87 = OpTypeMatrix %86 4 + %88 = OpTypeStruct %10 %87 %78 + %89 = OpTypePointer Uniform %88 + %90 = OpVariable %89 Uniform + %91 = OpTypePointer Uniform %87 + %94 = OpTypePointer Uniform %77 + %108 = OpConstant %24 3 + %110 = OpTypePointer Uniform %79 + %113 = OpTypePointer Uniform %78 + %129 = OpConstantComposite %32 %45 %45 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %135 = OpFunctionCall %2 %6 + %136 = OpFunctionCall %2 %8 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %12 = OpVariable %11 Function + %20 = OpVariable %11 Function + %44 = OpVariable %43 Function + %46 = OpVariable %43 Function + %56 = OpVariable %43 Function + %18 = OpAccessChain %17 %15 %16 + %19 = OpLoad %10 %18 + OpStore %12 %19 + %22 = OpAccessChain %17 %15 %21 + %23 = OpLoad %10 %22 + OpStore %20 %23 + %28 = OpLoad %25 %27 + %30 = OpLoad %13 %15 + %31 = OpVectorShuffle %29 %30 %30 0 1 + %33 = OpBitcast %32 %31 + %34 = OpLoad %10 %12 + %35 = OpLoad %10 %20 + %36 = OpIAdd %10 %34 %35 + %37 = OpBitcast %24 %36 + %39 = OpCompositeConstruct %38 %37 %37 %37 %37 + OpImageWrite %28 %33 %39 + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + OpStore %44 %45 + OpStore %46 %45 + OpBranch %47 + %47 = OpLabel + OpLoopMerge %49 %50 None + OpBranch %51 + %51 = OpLabel + %52 = OpLoad %24 %46 + %55 = OpSLessThan %54 %52 %53 + OpBranchConditional %55 %48 %49 + %48 = OpLabel + OpStore %56 %45 + OpBranch %57 + %57 = OpLabel + OpLoopMerge %59 %60 None + OpBranch %61 + %61 = OpLabel + %62 = OpLoad %24 %56 + %63 = OpSLessThan %54 %62 %53 + OpBranchConditional %63 %58 %59 + %58 = OpLabel + %64 = OpLoad %25 %27 + %65 = OpLoad %24 %46 + %66 = OpLoad %24 %56 + %67 = OpCompositeConstruct %32 %65 %66 + %68 = OpImageRead %38 %64 %67 + %69 = OpCompositeExtract %24 %68 0 + %70 = OpLoad %24 %44 + %71 = OpIAdd %24 %70 %69 + OpStore %44 %71 + OpBranch %60 + %60 = OpLabel + %72 = OpLoad %24 %56 + %74 = OpIAdd %24 %72 %73 + OpStore %56 %74 + OpBranch %57 + %59 = OpLabel + OpBranch %50 + %50 = OpLabel + %75 = OpLoad %24 %46 + %76 = OpIAdd %24 %75 %73 + OpStore %46 %76 + OpBranch %47 + %49 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %83 = OpLoad %24 %44 + %85 = OpAccessChain %84 %82 %53 + OpStore %85 %83 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %101 = OpVariable %43 Function + %92 = OpAccessChain %91 %90 %73 + %93 = OpLoad %87 %92 + %95 = OpAccessChain %94 %82 %45 + %96 = OpLoad %77 %95 + %97 = OpConvertUToF %86 %96 + %98 = OpMatrixTimesVector %86 %93 %97 + %99 = OpConvertFToU %77 %98 + %100 = OpAccessChain %94 %82 %45 + OpStore %100 %99 + OpStore %101 %45 + OpBranch %102 + %102 = OpLabel + OpLoopMerge %104 %105 None + OpBranch %106 + %106 = OpLabel + %107 = OpLoad %24 %101 + %109 = OpSLessThan %54 %107 %108 + OpBranchConditional %109 %103 %104 + %103 = OpLabel + %111 = OpAccessChain %110 %82 %73 + %112 = OpLoad %79 %111 + %114 = OpAccessChain %113 %90 %53 + %115 = OpLoad %78 %114 + %116 = OpVectorTimesScalar %79 %112 %115 + %117 = OpConvertFToU %13 %116 + %118 = OpCompositeExtract %10 %117 0 + %119 = OpCompositeExtract %10 %117 1 + %120 = OpCompositeExtract %10 %117 2 + %121 = OpCompositeConstruct %77 %118 %119 %120 %16 + %122 = OpAccessChain %94 %82 %45 + %123 = OpLoad %77 %122 + %124 = OpIAdd %77 %123 %121 + %125 = OpAccessChain %94 %82 %45 + OpStore %125 %124 + OpBranch %105 + %105 = OpLabel + %126 = OpLoad %24 %101 + %127 = OpIAdd %24 %126 %73 + OpStore %101 %127 + OpBranch %102 + %104 = OpLabel + OpMemoryBarrier %40 %41 + OpControlBarrier %40 %40 %42 + %128 = OpLoad %25 %27 + %130 = OpImageRead %38 %128 %129 + %131 = OpCompositeExtract %24 %130 0 + %132 = OpConvertSToF %78 %131 + %133 = OpCompositeConstruct %79 %132 %132 %132 + %134 = OpAccessChain %110 %82 %73 + OpStore %134 %133 + OpReturn + OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/multiple_different_entry_points_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/multiple_different_entry_points_autogen.cpp new file mode 100644 index 0000000000..29d4b1d875 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/multiple_different_entry_points_autogen.cpp @@ -0,0 +1,330 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Basic test for multiple entry points. The entry points have different +// execution models and so can be trivially matched. +constexpr char kSrc[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %mainv "mainv" %vo %a + OpEntryPoint Fragment %mainf "mainf" %color %vi + OpExecutionMode %mainf OriginUpperLeft + OpSource ESSL 310 + OpName %mainv "mainv" + OpName %mainf "mainf" + OpName %a "a" + OpName %vo "v" + OpName %vi "v" + OpName %color "color" + OpDecorate %a Location 0 + OpDecorate %vo Location 0 + OpDecorate %vi Location 0 + OpDecorate %color Location 0 + OpDecorate %color RelaxedPrecision + OpDecorate %vi RelaxedPrecision + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + +%_ptr_Input_float = OpTypePointer Input %float + %a = OpVariable %_ptr_Input_float Input +%_ptr_Output_float = OpTypePointer Output %float + %vo = OpVariable %_ptr_Output_float Output + %vi = OpVariable %_ptr_Input_float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %color = OpVariable %_ptr_Output_v4float Output + + %mainv = OpFunction %void None %3 + %5 = OpLabel + %11 = OpLoad %float %a + OpStore %vo %11 + OpReturn + OpFunctionEnd + + %mainf = OpFunction %void None %3 + %6 = OpLabel + %12 = OpLoad %float %vi + %13 = OpCompositeConstruct %v4float %12 %12 %12 %12 + OpStore %color %13 + OpReturn + OpFunctionEnd)"; +constexpr char kDst[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %frag "frag" %vi %color + OpEntryPoint Vertex %vert "vert" %a %vo + OpExecutionMode %frag OriginUpperLeft + OpSource ESSL 310 + OpName %frag "frag" + OpName %vert "vert" + OpName %vo "v" + OpName %a "a" + OpName %color "color" + OpName %vi "v" + OpDecorate %vi Location 0 + OpDecorate %color Location 0 + OpDecorate %a Location 0 + OpDecorate %vo Location 0 + OpDecorate %color RelaxedPrecision + OpDecorate %vi RelaxedPrecision + OpDecorate %14 RelaxedPrecision + OpDecorate %17 RelaxedPrecision + + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %void = OpTypeVoid + %3 = OpTypeFunction %void + +%_ptr_Output_float = OpTypePointer Output %float + %vo = OpVariable %_ptr_Output_float Output +%_ptr_Input_float = OpTypePointer Input %float + %a = OpVariable %_ptr_Input_float Input + %vi = OpVariable %_ptr_Input_float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %color = OpVariable %_ptr_Output_v4float Output + + %frag = OpFunction %void None %3 + %7 = OpLabel + %14 = OpLoad %float %vi + %17 = OpCompositeConstruct %v4float %14 %14 %14 %14 + OpStore %color %17 + OpReturn + OpFunctionEnd + + %vert = OpFunction %void None %3 + %8 = OpLabel + %13 = OpLoad %float %a + OpStore %vo %13 + OpReturn + OpFunctionEnd +)"; + +TEST(DiffTest, MultipleDifferentEntryPoints) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 + ; Bound: 20 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 +-OpEntryPoint Vertex %2 "mainv" %4 %7 ++OpEntryPoint Vertex %2 "vert" %7 %4 +-OpEntryPoint Fragment %8 "mainf" %9 %10 ++OpEntryPoint Fragment %8 "frag" %10 %9 + OpExecutionMode %8 OriginUpperLeft + OpSource ESSL 310 +-OpName %2 "mainv" ++OpName %2 "vert" +-OpName %8 "mainf" ++OpName %8 "frag" + OpName %7 "a" + OpName %4 "v" + OpName %10 "v" + OpName %9 "color" + OpDecorate %7 Location 0 + OpDecorate %4 Location 0 + OpDecorate %10 Location 0 + OpDecorate %9 Location 0 + OpDecorate %9 RelaxedPrecision + OpDecorate %10 RelaxedPrecision + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + %14 = OpTypeVoid + %3 = OpTypeFunction %14 + %15 = OpTypeFloat 32 + %16 = OpTypeVector %15 4 + %17 = OpTypePointer Input %15 + %7 = OpVariable %17 Input + %18 = OpTypePointer Output %15 + %4 = OpVariable %18 Output + %10 = OpVariable %17 Input + %19 = OpTypePointer Output %16 + %9 = OpVariable %19 Output + %2 = OpFunction %14 None %3 + %5 = OpLabel + %11 = OpLoad %15 %7 + OpStore %4 %11 + OpReturn + OpFunctionEnd + %8 = OpFunction %14 None %3 + %6 = OpLabel + %12 = OpLoad %15 %10 + %13 = OpCompositeConstruct %16 %12 %12 %12 %12 + OpStore %9 %13 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, MultipleDifferentEntryPointsNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %mainv "mainv" %vo %a + OpEntryPoint Fragment %mainf "mainf" %color %vi + OpExecutionMode %mainf OriginUpperLeft + OpSource ESSL 310 + OpDecorate %a Location 0 + OpDecorate %vo Location 0 + OpDecorate %vi Location 0 + OpDecorate %color Location 0 + OpDecorate %color RelaxedPrecision + OpDecorate %vi RelaxedPrecision + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + +%_ptr_Input_float = OpTypePointer Input %float + %a = OpVariable %_ptr_Input_float Input +%_ptr_Output_float = OpTypePointer Output %float + %vo = OpVariable %_ptr_Output_float Output + %vi = OpVariable %_ptr_Input_float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %color = OpVariable %_ptr_Output_v4float Output + + %mainv = OpFunction %void None %3 + %5 = OpLabel + %11 = OpLoad %float %a + OpStore %vo %11 + OpReturn + OpFunctionEnd + + %mainf = OpFunction %void None %3 + %6 = OpLabel + %12 = OpLoad %float %vi + %13 = OpCompositeConstruct %v4float %12 %12 %12 %12 + OpStore %color %13 + OpReturn + OpFunctionEnd +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %frag "frag" %vi %color + OpEntryPoint Vertex %vert "vert" %a %vo + OpExecutionMode %frag OriginUpperLeft + OpSource ESSL 310 + OpDecorate %vi Location 0 + OpDecorate %color Location 0 + OpDecorate %a Location 0 + OpDecorate %vo Location 0 + OpDecorate %color RelaxedPrecision + OpDecorate %vi RelaxedPrecision + OpDecorate %14 RelaxedPrecision + OpDecorate %17 RelaxedPrecision + + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %void = OpTypeVoid + %3 = OpTypeFunction %void + +%_ptr_Output_float = OpTypePointer Output %float + %vo = OpVariable %_ptr_Output_float Output +%_ptr_Input_float = OpTypePointer Input %float + %a = OpVariable %_ptr_Input_float Input + %vi = OpVariable %_ptr_Input_float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %color = OpVariable %_ptr_Output_v4float Output + + %frag = OpFunction %void None %3 + %7 = OpLabel + %14 = OpLoad %float %vi + %17 = OpCompositeConstruct %v4float %14 %14 %14 %14 + OpStore %color %17 + OpReturn + OpFunctionEnd + + %vert = OpFunction %void None %3 + %8 = OpLabel + %13 = OpLoad %float %a + OpStore %vo %13 + OpReturn + OpFunctionEnd +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 + ; Bound: 20 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 +-OpEntryPoint Vertex %2 "mainv" %4 %7 ++OpEntryPoint Vertex %2 "vert" %7 %4 +-OpEntryPoint Fragment %8 "mainf" %9 %10 ++OpEntryPoint Fragment %8 "frag" %10 %9 + OpExecutionMode %8 OriginUpperLeft + OpSource ESSL 310 + OpDecorate %7 Location 0 + OpDecorate %4 Location 0 + OpDecorate %10 Location 0 + OpDecorate %9 Location 0 + OpDecorate %9 RelaxedPrecision + OpDecorate %10 RelaxedPrecision + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + %14 = OpTypeVoid + %3 = OpTypeFunction %14 + %15 = OpTypeFloat 32 + %16 = OpTypeVector %15 4 + %17 = OpTypePointer Input %15 + %7 = OpVariable %17 Input + %18 = OpTypePointer Output %15 + %4 = OpVariable %18 Output + %10 = OpVariable %17 Input + %19 = OpTypePointer Output %16 + %9 = OpVariable %19 Output + %2 = OpFunction %14 None %3 + %5 = OpLabel + %11 = OpLoad %15 %7 + OpStore %4 %11 + OpReturn + OpFunctionEnd + %8 = OpFunction %14 None %3 + %6 = OpLabel + %12 = OpLoad %15 %10 + %13 = OpCompositeConstruct %16 %12 %12 %12 %12 + OpStore %9 %13 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/multiple_different_entry_points_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/multiple_different_entry_points_dst.spvasm new file mode 100644 index 0000000000..72cfe283db --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/multiple_different_entry_points_dst.spvasm @@ -0,0 +1,49 @@ + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %frag "frag" %vi %color + OpEntryPoint Vertex %vert "vert" %a %vo + OpExecutionMode %frag OriginUpperLeft + OpSource ESSL 310 + OpName %frag "frag" + OpName %vert "vert" + OpName %vo "v" + OpName %a "a" + OpName %color "color" + OpName %vi "v" + OpDecorate %vi Location 0 + OpDecorate %color Location 0 + OpDecorate %a Location 0 + OpDecorate %vo Location 0 + OpDecorate %color RelaxedPrecision + OpDecorate %vi RelaxedPrecision + OpDecorate %14 RelaxedPrecision + OpDecorate %17 RelaxedPrecision + + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %void = OpTypeVoid + %3 = OpTypeFunction %void + +%_ptr_Output_float = OpTypePointer Output %float + %vo = OpVariable %_ptr_Output_float Output +%_ptr_Input_float = OpTypePointer Input %float + %a = OpVariable %_ptr_Input_float Input + %vi = OpVariable %_ptr_Input_float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %color = OpVariable %_ptr_Output_v4float Output + + %frag = OpFunction %void None %3 + %7 = OpLabel + %14 = OpLoad %float %vi + %17 = OpCompositeConstruct %v4float %14 %14 %14 %14 + OpStore %color %17 + OpReturn + OpFunctionEnd + + %vert = OpFunction %void None %3 + %8 = OpLabel + %13 = OpLoad %float %a + OpStore %vo %13 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/multiple_different_entry_points_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/multiple_different_entry_points_src.spvasm new file mode 100644 index 0000000000..2119aa7312 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/multiple_different_entry_points_src.spvasm @@ -0,0 +1,51 @@ +;; Basic test for multiple entry points. The entry points have different +;; execution models and so can be trivially matched. + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %mainv "mainv" %vo %a + OpEntryPoint Fragment %mainf "mainf" %color %vi + OpExecutionMode %mainf OriginUpperLeft + OpSource ESSL 310 + OpName %mainv "mainv" + OpName %mainf "mainf" + OpName %a "a" + OpName %vo "v" + OpName %vi "v" + OpName %color "color" + OpDecorate %a Location 0 + OpDecorate %vo Location 0 + OpDecorate %vi Location 0 + OpDecorate %color Location 0 + OpDecorate %color RelaxedPrecision + OpDecorate %vi RelaxedPrecision + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + +%_ptr_Input_float = OpTypePointer Input %float + %a = OpVariable %_ptr_Input_float Input +%_ptr_Output_float = OpTypePointer Output %float + %vo = OpVariable %_ptr_Output_float Output + %vi = OpVariable %_ptr_Input_float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %color = OpVariable %_ptr_Output_v4float Output + + %mainv = OpFunction %void None %3 + %5 = OpLabel + %11 = OpLoad %float %a + OpStore %vo %11 + OpReturn + OpFunctionEnd + + %mainf = OpFunction %void None %3 + %6 = OpLabel + %12 = OpLoad %float %vi + %13 = OpCompositeConstruct %v4float %12 %12 %12 %12 + OpStore %color %13 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/multiple_same_entry_points_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/multiple_same_entry_points_autogen.cpp new file mode 100644 index 0000000000..9d011661c6 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/multiple_same_entry_points_autogen.cpp @@ -0,0 +1,375 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Test for multiple entry points with the same execution model. +constexpr char kSrc[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %4 "main1" %8 %10 + OpEntryPoint Vertex %12 "main2" %13 %14 %15 + OpSource ESSL 310 + OpName %4 "main1" + OpName %12 "main2" + OpName %8 "v" + OpName %10 "a" + OpName %13 "v" + OpName %14 "a" + OpName %15 "b" + OpDecorate %8 Location 0 + OpDecorate %10 Location 0 + OpDecorate %13 Location 0 + OpDecorate %14 Location 0 + OpDecorate %15 Location 1 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + + %7 = OpTypePointer Output %6 + %9 = OpTypePointer Input %6 + %8 = OpVariable %7 Output + %10 = OpVariable %9 Input + %13 = OpVariable %7 Output + %14 = OpVariable %9 Input + %15 = OpVariable %9 Input + + %4 = OpFunction %2 None %3 + %5 = OpLabel + %11 = OpLoad %6 %10 + OpStore %8 %11 + OpReturn + OpFunctionEnd + + %12 = OpFunction %2 None %3 + %16 = OpLabel + %17 = OpLoad %6 %14 + %18 = OpLoad %6 %15 + %19 = OpFAdd %6 %17 %18 + OpStore %13 %19 + OpReturn + OpFunctionEnd)"; +constexpr char kDst[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %4 "main2" %13 %14 %15 + OpEntryPoint Vertex %12 "main1" %8 %10 + OpSource ESSL 310 + OpName %12 "main1" + OpName %4 "main2" + OpName %8 "v" + OpName %10 "a" + OpName %13 "v" + OpName %14 "a" + OpName %15 "b" + OpDecorate %8 Location 0 + OpDecorate %10 Location 0 + OpDecorate %13 Location 0 + OpDecorate %14 Location 0 + OpDecorate %15 Location 1 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + + %7 = OpTypePointer Output %6 + %9 = OpTypePointer Input %6 + %8 = OpVariable %7 Output + %10 = OpVariable %9 Input + %13 = OpVariable %7 Output + %14 = OpVariable %9 Input + %15 = OpVariable %9 Input + + %4 = OpFunction %2 None %3 + %16 = OpLabel + %17 = OpLoad %6 %14 + %18 = OpLoad %6 %15 + %19 = OpFAdd %6 %17 %18 + OpStore %13 %19 + OpReturn + OpFunctionEnd + + %12 = OpFunction %2 None %3 + %5 = OpLabel + %11 = OpLoad %6 %10 + OpStore %8 %11 + OpReturn + OpFunctionEnd +)"; + +TEST(DiffTest, MultipleSameEntryPoints) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 + ; Bound: 20 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 ++OpEntryPoint Vertex %12 "main2" %13 %14 %15 + OpEntryPoint Vertex %4 "main1" %8 %10 +-OpEntryPoint Vertex %12 "main2" %13 %14 %15 + OpSource ESSL 310 + OpName %4 "main1" + OpName %12 "main2" + OpName %8 "v" + OpName %10 "a" + OpName %13 "v" + OpName %14 "a" + OpName %15 "b" + OpDecorate %8 Location 0 + OpDecorate %10 Location 0 + OpDecorate %13 Location 0 + OpDecorate %14 Location 0 + OpDecorate %15 Location 1 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypePointer Output %6 + %9 = OpTypePointer Input %6 + %8 = OpVariable %7 Output + %10 = OpVariable %9 Input + %13 = OpVariable %7 Output + %14 = OpVariable %9 Input + %15 = OpVariable %9 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %11 = OpLoad %6 %10 + OpStore %8 %11 + OpReturn + OpFunctionEnd + %12 = OpFunction %2 None %3 + %16 = OpLabel + %17 = OpLoad %6 %14 + %18 = OpLoad %6 %15 + %19 = OpFAdd %6 %17 %18 + OpStore %13 %19 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, MultipleSameEntryPointsNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %4 "main1" %8 %10 + OpEntryPoint Vertex %12 "main2" %13 %14 %15 + OpSource ESSL 310 + OpDecorate %8 Location 0 + OpDecorate %10 Location 0 + OpDecorate %13 Location 0 + OpDecorate %14 Location 0 + OpDecorate %15 Location 1 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + + %7 = OpTypePointer Output %6 + %9 = OpTypePointer Input %6 + %8 = OpVariable %7 Output + %10 = OpVariable %9 Input + %13 = OpVariable %7 Output + %14 = OpVariable %9 Input + %15 = OpVariable %9 Input + + %4 = OpFunction %2 None %3 + %5 = OpLabel + %11 = OpLoad %6 %10 + OpStore %8 %11 + OpReturn + OpFunctionEnd + + %12 = OpFunction %2 None %3 + %16 = OpLabel + %17 = OpLoad %6 %14 + %18 = OpLoad %6 %15 + %19 = OpFAdd %6 %17 %18 + OpStore %13 %19 + OpReturn + OpFunctionEnd +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %4 "main2" %13 %14 %15 + OpEntryPoint Vertex %12 "main1" %8 %10 + OpSource ESSL 310 + OpDecorate %8 Location 0 + OpDecorate %10 Location 0 + OpDecorate %13 Location 0 + OpDecorate %14 Location 0 + OpDecorate %15 Location 1 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + + %7 = OpTypePointer Output %6 + %9 = OpTypePointer Input %6 + %8 = OpVariable %7 Output + %10 = OpVariable %9 Input + %13 = OpVariable %7 Output + %14 = OpVariable %9 Input + %15 = OpVariable %9 Input + + %4 = OpFunction %2 None %3 + %16 = OpLabel + %17 = OpLoad %6 %14 + %18 = OpLoad %6 %15 + %19 = OpFAdd %6 %17 %18 + OpStore %13 %19 + OpReturn + OpFunctionEnd + + %12 = OpFunction %2 None %3 + %5 = OpLabel + %11 = OpLoad %6 %10 + OpStore %8 %11 + OpReturn + OpFunctionEnd +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 + ; Bound: 20 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 ++OpEntryPoint Vertex %12 "main2" %13 %14 %15 + OpEntryPoint Vertex %4 "main1" %8 %10 +-OpEntryPoint Vertex %12 "main2" %13 %14 %15 + OpSource ESSL 310 + OpDecorate %8 Location 0 + OpDecorate %10 Location 0 + OpDecorate %13 Location 0 + OpDecorate %14 Location 0 + OpDecorate %15 Location 1 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypePointer Output %6 + %9 = OpTypePointer Input %6 + %8 = OpVariable %7 Output + %10 = OpVariable %9 Input + %13 = OpVariable %7 Output + %14 = OpVariable %9 Input + %15 = OpVariable %9 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %11 = OpLoad %6 %10 + OpStore %8 %11 + OpReturn + OpFunctionEnd + %12 = OpFunction %2 None %3 + %16 = OpLabel + %17 = OpLoad %6 %14 + %18 = OpLoad %6 %15 + %19 = OpFAdd %6 %17 %18 + OpStore %13 %19 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +TEST(DiffTest, MultipleSameEntryPointsDumpIds) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 + ; Bound: 20 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 ++OpEntryPoint Vertex %12 "main2" %13 %14 %15 + OpEntryPoint Vertex %4 "main1" %8 %10 +-OpEntryPoint Vertex %12 "main2" %13 %14 %15 + OpSource ESSL 310 + OpName %4 "main1" + OpName %12 "main2" + OpName %8 "v" + OpName %10 "a" + OpName %13 "v" + OpName %14 "a" + OpName %15 "b" + OpDecorate %8 Location 0 + OpDecorate %10 Location 0 + OpDecorate %13 Location 0 + OpDecorate %14 Location 0 + OpDecorate %15 Location 1 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypePointer Output %6 + %9 = OpTypePointer Input %6 + %8 = OpVariable %7 Output + %10 = OpVariable %9 Input + %13 = OpVariable %7 Output + %14 = OpVariable %9 Input + %15 = OpVariable %9 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %11 = OpLoad %6 %10 + OpStore %8 %11 + OpReturn + OpFunctionEnd + %12 = OpFunction %2 None %3 + %16 = OpLabel + %17 = OpLoad %6 %14 + %18 = OpLoad %6 %15 + %19 = OpFAdd %6 %17 %18 + OpStore %13 %19 + OpReturn + OpFunctionEnd + Src -> Dst + 1 -> 1 [ExtInstImport] + 2 -> 2 [TypeVoid] + 3 -> 3 [TypeFunction] + 4 -> 12 [Function] + 5 -> 5 [Label] + 6 -> 6 [TypeFloat] + 7 -> 7 [TypePointer] + 8 -> 8 [Variable] + 9 -> 9 [TypePointer] + 10 -> 10 [Variable] + 11 -> 11 [Load] + 12 -> 4 [Function] + 13 -> 13 [Variable] + 14 -> 14 [Variable] + 15 -> 15 [Variable] + 16 -> 16 [Label] + 17 -> 17 [Load] + 18 -> 18 [Load] + 19 -> 19 [FAdd] +)"; + Options options; + options.dump_id_map = true; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/multiple_same_entry_points_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/multiple_same_entry_points_dst.spvasm new file mode 100644 index 0000000000..e200722039 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/multiple_same_entry_points_dst.spvasm @@ -0,0 +1,45 @@ + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %4 "main2" %13 %14 %15 + OpEntryPoint Vertex %12 "main1" %8 %10 + OpSource ESSL 310 + OpName %12 "main1" + OpName %4 "main2" + OpName %8 "v" + OpName %10 "a" + OpName %13 "v" + OpName %14 "a" + OpName %15 "b" + OpDecorate %8 Location 0 + OpDecorate %10 Location 0 + OpDecorate %13 Location 0 + OpDecorate %14 Location 0 + OpDecorate %15 Location 1 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + + %7 = OpTypePointer Output %6 + %9 = OpTypePointer Input %6 + %8 = OpVariable %7 Output + %10 = OpVariable %9 Input + %13 = OpVariable %7 Output + %14 = OpVariable %9 Input + %15 = OpVariable %9 Input + + %4 = OpFunction %2 None %3 + %16 = OpLabel + %17 = OpLoad %6 %14 + %18 = OpLoad %6 %15 + %19 = OpFAdd %6 %17 %18 + OpStore %13 %19 + OpReturn + OpFunctionEnd + + %12 = OpFunction %2 None %3 + %5 = OpLabel + %11 = OpLoad %6 %10 + OpStore %8 %11 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/multiple_same_entry_points_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/multiple_same_entry_points_src.spvasm new file mode 100644 index 0000000000..17001b573c --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/multiple_same_entry_points_src.spvasm @@ -0,0 +1,46 @@ +;; Test for multiple entry points with the same execution model. + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %4 "main1" %8 %10 + OpEntryPoint Vertex %12 "main2" %13 %14 %15 + OpSource ESSL 310 + OpName %4 "main1" + OpName %12 "main2" + OpName %8 "v" + OpName %10 "a" + OpName %13 "v" + OpName %14 "a" + OpName %15 "b" + OpDecorate %8 Location 0 + OpDecorate %10 Location 0 + OpDecorate %13 Location 0 + OpDecorate %14 Location 0 + OpDecorate %15 Location 1 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + + %7 = OpTypePointer Output %6 + %9 = OpTypePointer Input %6 + %8 = OpVariable %7 Output + %10 = OpVariable %9 Input + %13 = OpVariable %7 Output + %14 = OpVariable %9 Input + %15 = OpVariable %9 Input + + %4 = OpFunction %2 None %3 + %5 = OpLabel + %11 = OpLoad %6 %10 + OpStore %8 %11 + OpReturn + OpFunctionEnd + + %12 = OpFunction %2 None %3 + %16 = OpLabel + %17 = OpLoad %6 %14 + %18 = OpLoad %6 %15 + %19 = OpFAdd %6 %17 %18 + OpStore %13 %19 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/reordered_if_blocks_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/reordered_if_blocks_autogen.cpp new file mode 100644 index 0000000000..0788199f9f --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/reordered_if_blocks_autogen.cpp @@ -0,0 +1,568 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Test where src and dst have the true and false blocks of an if reordered. +constexpr char kSrc[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %8 %44 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %8 "v" + OpName %44 "color" + OpDecorate %8 RelaxedPrecision + OpDecorate %8 Location 0 + OpDecorate %9 RelaxedPrecision + OpDecorate %18 RelaxedPrecision + OpDecorate %19 RelaxedPrecision + OpDecorate %20 RelaxedPrecision + OpDecorate %23 RelaxedPrecision + OpDecorate %24 RelaxedPrecision + OpDecorate %25 RelaxedPrecision + OpDecorate %26 RelaxedPrecision + OpDecorate %27 RelaxedPrecision + OpDecorate %28 RelaxedPrecision + OpDecorate %29 RelaxedPrecision + OpDecorate %30 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %33 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %44 RelaxedPrecision + OpDecorate %44 Location 0 + OpDecorate %45 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypePointer Input %6 + %8 = OpVariable %7 Input + %10 = OpConstant %6 0 + %11 = OpTypeBool + %15 = OpTypeVector %6 4 + %16 = OpTypePointer Function %15 + %21 = OpConstant %6 -0.5 + %22 = OpConstant %6 -0.300000012 + %38 = OpConstant %6 0.5 + %43 = OpTypePointer Output %15 + %44 = OpVariable %43 Output + %4 = OpFunction %2 None %3 + %5 = OpLabel + %9 = OpLoad %6 %8 + %12 = OpFOrdLessThanEqual %11 %9 %10 + OpSelectionMerge %14 None + OpBranchConditional %12 %13 %32 + %13 = OpLabel + %18 = OpLoad %6 %8 + %19 = OpExtInst %6 %1 Log %18 + %20 = OpLoad %6 %8 + %23 = OpExtInst %6 %1 FClamp %20 %21 %22 + %24 = OpFMul %6 %19 %23 + %25 = OpLoad %6 %8 + %26 = OpExtInst %6 %1 Sin %25 + %27 = OpLoad %6 %8 + %28 = OpExtInst %6 %1 Cos %27 + %29 = OpLoad %6 %8 + %30 = OpExtInst %6 %1 Exp %29 + %31 = OpCompositeConstruct %15 %24 %26 %28 %30 + OpBranch %14 + %32 = OpLabel + %33 = OpLoad %6 %8 + %34 = OpExtInst %6 %1 Sqrt %33 + %35 = OpLoad %6 %8 + %36 = OpExtInst %6 %1 FSign %35 + %37 = OpLoad %6 %8 + %39 = OpExtInst %6 %1 FMax %37 %38 + %40 = OpLoad %6 %8 + %41 = OpExtInst %6 %1 Floor %40 + %42 = OpCompositeConstruct %15 %34 %36 %39 %41 + OpBranch %14 + %14 = OpLabel + %45 = OpPhi %15 %31 %13 %42 %32 + OpStore %44 %45 + OpReturn + OpFunctionEnd)"; +constexpr char kDst[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %8 %44 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %8 "v" + OpName %44 "color" + OpDecorate %8 RelaxedPrecision + OpDecorate %8 Location 0 + OpDecorate %9 RelaxedPrecision + OpDecorate %18 RelaxedPrecision + OpDecorate %19 RelaxedPrecision + OpDecorate %20 RelaxedPrecision + OpDecorate %21 RelaxedPrecision + OpDecorate %22 RelaxedPrecision + OpDecorate %24 RelaxedPrecision + OpDecorate %25 RelaxedPrecision + OpDecorate %26 RelaxedPrecision + OpDecorate %27 RelaxedPrecision + OpDecorate %29 RelaxedPrecision + OpDecorate %30 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %38 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %44 RelaxedPrecision + OpDecorate %44 Location 0 + OpDecorate %45 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypePointer Input %6 + %8 = OpVariable %7 Input + %10 = OpConstant %6 0 + %11 = OpTypeBool + %15 = OpTypeVector %6 4 + %16 = OpTypePointer Function %15 + %23 = OpConstant %6 0.5 + %32 = OpConstant %6 -0.5 + %33 = OpConstant %6 -0.300000012 + %43 = OpTypePointer Output %15 + %44 = OpVariable %43 Output + %4 = OpFunction %2 None %3 + %5 = OpLabel + %9 = OpLoad %6 %8 + %12 = OpFOrdLessThanEqual %11 %9 %10 + OpSelectionMerge %14 None + OpBranchConditional %12 %28 %13 + %13 = OpLabel + %18 = OpLoad %6 %8 + %19 = OpExtInst %6 %1 Sqrt %18 + %20 = OpLoad %6 %8 + %21 = OpExtInst %6 %1 FSign %20 + %22 = OpLoad %6 %8 + %24 = OpExtInst %6 %1 FMax %22 %23 + %25 = OpLoad %6 %8 + %26 = OpExtInst %6 %1 Floor %25 + %27 = OpCompositeConstruct %15 %19 %21 %24 %26 + OpBranch %14 + %28 = OpLabel + %29 = OpLoad %6 %8 + %30 = OpExtInst %6 %1 Log %29 + %31 = OpLoad %6 %8 + %34 = OpExtInst %6 %1 FClamp %31 %32 %33 + %35 = OpFMul %6 %30 %34 + %36 = OpLoad %6 %8 + %37 = OpExtInst %6 %1 Sin %36 + %38 = OpLoad %6 %8 + %39 = OpExtInst %6 %1 Cos %38 + %40 = OpLoad %6 %8 + %41 = OpExtInst %6 %1 Exp %40 + %42 = OpCompositeConstruct %15 %35 %37 %39 %41 + OpBranch %14 + %14 = OpLabel + %45 = OpPhi %15 %27 %13 %42 %28 + OpStore %44 %45 + OpReturn + OpFunctionEnd + +)"; + +TEST(DiffTest, ReorderedIfBlocks) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 46 ++; Bound: 47 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %8 %44 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %8 "v" + OpName %44 "color" + OpDecorate %8 RelaxedPrecision + OpDecorate %8 Location 0 + OpDecorate %9 RelaxedPrecision + OpDecorate %18 RelaxedPrecision + OpDecorate %19 RelaxedPrecision + OpDecorate %20 RelaxedPrecision + OpDecorate %23 RelaxedPrecision + OpDecorate %24 RelaxedPrecision + OpDecorate %25 RelaxedPrecision + OpDecorate %26 RelaxedPrecision + OpDecorate %27 RelaxedPrecision + OpDecorate %28 RelaxedPrecision + OpDecorate %29 RelaxedPrecision + OpDecorate %30 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %33 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %44 RelaxedPrecision + OpDecorate %44 Location 0 + OpDecorate %45 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypePointer Input %6 + %8 = OpVariable %7 Input + %10 = OpConstant %6 0 + %11 = OpTypeBool + %15 = OpTypeVector %6 4 + %16 = OpTypePointer Function %15 + %21 = OpConstant %6 -0.5 + %22 = OpConstant %6 -0.300000012 + %38 = OpConstant %6 0.5 + %43 = OpTypePointer Output %15 + %44 = OpVariable %43 Output + %4 = OpFunction %2 None %3 + %5 = OpLabel + %9 = OpLoad %6 %8 + %12 = OpFOrdLessThanEqual %11 %9 %10 + OpSelectionMerge %14 None + OpBranchConditional %12 %13 %32 + %32 = OpLabel + %33 = OpLoad %6 %8 + %34 = OpExtInst %6 %1 Sqrt %33 + %35 = OpLoad %6 %8 + %36 = OpExtInst %6 %1 FSign %35 + %37 = OpLoad %6 %8 + %39 = OpExtInst %6 %1 FMax %37 %38 + %40 = OpLoad %6 %8 + %41 = OpExtInst %6 %1 Floor %40 + %42 = OpCompositeConstruct %15 %34 %36 %39 %41 + OpBranch %14 + %13 = OpLabel + %18 = OpLoad %6 %8 + %19 = OpExtInst %6 %1 Log %18 + %20 = OpLoad %6 %8 + %23 = OpExtInst %6 %1 FClamp %20 %21 %22 + %24 = OpFMul %6 %19 %23 + %25 = OpLoad %6 %8 + %26 = OpExtInst %6 %1 Sin %25 + %27 = OpLoad %6 %8 + %28 = OpExtInst %6 %1 Cos %27 + %29 = OpLoad %6 %8 + %30 = OpExtInst %6 %1 Exp %29 + %31 = OpCompositeConstruct %15 %24 %26 %28 %30 + OpBranch %14 + %14 = OpLabel +-%45 = OpPhi %15 %31 %13 %42 %32 ++%45 = OpPhi %15 %42 %32 %31 %13 + OpStore %44 %45 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, ReorderedIfBlocksNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %8 %44 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpDecorate %8 RelaxedPrecision + OpDecorate %8 Location 0 + OpDecorate %9 RelaxedPrecision + OpDecorate %18 RelaxedPrecision + OpDecorate %19 RelaxedPrecision + OpDecorate %20 RelaxedPrecision + OpDecorate %23 RelaxedPrecision + OpDecorate %24 RelaxedPrecision + OpDecorate %25 RelaxedPrecision + OpDecorate %26 RelaxedPrecision + OpDecorate %27 RelaxedPrecision + OpDecorate %28 RelaxedPrecision + OpDecorate %29 RelaxedPrecision + OpDecorate %30 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %33 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %44 RelaxedPrecision + OpDecorate %44 Location 0 + OpDecorate %45 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypePointer Input %6 + %8 = OpVariable %7 Input + %10 = OpConstant %6 0 + %11 = OpTypeBool + %15 = OpTypeVector %6 4 + %16 = OpTypePointer Function %15 + %21 = OpConstant %6 -0.5 + %22 = OpConstant %6 -0.300000012 + %38 = OpConstant %6 0.5 + %43 = OpTypePointer Output %15 + %44 = OpVariable %43 Output + %4 = OpFunction %2 None %3 + %5 = OpLabel + %9 = OpLoad %6 %8 + %12 = OpFOrdLessThanEqual %11 %9 %10 + OpSelectionMerge %14 None + OpBranchConditional %12 %13 %32 + %13 = OpLabel + %18 = OpLoad %6 %8 + %19 = OpExtInst %6 %1 Log %18 + %20 = OpLoad %6 %8 + %23 = OpExtInst %6 %1 FClamp %20 %21 %22 + %24 = OpFMul %6 %19 %23 + %25 = OpLoad %6 %8 + %26 = OpExtInst %6 %1 Sin %25 + %27 = OpLoad %6 %8 + %28 = OpExtInst %6 %1 Cos %27 + %29 = OpLoad %6 %8 + %30 = OpExtInst %6 %1 Exp %29 + %31 = OpCompositeConstruct %15 %24 %26 %28 %30 + OpBranch %14 + %32 = OpLabel + %33 = OpLoad %6 %8 + %34 = OpExtInst %6 %1 Sqrt %33 + %35 = OpLoad %6 %8 + %36 = OpExtInst %6 %1 FSign %35 + %37 = OpLoad %6 %8 + %39 = OpExtInst %6 %1 FMax %37 %38 + %40 = OpLoad %6 %8 + %41 = OpExtInst %6 %1 Floor %40 + %42 = OpCompositeConstruct %15 %34 %36 %39 %41 + OpBranch %14 + %14 = OpLabel + %45 = OpPhi %15 %31 %13 %42 %32 + OpStore %44 %45 + OpReturn + OpFunctionEnd +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %8 %44 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpDecorate %8 RelaxedPrecision + OpDecorate %8 Location 0 + OpDecorate %9 RelaxedPrecision + OpDecorate %18 RelaxedPrecision + OpDecorate %19 RelaxedPrecision + OpDecorate %20 RelaxedPrecision + OpDecorate %21 RelaxedPrecision + OpDecorate %22 RelaxedPrecision + OpDecorate %24 RelaxedPrecision + OpDecorate %25 RelaxedPrecision + OpDecorate %26 RelaxedPrecision + OpDecorate %27 RelaxedPrecision + OpDecorate %29 RelaxedPrecision + OpDecorate %30 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %38 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %44 RelaxedPrecision + OpDecorate %44 Location 0 + OpDecorate %45 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypePointer Input %6 + %8 = OpVariable %7 Input + %10 = OpConstant %6 0 + %11 = OpTypeBool + %15 = OpTypeVector %6 4 + %16 = OpTypePointer Function %15 + %23 = OpConstant %6 0.5 + %32 = OpConstant %6 -0.5 + %33 = OpConstant %6 -0.300000012 + %43 = OpTypePointer Output %15 + %44 = OpVariable %43 Output + %4 = OpFunction %2 None %3 + %5 = OpLabel + %9 = OpLoad %6 %8 + %12 = OpFOrdLessThanEqual %11 %9 %10 + OpSelectionMerge %14 None + OpBranchConditional %12 %28 %13 + %13 = OpLabel + %18 = OpLoad %6 %8 + %19 = OpExtInst %6 %1 Sqrt %18 + %20 = OpLoad %6 %8 + %21 = OpExtInst %6 %1 FSign %20 + %22 = OpLoad %6 %8 + %24 = OpExtInst %6 %1 FMax %22 %23 + %25 = OpLoad %6 %8 + %26 = OpExtInst %6 %1 Floor %25 + %27 = OpCompositeConstruct %15 %19 %21 %24 %26 + OpBranch %14 + %28 = OpLabel + %29 = OpLoad %6 %8 + %30 = OpExtInst %6 %1 Log %29 + %31 = OpLoad %6 %8 + %34 = OpExtInst %6 %1 FClamp %31 %32 %33 + %35 = OpFMul %6 %30 %34 + %36 = OpLoad %6 %8 + %37 = OpExtInst %6 %1 Sin %36 + %38 = OpLoad %6 %8 + %39 = OpExtInst %6 %1 Cos %38 + %40 = OpLoad %6 %8 + %41 = OpExtInst %6 %1 Exp %40 + %42 = OpCompositeConstruct %15 %35 %37 %39 %41 + OpBranch %14 + %14 = OpLabel + %45 = OpPhi %15 %27 %13 %42 %28 + OpStore %44 %45 + OpReturn + OpFunctionEnd + +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 46 ++; Bound: 47 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %8 %44 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpDecorate %8 RelaxedPrecision + OpDecorate %8 Location 0 + OpDecorate %9 RelaxedPrecision + OpDecorate %18 RelaxedPrecision + OpDecorate %19 RelaxedPrecision + OpDecorate %20 RelaxedPrecision + OpDecorate %23 RelaxedPrecision + OpDecorate %24 RelaxedPrecision + OpDecorate %25 RelaxedPrecision + OpDecorate %26 RelaxedPrecision + OpDecorate %27 RelaxedPrecision + OpDecorate %28 RelaxedPrecision + OpDecorate %29 RelaxedPrecision + OpDecorate %30 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %33 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %44 RelaxedPrecision + OpDecorate %44 Location 0 + OpDecorate %45 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypePointer Input %6 + %8 = OpVariable %7 Input + %10 = OpConstant %6 0 + %11 = OpTypeBool + %15 = OpTypeVector %6 4 + %16 = OpTypePointer Function %15 + %21 = OpConstant %6 -0.5 + %22 = OpConstant %6 -0.300000012 + %38 = OpConstant %6 0.5 + %43 = OpTypePointer Output %15 + %44 = OpVariable %43 Output + %4 = OpFunction %2 None %3 + %5 = OpLabel + %9 = OpLoad %6 %8 + %12 = OpFOrdLessThanEqual %11 %9 %10 + OpSelectionMerge %14 None + OpBranchConditional %12 %13 %32 + %32 = OpLabel + %33 = OpLoad %6 %8 + %34 = OpExtInst %6 %1 Sqrt %33 + %35 = OpLoad %6 %8 + %36 = OpExtInst %6 %1 FSign %35 + %37 = OpLoad %6 %8 + %39 = OpExtInst %6 %1 FMax %37 %38 + %40 = OpLoad %6 %8 + %41 = OpExtInst %6 %1 Floor %40 + %42 = OpCompositeConstruct %15 %34 %36 %39 %41 + OpBranch %14 + %13 = OpLabel + %18 = OpLoad %6 %8 + %19 = OpExtInst %6 %1 Log %18 + %20 = OpLoad %6 %8 + %23 = OpExtInst %6 %1 FClamp %20 %21 %22 + %24 = OpFMul %6 %19 %23 + %25 = OpLoad %6 %8 + %26 = OpExtInst %6 %1 Sin %25 + %27 = OpLoad %6 %8 + %28 = OpExtInst %6 %1 Cos %27 + %29 = OpLoad %6 %8 + %30 = OpExtInst %6 %1 Exp %29 + %31 = OpCompositeConstruct %15 %24 %26 %28 %30 + OpBranch %14 + %14 = OpLabel +-%45 = OpPhi %15 %31 %13 %42 %32 ++%45 = OpPhi %15 %42 %32 %31 %13 + OpStore %44 %45 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/reordered_if_blocks_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/reordered_if_blocks_dst.spvasm new file mode 100644 index 0000000000..cd1d6d52e1 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/reordered_if_blocks_dst.spvasm @@ -0,0 +1,87 @@ + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %8 %44 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %8 "v" + OpName %44 "color" + OpDecorate %8 RelaxedPrecision + OpDecorate %8 Location 0 + OpDecorate %9 RelaxedPrecision + OpDecorate %18 RelaxedPrecision + OpDecorate %19 RelaxedPrecision + OpDecorate %20 RelaxedPrecision + OpDecorate %21 RelaxedPrecision + OpDecorate %22 RelaxedPrecision + OpDecorate %24 RelaxedPrecision + OpDecorate %25 RelaxedPrecision + OpDecorate %26 RelaxedPrecision + OpDecorate %27 RelaxedPrecision + OpDecorate %29 RelaxedPrecision + OpDecorate %30 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %38 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %44 RelaxedPrecision + OpDecorate %44 Location 0 + OpDecorate %45 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypePointer Input %6 + %8 = OpVariable %7 Input + %10 = OpConstant %6 0 + %11 = OpTypeBool + %15 = OpTypeVector %6 4 + %16 = OpTypePointer Function %15 + %23 = OpConstant %6 0.5 + %32 = OpConstant %6 -0.5 + %33 = OpConstant %6 -0.300000012 + %43 = OpTypePointer Output %15 + %44 = OpVariable %43 Output + %4 = OpFunction %2 None %3 + %5 = OpLabel + %9 = OpLoad %6 %8 + %12 = OpFOrdLessThanEqual %11 %9 %10 + OpSelectionMerge %14 None + OpBranchConditional %12 %28 %13 + %13 = OpLabel + %18 = OpLoad %6 %8 + %19 = OpExtInst %6 %1 Sqrt %18 + %20 = OpLoad %6 %8 + %21 = OpExtInst %6 %1 FSign %20 + %22 = OpLoad %6 %8 + %24 = OpExtInst %6 %1 FMax %22 %23 + %25 = OpLoad %6 %8 + %26 = OpExtInst %6 %1 Floor %25 + %27 = OpCompositeConstruct %15 %19 %21 %24 %26 + OpBranch %14 + %28 = OpLabel + %29 = OpLoad %6 %8 + %30 = OpExtInst %6 %1 Log %29 + %31 = OpLoad %6 %8 + %34 = OpExtInst %6 %1 FClamp %31 %32 %33 + %35 = OpFMul %6 %30 %34 + %36 = OpLoad %6 %8 + %37 = OpExtInst %6 %1 Sin %36 + %38 = OpLoad %6 %8 + %39 = OpExtInst %6 %1 Cos %38 + %40 = OpLoad %6 %8 + %41 = OpExtInst %6 %1 Exp %40 + %42 = OpCompositeConstruct %15 %35 %37 %39 %41 + OpBranch %14 + %14 = OpLabel + %45 = OpPhi %15 %27 %13 %42 %28 + OpStore %44 %45 + OpReturn + OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/reordered_if_blocks_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/reordered_if_blocks_src.spvasm new file mode 100644 index 0000000000..209cb45b75 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/reordered_if_blocks_src.spvasm @@ -0,0 +1,87 @@ +;; Test where src and dst have the true and false blocks of an if reordered. + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %8 %44 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %8 "v" + OpName %44 "color" + OpDecorate %8 RelaxedPrecision + OpDecorate %8 Location 0 + OpDecorate %9 RelaxedPrecision + OpDecorate %18 RelaxedPrecision + OpDecorate %19 RelaxedPrecision + OpDecorate %20 RelaxedPrecision + OpDecorate %23 RelaxedPrecision + OpDecorate %24 RelaxedPrecision + OpDecorate %25 RelaxedPrecision + OpDecorate %26 RelaxedPrecision + OpDecorate %27 RelaxedPrecision + OpDecorate %28 RelaxedPrecision + OpDecorate %29 RelaxedPrecision + OpDecorate %30 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %33 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %44 RelaxedPrecision + OpDecorate %44 Location 0 + OpDecorate %45 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypePointer Input %6 + %8 = OpVariable %7 Input + %10 = OpConstant %6 0 + %11 = OpTypeBool + %15 = OpTypeVector %6 4 + %16 = OpTypePointer Function %15 + %21 = OpConstant %6 -0.5 + %22 = OpConstant %6 -0.300000012 + %38 = OpConstant %6 0.5 + %43 = OpTypePointer Output %15 + %44 = OpVariable %43 Output + %4 = OpFunction %2 None %3 + %5 = OpLabel + %9 = OpLoad %6 %8 + %12 = OpFOrdLessThanEqual %11 %9 %10 + OpSelectionMerge %14 None + OpBranchConditional %12 %13 %32 + %13 = OpLabel + %18 = OpLoad %6 %8 + %19 = OpExtInst %6 %1 Log %18 + %20 = OpLoad %6 %8 + %23 = OpExtInst %6 %1 FClamp %20 %21 %22 + %24 = OpFMul %6 %19 %23 + %25 = OpLoad %6 %8 + %26 = OpExtInst %6 %1 Sin %25 + %27 = OpLoad %6 %8 + %28 = OpExtInst %6 %1 Cos %27 + %29 = OpLoad %6 %8 + %30 = OpExtInst %6 %1 Exp %29 + %31 = OpCompositeConstruct %15 %24 %26 %28 %30 + OpBranch %14 + %32 = OpLabel + %33 = OpLoad %6 %8 + %34 = OpExtInst %6 %1 Sqrt %33 + %35 = OpLoad %6 %8 + %36 = OpExtInst %6 %1 FSign %35 + %37 = OpLoad %6 %8 + %39 = OpExtInst %6 %1 FMax %37 %38 + %40 = OpLoad %6 %8 + %41 = OpExtInst %6 %1 Floor %40 + %42 = OpCompositeConstruct %15 %34 %36 %39 %41 + OpBranch %14 + %14 = OpLabel + %45 = OpPhi %15 %31 %13 %42 %32 + OpStore %44 %45 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/reordered_switch_blocks_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/reordered_switch_blocks_autogen.cpp new file mode 100644 index 0000000000..c0ba48d1e9 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/reordered_switch_blocks_autogen.cpp @@ -0,0 +1,582 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Test where src and dst have cases of a switch in different order. +constexpr char kSrc[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %7 "BufferIn" + OpMemberName %7 0 "i" + OpName %9 "" + OpName %23 "BufferOut" + OpMemberName %23 0 "o" + OpName %25 "" + OpMemberDecorate %7 0 Offset 0 + OpDecorate %7 Block + OpDecorate %9 DescriptorSet 0 + OpDecorate %9 Binding 0 + OpMemberDecorate %23 0 Offset 0 + OpDecorate %23 BufferBlock + OpDecorate %25 DescriptorSet 0 + OpDecorate %25 Binding 1 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeInt 32 0 + %7 = OpTypeStruct %6 + %8 = OpTypePointer Uniform %7 + %9 = OpVariable %8 Uniform + %10 = OpTypeInt 32 1 + %11 = OpConstant %10 0 + %12 = OpTypePointer Uniform %6 + %23 = OpTypeStruct %6 + %24 = OpTypePointer Uniform %23 + %25 = OpVariable %24 Uniform + %28 = OpConstant %10 1 + %34 = OpConstant %6 2 + %52 = OpConstant %6 1 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %13 = OpAccessChain %12 %9 %11 + %14 = OpLoad %6 %13 + OpSelectionMerge %22 None + OpSwitch %14 %21 0 %15 1 %16 2 %17 3 %18 4 %19 5 %20 + %21 = OpLabel + %54 = OpAccessChain %12 %25 %11 + %55 = OpLoad %6 %54 + %56 = OpIAdd %6 %55 %34 + %57 = OpAccessChain %12 %25 %11 + OpStore %57 %56 + OpBranch %22 + %15 = OpLabel + %26 = OpAccessChain %12 %25 %11 + %27 = OpLoad %6 %26 + %29 = OpIAdd %6 %27 %28 + OpStore %26 %29 + OpBranch %22 + %16 = OpLabel + %31 = OpAccessChain %12 %25 %11 + %32 = OpLoad %6 %31 + %33 = OpISub %6 %32 %28 + OpStore %31 %33 + OpBranch %17 + %17 = OpLabel + %35 = OpAccessChain %12 %25 %11 + %36 = OpLoad %6 %35 + %37 = OpIMul %6 %36 %34 + %38 = OpAccessChain %12 %25 %11 + OpStore %38 %37 + OpBranch %22 + %18 = OpLabel + %40 = OpAccessChain %12 %25 %11 + %41 = OpLoad %6 %40 + %42 = OpUDiv %6 %41 %34 + %43 = OpAccessChain %12 %25 %11 + OpStore %43 %42 + OpBranch %22 + %19 = OpLabel + %45 = OpAccessChain %12 %25 %11 + %46 = OpLoad %6 %45 + %47 = OpAccessChain %12 %25 %11 + %48 = OpLoad %6 %47 + %49 = OpIMul %6 %46 %48 + %50 = OpAccessChain %12 %25 %11 + OpStore %50 %49 + OpBranch %22 + %20 = OpLabel + %53 = OpAccessChain %12 %25 %11 + OpStore %53 %52 + OpBranch %21 + %22 = OpLabel + OpReturn + OpFunctionEnd)"; +constexpr char kDst[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %7 "BufferIn" + OpMemberName %7 0 "i" + OpName %9 "" + OpName %23 "BufferOut" + OpMemberName %23 0 "o" + OpName %25 "" + OpMemberDecorate %7 0 Offset 0 + OpDecorate %7 Block + OpDecorate %9 DescriptorSet 0 + OpDecorate %9 Binding 0 + OpMemberDecorate %23 0 Offset 0 + OpDecorate %23 BufferBlock + OpDecorate %25 DescriptorSet 0 + OpDecorate %25 Binding 1 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeInt 32 0 + %7 = OpTypeStruct %6 + %8 = OpTypePointer Uniform %7 + %9 = OpVariable %8 Uniform + %10 = OpTypeInt 32 1 + %11 = OpConstant %10 0 + %12 = OpTypePointer Uniform %6 + %23 = OpTypeStruct %6 + %24 = OpTypePointer Uniform %23 + %25 = OpVariable %24 Uniform + %28 = OpConstant %10 1 + %34 = OpConstant %6 2 + %52 = OpConstant %6 1 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %13 = OpAccessChain %12 %9 %11 + %14 = OpLoad %6 %13 + OpSelectionMerge %22 None + OpSwitch %14 %21 0 %15 1 %16 2 %17 3 %18 4 %19 5 %20 + %17 = OpLabel + %35 = OpAccessChain %12 %25 %11 + %36 = OpLoad %6 %35 + %37 = OpIMul %6 %36 %34 + %38 = OpAccessChain %12 %25 %11 + OpStore %38 %37 + OpBranch %22 + %18 = OpLabel + %40 = OpAccessChain %12 %25 %11 + %41 = OpLoad %6 %40 + %42 = OpUDiv %6 %41 %34 + %43 = OpAccessChain %12 %25 %11 + OpStore %43 %42 + OpBranch %22 + %21 = OpLabel + %54 = OpAccessChain %12 %25 %11 + %55 = OpLoad %6 %54 + %56 = OpIAdd %6 %55 %34 + %57 = OpAccessChain %12 %25 %11 + OpStore %57 %56 + OpBranch %22 + %20 = OpLabel + %53 = OpAccessChain %12 %25 %11 + OpStore %53 %52 + OpBranch %21 + %15 = OpLabel + %26 = OpAccessChain %12 %25 %11 + %27 = OpLoad %6 %26 + %29 = OpIAdd %6 %27 %28 + OpStore %26 %29 + OpBranch %22 + %19 = OpLabel + %45 = OpAccessChain %12 %25 %11 + %46 = OpLoad %6 %45 + %47 = OpAccessChain %12 %25 %11 + %48 = OpLoad %6 %47 + %49 = OpIMul %6 %46 %48 + %50 = OpAccessChain %12 %25 %11 + OpStore %50 %49 + OpBranch %22 + %16 = OpLabel + %31 = OpAccessChain %12 %25 %11 + %32 = OpLoad %6 %31 + %33 = OpISub %6 %32 %28 + OpStore %31 %33 + OpBranch %17 + %22 = OpLabel + OpReturn + OpFunctionEnd +)"; + +TEST(DiffTest, ReorderedSwitchBlocks) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 58 ++; Bound: 62 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %7 "BufferIn" + OpMemberName %7 0 "i" + OpName %9 "" + OpName %23 "BufferOut" + OpMemberName %23 0 "o" + OpName %25 "" + OpMemberDecorate %7 0 Offset 0 + OpDecorate %7 Block + OpDecorate %9 DescriptorSet 0 + OpDecorate %9 Binding 0 + OpMemberDecorate %23 0 Offset 0 + OpDecorate %23 BufferBlock + OpDecorate %25 DescriptorSet 0 + OpDecorate %25 Binding 1 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeInt 32 0 + %7 = OpTypeStruct %6 + %8 = OpTypePointer Uniform %7 + %9 = OpVariable %8 Uniform + %10 = OpTypeInt 32 1 + %11 = OpConstant %10 0 + %12 = OpTypePointer Uniform %6 + %23 = OpTypeStruct %6 + %24 = OpTypePointer Uniform %23 + %25 = OpVariable %24 Uniform + %28 = OpConstant %10 1 + %34 = OpConstant %6 2 + %52 = OpConstant %6 1 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %13 = OpAccessChain %12 %9 %11 + %14 = OpLoad %6 %13 + OpSelectionMerge %22 None + OpSwitch %14 %21 0 %15 1 %16 2 %17 3 %18 4 %19 5 %20 + %20 = OpLabel + %53 = OpAccessChain %12 %25 %11 + OpStore %53 %52 + OpBranch %21 + %19 = OpLabel + %45 = OpAccessChain %12 %25 %11 + %46 = OpLoad %6 %45 + %47 = OpAccessChain %12 %25 %11 + %48 = OpLoad %6 %47 + %49 = OpIMul %6 %46 %48 + %50 = OpAccessChain %12 %25 %11 + OpStore %50 %49 + OpBranch %22 + %18 = OpLabel + %40 = OpAccessChain %12 %25 %11 + %41 = OpLoad %6 %40 + %42 = OpUDiv %6 %41 %34 + %43 = OpAccessChain %12 %25 %11 + OpStore %43 %42 + OpBranch %22 + %16 = OpLabel + %31 = OpAccessChain %12 %25 %11 + %32 = OpLoad %6 %31 + %33 = OpISub %6 %32 %28 + OpStore %31 %33 + OpBranch %17 + %17 = OpLabel + %35 = OpAccessChain %12 %25 %11 + %36 = OpLoad %6 %35 + %37 = OpIMul %6 %36 %34 + %38 = OpAccessChain %12 %25 %11 + OpStore %38 %37 + OpBranch %22 + %15 = OpLabel + %26 = OpAccessChain %12 %25 %11 + %27 = OpLoad %6 %26 + %29 = OpIAdd %6 %27 %28 + OpStore %26 %29 + OpBranch %22 + %21 = OpLabel + %54 = OpAccessChain %12 %25 %11 + %55 = OpLoad %6 %54 + %56 = OpIAdd %6 %55 %34 + %57 = OpAccessChain %12 %25 %11 + OpStore %57 %56 + OpBranch %22 + %22 = OpLabel + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, ReorderedSwitchBlocksNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpMemberDecorate %7 0 Offset 0 + OpDecorate %7 Block + OpDecorate %9 DescriptorSet 0 + OpDecorate %9 Binding 0 + OpMemberDecorate %23 0 Offset 0 + OpDecorate %23 BufferBlock + OpDecorate %25 DescriptorSet 0 + OpDecorate %25 Binding 1 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeInt 32 0 + %7 = OpTypeStruct %6 + %8 = OpTypePointer Uniform %7 + %9 = OpVariable %8 Uniform + %10 = OpTypeInt 32 1 + %11 = OpConstant %10 0 + %12 = OpTypePointer Uniform %6 + %23 = OpTypeStruct %6 + %24 = OpTypePointer Uniform %23 + %25 = OpVariable %24 Uniform + %28 = OpConstant %10 1 + %34 = OpConstant %6 2 + %52 = OpConstant %6 1 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %13 = OpAccessChain %12 %9 %11 + %14 = OpLoad %6 %13 + OpSelectionMerge %22 None + OpSwitch %14 %21 0 %15 1 %16 2 %17 3 %18 4 %19 5 %20 + %21 = OpLabel + %54 = OpAccessChain %12 %25 %11 + %55 = OpLoad %6 %54 + %56 = OpIAdd %6 %55 %34 + %57 = OpAccessChain %12 %25 %11 + OpStore %57 %56 + OpBranch %22 + %15 = OpLabel + %26 = OpAccessChain %12 %25 %11 + %27 = OpLoad %6 %26 + %29 = OpIAdd %6 %27 %28 + OpStore %26 %29 + OpBranch %22 + %16 = OpLabel + %31 = OpAccessChain %12 %25 %11 + %32 = OpLoad %6 %31 + %33 = OpISub %6 %32 %28 + OpStore %31 %33 + OpBranch %17 + %17 = OpLabel + %35 = OpAccessChain %12 %25 %11 + %36 = OpLoad %6 %35 + %37 = OpIMul %6 %36 %34 + %38 = OpAccessChain %12 %25 %11 + OpStore %38 %37 + OpBranch %22 + %18 = OpLabel + %40 = OpAccessChain %12 %25 %11 + %41 = OpLoad %6 %40 + %42 = OpUDiv %6 %41 %34 + %43 = OpAccessChain %12 %25 %11 + OpStore %43 %42 + OpBranch %22 + %19 = OpLabel + %45 = OpAccessChain %12 %25 %11 + %46 = OpLoad %6 %45 + %47 = OpAccessChain %12 %25 %11 + %48 = OpLoad %6 %47 + %49 = OpIMul %6 %46 %48 + %50 = OpAccessChain %12 %25 %11 + OpStore %50 %49 + OpBranch %22 + %20 = OpLabel + %53 = OpAccessChain %12 %25 %11 + OpStore %53 %52 + OpBranch %21 + %22 = OpLabel + OpReturn + OpFunctionEnd +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpMemberDecorate %7 0 Offset 0 + OpDecorate %7 Block + OpDecorate %9 DescriptorSet 0 + OpDecorate %9 Binding 0 + OpMemberDecorate %23 0 Offset 0 + OpDecorate %23 BufferBlock + OpDecorate %25 DescriptorSet 0 + OpDecorate %25 Binding 1 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeInt 32 0 + %7 = OpTypeStruct %6 + %8 = OpTypePointer Uniform %7 + %9 = OpVariable %8 Uniform + %10 = OpTypeInt 32 1 + %11 = OpConstant %10 0 + %12 = OpTypePointer Uniform %6 + %23 = OpTypeStruct %6 + %24 = OpTypePointer Uniform %23 + %25 = OpVariable %24 Uniform + %28 = OpConstant %10 1 + %34 = OpConstant %6 2 + %52 = OpConstant %6 1 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %13 = OpAccessChain %12 %9 %11 + %14 = OpLoad %6 %13 + OpSelectionMerge %22 None + OpSwitch %14 %21 0 %15 1 %16 2 %17 3 %18 4 %19 5 %20 + %17 = OpLabel + %35 = OpAccessChain %12 %25 %11 + %36 = OpLoad %6 %35 + %37 = OpIMul %6 %36 %34 + %38 = OpAccessChain %12 %25 %11 + OpStore %38 %37 + OpBranch %22 + %18 = OpLabel + %40 = OpAccessChain %12 %25 %11 + %41 = OpLoad %6 %40 + %42 = OpUDiv %6 %41 %34 + %43 = OpAccessChain %12 %25 %11 + OpStore %43 %42 + OpBranch %22 + %21 = OpLabel + %54 = OpAccessChain %12 %25 %11 + %55 = OpLoad %6 %54 + %56 = OpIAdd %6 %55 %34 + %57 = OpAccessChain %12 %25 %11 + OpStore %57 %56 + OpBranch %22 + %20 = OpLabel + %53 = OpAccessChain %12 %25 %11 + OpStore %53 %52 + OpBranch %21 + %15 = OpLabel + %26 = OpAccessChain %12 %25 %11 + %27 = OpLoad %6 %26 + %29 = OpIAdd %6 %27 %28 + OpStore %26 %29 + OpBranch %22 + %19 = OpLabel + %45 = OpAccessChain %12 %25 %11 + %46 = OpLoad %6 %45 + %47 = OpAccessChain %12 %25 %11 + %48 = OpLoad %6 %47 + %49 = OpIMul %6 %46 %48 + %50 = OpAccessChain %12 %25 %11 + OpStore %50 %49 + OpBranch %22 + %16 = OpLabel + %31 = OpAccessChain %12 %25 %11 + %32 = OpLoad %6 %31 + %33 = OpISub %6 %32 %28 + OpStore %31 %33 + OpBranch %17 + %22 = OpLabel + OpReturn + OpFunctionEnd +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 58 ++; Bound: 62 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpMemberDecorate %7 0 Offset 0 + OpDecorate %7 Block + OpDecorate %9 DescriptorSet 0 + OpDecorate %9 Binding 0 + OpMemberDecorate %23 0 Offset 0 + OpDecorate %23 BufferBlock + OpDecorate %25 DescriptorSet 0 + OpDecorate %25 Binding 1 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeInt 32 0 + %7 = OpTypeStruct %6 + %8 = OpTypePointer Uniform %7 + %9 = OpVariable %8 Uniform + %10 = OpTypeInt 32 1 + %11 = OpConstant %10 0 + %12 = OpTypePointer Uniform %6 + %23 = OpTypeStruct %6 + %24 = OpTypePointer Uniform %23 + %25 = OpVariable %24 Uniform + %28 = OpConstant %10 1 + %34 = OpConstant %6 2 + %52 = OpConstant %6 1 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %13 = OpAccessChain %12 %9 %11 + %14 = OpLoad %6 %13 + OpSelectionMerge %22 None + OpSwitch %14 %21 0 %15 1 %16 2 %17 3 %18 4 %19 5 %20 + %20 = OpLabel + %53 = OpAccessChain %12 %25 %11 + OpStore %53 %52 + OpBranch %21 + %19 = OpLabel + %45 = OpAccessChain %12 %25 %11 + %46 = OpLoad %6 %45 + %47 = OpAccessChain %12 %25 %11 + %48 = OpLoad %6 %47 + %49 = OpIMul %6 %46 %48 + %50 = OpAccessChain %12 %25 %11 + OpStore %50 %49 + OpBranch %22 + %18 = OpLabel + %40 = OpAccessChain %12 %25 %11 + %41 = OpLoad %6 %40 + %42 = OpUDiv %6 %41 %34 + %43 = OpAccessChain %12 %25 %11 + OpStore %43 %42 + OpBranch %22 + %16 = OpLabel + %31 = OpAccessChain %12 %25 %11 + %32 = OpLoad %6 %31 + %33 = OpISub %6 %32 %28 + OpStore %31 %33 + OpBranch %17 + %17 = OpLabel + %35 = OpAccessChain %12 %25 %11 + %36 = OpLoad %6 %35 + %37 = OpIMul %6 %36 %34 + %38 = OpAccessChain %12 %25 %11 + OpStore %38 %37 + OpBranch %22 + %15 = OpLabel + %26 = OpAccessChain %12 %25 %11 + %27 = OpLoad %6 %26 + %29 = OpIAdd %6 %27 %28 + OpStore %26 %29 + OpBranch %22 + %21 = OpLabel + %54 = OpAccessChain %12 %25 %11 + %55 = OpLoad %6 %54 + %56 = OpIAdd %6 %55 %34 + %57 = OpAccessChain %12 %25 %11 + OpStore %57 %56 + OpBranch %22 + %22 = OpLabel + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/reordered_switch_blocks_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/reordered_switch_blocks_dst.spvasm new file mode 100644 index 0000000000..8eabb4efa4 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/reordered_switch_blocks_dst.spvasm @@ -0,0 +1,91 @@ + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %7 "BufferIn" + OpMemberName %7 0 "i" + OpName %9 "" + OpName %23 "BufferOut" + OpMemberName %23 0 "o" + OpName %25 "" + OpMemberDecorate %7 0 Offset 0 + OpDecorate %7 Block + OpDecorate %9 DescriptorSet 0 + OpDecorate %9 Binding 0 + OpMemberDecorate %23 0 Offset 0 + OpDecorate %23 BufferBlock + OpDecorate %25 DescriptorSet 0 + OpDecorate %25 Binding 1 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeInt 32 0 + %7 = OpTypeStruct %6 + %8 = OpTypePointer Uniform %7 + %9 = OpVariable %8 Uniform + %10 = OpTypeInt 32 1 + %11 = OpConstant %10 0 + %12 = OpTypePointer Uniform %6 + %23 = OpTypeStruct %6 + %24 = OpTypePointer Uniform %23 + %25 = OpVariable %24 Uniform + %28 = OpConstant %10 1 + %34 = OpConstant %6 2 + %52 = OpConstant %6 1 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %13 = OpAccessChain %12 %9 %11 + %14 = OpLoad %6 %13 + OpSelectionMerge %22 None + OpSwitch %14 %21 0 %15 1 %16 2 %17 3 %18 4 %19 5 %20 + %17 = OpLabel + %35 = OpAccessChain %12 %25 %11 + %36 = OpLoad %6 %35 + %37 = OpIMul %6 %36 %34 + %38 = OpAccessChain %12 %25 %11 + OpStore %38 %37 + OpBranch %22 + %18 = OpLabel + %40 = OpAccessChain %12 %25 %11 + %41 = OpLoad %6 %40 + %42 = OpUDiv %6 %41 %34 + %43 = OpAccessChain %12 %25 %11 + OpStore %43 %42 + OpBranch %22 + %21 = OpLabel + %54 = OpAccessChain %12 %25 %11 + %55 = OpLoad %6 %54 + %56 = OpIAdd %6 %55 %34 + %57 = OpAccessChain %12 %25 %11 + OpStore %57 %56 + OpBranch %22 + %20 = OpLabel + %53 = OpAccessChain %12 %25 %11 + OpStore %53 %52 + OpBranch %21 + %15 = OpLabel + %26 = OpAccessChain %12 %25 %11 + %27 = OpLoad %6 %26 + %29 = OpIAdd %6 %27 %28 + OpStore %26 %29 + OpBranch %22 + %19 = OpLabel + %45 = OpAccessChain %12 %25 %11 + %46 = OpLoad %6 %45 + %47 = OpAccessChain %12 %25 %11 + %48 = OpLoad %6 %47 + %49 = OpIMul %6 %46 %48 + %50 = OpAccessChain %12 %25 %11 + OpStore %50 %49 + OpBranch %22 + %16 = OpLabel + %31 = OpAccessChain %12 %25 %11 + %32 = OpLoad %6 %31 + %33 = OpISub %6 %32 %28 + OpStore %31 %33 + OpBranch %17 + %22 = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/reordered_switch_blocks_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/reordered_switch_blocks_src.spvasm new file mode 100644 index 0000000000..e377228203 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/reordered_switch_blocks_src.spvasm @@ -0,0 +1,92 @@ +;; Test where src and dst have cases of a switch in different order. + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %7 "BufferIn" + OpMemberName %7 0 "i" + OpName %9 "" + OpName %23 "BufferOut" + OpMemberName %23 0 "o" + OpName %25 "" + OpMemberDecorate %7 0 Offset 0 + OpDecorate %7 Block + OpDecorate %9 DescriptorSet 0 + OpDecorate %9 Binding 0 + OpMemberDecorate %23 0 Offset 0 + OpDecorate %23 BufferBlock + OpDecorate %25 DescriptorSet 0 + OpDecorate %25 Binding 1 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeInt 32 0 + %7 = OpTypeStruct %6 + %8 = OpTypePointer Uniform %7 + %9 = OpVariable %8 Uniform + %10 = OpTypeInt 32 1 + %11 = OpConstant %10 0 + %12 = OpTypePointer Uniform %6 + %23 = OpTypeStruct %6 + %24 = OpTypePointer Uniform %23 + %25 = OpVariable %24 Uniform + %28 = OpConstant %10 1 + %34 = OpConstant %6 2 + %52 = OpConstant %6 1 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %13 = OpAccessChain %12 %9 %11 + %14 = OpLoad %6 %13 + OpSelectionMerge %22 None + OpSwitch %14 %21 0 %15 1 %16 2 %17 3 %18 4 %19 5 %20 + %21 = OpLabel + %54 = OpAccessChain %12 %25 %11 + %55 = OpLoad %6 %54 + %56 = OpIAdd %6 %55 %34 + %57 = OpAccessChain %12 %25 %11 + OpStore %57 %56 + OpBranch %22 + %15 = OpLabel + %26 = OpAccessChain %12 %25 %11 + %27 = OpLoad %6 %26 + %29 = OpIAdd %6 %27 %28 + OpStore %26 %29 + OpBranch %22 + %16 = OpLabel + %31 = OpAccessChain %12 %25 %11 + %32 = OpLoad %6 %31 + %33 = OpISub %6 %32 %28 + OpStore %31 %33 + OpBranch %17 + %17 = OpLabel + %35 = OpAccessChain %12 %25 %11 + %36 = OpLoad %6 %35 + %37 = OpIMul %6 %36 %34 + %38 = OpAccessChain %12 %25 %11 + OpStore %38 %37 + OpBranch %22 + %18 = OpLabel + %40 = OpAccessChain %12 %25 %11 + %41 = OpLoad %6 %40 + %42 = OpUDiv %6 %41 %34 + %43 = OpAccessChain %12 %25 %11 + OpStore %43 %42 + OpBranch %22 + %19 = OpLabel + %45 = OpAccessChain %12 %25 %11 + %46 = OpLoad %6 %45 + %47 = OpAccessChain %12 %25 %11 + %48 = OpLoad %6 %47 + %49 = OpIMul %6 %46 %48 + %50 = OpAccessChain %12 %25 %11 + OpStore %50 %49 + OpBranch %22 + %20 = OpLabel + %53 = OpAccessChain %12 %25 %11 + OpStore %53 %52 + OpBranch %21 + %22 = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/small_functions_small_diffs_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/small_functions_small_diffs_autogen.cpp new file mode 100644 index 0000000000..c1a91009cd --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/small_functions_small_diffs_autogen.cpp @@ -0,0 +1,747 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Test where src and dst have many small functions with small differences. +constexpr char kSrc[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %6 "f1(" + OpName %8 "f2(" + OpName %10 "f3(" + OpName %12 "f4(" + OpName %14 "f5(" + OpName %17 "BufferOut" + OpMemberName %17 0 "o" + OpName %19 "" + OpName %22 "BufferIn" + OpMemberName %22 0 "i" + OpName %24 "" + OpMemberDecorate %17 0 Offset 0 + OpDecorate %17 BufferBlock + OpDecorate %19 DescriptorSet 0 + OpDecorate %19 Binding 1 + OpMemberDecorate %22 0 Offset 0 + OpDecorate %22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %16 = OpTypeInt 32 0 + %17 = OpTypeStruct %16 + %18 = OpTypePointer Uniform %17 + %19 = OpVariable %18 Uniform + %20 = OpTypeInt 32 1 + %21 = OpConstant %20 0 + %22 = OpTypeStruct %16 + %23 = OpTypePointer Uniform %22 + %24 = OpVariable %23 Uniform + %25 = OpTypePointer Uniform %16 + %31 = OpConstant %20 1 + %36 = OpConstant %16 2 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %45 = OpFunctionCall %2 %6 + %46 = OpFunctionCall %2 %8 + %47 = OpFunctionCall %2 %10 + %48 = OpFunctionCall %2 %12 + %49 = OpFunctionCall %2 %14 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %26 = OpAccessChain %25 %24 %21 + %27 = OpLoad %16 %26 + %28 = OpAccessChain %25 %19 %21 + OpStore %28 %27 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %29 = OpAccessChain %25 %19 %21 + %30 = OpLoad %16 %29 + %32 = OpIAdd %16 %30 %31 + OpStore %29 %32 + OpReturn + OpFunctionEnd + %10 = OpFunction %2 None %3 + %11 = OpLabel + %33 = OpAccessChain %25 %19 %21 + %34 = OpLoad %16 %33 + %35 = OpISub %16 %34 %31 + OpStore %33 %35 + OpReturn + OpFunctionEnd + %12 = OpFunction %2 None %3 + %13 = OpLabel + %37 = OpAccessChain %25 %19 %21 + %38 = OpLoad %16 %37 + %39 = OpIMul %16 %38 %36 + %40 = OpAccessChain %25 %19 %21 + OpStore %40 %39 + OpReturn + OpFunctionEnd + %14 = OpFunction %2 None %3 + %15 = OpLabel + %41 = OpAccessChain %25 %19 %21 + %42 = OpLoad %16 %41 + %43 = OpUDiv %16 %42 %36 + %44 = OpAccessChain %25 %19 %21 + OpStore %44 %43 + OpReturn + OpFunctionEnd +)"; +constexpr char kDst[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %6 "f1(" + OpName %8 "f2(" + OpName %10 "f3(" + OpName %12 "f4(" + OpName %14 "f5(" + OpName %17 "BufferOut" + OpMemberName %17 0 "o" + OpName %19 "" + OpName %22 "BufferIn" + OpMemberName %22 0 "i" + OpName %24 "" + OpMemberDecorate %17 0 Offset 0 + OpDecorate %17 BufferBlock + OpDecorate %19 DescriptorSet 0 + OpDecorate %19 Binding 1 + OpMemberDecorate %22 0 Offset 0 + OpDecorate %22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %16 = OpTypeInt 32 0 + %17 = OpTypeStruct %16 + %18 = OpTypePointer Uniform %17 + %19 = OpVariable %18 Uniform + %20 = OpTypeInt 32 1 + %21 = OpConstant %20 0 + %22 = OpTypeStruct %16 + %23 = OpTypePointer Uniform %22 + %24 = OpVariable %23 Uniform + %25 = OpTypePointer Uniform %16 + %31 = OpConstant %20 1 + %36 = OpConstant %16 2 + %6 = OpFunction %2 None %3 + %7 = OpLabel + %26 = OpAccessChain %25 %24 %21 + %27 = OpLoad %16 %26 + %28 = OpAccessChain %25 %19 %21 + OpStore %28 %27 + OpReturn + OpFunctionEnd + %14 = OpFunction %2 None %3 + %15 = OpLabel + %41 = OpAccessChain %25 %19 %21 + %42 = OpLoad %16 %41 + %43 = OpIAdd %16 %42 %36 + %44 = OpAccessChain %25 %19 %21 + OpStore %44 %43 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %29 = OpAccessChain %25 %19 %21 + %30 = OpLoad %16 %29 + %32 = OpISub %16 %30 %31 + OpStore %29 %32 + OpReturn + OpFunctionEnd + %10 = OpFunction %2 None %3 + %11 = OpLabel + %33 = OpAccessChain %25 %19 %21 + %34 = OpLoad %16 %33 + %35 = OpIAdd %16 %34 %31 + OpStore %33 %35 + OpReturn + OpFunctionEnd + %4 = OpFunction %2 None %3 + %5 = OpLabel + %45 = OpFunctionCall %2 %6 + %46 = OpFunctionCall %2 %8 + %47 = OpFunctionCall %2 %10 + %48 = OpFunctionCall %2 %12 + %49 = OpFunctionCall %2 %14 + OpReturn + OpFunctionEnd + %12 = OpFunction %2 None %3 + %13 = OpLabel + %37 = OpAccessChain %25 %19 %21 + %38 = OpLoad %16 %37 + %39 = OpISub %16 %38 %36 + %40 = OpAccessChain %25 %19 %21 + OpStore %40 %39 + OpReturn + OpFunctionEnd + +)"; + +TEST(DiffTest, SmallFunctionsSmallDiffs) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 50 ++; Bound: 54 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %6 "f1(" + OpName %8 "f2(" + OpName %10 "f3(" + OpName %12 "f4(" + OpName %14 "f5(" + OpName %17 "BufferOut" + OpMemberName %17 0 "o" + OpName %19 "" + OpName %22 "BufferIn" + OpMemberName %22 0 "i" + OpName %24 "" + OpMemberDecorate %17 0 Offset 0 + OpDecorate %17 BufferBlock + OpDecorate %19 DescriptorSet 0 + OpDecorate %19 Binding 1 + OpMemberDecorate %22 0 Offset 0 + OpDecorate %22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %16 = OpTypeInt 32 0 + %17 = OpTypeStruct %16 + %18 = OpTypePointer Uniform %17 + %19 = OpVariable %18 Uniform + %20 = OpTypeInt 32 1 + %21 = OpConstant %20 0 + %22 = OpTypeStruct %16 + %23 = OpTypePointer Uniform %22 + %24 = OpVariable %23 Uniform + %25 = OpTypePointer Uniform %16 + %31 = OpConstant %20 1 + %36 = OpConstant %16 2 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %45 = OpFunctionCall %2 %6 + %46 = OpFunctionCall %2 %8 + %47 = OpFunctionCall %2 %10 + %48 = OpFunctionCall %2 %12 + %49 = OpFunctionCall %2 %14 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %26 = OpAccessChain %25 %24 %21 + %27 = OpLoad %16 %26 + %28 = OpAccessChain %25 %19 %21 + OpStore %28 %27 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %29 = OpAccessChain %25 %19 %21 + %30 = OpLoad %16 %29 +-%32 = OpIAdd %16 %30 %31 ++%50 = OpISub %16 %30 %31 +-OpStore %29 %32 ++OpStore %29 %50 + OpReturn + OpFunctionEnd + %10 = OpFunction %2 None %3 + %11 = OpLabel + %33 = OpAccessChain %25 %19 %21 + %34 = OpLoad %16 %33 +-%35 = OpISub %16 %34 %31 ++%51 = OpIAdd %16 %34 %31 +-OpStore %33 %35 ++OpStore %33 %51 + OpReturn + OpFunctionEnd + %12 = OpFunction %2 None %3 + %13 = OpLabel + %37 = OpAccessChain %25 %19 %21 + %38 = OpLoad %16 %37 +-%39 = OpIMul %16 %38 %36 ++%52 = OpISub %16 %38 %36 + %40 = OpAccessChain %25 %19 %21 +-OpStore %40 %39 ++OpStore %40 %52 + OpReturn + OpFunctionEnd + %14 = OpFunction %2 None %3 + %15 = OpLabel + %41 = OpAccessChain %25 %19 %21 + %42 = OpLoad %16 %41 +-%43 = OpUDiv %16 %42 %36 ++%53 = OpIAdd %16 %42 %36 + %44 = OpAccessChain %25 %19 %21 +-OpStore %44 %43 ++OpStore %44 %53 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, SmallFunctionsSmallDiffsNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpMemberDecorate %17 0 Offset 0 + OpDecorate %17 BufferBlock + OpDecorate %19 DescriptorSet 0 + OpDecorate %19 Binding 1 + OpMemberDecorate %22 0 Offset 0 + OpDecorate %22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %16 = OpTypeInt 32 0 + %17 = OpTypeStruct %16 + %18 = OpTypePointer Uniform %17 + %19 = OpVariable %18 Uniform + %20 = OpTypeInt 32 1 + %21 = OpConstant %20 0 + %22 = OpTypeStruct %16 + %23 = OpTypePointer Uniform %22 + %24 = OpVariable %23 Uniform + %25 = OpTypePointer Uniform %16 + %31 = OpConstant %20 1 + %36 = OpConstant %16 2 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %45 = OpFunctionCall %2 %6 + %46 = OpFunctionCall %2 %8 + %47 = OpFunctionCall %2 %10 + %48 = OpFunctionCall %2 %12 + %49 = OpFunctionCall %2 %14 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %26 = OpAccessChain %25 %24 %21 + %27 = OpLoad %16 %26 + %28 = OpAccessChain %25 %19 %21 + OpStore %28 %27 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %29 = OpAccessChain %25 %19 %21 + %30 = OpLoad %16 %29 + %32 = OpIAdd %16 %30 %31 + OpStore %29 %32 + OpReturn + OpFunctionEnd + %10 = OpFunction %2 None %3 + %11 = OpLabel + %33 = OpAccessChain %25 %19 %21 + %34 = OpLoad %16 %33 + %35 = OpISub %16 %34 %31 + OpStore %33 %35 + OpReturn + OpFunctionEnd + %12 = OpFunction %2 None %3 + %13 = OpLabel + %37 = OpAccessChain %25 %19 %21 + %38 = OpLoad %16 %37 + %39 = OpIMul %16 %38 %36 + %40 = OpAccessChain %25 %19 %21 + OpStore %40 %39 + OpReturn + OpFunctionEnd + %14 = OpFunction %2 None %3 + %15 = OpLabel + %41 = OpAccessChain %25 %19 %21 + %42 = OpLoad %16 %41 + %43 = OpUDiv %16 %42 %36 + %44 = OpAccessChain %25 %19 %21 + OpStore %44 %43 + OpReturn + OpFunctionEnd + +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpMemberDecorate %17 0 Offset 0 + OpDecorate %17 BufferBlock + OpDecorate %19 DescriptorSet 0 + OpDecorate %19 Binding 1 + OpMemberDecorate %22 0 Offset 0 + OpDecorate %22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %16 = OpTypeInt 32 0 + %17 = OpTypeStruct %16 + %18 = OpTypePointer Uniform %17 + %19 = OpVariable %18 Uniform + %20 = OpTypeInt 32 1 + %21 = OpConstant %20 0 + %22 = OpTypeStruct %16 + %23 = OpTypePointer Uniform %22 + %24 = OpVariable %23 Uniform + %25 = OpTypePointer Uniform %16 + %31 = OpConstant %20 1 + %36 = OpConstant %16 2 + %6 = OpFunction %2 None %3 + %7 = OpLabel + %26 = OpAccessChain %25 %24 %21 + %27 = OpLoad %16 %26 + %28 = OpAccessChain %25 %19 %21 + OpStore %28 %27 + OpReturn + OpFunctionEnd + %14 = OpFunction %2 None %3 + %15 = OpLabel + %41 = OpAccessChain %25 %19 %21 + %42 = OpLoad %16 %41 + %43 = OpIAdd %16 %42 %36 + %44 = OpAccessChain %25 %19 %21 + OpStore %44 %43 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %29 = OpAccessChain %25 %19 %21 + %30 = OpLoad %16 %29 + %32 = OpISub %16 %30 %31 + OpStore %29 %32 + OpReturn + OpFunctionEnd + %10 = OpFunction %2 None %3 + %11 = OpLabel + %33 = OpAccessChain %25 %19 %21 + %34 = OpLoad %16 %33 + %35 = OpIAdd %16 %34 %31 + OpStore %33 %35 + OpReturn + OpFunctionEnd + %4 = OpFunction %2 None %3 + %5 = OpLabel + %45 = OpFunctionCall %2 %6 + %46 = OpFunctionCall %2 %8 + %47 = OpFunctionCall %2 %10 + %48 = OpFunctionCall %2 %12 + %49 = OpFunctionCall %2 %14 + OpReturn + OpFunctionEnd + %12 = OpFunction %2 None %3 + %13 = OpLabel + %37 = OpAccessChain %25 %19 %21 + %38 = OpLoad %16 %37 + %39 = OpISub %16 %38 %36 + %40 = OpAccessChain %25 %19 %21 + OpStore %40 %39 + OpReturn + OpFunctionEnd + +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 50 ++; Bound: 52 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpMemberDecorate %17 0 Offset 0 + OpDecorate %17 BufferBlock + OpDecorate %19 DescriptorSet 0 + OpDecorate %19 Binding 1 + OpMemberDecorate %22 0 Offset 0 + OpDecorate %22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %16 = OpTypeInt 32 0 + %17 = OpTypeStruct %16 + %18 = OpTypePointer Uniform %17 + %19 = OpVariable %18 Uniform + %20 = OpTypeInt 32 1 + %21 = OpConstant %20 0 + %22 = OpTypeStruct %16 + %23 = OpTypePointer Uniform %22 + %24 = OpVariable %23 Uniform + %25 = OpTypePointer Uniform %16 + %31 = OpConstant %20 1 + %36 = OpConstant %16 2 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %45 = OpFunctionCall %2 %6 +-%46 = OpFunctionCall %2 %8 ++%46 = OpFunctionCall %2 %10 +-%47 = OpFunctionCall %2 %10 ++%47 = OpFunctionCall %2 %8 + %48 = OpFunctionCall %2 %12 + %49 = OpFunctionCall %2 %14 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %26 = OpAccessChain %25 %24 %21 + %27 = OpLoad %16 %26 + %28 = OpAccessChain %25 %19 %21 + OpStore %28 %27 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %29 = OpAccessChain %25 %19 %21 + %30 = OpLoad %16 %29 + %32 = OpIAdd %16 %30 %31 + OpStore %29 %32 + OpReturn + OpFunctionEnd + %10 = OpFunction %2 None %3 + %11 = OpLabel + %33 = OpAccessChain %25 %19 %21 + %34 = OpLoad %16 %33 + %35 = OpISub %16 %34 %31 + OpStore %33 %35 + OpReturn + OpFunctionEnd + %12 = OpFunction %2 None %3 + %13 = OpLabel + %37 = OpAccessChain %25 %19 %21 + %38 = OpLoad %16 %37 +-%39 = OpIMul %16 %38 %36 ++%50 = OpISub %16 %38 %36 + %40 = OpAccessChain %25 %19 %21 +-OpStore %40 %39 ++OpStore %40 %50 + OpReturn + OpFunctionEnd + %14 = OpFunction %2 None %3 + %15 = OpLabel + %41 = OpAccessChain %25 %19 %21 + %42 = OpLoad %16 %41 +-%43 = OpUDiv %16 %42 %36 ++%51 = OpIAdd %16 %42 %36 + %44 = OpAccessChain %25 %19 %21 +-OpStore %44 %43 ++OpStore %44 %51 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +TEST(DiffTest, SmallFunctionsSmallDiffsDumpIds) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 50 ++; Bound: 54 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %6 "f1(" + OpName %8 "f2(" + OpName %10 "f3(" + OpName %12 "f4(" + OpName %14 "f5(" + OpName %17 "BufferOut" + OpMemberName %17 0 "o" + OpName %19 "" + OpName %22 "BufferIn" + OpMemberName %22 0 "i" + OpName %24 "" + OpMemberDecorate %17 0 Offset 0 + OpDecorate %17 BufferBlock + OpDecorate %19 DescriptorSet 0 + OpDecorate %19 Binding 1 + OpMemberDecorate %22 0 Offset 0 + OpDecorate %22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %16 = OpTypeInt 32 0 + %17 = OpTypeStruct %16 + %18 = OpTypePointer Uniform %17 + %19 = OpVariable %18 Uniform + %20 = OpTypeInt 32 1 + %21 = OpConstant %20 0 + %22 = OpTypeStruct %16 + %23 = OpTypePointer Uniform %22 + %24 = OpVariable %23 Uniform + %25 = OpTypePointer Uniform %16 + %31 = OpConstant %20 1 + %36 = OpConstant %16 2 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %45 = OpFunctionCall %2 %6 + %46 = OpFunctionCall %2 %8 + %47 = OpFunctionCall %2 %10 + %48 = OpFunctionCall %2 %12 + %49 = OpFunctionCall %2 %14 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %26 = OpAccessChain %25 %24 %21 + %27 = OpLoad %16 %26 + %28 = OpAccessChain %25 %19 %21 + OpStore %28 %27 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %29 = OpAccessChain %25 %19 %21 + %30 = OpLoad %16 %29 +-%32 = OpIAdd %16 %30 %31 ++%50 = OpISub %16 %30 %31 +-OpStore %29 %32 ++OpStore %29 %50 + OpReturn + OpFunctionEnd + %10 = OpFunction %2 None %3 + %11 = OpLabel + %33 = OpAccessChain %25 %19 %21 + %34 = OpLoad %16 %33 +-%35 = OpISub %16 %34 %31 ++%51 = OpIAdd %16 %34 %31 +-OpStore %33 %35 ++OpStore %33 %51 + OpReturn + OpFunctionEnd + %12 = OpFunction %2 None %3 + %13 = OpLabel + %37 = OpAccessChain %25 %19 %21 + %38 = OpLoad %16 %37 +-%39 = OpIMul %16 %38 %36 ++%52 = OpISub %16 %38 %36 + %40 = OpAccessChain %25 %19 %21 +-OpStore %40 %39 ++OpStore %40 %52 + OpReturn + OpFunctionEnd + %14 = OpFunction %2 None %3 + %15 = OpLabel + %41 = OpAccessChain %25 %19 %21 + %42 = OpLoad %16 %41 +-%43 = OpUDiv %16 %42 %36 ++%53 = OpIAdd %16 %42 %36 + %44 = OpAccessChain %25 %19 %21 +-OpStore %44 %43 ++OpStore %44 %53 + OpReturn + OpFunctionEnd + Src -> Dst + 1 -> 1 [ExtInstImport] + 2 -> 2 [TypeVoid] + 3 -> 3 [TypeFunction] + 4 -> 4 [Function] + 5 -> 5 [Label] + 6 -> 6 [Function] + 7 -> 7 [Label] + 8 -> 8 [Function] + 9 -> 9 [Label] + 10 -> 10 [Function] + 11 -> 11 [Label] + 12 -> 12 [Function] + 13 -> 13 [Label] + 14 -> 14 [Function] + 15 -> 15 [Label] + 16 -> 16 [TypeInt] + 17 -> 17 [TypeStruct] + 18 -> 18 [TypePointer] + 19 -> 19 [Variable] + 20 -> 20 [TypeInt] + 21 -> 21 [Constant] + 22 -> 22 [TypeStruct] + 23 -> 23 [TypePointer] + 24 -> 24 [Variable] + 25 -> 25 [TypePointer] + 26 -> 26 [AccessChain] + 27 -> 27 [Load] + 28 -> 28 [AccessChain] + 29 -> 29 [AccessChain] + 30 -> 30 [Load] + 31 -> 31 [Constant] + 32 -> 50 [IAdd] + 33 -> 33 [AccessChain] + 34 -> 34 [Load] + 35 -> 51 [ISub] + 36 -> 36 [Constant] + 37 -> 37 [AccessChain] + 38 -> 38 [Load] + 39 -> 52 [IMul] + 40 -> 40 [AccessChain] + 41 -> 41 [AccessChain] + 42 -> 42 [Load] + 43 -> 53 [UDiv] + 44 -> 44 [AccessChain] + 45 -> 45 [FunctionCall] + 46 -> 46 [FunctionCall] + 47 -> 47 [FunctionCall] + 48 -> 48 [FunctionCall] + 49 -> 49 [FunctionCall] +)"; + Options options; + options.dump_id_map = true; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/small_functions_small_diffs_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/small_functions_small_diffs_dst.spvasm new file mode 100644 index 0000000000..fabf5692a8 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/small_functions_small_diffs_dst.spvasm @@ -0,0 +1,92 @@ + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %6 "f1(" + OpName %8 "f2(" + OpName %10 "f3(" + OpName %12 "f4(" + OpName %14 "f5(" + OpName %17 "BufferOut" + OpMemberName %17 0 "o" + OpName %19 "" + OpName %22 "BufferIn" + OpMemberName %22 0 "i" + OpName %24 "" + OpMemberDecorate %17 0 Offset 0 + OpDecorate %17 BufferBlock + OpDecorate %19 DescriptorSet 0 + OpDecorate %19 Binding 1 + OpMemberDecorate %22 0 Offset 0 + OpDecorate %22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %16 = OpTypeInt 32 0 + %17 = OpTypeStruct %16 + %18 = OpTypePointer Uniform %17 + %19 = OpVariable %18 Uniform + %20 = OpTypeInt 32 1 + %21 = OpConstant %20 0 + %22 = OpTypeStruct %16 + %23 = OpTypePointer Uniform %22 + %24 = OpVariable %23 Uniform + %25 = OpTypePointer Uniform %16 + %31 = OpConstant %20 1 + %36 = OpConstant %16 2 + %6 = OpFunction %2 None %3 + %7 = OpLabel + %26 = OpAccessChain %25 %24 %21 + %27 = OpLoad %16 %26 + %28 = OpAccessChain %25 %19 %21 + OpStore %28 %27 + OpReturn + OpFunctionEnd + %14 = OpFunction %2 None %3 + %15 = OpLabel + %41 = OpAccessChain %25 %19 %21 + %42 = OpLoad %16 %41 + %43 = OpIAdd %16 %42 %36 + %44 = OpAccessChain %25 %19 %21 + OpStore %44 %43 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %29 = OpAccessChain %25 %19 %21 + %30 = OpLoad %16 %29 + %32 = OpISub %16 %30 %31 + OpStore %29 %32 + OpReturn + OpFunctionEnd + %10 = OpFunction %2 None %3 + %11 = OpLabel + %33 = OpAccessChain %25 %19 %21 + %34 = OpLoad %16 %33 + %35 = OpIAdd %16 %34 %31 + OpStore %33 %35 + OpReturn + OpFunctionEnd + %4 = OpFunction %2 None %3 + %5 = OpLabel + %45 = OpFunctionCall %2 %6 + %46 = OpFunctionCall %2 %8 + %47 = OpFunctionCall %2 %10 + %48 = OpFunctionCall %2 %12 + %49 = OpFunctionCall %2 %14 + OpReturn + OpFunctionEnd + %12 = OpFunction %2 None %3 + %13 = OpLabel + %37 = OpAccessChain %25 %19 %21 + %38 = OpLoad %16 %37 + %39 = OpISub %16 %38 %36 + %40 = OpAccessChain %25 %19 %21 + OpStore %40 %39 + OpReturn + OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/small_functions_small_diffs_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/small_functions_small_diffs_src.spvasm new file mode 100644 index 0000000000..895285b19c --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/small_functions_small_diffs_src.spvasm @@ -0,0 +1,93 @@ +;; Test where src and dst have many small functions with small differences. + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %6 "f1(" + OpName %8 "f2(" + OpName %10 "f3(" + OpName %12 "f4(" + OpName %14 "f5(" + OpName %17 "BufferOut" + OpMemberName %17 0 "o" + OpName %19 "" + OpName %22 "BufferIn" + OpMemberName %22 0 "i" + OpName %24 "" + OpMemberDecorate %17 0 Offset 0 + OpDecorate %17 BufferBlock + OpDecorate %19 DescriptorSet 0 + OpDecorate %19 Binding 1 + OpMemberDecorate %22 0 Offset 0 + OpDecorate %22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %16 = OpTypeInt 32 0 + %17 = OpTypeStruct %16 + %18 = OpTypePointer Uniform %17 + %19 = OpVariable %18 Uniform + %20 = OpTypeInt 32 1 + %21 = OpConstant %20 0 + %22 = OpTypeStruct %16 + %23 = OpTypePointer Uniform %22 + %24 = OpVariable %23 Uniform + %25 = OpTypePointer Uniform %16 + %31 = OpConstant %20 1 + %36 = OpConstant %16 2 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %45 = OpFunctionCall %2 %6 + %46 = OpFunctionCall %2 %8 + %47 = OpFunctionCall %2 %10 + %48 = OpFunctionCall %2 %12 + %49 = OpFunctionCall %2 %14 + OpReturn + OpFunctionEnd + %6 = OpFunction %2 None %3 + %7 = OpLabel + %26 = OpAccessChain %25 %24 %21 + %27 = OpLoad %16 %26 + %28 = OpAccessChain %25 %19 %21 + OpStore %28 %27 + OpReturn + OpFunctionEnd + %8 = OpFunction %2 None %3 + %9 = OpLabel + %29 = OpAccessChain %25 %19 %21 + %30 = OpLoad %16 %29 + %32 = OpIAdd %16 %30 %31 + OpStore %29 %32 + OpReturn + OpFunctionEnd + %10 = OpFunction %2 None %3 + %11 = OpLabel + %33 = OpAccessChain %25 %19 %21 + %34 = OpLoad %16 %33 + %35 = OpISub %16 %34 %31 + OpStore %33 %35 + OpReturn + OpFunctionEnd + %12 = OpFunction %2 None %3 + %13 = OpLabel + %37 = OpAccessChain %25 %19 %21 + %38 = OpLoad %16 %37 + %39 = OpIMul %16 %38 %36 + %40 = OpAccessChain %25 %19 %21 + OpStore %40 %39 + OpReturn + OpFunctionEnd + %14 = OpFunction %2 None %3 + %15 = OpLabel + %41 = OpAccessChain %25 %19 %21 + %42 = OpLoad %16 %41 + %43 = OpUDiv %16 %42 %36 + %44 = OpAccessChain %25 %19 %21 + OpStore %44 %43 + OpReturn + OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/spec_constant_array_size_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/spec_constant_array_size_autogen.cpp new file mode 100644 index 0000000000..1962d27e70 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/spec_constant_array_size_autogen.cpp @@ -0,0 +1,310 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Tests that identical specialization constants are not matched with constants +// when used as array size. +constexpr char kSrc[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Google ANGLE Shader Compiler; 0 +; Bound: 27 +; Schema: 0 +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %22 "main" %4 %19 +OpSource GLSL 450 +OpName %4 "_ua_position" +OpName %17 "gl_PerVertex" +OpMemberName %17 0 "gl_Position" +OpMemberName %17 1 "gl_PointSize" +OpMemberName %17 2 "gl_ClipDistance" +OpMemberName %17 3 "gl_CullDistance" +OpName %19 "" +OpName %22 "main" +OpDecorate %4 Location 0 +OpMemberDecorate %17 1 RelaxedPrecision +OpMemberDecorate %17 0 BuiltIn Position +OpMemberDecorate %17 1 BuiltIn PointSize +OpMemberDecorate %17 2 BuiltIn ClipDistance +OpMemberDecorate %17 3 BuiltIn CullDistance +OpDecorate %17 Block +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeInt 32 0 +%8 = OpTypeVector %5 4 +%15 = OpConstant %5 8 +%16 = OpTypeArray %1 %15 +%17 = OpTypeStruct %2 %1 %16 %16 +%20 = OpTypeVoid +%25 = OpConstant %5 0 +%3 = OpTypePointer Input %2 +%13 = OpTypePointer Output %2 +%18 = OpTypePointer Output %17 +%21 = OpTypeFunction %20 +%4 = OpVariable %3 Input +%19 = OpVariable %18 Output +%22 = OpFunction %20 None %21 +%23 = OpLabel +%24 = OpLoad %2 %4 +%26 = OpAccessChain %13 %19 %25 +OpStore %26 %24 +OpReturn +OpFunctionEnd)"; +constexpr char kDst[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Google ANGLE Shader Compiler; 0 +; Bound: 27 +; Schema: 0 +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %22 "main" %4 %19 +OpSource GLSL 450 +OpName %4 "_ua_position" +OpName %17 "gl_PerVertex" +OpMemberName %17 0 "gl_Position" +OpMemberName %17 1 "gl_PointSize" +OpMemberName %17 2 "gl_ClipDistance" +OpMemberName %17 3 "gl_CullDistance" +OpName %19 "" +OpName %22 "main" +OpDecorate %4 Location 0 +OpDecorate %15 SpecId 4 +OpMemberDecorate %17 1 RelaxedPrecision +OpMemberDecorate %17 0 BuiltIn Position +OpMemberDecorate %17 1 BuiltIn PointSize +OpMemberDecorate %17 2 BuiltIn ClipDistance +OpMemberDecorate %17 3 BuiltIn CullDistance +OpDecorate %17 Block +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeInt 32 0 +%8 = OpTypeVector %5 4 +%15 = OpSpecConstant %5 8 +%16 = OpTypeArray %1 %15 +%17 = OpTypeStruct %2 %1 %16 %16 +%20 = OpTypeVoid +%25 = OpConstant %5 0 +%3 = OpTypePointer Input %2 +%13 = OpTypePointer Output %2 +%18 = OpTypePointer Output %17 +%21 = OpTypeFunction %20 +%4 = OpVariable %3 Input +%19 = OpVariable %18 Output +%22 = OpFunction %20 None %21 +%23 = OpLabel +%24 = OpLoad %2 %4 +%26 = OpAccessChain %13 %19 %25 +OpStore %26 %24 +OpReturn +OpFunctionEnd +)"; + +TEST(DiffTest, SpecConstantArraySize) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 27 ++; Bound: 36 + ; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %22 "main" %4 %19 + OpSource GLSL 450 + OpName %4 "_ua_position" + OpName %17 "gl_PerVertex" + OpMemberName %17 0 "gl_Position" + OpMemberName %17 1 "gl_PointSize" + OpMemberName %17 2 "gl_ClipDistance" + OpMemberName %17 3 "gl_CullDistance" + OpName %19 "" + OpName %22 "main" + OpDecorate %4 Location 0 ++OpDecorate %34 SpecId 4 + OpMemberDecorate %17 1 RelaxedPrecision + OpMemberDecorate %17 0 BuiltIn Position + OpMemberDecorate %17 1 BuiltIn PointSize + OpMemberDecorate %17 2 BuiltIn ClipDistance + OpMemberDecorate %17 3 BuiltIn CullDistance + OpDecorate %17 Block + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %5 = OpTypeInt 32 0 + %8 = OpTypeVector %5 4 +-%15 = OpConstant %5 8 +-%16 = OpTypeArray %1 %15 ++%34 = OpSpecConstant %5 8 ++%35 = OpTypeArray %1 %34 +-%17 = OpTypeStruct %2 %1 %16 %16 ++%17 = OpTypeStruct %2 %1 %35 %35 + %20 = OpTypeVoid + %25 = OpConstant %5 0 + %3 = OpTypePointer Input %2 + %13 = OpTypePointer Output %2 + %18 = OpTypePointer Output %17 + %21 = OpTypeFunction %20 + %4 = OpVariable %3 Input + %19 = OpVariable %18 Output + %22 = OpFunction %20 None %21 + %23 = OpLabel + %24 = OpLoad %2 %4 + %26 = OpAccessChain %13 %19 %25 + OpStore %26 %24 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, SpecConstantArraySizeNoDebug) { + constexpr char kSrcNoDebug[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Google ANGLE Shader Compiler; 0 +; Bound: 27 +; Schema: 0 +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %22 "main" %4 %19 +OpSource GLSL 450 +OpDecorate %4 Location 0 +OpMemberDecorate %17 1 RelaxedPrecision +OpMemberDecorate %17 0 BuiltIn Position +OpMemberDecorate %17 1 BuiltIn PointSize +OpMemberDecorate %17 2 BuiltIn ClipDistance +OpMemberDecorate %17 3 BuiltIn CullDistance +OpDecorate %17 Block +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeInt 32 0 +%8 = OpTypeVector %5 4 +%15 = OpConstant %5 8 +%16 = OpTypeArray %1 %15 +%17 = OpTypeStruct %2 %1 %16 %16 +%20 = OpTypeVoid +%25 = OpConstant %5 0 +%3 = OpTypePointer Input %2 +%13 = OpTypePointer Output %2 +%18 = OpTypePointer Output %17 +%21 = OpTypeFunction %20 +%4 = OpVariable %3 Input +%19 = OpVariable %18 Output +%22 = OpFunction %20 None %21 +%23 = OpLabel +%24 = OpLoad %2 %4 +%26 = OpAccessChain %13 %19 %25 +OpStore %26 %24 +OpReturn +OpFunctionEnd +)"; + constexpr char kDstNoDebug[] = R"(; SPIR-V +; Version: 1.0 +; Generator: Google ANGLE Shader Compiler; 0 +; Bound: 27 +; Schema: 0 +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %22 "main" %4 %19 +OpSource GLSL 450 +OpDecorate %4 Location 0 +OpDecorate %15 SpecId 4 +OpMemberDecorate %17 1 RelaxedPrecision +OpMemberDecorate %17 0 BuiltIn Position +OpMemberDecorate %17 1 BuiltIn PointSize +OpMemberDecorate %17 2 BuiltIn ClipDistance +OpMemberDecorate %17 3 BuiltIn CullDistance +OpDecorate %17 Block +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeInt 32 0 +%8 = OpTypeVector %5 4 +%15 = OpSpecConstant %5 8 +%16 = OpTypeArray %1 %15 +%17 = OpTypeStruct %2 %1 %16 %16 +%20 = OpTypeVoid +%25 = OpConstant %5 0 +%3 = OpTypePointer Input %2 +%13 = OpTypePointer Output %2 +%18 = OpTypePointer Output %17 +%21 = OpTypeFunction %20 +%4 = OpVariable %3 Input +%19 = OpVariable %18 Output +%22 = OpFunction %20 None %21 +%23 = OpLabel +%24 = OpLoad %2 %4 +%26 = OpAccessChain %13 %19 %25 +OpStore %26 %24 +OpReturn +OpFunctionEnd +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 27 ++; Bound: 36 + ; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %22 "main" %4 %19 + OpSource GLSL 450 + OpDecorate %4 Location 0 ++OpDecorate %34 SpecId 4 + OpMemberDecorate %17 1 RelaxedPrecision + OpMemberDecorate %17 0 BuiltIn Position + OpMemberDecorate %17 1 BuiltIn PointSize + OpMemberDecorate %17 2 BuiltIn ClipDistance + OpMemberDecorate %17 3 BuiltIn CullDistance + OpDecorate %17 Block + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %5 = OpTypeInt 32 0 + %8 = OpTypeVector %5 4 +-%15 = OpConstant %5 8 +-%16 = OpTypeArray %1 %15 ++%34 = OpSpecConstant %5 8 ++%35 = OpTypeArray %1 %34 +-%17 = OpTypeStruct %2 %1 %16 %16 ++%17 = OpTypeStruct %2 %1 %35 %35 + %20 = OpTypeVoid + %25 = OpConstant %5 0 + %3 = OpTypePointer Input %2 + %13 = OpTypePointer Output %2 + %18 = OpTypePointer Output %17 + %21 = OpTypeFunction %20 + %4 = OpVariable %3 Input + %19 = OpVariable %18 Output + %22 = OpFunction %20 None %21 + %23 = OpLabel + %24 = OpLoad %2 %4 + %26 = OpAccessChain %13 %19 %25 + OpStore %26 %24 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/spec_constant_array_size_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/spec_constant_array_size_dst.spvasm new file mode 100644 index 0000000000..7cedf08385 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/spec_constant_array_size_dst.spvasm @@ -0,0 +1,47 @@ +; SPIR-V +; Version: 1.0 +; Generator: Google ANGLE Shader Compiler; 0 +; Bound: 27 +; Schema: 0 +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %22 "main" %4 %19 +OpSource GLSL 450 +OpName %4 "_ua_position" +OpName %17 "gl_PerVertex" +OpMemberName %17 0 "gl_Position" +OpMemberName %17 1 "gl_PointSize" +OpMemberName %17 2 "gl_ClipDistance" +OpMemberName %17 3 "gl_CullDistance" +OpName %19 "" +OpName %22 "main" +OpDecorate %4 Location 0 +OpDecorate %15 SpecId 4 +OpMemberDecorate %17 1 RelaxedPrecision +OpMemberDecorate %17 0 BuiltIn Position +OpMemberDecorate %17 1 BuiltIn PointSize +OpMemberDecorate %17 2 BuiltIn ClipDistance +OpMemberDecorate %17 3 BuiltIn CullDistance +OpDecorate %17 Block +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeInt 32 0 +%8 = OpTypeVector %5 4 +%15 = OpSpecConstant %5 8 +%16 = OpTypeArray %1 %15 +%17 = OpTypeStruct %2 %1 %16 %16 +%20 = OpTypeVoid +%25 = OpConstant %5 0 +%3 = OpTypePointer Input %2 +%13 = OpTypePointer Output %2 +%18 = OpTypePointer Output %17 +%21 = OpTypeFunction %20 +%4 = OpVariable %3 Input +%19 = OpVariable %18 Output +%22 = OpFunction %20 None %21 +%23 = OpLabel +%24 = OpLoad %2 %4 +%26 = OpAccessChain %13 %19 %25 +OpStore %26 %24 +OpReturn +OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/spec_constant_array_size_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/spec_constant_array_size_src.spvasm new file mode 100644 index 0000000000..e17e04acff --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/spec_constant_array_size_src.spvasm @@ -0,0 +1,48 @@ +;; Tests that identical specialization constants are not matched with constants +;; when used as array size. +; SPIR-V +; Version: 1.0 +; Generator: Google ANGLE Shader Compiler; 0 +; Bound: 27 +; Schema: 0 +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %22 "main" %4 %19 +OpSource GLSL 450 +OpName %4 "_ua_position" +OpName %17 "gl_PerVertex" +OpMemberName %17 0 "gl_Position" +OpMemberName %17 1 "gl_PointSize" +OpMemberName %17 2 "gl_ClipDistance" +OpMemberName %17 3 "gl_CullDistance" +OpName %19 "" +OpName %22 "main" +OpDecorate %4 Location 0 +OpMemberDecorate %17 1 RelaxedPrecision +OpMemberDecorate %17 0 BuiltIn Position +OpMemberDecorate %17 1 BuiltIn PointSize +OpMemberDecorate %17 2 BuiltIn ClipDistance +OpMemberDecorate %17 3 BuiltIn CullDistance +OpDecorate %17 Block +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeInt 32 0 +%8 = OpTypeVector %5 4 +%15 = OpConstant %5 8 +%16 = OpTypeArray %1 %15 +%17 = OpTypeStruct %2 %1 %16 %16 +%20 = OpTypeVoid +%25 = OpConstant %5 0 +%3 = OpTypePointer Input %2 +%13 = OpTypePointer Output %2 +%18 = OpTypePointer Output %17 +%21 = OpTypeFunction %20 +%4 = OpVariable %3 Input +%19 = OpVariable %18 Output +%22 = OpFunction %20 None %21 +%23 = OpLabel +%24 = OpLoad %2 %4 +%26 = OpAccessChain %13 %19 %25 +OpStore %26 %24 +OpReturn +OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/spec_constant_composite_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/spec_constant_composite_autogen.cpp new file mode 100644 index 0000000000..e4b52cb658 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/spec_constant_composite_autogen.cpp @@ -0,0 +1,186 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Tests OpSpecConstantComposite matching. +constexpr char kSrc[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 450 + OpName %main "main" + OpDecorate %7 SpecId 3 + OpDecorate %8 SpecId 4 + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %7 = OpSpecConstant %uint 1 + %8 = OpSpecConstant %uint 1 + %uint_1 = OpConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %7 %8 %uint_1 + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd)"; +constexpr char kDst[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 450 + OpName %main "main" + OpDecorate %7 SpecId 3 + OpDecorate %8 SpecId 4 + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %7 = OpSpecConstant %uint 2048 + %8 = OpSpecConstant %uint 1 + %uint_1 = OpConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %7 %8 %uint_1 + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd +)"; + +TEST(DiffTest, SpecConstantComposite) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 + ; Bound: 12 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + OpExecutionMode %2 LocalSize 1 1 1 + OpSource GLSL 450 + OpName %2 "main" + OpDecorate %7 SpecId 3 + OpDecorate %8 SpecId 4 + OpDecorate %4 BuiltIn WorkgroupSize + %6 = OpTypeVoid + %3 = OpTypeFunction %6 + %9 = OpTypeInt 32 0 +-%7 = OpSpecConstant %9 1 ++%7 = OpSpecConstant %9 2048 + %8 = OpSpecConstant %9 1 + %10 = OpConstant %9 1 + %11 = OpTypeVector %9 3 + %4 = OpSpecConstantComposite %11 %7 %8 %10 + %2 = OpFunction %6 None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, SpecConstantCompositeNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 450 + OpDecorate %7 SpecId 3 + OpDecorate %8 SpecId 4 + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %7 = OpSpecConstant %uint 1 + %8 = OpSpecConstant %uint 1 + %uint_1 = OpConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %7 %8 %uint_1 + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 450 + OpDecorate %7 SpecId 3 + OpDecorate %8 SpecId 4 + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %7 = OpSpecConstant %uint 2048 + %8 = OpSpecConstant %uint 1 + %uint_1 = OpConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %7 %8 %uint_1 + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 + ; Bound: 12 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + OpExecutionMode %2 LocalSize 1 1 1 + OpSource GLSL 450 + OpDecorate %7 SpecId 3 + OpDecorate %8 SpecId 4 + OpDecorate %4 BuiltIn WorkgroupSize + %6 = OpTypeVoid + %3 = OpTypeFunction %6 + %9 = OpTypeInt 32 0 +-%7 = OpSpecConstant %9 1 ++%7 = OpSpecConstant %9 2048 + %8 = OpSpecConstant %9 1 + %10 = OpConstant %9 1 + %11 = OpTypeVector %9 3 + %4 = OpSpecConstantComposite %11 %7 %8 %10 + %2 = OpFunction %6 None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/spec_constant_composite_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/spec_constant_composite_dst.spvasm new file mode 100644 index 0000000000..3ab8d4d311 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/spec_constant_composite_dst.spvasm @@ -0,0 +1,22 @@ + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 450 + OpName %main "main" + OpDecorate %7 SpecId 3 + OpDecorate %8 SpecId 4 + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %7 = OpSpecConstant %uint 2048 + %8 = OpSpecConstant %uint 1 + %uint_1 = OpConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %7 %8 %uint_1 + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/spec_constant_composite_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/spec_constant_composite_src.spvasm new file mode 100644 index 0000000000..ee48ef9dbc --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/spec_constant_composite_src.spvasm @@ -0,0 +1,23 @@ +;; Tests OpSpecConstantComposite matching. + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 450 + OpName %main "main" + OpDecorate %7 SpecId 3 + OpDecorate %8 SpecId 4 + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %7 = OpSpecConstant %uint 1 + %8 = OpSpecConstant %uint 1 + %uint_1 = OpConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %7 %8 %uint_1 + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/unrelated_shaders_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/unrelated_shaders_autogen.cpp new file mode 100644 index 0000000000..e1a58cccfc --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/unrelated_shaders_autogen.cpp @@ -0,0 +1,230 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Tests diff of unrelated shaders (with different execution models). +constexpr char kSrc[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %4 "main" %8 %10 + OpSource ESSL 310 + OpName %4 "main" + OpName %8 "v" + OpName %10 "a" + OpDecorate %8 Location 0 + OpDecorate %10 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypePointer Output %6 + %8 = OpVariable %7 Output + %9 = OpTypePointer Input %6 + %10 = OpVariable %9 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %11 = OpLoad %6 %10 + OpStore %8 %11 + OpReturn + OpFunctionEnd +)"; +constexpr char kDst[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %9 "color" + OpName %11 "v" + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 + %13 = OpCompositeConstruct %7 %12 %12 %12 %12 + OpStore %9 %13 + OpReturn + OpFunctionEnd + +)"; + +TEST(DiffTest, UnrelatedShaders) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 12 ++; Bound: 16 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 +-OpEntryPoint Vertex %4 "main" %8 %10 ++OpEntryPoint Fragment %4 "main" %14 %8 ++OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" ++OpName %14 "color" + OpName %8 "v" +-OpName %10 "a" ++OpDecorate %14 RelaxedPrecision ++OpDecorate %14 Location 0 ++OpDecorate %8 RelaxedPrecision + OpDecorate %8 Location 0 +-OpDecorate %10 Location 0 ++OpDecorate %11 RelaxedPrecision ++OpDecorate %15 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 +-%7 = OpTypePointer Output %6 ++%12 = OpTypeVector %6 4 ++%13 = OpTypePointer Output %12 ++%14 = OpVariable %13 Output +-%8 = OpVariable %7 Output ++%8 = OpVariable %9 Input + %9 = OpTypePointer Input %6 +-%10 = OpVariable %9 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel +-%11 = OpLoad %6 %10 ++%11 = OpLoad %6 %8 +-OpStore %8 %11 ++%15 = OpCompositeConstruct %12 %11 %11 %11 %11 ++OpStore %14 %15 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, UnrelatedShadersNoDebug) { + constexpr char kSrcNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %4 "main" %8 %10 + OpSource ESSL 310 + OpDecorate %8 Location 0 + OpDecorate %10 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypePointer Output %6 + %8 = OpVariable %7 Output + %9 = OpTypePointer Input %6 + %10 = OpVariable %9 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %11 = OpLoad %6 %10 + OpStore %8 %11 + OpReturn + OpFunctionEnd + +)"; + constexpr char kDstNoDebug[] = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 + %13 = OpCompositeConstruct %7 %12 %12 %12 %12 + OpStore %9 %13 + OpReturn + OpFunctionEnd + +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 +-; Bound: 12 ++; Bound: 15 + ; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 +-OpEntryPoint Vertex %4 "main" %8 %10 ++OpEntryPoint Fragment %4 "main" %8 %10 ++OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 ++OpDecorate %8 RelaxedPrecision + OpDecorate %8 Location 0 ++OpDecorate %10 RelaxedPrecision + OpDecorate %10 Location 0 ++OpDecorate %11 RelaxedPrecision ++OpDecorate %14 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 +-%7 = OpTypePointer Output %6 ++%12 = OpTypeVector %6 4 ++%13 = OpTypePointer Output %12 +-%8 = OpVariable %7 Output ++%8 = OpVariable %13 Output + %9 = OpTypePointer Input %6 + %10 = OpVariable %9 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %11 = OpLoad %6 %10 ++%14 = OpCompositeConstruct %12 %11 %11 %11 %11 +-OpStore %8 %11 ++OpStore %8 %14 + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/unrelated_shaders_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/unrelated_shaders_dst.spvasm new file mode 100644 index 0000000000..719715bad7 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/unrelated_shaders_dst.spvasm @@ -0,0 +1,31 @@ + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %9 %11 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %9 "color" + OpName %11 "v" + OpDecorate %9 RelaxedPrecision + OpDecorate %9 Location 0 + OpDecorate %11 RelaxedPrecision + OpDecorate %11 Location 0 + OpDecorate %12 RelaxedPrecision + OpDecorate %13 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypePointer Output %7 + %9 = OpVariable %8 Output + %10 = OpTypePointer Input %6 + %11 = OpVariable %10 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %12 = OpLoad %6 %11 + %13 = OpCompositeConstruct %7 %12 %12 %12 %12 + OpStore %9 %13 + OpReturn + OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_files/unrelated_shaders_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/unrelated_shaders_src.spvasm new file mode 100644 index 0000000000..e77b2d2042 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/unrelated_shaders_src.spvasm @@ -0,0 +1,25 @@ +;; Tests diff of unrelated shaders (with different execution models). + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %4 "main" %8 %10 + OpSource ESSL 310 + OpName %4 "main" + OpName %8 "v" + OpName %10 "a" + OpDecorate %8 Location 0 + OpDecorate %10 Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypePointer Output %6 + %8 = OpVariable %7 Output + %9 = OpTypePointer Input %6 + %10 = OpVariable %9 Input + %4 = OpFunction %2 None %3 + %5 = OpLabel + %11 = OpLoad %6 %10 + OpStore %8 %11 + OpReturn + OpFunctionEnd + diff --git a/third_party/spirv-tools/test/diff/diff_test.cpp b/third_party/spirv-tools/test/diff/diff_test.cpp new file mode 100644 index 0000000000..5b11d0eb25 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_test.cpp @@ -0,0 +1,228 @@ +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "source/diff/diff.h" + +#include "diff_test_utils.h" + +#include "source/opt/build_module.h" +#include "source/opt/ir_context.h" +#include "source/spirv_constant.h" +#include "spirv-tools/libspirv.hpp" +#include "tools/io.h" +#include "tools/util/cli_consumer.h" + +#include +#include + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +constexpr auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; + +std::unique_ptr Assemble(const std::string& spirv) { + spvtools::SpirvTools t(kDefaultEnvironment); + t.SetMessageConsumer(spvtools::utils::CLIMessageConsumer); + std::vector binary; + if (!t.Assemble(spirv, &binary, + spvtools::SpirvTools::kDefaultAssembleOption | + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS)) + return nullptr; + return spvtools::BuildModule(kDefaultEnvironment, + spvtools::utils::CLIMessageConsumer, + binary.data(), binary.size()); +} + +TEST(DiffIndentTest, Diff) { + const std::string src = R"(OpCapability Shader + %ext_inst = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + %void = OpTypeVoid + %func = OpTypeFunction %void + + %main = OpFunction %void None %func + %main_entry = OpLabel + OpReturn + OpFunctionEnd;)"; + + const std::string dst = R"(OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + %void = OpTypeVoid + %func = OpTypeFunction %void + + %main = OpFunction %void None %func + %main_entry = OpLabel + OpReturn + OpFunctionEnd;)"; + + const std::string diff = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 + ; Bound: 6 + ; Schema: 0 + OpCapability Shader +- %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" + OpExecutionMode %2 OriginUpperLeft + %3 = OpTypeVoid + %4 = OpTypeFunction %3 + %2 = OpFunction %3 None %4 + %5 = OpLabel + OpReturn + OpFunctionEnd +)"; + + Options options; + options.indent = true; + DoStringDiffTest(src, dst, diff, options); +} + +TEST(DiffNoHeaderTest, Diff) { + const std::string src = R"(OpCapability Shader + %ext_inst = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + %void = OpTypeVoid + %func = OpTypeFunction %void + + %main = OpFunction %void None %func + %main_entry = OpLabel + OpReturn + OpFunctionEnd;)"; + + const std::string dst = R"(OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + %void = OpTypeVoid + %func = OpTypeFunction %void + + %main = OpFunction %void None %func + %main_entry = OpLabel + OpReturn + OpFunctionEnd;)"; + + const std::string diff = R"( OpCapability Shader +-%1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" + OpExecutionMode %2 OriginUpperLeft + %3 = OpTypeVoid + %4 = OpTypeFunction %3 + %2 = OpFunction %3 None %4 + %5 = OpLabel + OpReturn + OpFunctionEnd +)"; + + Options options; + options.no_header = true; + DoStringDiffTest(src, dst, diff, options); +} + +TEST(DiffHeaderTest, Diff) { + const std::string src_spirv = R"(OpCapability Shader + %ext_inst = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + %void = OpTypeVoid + %func = OpTypeFunction %void + + %main = OpFunction %void None %func + %main_entry = OpLabel + OpReturn + OpFunctionEnd;)"; + + const std::string dst_spirv = R"(OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + %void = OpTypeVoid + %func = OpTypeFunction %void + + %main = OpFunction %void None %func + %main_entry = OpLabel + OpReturn + OpFunctionEnd;)"; + + const std::string diff = R"( ; SPIR-V +-; Version: 1.3 ++; Version: 1.2 +-; Generator: Khronos SPIR-V Tools Assembler; 3 ++; Generator: Khronos Glslang Reference Front End; 10 + ; Bound: 6 + ; Schema: 0 + OpCapability Shader +-%1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" + OpExecutionMode %2 OriginUpperLeft + %3 = OpTypeVoid + %4 = OpTypeFunction %3 + %2 = OpFunction %3 None %4 + %5 = OpLabel + OpReturn + OpFunctionEnd +)"; + + // Load the src and dst modules + std::unique_ptr src = Assemble(src_spirv); + ASSERT_TRUE(src); + + std::unique_ptr dst = Assemble(dst_spirv); + ASSERT_TRUE(dst); + + // Differentiate them in the header. + const spvtools::opt::ModuleHeader src_header = { + SpvMagicNumber, + SPV_SPIRV_VERSION_WORD(1, 3), + SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS_ASSEMBLER, 3), + src->module()->IdBound(), + src->module()->schema(), + }; + const spvtools::opt::ModuleHeader dst_header = { + SpvMagicNumber, + SPV_SPIRV_VERSION_WORD(1, 2), + SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS_GLSLANG, 10), + dst->module()->IdBound(), + dst->module()->schema(), + }; + + src->module()->SetHeader(src_header); + dst->module()->SetHeader(dst_header); + + // Take the diff + Options options; + std::ostringstream diff_result; + spv_result_t result = + spvtools::diff::Diff(src.get(), dst.get(), diff_result, options); + ASSERT_EQ(result, SPV_SUCCESS); + + // Expect they match + EXPECT_EQ(diff_result.str(), diff); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_test_utils.cpp b/third_party/spirv-tools/test/diff/diff_test_utils.cpp new file mode 100644 index 0000000000..14bb821536 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_test_utils.cpp @@ -0,0 +1,58 @@ +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "diff_test_utils.h" + +#include "source/opt/build_module.h" +#include "source/opt/ir_context.h" + +#include "spirv-tools/libspirv.hpp" +#include "tools/io.h" +#include "tools/util/cli_consumer.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { + +static constexpr auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; + +void DoStringDiffTest(const std::string& src_spirv, + const std::string& dst_spirv, + const std::string& expected_diff, Options options) { + // Load the src and dst modules + std::unique_ptr src = spvtools::BuildModule( + kDefaultEnvironment, spvtools::utils::CLIMessageConsumer, src_spirv, + spvtools::SpirvTools::kDefaultAssembleOption | + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + ASSERT_TRUE(src); + + std::unique_ptr dst = spvtools::BuildModule( + kDefaultEnvironment, spvtools::utils::CLIMessageConsumer, dst_spirv, + spvtools::SpirvTools::kDefaultAssembleOption | + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + ASSERT_TRUE(dst); + + // Take the diff + std::ostringstream diff_result; + spv_result_t result = + spvtools::diff::Diff(src.get(), dst.get(), diff_result, options); + ASSERT_EQ(result, SPV_SUCCESS); + + // Expect they match + EXPECT_EQ(diff_result.str(), expected_diff); +} + +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_test_utils.h b/third_party/spirv-tools/test/diff/diff_test_utils.h new file mode 100644 index 0000000000..938236e649 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_test_utils.h @@ -0,0 +1,30 @@ +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef TEST_DIFF_DIFF_TEST_UTILS_H_ +#define TEST_DIFF_DIFF_TEST_UTILS_H_ + +#include "source/diff/diff.h" + +namespace spvtools { +namespace diff { + +void DoStringDiffTest(const std::string& src_spirv, + const std::string& dst_spirv, + const std::string& expected_diff, Options options); + +} // namespace diff +} // namespace spvtools + +#endif // TEST_DIFF_DIFF_TEST_UTILS_H_ diff --git a/third_party/spirv-tools/test/diff/lcs_test.cpp b/third_party/spirv-tools/test/diff/lcs_test.cpp new file mode 100644 index 0000000000..3e097b3e7b --- /dev/null +++ b/third_party/spirv-tools/test/diff/lcs_test.cpp @@ -0,0 +1,329 @@ +// Copyright (c) 2022 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "source/diff/lcs.h" + +#include + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +using Sequence = std::vector; +using LCS = LongestCommonSubsequence; + +void VerifyMatch(const Sequence& src, const Sequence& dst, + size_t expected_match_count) { + DiffMatch src_match, dst_match; + + LCS lcs(src, dst); + size_t match_count = + lcs.Get([](int s, int d) { return s == d; }, &src_match, &dst_match); + + EXPECT_EQ(match_count, expected_match_count); + + size_t src_cur = 0; + size_t dst_cur = 0; + size_t matches_seen = 0; + + while (src_cur < src.size() && dst_cur < dst.size()) { + if (src_match[src_cur] && dst_match[dst_cur]) { + EXPECT_EQ(src[src_cur], dst[dst_cur]) + << "Src: " << src_cur << " Dst: " << dst_cur; + ++src_cur; + ++dst_cur; + ++matches_seen; + continue; + } + if (!src_match[src_cur]) { + ++src_cur; + } + if (!dst_match[dst_cur]) { + ++dst_cur; + } + } + + EXPECT_EQ(matches_seen, expected_match_count); +} + +TEST(LCSTest, EmptySequences) { + Sequence src, dst; + + DiffMatch src_match, dst_match; + + LCS lcs(src, dst); + size_t match_count = + lcs.Get([](int s, int d) { return s == d; }, &src_match, &dst_match); + + EXPECT_EQ(match_count, 0u); + EXPECT_TRUE(src_match.empty()); + EXPECT_TRUE(dst_match.empty()); +} + +TEST(LCSTest, EmptySrc) { + Sequence src, dst = {1, 2, 3}; + + DiffMatch src_match, dst_match; + + LCS lcs(src, dst); + size_t match_count = + lcs.Get([](int s, int d) { return s == d; }, &src_match, &dst_match); + + EXPECT_EQ(match_count, 0u); + EXPECT_TRUE(src_match.empty()); + EXPECT_EQ(dst_match, DiffMatch(3, false)); +} + +TEST(LCSTest, EmptyDst) { + Sequence src = {1, 2, 3}, dst; + + DiffMatch src_match, dst_match; + + LCS lcs(src, dst); + size_t match_count = + lcs.Get([](int s, int d) { return s == d; }, &src_match, &dst_match); + + EXPECT_EQ(match_count, 0u); + EXPECT_EQ(src_match, DiffMatch(3, false)); + EXPECT_TRUE(dst_match.empty()); +} + +TEST(LCSTest, Identical) { + Sequence src = {1, 2, 3, 4, 5, 6}, dst = {1, 2, 3, 4, 5, 6}; + + DiffMatch src_match, dst_match; + + LCS lcs(src, dst); + size_t match_count = + lcs.Get([](int s, int d) { return s == d; }, &src_match, &dst_match); + + EXPECT_EQ(match_count, 6u); + EXPECT_EQ(src_match, DiffMatch(6, true)); + EXPECT_EQ(dst_match, DiffMatch(6, true)); +} + +TEST(LCSTest, SrcPrefix) { + Sequence src = {1, 2, 3, 4}, dst = {1, 2, 3, 4, 5, 6}; + + DiffMatch src_match, dst_match; + + LCS lcs(src, dst); + size_t match_count = + lcs.Get([](int s, int d) { return s == d; }, &src_match, &dst_match); + + const DiffMatch src_expect = {true, true, true, true}; + const DiffMatch dst_expect = {true, true, true, true, false, false}; + + EXPECT_EQ(match_count, 4u); + EXPECT_EQ(src_match, src_expect); + EXPECT_EQ(dst_match, dst_expect); +} + +TEST(LCSTest, DstPrefix) { + Sequence src = {1, 2, 3, 4, 5, 6}, dst = {1, 2, 3, 4, 5}; + + DiffMatch src_match, dst_match; + + LCS lcs(src, dst); + size_t match_count = + lcs.Get([](int s, int d) { return s == d; }, &src_match, &dst_match); + + const DiffMatch src_expect = {true, true, true, true, true, false}; + const DiffMatch dst_expect = {true, true, true, true, true}; + + EXPECT_EQ(match_count, 5u); + EXPECT_EQ(src_match, src_expect); + EXPECT_EQ(dst_match, dst_expect); +} + +TEST(LCSTest, SrcSuffix) { + Sequence src = {3, 4, 5, 6}, dst = {1, 2, 3, 4, 5, 6}; + + DiffMatch src_match, dst_match; + + LCS lcs(src, dst); + size_t match_count = + lcs.Get([](int s, int d) { return s == d; }, &src_match, &dst_match); + + const DiffMatch src_expect = {true, true, true, true}; + const DiffMatch dst_expect = {false, false, true, true, true, true}; + + EXPECT_EQ(match_count, 4u); + EXPECT_EQ(src_match, src_expect); + EXPECT_EQ(dst_match, dst_expect); +} + +TEST(LCSTest, DstSuffix) { + Sequence src = {1, 2, 3, 4, 5, 6}, dst = {5, 6}; + + DiffMatch src_match, dst_match; + + LCS lcs(src, dst); + size_t match_count = + lcs.Get([](int s, int d) { return s == d; }, &src_match, &dst_match); + + const DiffMatch src_expect = {false, false, false, false, true, true}; + const DiffMatch dst_expect = {true, true}; + + EXPECT_EQ(match_count, 2u); + EXPECT_EQ(src_match, src_expect); + EXPECT_EQ(dst_match, dst_expect); +} + +TEST(LCSTest, None) { + Sequence src = {1, 3, 5, 7, 9}, dst = {2, 4, 6, 8, 10, 12}; + + DiffMatch src_match, dst_match; + + LCS lcs(src, dst); + size_t match_count = + lcs.Get([](int s, int d) { return s == d; }, &src_match, &dst_match); + + EXPECT_EQ(match_count, 0u); + EXPECT_EQ(src_match, DiffMatch(5, false)); + EXPECT_EQ(dst_match, DiffMatch(6, false)); +} + +TEST(LCSTest, NonContiguous) { + Sequence src = {1, 2, 3, 4, 5, 6, 10}, dst = {2, 4, 5, 8, 9, 10, 12}; + + DiffMatch src_match, dst_match; + + LCS lcs(src, dst); + size_t match_count = + lcs.Get([](int s, int d) { return s == d; }, &src_match, &dst_match); + + const DiffMatch src_expect = {false, true, false, true, true, false, true}; + const DiffMatch dst_expect = {true, true, true, false, false, true, false}; + + EXPECT_EQ(match_count, 4u); + EXPECT_EQ(src_match, src_expect); + EXPECT_EQ(dst_match, dst_expect); +} + +TEST(LCSTest, WithDuplicates) { + Sequence src = {1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4}, + dst = {1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}; + VerifyMatch(src, dst, 6); +} + +TEST(LCSTest, Large) { + const std::string src_str = + "GUJwrJSlkKJXxCVIAxlVgnUyOrdyRyFtlZwWMmFhYGfkFTNnhiBmClgHyrcXMVwfrRxNUfQk" + "qaoGvCbPZHAzXsaZpXHPfJxOMCUtRDmIQpfiXKbHQbhTfPqhxBDWvmTQAqwsWTLajZYtMUnf" + "hNNCfkuAXkZsaebwEbIZOxTDZsqSMUfCMoGeKJGVSNFgLTiBMbdvchHGfFRkHKcYCDjBfIcj" + "todPnvDjzQYWBcvIfVvyBzHikrwpDORaGEZLhmyztIFCLJOqeLhOzERYmVqzlsoUzruTXTXq" + "DLTxQRakOCMRrgRzCDTXfwwfDcKMBVnxRZemjcwcEsOVxwtwdBCWJycsDcZKlvrCvZaenKlv" + "vyByDQeLdxAyBnPkIMQlMQwqjUfRLybeoaOanlbFkpTPPZdHelQrIvucTHzMpWWQTbuANwvN" + "OVhCGGoIcGNDpfIsaBexlMMdHsxMGerTngmjpdPeQQJHfvKZkdYqAzrtDohqtDsaFMxQViVQ" + "YszDVgyoSHZdOXAvXkJidojLvGZOzhRajVPhWDwKuGqdaympELxHsrXAJYufdCPwJdGJfWqq" + "yvTWpcrFHOIuCEmNLnSCDsxQGRVDwyCykBJazhApfCnrOadnafvqfVuFqEXMSrYbHTfTnzbz" + "MhISyOtMUITaurCXvanCbuOXBhHyCjOhVbxnMvhlPmZBMQgEHCghtAJVMXGPNRtszVZlPxVl" + "QIPTBnPUPejlyZGPqeICyNngdQGkvKbIoWlTLBtVhMdBeUMozNlKQTIPYBeImVcMdLafuxUf" + "TIXysmcTrUTcspOSKBxhdhLwiRnREGFWJTfUKsgGOAQeYojXdrqsGjMJfiKalyoiqrgLnlij" + "CtOapoxDGVOOBalNYGzCtBlxbvaAzxipGnJpOEbmXcpeoIsAdxspKBzBDgoPVxnuRBUwmTSr" + "CRpWhxikgUYQVCwalLUIeBPRyhhsECGCXJmGDZSCIUaBwROkigzdeVPOXhgCGBEprWtNdYfL" + "tOUYJHQXxiIJgSGmWntezJFpNQoTPbRRYAGhtYvAechvBcYWocLkYFxsDAuszvQNLXdhmAHw" + "DErcjbtCdQllnKcDADVNWVezljjLrAuyGHetINMgAvJZwOEYakihYVUbZGCsHEufluLNyNHy" + "gqtSTSFFjBHiIqQejTPWybLdpWNwZrWvIWnlzUcGNQPEYHVPCbteWknjAnWrdTBeCbHUDBoK" + "aHvDStmpNRGIjvlumiZTbdZNAzUeSFnFChCsSExwXeEfDJfjyOoSBofHzJqJErvHLNyUJTjX" + "qmtgKPpMKohUPBMhtCteQFcNEpWrUVGbibMOpvBwdiWYXNissArpSasVJFgDzrqTyGkerTMX" + "gcrzFUGFZRhNdekaJeKYPogsofJaRsUQmIRyYdkrxKeMgLPpwOfSKJOqzXDoeHljTzhOwEVy" + "krOEnACFrWhufajsMitjOWdLOHHchQDddGPzxknEgdwmZepKDvRZGCuPqzeQkjOPqUBKpKLJ" + "eKieSsRXkaqxSPGajfvPKmwFWdLByEcLgvrmteazgFjmMGrLYqRRxzUOfOCokenqHVYstBHf" + "AwsWsqPTvqsRJUfGGTaYiylZMGbQqTzINhFHvdlRQvvYKBcuAHdBeKlHSxVrSsEKbcAvnIcf" + "xzdVDdwQPHMCHeZZRpGHWvKzgTGzSTbYTeOPyKvvYWmQToTpsjAtKUJUjcEHWhmdBLDTBMHJ" + "ivBXcLGtCsumNNVFyGbVviGmqHTdyBlkneibXBesKJGOUzOtIwXCPJggqBekSzNQYkALlItk" + "cbEhbdXAIKVHYpInLwxXalKZrkrpxtfuagqMGmRJnJbFQaEoYMoqPsxZpocddPXXPyvxVkaF" + "qdKISejWDhBImnEEOPDcyWTubbfVfwUztciaFJcsPLhgYVfhqlOfoNjKbmTFptFttYuyBrUI" + "zzmZypOqrjQHTGFwlHStpIwxPtMvtsEDpsmWIgwzYgwmdpbMOnfElZMYpVIcvzSWejeJcdUB" + "QUoBRUmGQVVWvEDseuozrDjgdXFScPwwsgaUPwSzScfBNrkpmEFDSZLKfNjMqvOmUtocUkbo" + "VGFEKgGLbNruwLgXHTloWDrnqymPVAtzjWPutonIsMDPeeCmTjYWAFXcyTAlBeiJTIRkZxiM" + "kLjMnAflSNJzmZkatXkYiPEMYSmzHbLKEizHbEjQOxBDzpRHiFjhedqiyMiUMvThjaRFmwll" + "aMGgwKBIKepwyoEdnuhtzJzboiNEAFKiqiWxxmkRFRoTiFWXLPAWLuzSCrajgkQhDxAQDqyM" + "VwZlhZicQLEDYYisEalesDWZAYzcvENuHUwRutIsGgsdoYwOZiURhcgdbTGWBNqhrFjvTQCj" + "VlTPNlRdRLaaqzUBBwbdtyXFkCBUYYMbmRrkFxfxbCqkgZNGyHPKLkOPnezfVTRmRQgCgHbx" + "wcZlInVOwmFePnSIbThMJosimzkhfuiqYEpwHQiemqsSDNNdbNhBLzbsPZBJZujSHJGtYKGb" + "HaAYGJZxBumsKUrATwPuqXFLfwNyImLQbchBKiJAYRZhkcrKCHXBEGYyBhBGvSqvabcRUrfq" + "AbPiMzjHAehGYjDEmxAnYLyoSFdeWVrfJUCuYZPluhXEBuyUpKaRXDKXeiCvGidpvATwMbcz" + "DZpzxrhTZYyrFORFQWTbPLCBjMKMhlRMFEiarDgGPttjmkrQVlujztMSkxXffXFNqLWOLThI" + "KBoyMHoFTEPCdUAZjLTifAdjjUehyDLEGKlRTFoLpjalziRSUjZfRYbNzhiHgTHowMMkKTwE" + "ZgnqiirMtnNpaBJqhcIVrWXPpcPWZfRpsPstHleFJDZYAsxYhOREVbFtebXTZRAIjGgWeoiN" + "qPLCCAVadqmUrjOcqIbdCTpcDRWuDVbHrZOQRPhqbyvOWwxAWJphjLiDgoAybcjzgfVktPlj" + "kNBCjelpuQfnYsiTgPpCNKYtOrxGaLEEtAuLdGdDsONHNhSn"; + const std::string dst_str = + "KzitfifORCbGhfNEbnbObUdFLLaAsLOpMkOeKupjCoatzqfHBkNJfSgqSMYouswfNMnoQngK" + "jWwyPKmEnoZWyPBUdQRmKUNudUclueKXKQefUdXWUyyqtumzsFKznrLVLwfvPZpLChNYrrHK" + "AtpfOuVHiUKyeRCrktJAhkyFKmPWrASEMvBLNOzuGlvinZjvZUUXazNEkyMPiOLdqXvCIroC" + "MeWsvjHShlLhDwLZrVlpYBnDJmILcsNFDSoaLWOKNNkNGBgNBvVjPCJXAuKfsrKZhYcdEpxK" + "UihiRkYvMiLyOUvaqBMklLDwEhvQBfCXHSRoqsLsSCzLZQhIYMhBapvHaPbDoRrHoJXZsNXc" + "rxZYCrOMIzYcVPwDCFiHBFnPNTTeAeKEMGeVUeCaAeuWZmngyPWlQBcgWumSUIfbhjVYdnpV" + "hRSJXrIoFZubBXfNOMhilAkVPixrhILZKgDoFTvytPFPfBLMnbhSOBmLWCbJsLQxrCrMAlOw" + "RmfSQyGhrjhzYVqFSBHeoQBagFwyxIjcHFZngntpVHbSwqhwHeMnWSsISPljTxSNXfCxLebW" + "GhMdlphtJbdvhEcjNpwPCFqhdquxCyOxkjsDUPNgjpDcpIMhMwMclNhfESTrroJaoyeGQclV" + "gonnhuQRmXcBwcsWeLqjNngZOlyMyfeQBwnwMVJEvGqknDyzSApniRTPgJpFoDkJJhXQFuFB" + "VqhuEPMRGCeTDOSEFmXeIHOnDxaJacvnmORwVpmrRhGjDpUCkuODNPdZMdupYExDEDnDLdNF" + "iObKBaVWpGVMKdgNLgsNxcpypBPPKKoaajeSGPZQJWSOKrkLjiFexYVmUGxJnbTNsCXXLfZp" + "jfxQAEVYvqKehBzMsVHVGWmTshWFAoCNDkNppzzjHBZWckrzSTANICioCJSpLwPwQvtXVxst" + "nTRBAboPFREEUFazibpFesCsjzUOnECwoPCOFiwGORlIZVLpUkJyhYXCENmzTBLVigOFuCWO" + "IiXBYmiMtsxnUdoqSTTGyEFFrQsNAjcDdOKDtHwlANWoUVwiJCMCQFILdGqzEePuSXFbOEOz" + "dLlEnTJbKRSTfAFToOZNtDXTfFgvQiefAKbSUWUXFcpCjRYCBNXCCcLMjjuUDXErpiNsRuIx" + "mgHsrObTEXcnmjdqxTGhTjTeYizNnkrJRhNQIqDXmZMwArBccnixpcuiGOOexjgkpcEyGAnz" + "UbgiBfflTUyJfZeFFLrZVueFkSRosebnnwAnakIrywTGByhQKWvmNQJsWQezqLhHQzXnEpeD" + "rFRTSQSpVxPzSeEzfWYzfpcenxsUyzOMLxhNEhfcuprDtqubsXehuqKqZlLQeSclvoGjuKJK" + "XoWrazsgjXXnkWHdqFESZdMGDYldyYdbpSZcgBPgEKLWZHfBirNPLUadmajYkiEzmGuWGELB" + "WLiSrMdaGSbptKmgYVqMGcQaaATStiZYteGAPxSEBHuAzzjlRHYsrdDkaGNXmzRGoalJMiCC" + "GMtWSDMhgvRSEgKnywbRgnqWXFlwrhXbbvcgLGtWSuKQBiqIlWkfPMozOTWgVoLHavDJGRYI" + "YerrmZnTMtuuxmZALWakfzUbksTwoetqkOiRPGqGZepcVXHoZyOaaaijjZWQLlIhYwiQNbfc" + "KCwhhFaMQBoaCnOecJEdKzdsMPFEYQuJNPYiiNtsYxaWBRuWjlLqGokHMNtyTQfSJKbgGdol" + "fWlOZdupouQMfUWXIYHzyJHefMDnqxxasDxtgArvDqtwjDBaVEMACPkLFpiDOoKCHqkWVizh" + "lKqbOHpsPKkhjRQRNGYRYEfxtBjYvlCvHBNUwVuIwDJYMqHxEFtwdLqYWvjdOfQmNiviDfUq" + "pbucbNwjNQfMYgwUuPnQWIPOlqHcbjtuDXvTzLtkdBQanJbrmLSyFqSapZCSPMDOrxWVYzyO" + "lwDTTJFmKxoyfPunadkHcrcSQaQsAbrQtbhqwSTXGTPURYTCbNozjAVwbmcyVxIbZudBZWYm" + "rnSDyelGCRRWYtrUxvOVWlTLHHdYuAmVMGnGbHscbjmjmAzmYLaCxNNwhmMYdExKvySxuYpE" + "rVGwfqMngBCHnZodotNaNJZiNRFWubuPDfiywXPiyVWoQMeOlSuWmpilLTIFOvfpjmJTgrWa" + "dgoxYeyPyOaglOvZVGdFOBSeqEcGXBwjoeUAXqkpvOxEpSXhmklKZydTvRVYVvfQdRNNDkCT" + "dLNfcZCFQbZORdcDOhwotoyccrSbWvlqYMoiAYeEpDzZTvkamapzZMmCpEutZFCcHBWGIIkr" + "urwDNHrobaErPpclyEegLJDtkfUWSNWZosWSbBGAHIvJsFNUlJXbnkSVycLkOVQVcNcUtiBy" + "djLDIFsycbPBEWaMvCbntNtJlOeCttvXypGnHAQFnFSiXFWWqonWuVIKmVPpKXuJtFguXCWC" + "rNExYYvxLGEmuZJLJDjHgjlQyOzeieCpizJxkrdqKCgomyEkvsyVYSsLeyLvOZQrrgEJgRFK" + "CjYtoOfluNrLdRMTRkQXmAiMRFwloYECpXCReAMxOkNiwCtutsrqWoMHsrogRqPoUCueonvW" + "MTwmkAkajfGJkhnQidwpwIMEttQkzIMOPvvyWZHpqkMHWlNTeSKibfRfwDyxveKENZhtlPwP" + "dfAjwegjRcavtFnkkTNVYdCdCrgdUvzsIcqmUjwGmVvuuQvjVrWWIDBmAzQtiZPYvCOEWjce" + "rWzeqVKeiYTJBOedmQCVidOgUIEjfRnbGvUbctYxfRybJkdmeAkLZQMRMGPOnsPbFswXAoCK" + "IxWGwohoPpEJxslbqHFKSwknxTmrDCITRZWEDkGQeucPxHBdYkduwbYhKnoxCKhgjBFiFawC" + "QtgTDldTQmlOsBiGLquMjuecAbrUJJvNtXbFNGjWxaZPimSRXUJWgRbydpsczOqSFIeEtuKA" + "ZpRhmLtPdVNKdSDQZeeImUFmUwXApRTUNHItyvFyJtNtn"; + + Sequence src; + Sequence dst; + + src.reserve(src_str.length()); + dst.reserve(dst_str.length()); + + for (char c : src_str) { + src.push_back(c); + } + for (char c : dst_str) { + dst.push_back(c); + } + + VerifyMatch(src, dst, 723); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/ext_inst.cldebug100_test.cpp b/third_party/spirv-tools/test/ext_inst.cldebug100_test.cpp index 4f1e10672d..0bbdd3a9a0 100644 --- a/third_party/spirv-tools/test/ext_inst.cldebug100_test.cpp +++ b/third_party/spirv-tools/test/ext_inst.cldebug100_test.cpp @@ -581,7 +581,7 @@ INSTANTIATE_TEST_SUITE_P( OpenCLDebugInfo100DebugSource, ExtInstCLDebugInfo100RoundTripTest, ::testing::ValuesIn(std::vector({ // TODO(dneto): Should this be a list of sourc texts, - // to accomodate length limits? + // to accommodate length limits? CASE_I(Source), CASE_II(Source), }))); diff --git a/third_party/spirv-tools/test/ext_inst.opencl_test.cpp b/third_party/spirv-tools/test/ext_inst.opencl_test.cpp index 7547d92240..d80a9bd740 100644 --- a/third_party/spirv-tools/test/ext_inst.opencl_test.cpp +++ b/third_party/spirv-tools/test/ext_inst.opencl_test.cpp @@ -233,7 +233,7 @@ INSTANTIATE_TEST_SUITE_P( CASE3(UMad_hi, u_mad_hi), // enum value 204 }))); -// OpenCL.std: 2.3 Common instrucitons +// OpenCL.std: 2.3 Common instructions INSTANTIATE_TEST_SUITE_P( OpenCLCommon, ExtInstOpenCLStdRoundTripTest, ::testing::ValuesIn(std::vector({ diff --git a/third_party/spirv-tools/test/fuzz/fuzz_test_util.cpp b/third_party/spirv-tools/test/fuzz/fuzz_test_util.cpp index bf0a4ff5dc..93c9c584d9 100644 --- a/third_party/spirv-tools/test/fuzz/fuzz_test_util.cpp +++ b/third_party/spirv-tools/test/fuzz/fuzz_test_util.cpp @@ -149,7 +149,7 @@ void DumpTransformationsJson( json_options.add_whitespace = true; auto json_generation_status = google::protobuf::util::MessageToJsonString( transformations, &json_string, json_options); - if (json_generation_status == google::protobuf::util::Status::OK) { + if (json_generation_status.ok()) { std::ofstream transformations_json_file(filename); transformations_json_file << json_string; transformations_json_file.close(); diff --git a/third_party/spirv-tools/test/fuzz/fuzzerutil_test.cpp b/third_party/spirv-tools/test/fuzz/fuzzerutil_test.cpp index 0ad3e742b1..1286d38ddc 100644 --- a/third_party/spirv-tools/test/fuzz/fuzzerutil_test.cpp +++ b/third_party/spirv-tools/test/fuzz/fuzzerutil_test.cpp @@ -70,7 +70,7 @@ TEST(FuzzerUtilMaybeFindBlockTest, BasicTest) { ASSERT_TRUE(fuzzerutil::MaybeFindBlock(ir_context, block_id2) != nullptr); // Block with id 13 cannot be found. ASSERT_FALSE(fuzzerutil::MaybeFindBlock(ir_context, block_id3) != nullptr); - // Block with id 8 exisits but don't not of type OpLabel. + // Block with id 8 exists but don't not of type OpLabel. ASSERT_FALSE(fuzzerutil::MaybeFindBlock(ir_context, block_id4) != nullptr); } @@ -965,7 +965,7 @@ TEST(FuzzerutilTest, FuzzerUtilMaybeGetPointerTypeTest) { ASSERT_EQ( 91, fuzzerutil::MaybeGetPointerType(ir_context, 90, input_storage_class)); - // A pointer with id=91 and pointee type 90 exisits, but the type should be + // A pointer with id=91 and pointee type 90 exists, but the type should be // input. ASSERT_EQ(0, fuzzerutil::MaybeGetPointerType(ir_context, 90, function_storage_class)); diff --git a/third_party/spirv-tools/test/fuzz/transformation_add_parameter_test.cpp b/third_party/spirv-tools/test/fuzz/transformation_add_parameter_test.cpp index 2ae60c9d64..7f069b5582 100644 --- a/third_party/spirv-tools/test/fuzz/transformation_add_parameter_test.cpp +++ b/third_party/spirv-tools/test/fuzz/transformation_add_parameter_test.cpp @@ -367,7 +367,7 @@ TEST(TransformationAddParameterTest, NonPointerNotApplicableTest) { transformation_bad_3.IsApplicable(context.get(), transformation_context)); // Function with id 14 does not have any callers. - // Bad: Id 18 is not a vaild type. + // Bad: Id 18 is not a valid type. TransformationAddParameter transformation_bad_4(14, 50, 18, {{}}, 51); ASSERT_FALSE( transformation_bad_4.IsApplicable(context.get(), transformation_context)); diff --git a/third_party/spirv-tools/test/fuzz/transformation_add_type_int_test.cpp b/third_party/spirv-tools/test/fuzz/transformation_add_type_int_test.cpp index ed8e00a620..4cbfed0fd0 100644 --- a/third_party/spirv-tools/test/fuzz/transformation_add_type_int_test.cpp +++ b/third_party/spirv-tools/test/fuzz/transformation_add_type_int_test.cpp @@ -87,7 +87,7 @@ TEST(TransformationAddTypeIntTest, IsApplicable) { transformation.IsApplicable(context.get(), transformation_context)); // By default SPIR-V does not support 16-bit integers. - // Below we add such capability, so the test should now be succesful. + // Below we add such capability, so the test should now be successful. context.get()->get_feature_mgr()->AddCapability(SpvCapabilityInt16); ASSERT_TRUE(TransformationAddTypeInt(7, 16, true) .IsApplicable(context.get(), transformation_context)); diff --git a/third_party/spirv-tools/test/fuzz/transformation_adjust_branch_weights_test.cpp b/third_party/spirv-tools/test/fuzz/transformation_adjust_branch_weights_test.cpp index 1bf2c59314..5984a3e996 100644 --- a/third_party/spirv-tools/test/fuzz/transformation_adjust_branch_weights_test.cpp +++ b/third_party/spirv-tools/test/fuzz/transformation_adjust_branch_weights_test.cpp @@ -106,7 +106,7 @@ TEST(TransformationAdjustBranchWeightsTest, IsApplicableTest) { kConsoleMessageConsumer)); TransformationContext transformation_context( MakeUnique(context.get()), validator_options); - // Tests OpBranchConditional instruction with weigths. + // Tests OpBranchConditional instruction with weights. auto instruction_descriptor = MakeInstructionDescriptor(33, SpvOpBranchConditional, 0); auto transformation = diff --git a/third_party/spirv-tools/test/fuzzers/BUILD.gn b/third_party/spirv-tools/test/fuzzers/BUILD.gn index 2aef4e8f22..fc458a4fb3 100644 --- a/third_party/spirv-tools/test/fuzzers/BUILD.gn +++ b/third_party/spirv-tools/test/fuzzers/BUILD.gn @@ -87,18 +87,21 @@ spvtools_fuzzer("spvtools_dis_fuzzer_src") { spvtools_fuzzer("spvtools_opt_performance_fuzzer_src") { sources = [ "spvtools_opt_performance_fuzzer.cpp", + "spvtools_opt_fuzzer_common.cpp", ] } spvtools_fuzzer("spvtools_opt_legalization_fuzzer_src") { sources = [ "spvtools_opt_legalization_fuzzer.cpp", + "spvtools_opt_fuzzer_common.cpp", ] } spvtools_fuzzer("spvtools_opt_size_fuzzer_src") { sources = [ "spvtools_opt_size_fuzzer.cpp", + "spvtools_opt_fuzzer_common.cpp", ] } diff --git a/third_party/spirv-tools/test/fuzzers/CMakeLists.txt b/third_party/spirv-tools/test/fuzzers/CMakeLists.txt index 50c458957e..e1fe516a42 100644 --- a/third_party/spirv-tools/test/fuzzers/CMakeLists.txt +++ b/third_party/spirv-tools/test/fuzzers/CMakeLists.txt @@ -46,9 +46,9 @@ if (${SPIRV_BUILD_LIBFUZZER_TARGETS}) add_spvtools_libfuzzer_target(TARGET spvtools_as_fuzzer SRCS spvtools_as_fuzzer.cpp random_generator.cpp LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) add_spvtools_libfuzzer_target(TARGET spvtools_binary_parser_fuzzer SRCS spvtools_binary_parser_fuzzer.cpp random_generator.cpp LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) add_spvtools_libfuzzer_target(TARGET spvtools_dis_fuzzer SRCS spvtools_dis_fuzzer.cpp random_generator.cpp LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) - add_spvtools_libfuzzer_target(TARGET spvtools_opt_legalization_fuzzer SRCS spvtools_opt_legalization_fuzzer.cpp random_generator.cpp LIBS SPIRV-Tools-opt ${SPIRV_TOOLS_FULL_VISIBILITY}) - add_spvtools_libfuzzer_target(TARGET spvtools_opt_performance_fuzzer SRCS spvtools_opt_performance_fuzzer.cpp random_generator.cpp LIBS SPIRV-Tools-opt ${SPIRV_TOOLS_FULL_VISIBILITY}) - add_spvtools_libfuzzer_target(TARGET spvtools_opt_size_fuzzer SRCS spvtools_opt_size_fuzzer.cpp random_generator.cpp LIBS SPIRV-Tools-opt ${SPIRV_TOOLS_FULL_VISIBILITY}) + add_spvtools_libfuzzer_target(TARGET spvtools_opt_legalization_fuzzer SRCS spvtools_opt_legalization_fuzzer.cpp spvtools_opt_fuzzer_common.cpp random_generator.cpp LIBS SPIRV-Tools-opt ${SPIRV_TOOLS_FULL_VISIBILITY}) + add_spvtools_libfuzzer_target(TARGET spvtools_opt_performance_fuzzer SRCS spvtools_opt_performance_fuzzer.cpp spvtools_opt_fuzzer_common.cpp random_generator.cpp LIBS SPIRV-Tools-opt ${SPIRV_TOOLS_FULL_VISIBILITY}) + add_spvtools_libfuzzer_target(TARGET spvtools_opt_size_fuzzer SRCS spvtools_opt_size_fuzzer.cpp spvtools_opt_fuzzer_common.cpp random_generator.cpp LIBS SPIRV-Tools-opt ${SPIRV_TOOLS_FULL_VISIBILITY}) add_spvtools_libfuzzer_target(TARGET spvtools_val_fuzzer SRCS spvtools_val_fuzzer.cpp random_generator.cpp LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) if (${SPIRV_BUILD_FUZZER}) add_spvtools_libfuzzer_target(TARGET spvtools_fuzz_fuzzer SRCS spvtools_fuzz_fuzzer.cpp random_generator.cpp LIBS SPIRV-Tools-fuzz ${SPIRV_TOOLS_FULL_VISIBILITY}) diff --git a/third_party/spirv-tools/test/fuzzers/spvtools_as_fuzzer.cpp b/third_party/spirv-tools/test/fuzzers/spvtools_as_fuzzer.cpp index ba3f5b97d1..8ead1cff18 100644 --- a/third_party/spirv-tools/test/fuzzers/spvtools_as_fuzzer.cpp +++ b/third_party/spirv-tools/test/fuzzers/spvtools_as_fuzzer.cpp @@ -32,22 +32,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { return 0; } - std::vector input; - input.resize(size >> 2); - size_t count = 0; - for (size_t i = 0; (i + 3) < size; i += 4) { - input[count++] = data[i] | (data[i + 1] << 8) | (data[i + 2] << 16) | - (data[i + 3]) << 24; - } - - std::vector input_str; - size_t char_count = input.size() * sizeof(uint32_t) / sizeof(char); - input_str.resize(char_count); - memcpy(input_str.data(), input.data(), input.size() * sizeof(uint32_t)); + std::vector contents; + contents.resize(size); + memcpy(contents.data(), data, size); spv_binary binary = nullptr; spv_diagnostic diagnostic = nullptr; - spvTextToBinaryWithOptions(context, input_str.data(), input_str.size(), + spvTextToBinaryWithOptions(context, contents.data(), contents.size(), SPV_TEXT_TO_BINARY_OPTION_NONE, &binary, &diagnostic); if (diagnostic) { @@ -61,7 +52,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { binary = nullptr; } - spvTextToBinaryWithOptions(context, input_str.data(), input_str.size(), + spvTextToBinaryWithOptions(context, contents.data(), contents.size(), SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS, &binary, &diagnostic); if (diagnostic) { diff --git a/third_party/spirv-tools/test/fuzzers/spvtools_opt_fuzzer_common.cpp b/third_party/spirv-tools/test/fuzzers/spvtools_opt_fuzzer_common.cpp new file mode 100644 index 0000000000..4978509063 --- /dev/null +++ b/third_party/spirv-tools/test/fuzzers/spvtools_opt_fuzzer_common.cpp @@ -0,0 +1,84 @@ +// Copyright (c) 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "test/fuzzers/spvtools_opt_fuzzer_common.h" + +#include "source/opt/build_module.h" +#include "test/fuzzers/random_generator.h" + +namespace spvtools { +namespace fuzzers { + +int OptFuzzerTestOneInput( + const uint8_t* data, size_t size, + const std::function& register_passes) { + if (size < 1) { + return 0; + } + + spvtools::fuzzers::RandomGenerator random_gen(data, size); + auto target_env = random_gen.GetTargetEnv(); + spvtools::Optimizer optimizer(target_env); + optimizer.SetMessageConsumer([](spv_message_level_t, const char*, + const spv_position_t&, const char*) {}); + + std::vector input; + input.resize(size >> 2); + + size_t count = 0; + for (size_t i = 0; (i + 3) < size; i += 4) { + input[count++] = data[i] | (data[i + 1] << 8) | (data[i + 2] << 16) | + (data[i + 3]) << 24; + } + + // The largest possible id bound is used when running the optimizer, to avoid + // the problem of id overflows. + const size_t kFinalIdLimit = UINT32_MAX; + + // The input is scanned to check that it does not already use an id too close + // to this limit. This still gives the optimizer a large set of ids to + // consume. It is thus very unlikely that id overflow will occur during + // fuzzing. If it does, then the initial id limit should be decreased. + const size_t kInitialIdLimit = kFinalIdLimit - 1000000U; + + // Build the module and scan it to check that all used ids are below the + // initial limit. + auto ir_context = + spvtools::BuildModule(target_env, nullptr, input.data(), input.size()); + if (ir_context == nullptr) { + // It was not possible to build a valid module; that's OK - skip this input. + return 0; + } + if (ir_context->module()->id_bound() >= kInitialIdLimit) { + // The input already has a very large id bound. The input is thus abandoned, + // to avoid the possibility of ending up hitting the id bound limit. + return 0; + } + + // Set the optimizer and its validator up with the largest possible id bound + // limit. + spvtools::ValidatorOptions validator_options; + spvtools::OptimizerOptions optimizer_options; + optimizer_options.set_max_id_bound(kFinalIdLimit); + validator_options.SetUniversalLimit(spv_validator_limit_max_id_bound, + kFinalIdLimit); + optimizer_options.set_validator_options(validator_options); + register_passes(optimizer); + optimizer.Run(input.data(), input.size(), &input, optimizer_options); + + return 0; +} + +} // namespace fuzzers +} // namespace spvtools diff --git a/third_party/spirv-tools/test/fuzzers/spvtools_opt_fuzzer_common.h b/third_party/spirv-tools/test/fuzzers/spvtools_opt_fuzzer_common.h new file mode 100644 index 0000000000..b8d4281cdd --- /dev/null +++ b/third_party/spirv-tools/test/fuzzers/spvtools_opt_fuzzer_common.h @@ -0,0 +1,35 @@ +// Copyright (c) 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef TEST_FUZZERS_SPVTOOLS_OPT_FUZZER_COMMON_H_ +#define TEST_FUZZERS_SPVTOOLS_OPT_FUZZER_COMMON_H_ + +#include +#include +#include + +#include "spirv-tools/optimizer.hpp" + +namespace spvtools { +namespace fuzzers { + +// Helper function capturing the common logic for the various optimizer fuzzers. +int OptFuzzerTestOneInput( + const uint8_t* data, size_t size, + const std::function& register_passes); + +} // namespace fuzzers +} // namespace spvtools + +#endif // TEST_FUZZERS_SPVTOOLS_OPT_FUZZER_COMMON_H_ diff --git a/third_party/spirv-tools/test/fuzzers/spvtools_opt_legalization_fuzzer.cpp b/third_party/spirv-tools/test/fuzzers/spvtools_opt_legalization_fuzzer.cpp index 6f4d7e8b74..fac4d23c19 100644 --- a/third_party/spirv-tools/test/fuzzers/spvtools_opt_legalization_fuzzer.cpp +++ b/third_party/spirv-tools/test/fuzzers/spvtools_opt_legalization_fuzzer.cpp @@ -12,33 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include +#include +#include +#include #include "spirv-tools/optimizer.hpp" -#include "test/fuzzers/random_generator.h" +#include "test/fuzzers/spvtools_opt_fuzzer_common.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - if (size < 1) { - return 0; - } - - spvtools::fuzzers::RandomGenerator random_gen(data, size); - spvtools::Optimizer optimizer(random_gen.GetTargetEnv()); - optimizer.SetMessageConsumer([](spv_message_level_t, const char*, - const spv_position_t&, const char*) {}); - - std::vector input; - input.resize(size >> 2); - - size_t count = 0; - for (size_t i = 0; (i + 3) < size; i += 4) { - input[count++] = data[i] | (data[i + 1] << 8) | (data[i + 2] << 16) | - (data[i + 3]) << 24; - } - - optimizer.RegisterLegalizationPasses(); - optimizer.Run(input.data(), input.size(), &input); - - return 0; + return spvtools::fuzzers::OptFuzzerTestOneInput( + data, size, [](spvtools::Optimizer& optimizer) -> void { + optimizer.RegisterLegalizationPasses(); + }); } diff --git a/third_party/spirv-tools/test/fuzzers/spvtools_opt_performance_fuzzer.cpp b/third_party/spirv-tools/test/fuzzers/spvtools_opt_performance_fuzzer.cpp index 9c47d7d7af..e6038b90dc 100644 --- a/third_party/spirv-tools/test/fuzzers/spvtools_opt_performance_fuzzer.cpp +++ b/third_party/spirv-tools/test/fuzzers/spvtools_opt_performance_fuzzer.cpp @@ -12,33 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include +#include +#include +#include #include "spirv-tools/optimizer.hpp" -#include "test/fuzzers/random_generator.h" +#include "test/fuzzers/spvtools_opt_fuzzer_common.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - if (size < 1) { - return 0; - } - - spvtools::fuzzers::RandomGenerator random_gen(data, size); - spvtools::Optimizer optimizer(random_gen.GetTargetEnv()); - optimizer.SetMessageConsumer([](spv_message_level_t, const char*, - const spv_position_t&, const char*) {}); - - std::vector input; - input.resize(size >> 2); - - size_t count = 0; - for (size_t i = 0; (i + 3) < size; i += 4) { - input[count++] = data[i] | (data[i + 1] << 8) | (data[i + 2] << 16) | - (data[i + 3]) << 24; - } - - optimizer.RegisterPerformancePasses(); - optimizer.Run(input.data(), input.size(), &input); - - return 0; + return spvtools::fuzzers::OptFuzzerTestOneInput( + data, size, [](spvtools::Optimizer& optimizer) -> void { + optimizer.RegisterPerformancePasses(); + }); } diff --git a/third_party/spirv-tools/test/fuzzers/spvtools_opt_size_fuzzer.cpp b/third_party/spirv-tools/test/fuzzers/spvtools_opt_size_fuzzer.cpp index 10fac42ac6..65492b1a5f 100644 --- a/third_party/spirv-tools/test/fuzzers/spvtools_opt_size_fuzzer.cpp +++ b/third_party/spirv-tools/test/fuzzers/spvtools_opt_size_fuzzer.cpp @@ -12,33 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include +#include +#include +#include #include "spirv-tools/optimizer.hpp" -#include "test/fuzzers/random_generator.h" +#include "test/fuzzers/spvtools_opt_fuzzer_common.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - if (size < 1) { - return 0; - } - - spvtools::fuzzers::RandomGenerator random_gen(data, size); - spvtools::Optimizer optimizer(random_gen.GetTargetEnv()); - optimizer.SetMessageConsumer([](spv_message_level_t, const char*, - const spv_position_t&, const char*) {}); - - std::vector input; - input.resize(size >> 2); - - size_t count = 0; - for (size_t i = 0; (i + 3) < size; i += 4) { - input[count++] = data[i] | (data[i + 1] << 8) | (data[i + 2] << 16) | - (data[i + 3]) << 24; - } - - optimizer.RegisterSizePasses(); - optimizer.Run(input.data(), input.size(), &input); - - return 0; + return spvtools::fuzzers::OptFuzzerTestOneInput( + data, size, [](spvtools::Optimizer& optimizer) -> void { + optimizer.RegisterSizePasses(); + }); } diff --git a/third_party/spirv-tools/test/hex_float_test.cpp b/third_party/spirv-tools/test/hex_float_test.cpp index ffdb8bda61..7edfd43df2 100644 --- a/third_party/spirv-tools/test/hex_float_test.cpp +++ b/third_party/spirv-tools/test/hex_float_test.cpp @@ -1343,7 +1343,7 @@ struct StreamParseCase { template std::ostream& operator<<(std::ostream& os, const StreamParseCase& fspc) { os << "StreamParseCase(" << fspc.literal - << ", expect_succes:" << int(fspc.expect_success) << "," + << ", expect_success:" << int(fspc.expect_success) << "," << fspc.expected_suffix << "," << fspc.expected_value << ")"; return os; } diff --git a/third_party/spirv-tools/test/link/binary_version_test.cpp b/third_party/spirv-tools/test/link/binary_version_test.cpp index 80aab0fd1d..a56030f4e1 100644 --- a/third_party/spirv-tools/test/link/binary_version_test.cpp +++ b/third_party/spirv-tools/test/link/binary_version_test.cpp @@ -20,40 +20,57 @@ namespace spvtools { namespace { +using ::testing::HasSubstr; using BinaryVersion = spvtest::LinkerTest; -TEST_F(BinaryVersion, LinkerChoosesMaxSpirvVersion) { +spvtest::Binary CreateBinary(uint32_t version) { + return { + // clang-format off + // Header + SpvMagicNumber, + version, + SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS, 0), + 1u, // NOTE: Bound + 0u, // NOTE: Schema; reserved + + // OpCapability Shader + SpvOpCapability | 2u << SpvWordCountShift, + SpvCapabilityShader, + + // OpMemoryModel Logical Simple + SpvOpMemoryModel | 3u << SpvWordCountShift, + SpvAddressingModelLogical, + SpvMemoryModelSimple + // clang-format on + }; +} + +TEST_F(BinaryVersion, Match) { // clang-format off spvtest::Binaries binaries = { - { - SpvMagicNumber, - 0x00010300u, - SPV_GENERATOR_CODEPLAY, - 1u, // NOTE: Bound - 0u // NOTE: Schema; reserved - }, - { - SpvMagicNumber, - 0x00010500u, - SPV_GENERATOR_CODEPLAY, - 1u, // NOTE: Bound - 0u // NOTE: Schema; reserved - }, - { - SpvMagicNumber, - 0x00010100u, - SPV_GENERATOR_CODEPLAY, - 1u, // NOTE: Bound - 0u // NOTE: Schema; reserved - } + CreateBinary(SPV_SPIRV_VERSION_WORD(1, 3)), + CreateBinary(SPV_SPIRV_VERSION_WORD(1, 3)), }; // clang-format on spvtest::Binary linked_binary; - - ASSERT_EQ(SPV_SUCCESS, Link(binaries, &linked_binary)); + ASSERT_EQ(SPV_SUCCESS, Link(binaries, &linked_binary)) << GetErrorMessage(); EXPECT_THAT(GetErrorMessage(), std::string()); + EXPECT_EQ(SPV_SPIRV_VERSION_WORD(1, 3), linked_binary[1]); +} - EXPECT_EQ(0x00010500u, linked_binary[1]); +TEST_F(BinaryVersion, Mismatch) { + // clang-format off + spvtest::Binaries binaries = { + CreateBinary(SPV_SPIRV_VERSION_WORD(1, 3)), + CreateBinary(SPV_SPIRV_VERSION_WORD(1, 5)), + }; + // clang-format on + spvtest::Binary linked_binary; + ASSERT_EQ(SPV_ERROR_INTERNAL, Link(binaries, &linked_binary)) + << GetErrorMessage(); + EXPECT_THAT(GetErrorMessage(), + HasSubstr("Conflicting SPIR-V versions: 1.3 (input modules 1 " + "through 1) vs 1.5 (input module 2).")); } } // namespace diff --git a/third_party/spirv-tools/test/link/entry_points_test.cpp b/third_party/spirv-tools/test/link/entry_points_test.cpp index bac8e02ef6..edf9f42499 100644 --- a/third_party/spirv-tools/test/link/entry_points_test.cpp +++ b/third_party/spirv-tools/test/link/entry_points_test.cpp @@ -26,6 +26,8 @@ class EntryPoints : public spvtest::LinkerTest {}; TEST_F(EntryPoints, SameModelDifferentName) { const std::string body1 = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %3 "foo" %1 = OpTypeVoid %2 = OpTypeFunction %1 @@ -33,6 +35,8 @@ OpEntryPoint GLCompute %3 "foo" OpFunctionEnd )"; const std::string body2 = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %3 "bar" %1 = OpTypeVoid %2 = OpTypeFunction %1 @@ -41,12 +45,15 @@ OpFunctionEnd )"; spvtest::Binary linked_binary; - EXPECT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary)); + ASSERT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary)) + << GetErrorMessage(); EXPECT_THAT(GetErrorMessage(), std::string()); } TEST_F(EntryPoints, DifferentModelSameName) { const std::string body1 = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %3 "foo" %1 = OpTypeVoid %2 = OpTypeFunction %1 @@ -54,6 +61,8 @@ OpEntryPoint GLCompute %3 "foo" OpFunctionEnd )"; const std::string body2 = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %3 "foo" %1 = OpTypeVoid %2 = OpTypeFunction %1 @@ -62,12 +71,15 @@ OpFunctionEnd )"; spvtest::Binary linked_binary; - EXPECT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary)); + ASSERT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary)) + << GetErrorMessage(); EXPECT_THAT(GetErrorMessage(), std::string()); } TEST_F(EntryPoints, SameModelAndName) { const std::string body1 = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %3 "foo" %1 = OpTypeVoid %2 = OpTypeFunction %1 @@ -75,6 +87,8 @@ OpEntryPoint GLCompute %3 "foo" OpFunctionEnd )"; const std::string body2 = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %3 "foo" %1 = OpTypeVoid %2 = OpTypeFunction %1 @@ -90,5 +104,48 @@ OpFunctionEnd "GLCompute, was already defined.")); } +TEST_F(EntryPoints, LinkedVariables) { + const std::string body1 = R"( + OpCapability Addresses +OpCapability Linkage +OpCapability Kernel +OpMemoryModel Physical64 OpenCL +OpDecorate %7 LinkageAttributes "foo" Export +%1 = OpTypeInt 32 0 +%2 = OpTypeVector %1 3 +%3 = OpTypePointer Input %2 +%4 = OpVariable %3 Input +%5 = OpTypeVoid +%6 = OpTypeFunction %5 +%7 = OpFunction %5 None %6 +%8 = OpLabel +%9 = OpLoad %2 %4 Aligned 32 +OpReturn +OpFunctionEnd +)"; + const std::string body2 = R"( +OpCapability Linkage +OpCapability Kernel +OpMemoryModel Physical64 OpenCL +OpEntryPoint Kernel %4 "bar" +OpDecorate %3 LinkageAttributes "foo" Import +%1 = OpTypeVoid +%2 = OpTypeFunction %1 +%3 = OpFunction %1 None %2 +OpFunctionEnd +%4 = OpFunction %1 None %2 +%5 = OpLabel +%6 = OpFunctionCall %1 %3 +OpReturn +OpFunctionEnd +)"; + + spvtest::Binary linked_binary; + EXPECT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary)); + EXPECT_THAT(GetErrorMessage(), std::string()); + EXPECT_TRUE(Validate(linked_binary)); + EXPECT_THAT(GetErrorMessage(), std::string()); +} + } // namespace } // namespace spvtools diff --git a/third_party/spirv-tools/test/link/global_values_amount_test.cpp b/third_party/spirv-tools/test/link/global_values_amount_test.cpp index 2c4ee1f03d..3158b7ec71 100644 --- a/third_party/spirv-tools/test/link/global_values_amount_test.cpp +++ b/third_party/spirv-tools/test/link/global_values_amount_test.cpp @@ -22,85 +22,56 @@ namespace { using ::testing::HasSubstr; +const uint32_t binary_count = 2u; + class EntryPointsAmountTest : public spvtest::LinkerTest { public: - EntryPointsAmountTest() { binaries.reserve(0xFFFF); } + EntryPointsAmountTest() { binaries.reserve(binary_count + 1u); } void SetUp() override { - binaries.push_back({SpvMagicNumber, - SpvVersion, - SPV_GENERATOR_CODEPLAY, - 10u, // NOTE: Bound - 0u, // NOTE: Schema; reserved + const uint32_t global_variable_count_per_binary = + (SPV_LIMIT_GLOBAL_VARIABLES_MAX - 1u) / binary_count; - 3u << SpvWordCountShift | SpvOpTypeFloat, - 1u, // NOTE: Result ID - 32u, // NOTE: Width + spvtest::Binary common_binary = { + // clang-format off + SpvMagicNumber, + SpvVersion, + SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS, 0), + 3u + global_variable_count_per_binary, // NOTE: Bound + 0u, // NOTE: Schema; reserved - 4u << SpvWordCountShift | SpvOpTypePointer, - 2u, // NOTE: Result ID - SpvStorageClassInput, - 1u, // NOTE: Type ID + SpvOpCapability | 2u << SpvWordCountShift, + SpvCapabilityShader, - 2u << SpvWordCountShift | SpvOpTypeVoid, - 3u, // NOTE: Result ID + SpvOpMemoryModel | 3u << SpvWordCountShift, + SpvAddressingModelLogical, + SpvMemoryModelSimple, - 3u << SpvWordCountShift | SpvOpTypeFunction, - 4u, // NOTE: Result ID - 3u, // NOTE: Return type + SpvOpTypeFloat | 3u << SpvWordCountShift, + 1u, // NOTE: Result ID + 32u, // NOTE: Width - 5u << SpvWordCountShift | SpvOpFunction, - 3u, // NOTE: Result type - 5u, // NOTE: Result ID - SpvFunctionControlMaskNone, - 4u, // NOTE: Function type + SpvOpTypePointer | 4u << SpvWordCountShift, + 2u, // NOTE: Result ID + SpvStorageClassInput, + 1u // NOTE: Type ID + // clang-format on + }; - 2u << SpvWordCountShift | SpvOpLabel, - 6u, // NOTE: Result ID + binaries.push_back({}); + spvtest::Binary& binary = binaries.back(); + binary.reserve(common_binary.size() + global_variable_count_per_binary * 4); + binary.insert(binary.end(), common_binary.cbegin(), common_binary.cend()); - 4u << SpvWordCountShift | SpvOpVariable, - 2u, // NOTE: Type ID - 7u, // NOTE: Result ID - SpvStorageClassFunction, + for (uint32_t i = 0u; i < global_variable_count_per_binary; ++i) { + binary.push_back(SpvOpVariable | 4u << SpvWordCountShift); + binary.push_back(2u); // NOTE: Type ID + binary.push_back(3u + i); // NOTE: Result ID + binary.push_back(SpvStorageClassInput); + } - 4u << SpvWordCountShift | SpvOpVariable, - 2u, // NOTE: Type ID - 8u, // NOTE: Result ID - SpvStorageClassFunction, - - 4u << SpvWordCountShift | SpvOpVariable, - 2u, // NOTE: Type ID - 9u, // NOTE: Result ID - SpvStorageClassFunction, - - 1u << SpvWordCountShift | SpvOpReturn, - - 1u << SpvWordCountShift | SpvOpFunctionEnd}); - for (size_t i = 0u; i < 2u; ++i) { - spvtest::Binary binary = { - SpvMagicNumber, - SpvVersion, - SPV_GENERATOR_CODEPLAY, - 103u, // NOTE: Bound - 0u, // NOTE: Schema; reserved - - 3u << SpvWordCountShift | SpvOpTypeFloat, - 1u, // NOTE: Result ID - 32u, // NOTE: Width - - 4u << SpvWordCountShift | SpvOpTypePointer, - 2u, // NOTE: Result ID - SpvStorageClassInput, - 1u // NOTE: Type ID - }; - - for (uint32_t j = 0u; j < 0xFFFFu / 2u; ++j) { - binary.push_back(4u << SpvWordCountShift | SpvOpVariable); - binary.push_back(2u); // NOTE: Type ID - binary.push_back(j + 3u); // NOTE: Result ID - binary.push_back(SpvStorageClassInput); - } - binaries.push_back(binary); + for (uint32_t i = 0u; i < binary_count - 1u; ++i) { + binaries.push_back(binaries.back()); } } void TearDown() override { binaries.clear(); } @@ -111,42 +82,53 @@ class EntryPointsAmountTest : public spvtest::LinkerTest { TEST_F(EntryPointsAmountTest, UnderLimit) { spvtest::Binary linked_binary; - EXPECT_EQ(SPV_SUCCESS, Link(binaries, &linked_binary)); + ASSERT_EQ(SPV_SUCCESS, Link(binaries, &linked_binary)) << GetErrorMessage(); EXPECT_THAT(GetErrorMessage(), std::string()); } TEST_F(EntryPointsAmountTest, OverLimit) { - binaries.push_back({SpvMagicNumber, - SpvVersion, - SPV_GENERATOR_CODEPLAY, - 5u, // NOTE: Bound - 0u, // NOTE: Schema; reserved + binaries.push_back({ + // clang-format off + SpvMagicNumber, + SpvVersion, + SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS, 0), + 5u, // NOTE: Bound + 0u, // NOTE: Schema; reserved - 3u << SpvWordCountShift | SpvOpTypeFloat, - 1u, // NOTE: Result ID - 32u, // NOTE: Width + SpvOpCapability | 2u << SpvWordCountShift, + SpvCapabilityShader, - 4u << SpvWordCountShift | SpvOpTypePointer, - 2u, // NOTE: Result ID - SpvStorageClassInput, - 1u, // NOTE: Type ID + SpvOpMemoryModel | 3u << SpvWordCountShift, + SpvAddressingModelLogical, + SpvMemoryModelSimple, - 4u << SpvWordCountShift | SpvOpVariable, - 2u, // NOTE: Type ID - 3u, // NOTE: Result ID - SpvStorageClassInput, + SpvOpTypeFloat | 3u << SpvWordCountShift, + 1u, // NOTE: Result ID + 32u, // NOTE: Width - 4u << SpvWordCountShift | SpvOpVariable, - 2u, // NOTE: Type ID - 4u, // NOTE: Result ID - SpvStorageClassInput}); + SpvOpTypePointer | 4u << SpvWordCountShift, + 2u, // NOTE: Result ID + SpvStorageClassInput, + 1u, // NOTE: Type ID + + SpvOpVariable | 4u << SpvWordCountShift, + 2u, // NOTE: Type ID + 3u, // NOTE: Result ID + SpvStorageClassInput, + + SpvOpVariable | 4u << SpvWordCountShift, + 2u, // NOTE: Type ID + 4u, // NOTE: Result ID + SpvStorageClassInput + // clang-format on + }); spvtest::Binary linked_binary; - - EXPECT_EQ(SPV_ERROR_INTERNAL, Link(binaries, &linked_binary)); - EXPECT_THAT(GetErrorMessage(), - HasSubstr("The limit of global values, 65535, was exceeded; " - "65536 global values were found.")); + ASSERT_EQ(SPV_SUCCESS, Link(binaries, &linked_binary)) << GetErrorMessage(); + EXPECT_THAT( + GetErrorMessage(), + HasSubstr("The minimum limit of global values, 65535, was exceeded; " + "65536 global values were found.")); } } // namespace diff --git a/third_party/spirv-tools/test/link/ids_limit_test.cpp b/third_party/spirv-tools/test/link/ids_limit_test.cpp index 6d7815a24d..846fbef89a 100644 --- a/third_party/spirv-tools/test/link/ids_limit_test.cpp +++ b/third_party/spirv-tools/test/link/ids_limit_test.cpp @@ -21,51 +21,114 @@ namespace spvtools { namespace { using ::testing::HasSubstr; -using IdsLimit = spvtest::LinkerTest; -TEST_F(IdsLimit, UnderLimit) { - spvtest::Binaries binaries = { - { - SpvMagicNumber, SpvVersion, SPV_GENERATOR_CODEPLAY, - 0x2FFFFFu, // NOTE: Bound - 0u, // NOTE: Schema; reserved - }, - { - SpvMagicNumber, SpvVersion, SPV_GENERATOR_CODEPLAY, - 0x100000u, // NOTE: Bound - 0u, // NOTE: Schema; reserved - }}; - spvtest::Binary linked_binary; +class IdsLimit : public spvtest::LinkerTest { + public: + IdsLimit() { binaries.reserve(2u); } - ASSERT_EQ(SPV_SUCCESS, Link(binaries, &linked_binary)); - EXPECT_THAT(GetErrorMessage(), std::string()); - EXPECT_EQ(0x3FFFFEu, linked_binary[3]); + void SetUp() override { + const uint32_t id_bound = SPV_LIMIT_RESULT_ID_BOUND - 1u; + const uint32_t constant_count = + id_bound - + 2u; // One ID is used for TypeBool, and (constant_count + 1) < id_bound + + // This is needed, as otherwise the ID bound will get reset to 1 while + // running the RemoveDuplicates pass. + spvtest::Binary common_binary = { + // clang-format off + SpvMagicNumber, + SpvVersion, + SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS, 0), + id_bound, // NOTE: Bound + 0u, // NOTE: Schema; reserved + + SpvOpCapability | 2u << SpvWordCountShift, + SpvCapabilityShader, + + SpvOpMemoryModel | 3u << SpvWordCountShift, + SpvAddressingModelLogical, + SpvMemoryModelSimple, + + SpvOpTypeBool | 2u << SpvWordCountShift, + 1u // NOTE: Result ID + // clang-format on + }; + + binaries.push_back({}); + spvtest::Binary& binary = binaries.back(); + binary.reserve(common_binary.size() + constant_count * 3u); + binary.insert(binary.end(), common_binary.cbegin(), common_binary.cend()); + + for (uint32_t i = 0u; i < constant_count; ++i) { + binary.push_back(SpvOpConstantTrue | 3u << SpvWordCountShift); + binary.push_back(1u); // NOTE: Type ID + binary.push_back(2u + i); // NOTE: Result ID + } + } + void TearDown() override { binaries.clear(); } + + spvtest::Binaries binaries; +}; + +spvtest::Binary CreateBinary(uint32_t id_bound) { + return { + // clang-format off + // Header + SpvMagicNumber, + SpvVersion, + SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS, 0), + id_bound, // NOTE: Bound + 0u, // NOTE: Schema; reserved + + // OpCapability Shader + SpvOpCapability | 2u << SpvWordCountShift, + SpvCapabilityShader, + + // OpMemoryModel Logical Simple + SpvOpMemoryModel | 3u << SpvWordCountShift, + SpvAddressingModelLogical, + SpvMemoryModelSimple + // clang-format on + }; } -TEST_F(IdsLimit, OverLimit) { - spvtest::Binaries binaries = { - { - SpvMagicNumber, SpvVersion, SPV_GENERATOR_CODEPLAY, - 0x2FFFFFu, // NOTE: Bound - 0u, // NOTE: Schema; reserved - }, - { - SpvMagicNumber, SpvVersion, SPV_GENERATOR_CODEPLAY, - 0x100000u, // NOTE: Bound - 0u, // NOTE: Schema; reserved - }, - { - SpvMagicNumber, SpvVersion, SPV_GENERATOR_CODEPLAY, - 3u, // NOTE: Bound - 0u, // NOTE: Schema; reserved - }}; +TEST_F(IdsLimit, DISABLED_UnderLimit) { + spvtest::Binary linked_binary; + ASSERT_EQ(SPV_SUCCESS, Link(binaries, &linked_binary)) << GetErrorMessage(); + EXPECT_THAT(GetErrorMessage(), std::string()); + EXPECT_EQ(0x3FFFFFu, linked_binary[3]); +} + +TEST_F(IdsLimit, DISABLED_OverLimit) { + spvtest::Binary& binary = binaries.back(); + + const uint32_t id_bound = binary[3]; + binary[3] = id_bound + 1u; + + binary.push_back(SpvOpConstantFalse | 3u << SpvWordCountShift); + binary.push_back(1u); // NOTE: Type ID + binary.push_back(id_bound); // NOTE: Result ID + + spvtest::Binary linked_binary; + ASSERT_EQ(SPV_SUCCESS, Link(binaries, &linked_binary)) << GetErrorMessage(); + EXPECT_THAT( + GetErrorMessage(), + HasSubstr("The minimum limit of IDs, 4194303, was exceeded: 4194304 is " + "the current ID bound.")); + EXPECT_EQ(0x400000u, linked_binary[3]); +} + +TEST_F(IdsLimit, DISABLED_Overflow) { + spvtest::Binaries binaries = {CreateBinary(0xFFFFFFFFu), + CreateBinary(0x00000002u)}; spvtest::Binary linked_binary; - EXPECT_EQ(SPV_ERROR_INVALID_ID, Link(binaries, &linked_binary)); - EXPECT_THAT(GetErrorMessage(), - HasSubstr("The limit of IDs, 4194303, was exceeded: 4194304 is " - "the current ID bound.")); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, Link(binaries, &linked_binary)); + EXPECT_THAT( + GetErrorMessage(), + HasSubstr("Too many IDs (4294967296): combining all modules would " + "overflow the 32-bit word of the SPIR-V header.")); } } // namespace diff --git a/third_party/spirv-tools/test/link/linker_fixture.h b/third_party/spirv-tools/test/link/linker_fixture.h index 7bb122354d..d005288cf0 100644 --- a/third_party/spirv-tools/test/link/linker_fixture.h +++ b/third_party/spirv-tools/test/link/linker_fixture.h @@ -208,6 +208,10 @@ class LinkerTest : public ::testing::Test { // Returns the accumulated error messages for the test. std::string GetErrorMessage() const { return error_message_; } + bool Validate(const spvtest::Binary& binary) { + return tools_.Validate(binary); + } + private: spvtools::Context context_; spvtools::SpirvTools diff --git a/third_party/spirv-tools/test/link/matching_imports_to_exports_test.cpp b/third_party/spirv-tools/test/link/matching_imports_to_exports_test.cpp index e76c69fb31..6b02fc46dd 100644 --- a/third_party/spirv-tools/test/link/matching_imports_to_exports_test.cpp +++ b/third_party/spirv-tools/test/link/matching_imports_to_exports_test.cpp @@ -26,6 +26,9 @@ using MatchingImportsToExports = spvtest::LinkerTest; TEST_F(MatchingImportsToExports, Default) { const std::string body1 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Import %2 = OpTypeFloat 32 %1 = OpVariable %2 Uniform @@ -33,6 +36,9 @@ OpDecorate %1 LinkageAttributes "foo" Import )"; const std::string body2 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Export %2 = OpTypeFloat 32 %3 = OpConstant %2 42 @@ -40,11 +46,14 @@ OpDecorate %1 LinkageAttributes "foo" Export )"; spvtest::Binary linked_binary; - EXPECT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary)) + ASSERT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary)) << GetErrorMessage(); const std::string expected_res = - R"(OpModuleProcessed "Linked by SPIR-V Tools Linker" + R"(OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL +OpModuleProcessed "Linked by SPIR-V Tools Linker" %1 = OpTypeFloat 32 %2 = OpVariable %1 Input %3 = OpConstant %1 42 @@ -52,7 +61,7 @@ OpDecorate %1 LinkageAttributes "foo" Export )"; std::string res_body; SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER); - EXPECT_EQ(SPV_SUCCESS, Disassemble(linked_binary, &res_body)) + ASSERT_EQ(SPV_SUCCESS, Disassemble(linked_binary, &res_body)) << GetErrorMessage(); EXPECT_EQ(expected_res, res_body); } @@ -60,23 +69,29 @@ OpDecorate %1 LinkageAttributes "foo" Export TEST_F(MatchingImportsToExports, NotALibraryExtraExports) { const std::string body = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Export %2 = OpTypeFloat 32 %1 = OpVariable %2 Uniform )"; spvtest::Binary linked_binary; - EXPECT_EQ(SPV_SUCCESS, AssembleAndLink({body}, &linked_binary)) + ASSERT_EQ(SPV_SUCCESS, AssembleAndLink({body}, &linked_binary)) << GetErrorMessage(); const std::string expected_res = - R"(OpModuleProcessed "Linked by SPIR-V Tools Linker" + R"(OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL +OpModuleProcessed "Linked by SPIR-V Tools Linker" %1 = OpTypeFloat 32 %2 = OpVariable %1 Uniform )"; std::string res_body; SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER); - EXPECT_EQ(SPV_SUCCESS, Disassemble(linked_binary, &res_body)) + ASSERT_EQ(SPV_SUCCESS, Disassemble(linked_binary, &res_body)) << GetErrorMessage(); EXPECT_EQ(expected_res, res_body); } @@ -84,6 +99,9 @@ OpDecorate %1 LinkageAttributes "foo" Export TEST_F(MatchingImportsToExports, LibraryExtraExports) { const std::string body = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Export %2 = OpTypeFloat 32 %1 = OpVariable %2 Uniform @@ -92,10 +110,13 @@ OpDecorate %1 LinkageAttributes "foo" Export spvtest::Binary linked_binary; LinkerOptions options; options.SetCreateLibrary(true); - EXPECT_EQ(SPV_SUCCESS, AssembleAndLink({body}, &linked_binary, options)) + ASSERT_EQ(SPV_SUCCESS, AssembleAndLink({body}, &linked_binary, options)) << GetErrorMessage(); const std::string expected_res = R"(OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpModuleProcessed "Linked by SPIR-V Tools Linker" OpDecorate %1 LinkageAttributes "foo" Export %2 = OpTypeFloat 32 @@ -103,7 +124,7 @@ OpDecorate %1 LinkageAttributes "foo" Export )"; std::string res_body; SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER); - EXPECT_EQ(SPV_SUCCESS, Disassemble(linked_binary, &res_body)) + ASSERT_EQ(SPV_SUCCESS, Disassemble(linked_binary, &res_body)) << GetErrorMessage(); EXPECT_EQ(expected_res, res_body); } @@ -111,11 +132,18 @@ OpDecorate %1 LinkageAttributes "foo" Export TEST_F(MatchingImportsToExports, UnresolvedImports) { const std::string body1 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Import %2 = OpTypeFloat 32 %1 = OpVariable %2 Uniform )"; - const std::string body2 = R"()"; + const std::string body2 = R"( +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL +)"; spvtest::Binary linked_binary; EXPECT_EQ(SPV_ERROR_INVALID_BINARY, @@ -127,6 +155,9 @@ OpDecorate %1 LinkageAttributes "foo" Import TEST_F(MatchingImportsToExports, TypeMismatch) { const std::string body1 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Import %2 = OpTypeFloat 32 %1 = OpVariable %2 Uniform @@ -134,6 +165,9 @@ OpDecorate %1 LinkageAttributes "foo" Import )"; const std::string body2 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Export %2 = OpTypeInt 32 0 %3 = OpConstant %2 42 @@ -153,6 +187,9 @@ OpDecorate %1 LinkageAttributes "foo" Export TEST_F(MatchingImportsToExports, MultipleDefinitions) { const std::string body1 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Import %2 = OpTypeFloat 32 %1 = OpVariable %2 Uniform @@ -160,6 +197,9 @@ OpDecorate %1 LinkageAttributes "foo" Import )"; const std::string body2 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Export %2 = OpTypeFloat 32 %3 = OpConstant %2 42 @@ -167,6 +207,9 @@ OpDecorate %1 LinkageAttributes "foo" Export )"; const std::string body3 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Export %2 = OpTypeFloat 32 %3 = OpConstant %2 -1 @@ -185,6 +228,9 @@ OpDecorate %1 LinkageAttributes "foo" Export TEST_F(MatchingImportsToExports, SameNameDifferentTypes) { const std::string body1 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Import %2 = OpTypeFloat 32 %1 = OpVariable %2 Uniform @@ -192,6 +238,9 @@ OpDecorate %1 LinkageAttributes "foo" Import )"; const std::string body2 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Export %2 = OpTypeInt 32 0 %3 = OpConstant %2 42 @@ -199,6 +248,9 @@ OpDecorate %1 LinkageAttributes "foo" Export )"; const std::string body3 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Export %2 = OpTypeFloat 32 %3 = OpConstant %2 12 @@ -217,6 +269,9 @@ OpDecorate %1 LinkageAttributes "foo" Export TEST_F(MatchingImportsToExports, DecorationMismatch) { const std::string body1 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Import OpDecorate %2 Constant %2 = OpTypeFloat 32 @@ -225,6 +280,9 @@ OpDecorate %2 Constant )"; const std::string body2 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Export %2 = OpTypeFloat 32 %3 = OpConstant %2 42 @@ -244,8 +302,10 @@ OpDecorate %1 LinkageAttributes "foo" Export TEST_F(MatchingImportsToExports, FuncParamAttrDifferButStillMatchExportToImport) { const std::string body1 = R"( -OpCapability Kernel OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Import OpDecorate %2 FuncParamAttr Zext %3 = OpTypeVoid @@ -256,8 +316,10 @@ OpDecorate %2 FuncParamAttr Zext OpFunctionEnd )"; const std::string body2 = R"( -OpCapability Kernel OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Export OpDecorate %2 FuncParamAttr Sext %3 = OpTypeVoid @@ -271,10 +333,12 @@ OpFunctionEnd )"; spvtest::Binary linked_binary; - EXPECT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary)) + ASSERT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary)) << GetErrorMessage(); - const std::string expected_res = R"(OpCapability Kernel + const std::string expected_res = R"(OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpModuleProcessed "Linked by SPIR-V Tools Linker" OpDecorate %1 FuncParamAttr Sext %2 = OpTypeVoid @@ -288,7 +352,7 @@ OpFunctionEnd )"; std::string res_body; SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER); - EXPECT_EQ(SPV_SUCCESS, Disassemble(linked_binary, &res_body)) + ASSERT_EQ(SPV_SUCCESS, Disassemble(linked_binary, &res_body)) << GetErrorMessage(); EXPECT_EQ(expected_res, res_body); } @@ -296,6 +360,9 @@ OpFunctionEnd TEST_F(MatchingImportsToExports, FunctionCtrl) { const std::string body1 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Import %2 = OpTypeVoid %3 = OpTypeFunction %2 @@ -306,6 +373,9 @@ OpFunctionEnd )"; const std::string body2 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Export %2 = OpTypeVoid %3 = OpTypeFunction %2 @@ -316,11 +386,14 @@ OpFunctionEnd )"; spvtest::Binary linked_binary; - EXPECT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary)) + ASSERT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary)) << GetErrorMessage(); const std::string expected_res = - R"(OpModuleProcessed "Linked by SPIR-V Tools Linker" + R"(OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL +OpModuleProcessed "Linked by SPIR-V Tools Linker" %1 = OpTypeVoid %2 = OpTypeFunction %1 %3 = OpTypeFloat 32 @@ -332,15 +405,17 @@ OpFunctionEnd )"; std::string res_body; SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER); - EXPECT_EQ(SPV_SUCCESS, Disassemble(linked_binary, &res_body)) + ASSERT_EQ(SPV_SUCCESS, Disassemble(linked_binary, &res_body)) << GetErrorMessage(); EXPECT_EQ(expected_res, res_body); } TEST_F(MatchingImportsToExports, UseExportedFuncParamAttr) { const std::string body1 = R"( -OpCapability Kernel OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Import OpDecorate %2 FuncParamAttr Zext %2 = OpDecorationGroup @@ -356,8 +431,10 @@ OpFunctionEnd OpFunctionEnd )"; const std::string body2 = R"( -OpCapability Kernel OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Export OpDecorate %2 FuncParamAttr Sext %3 = OpTypeVoid @@ -371,10 +448,12 @@ OpFunctionEnd )"; spvtest::Binary linked_binary; - EXPECT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary)) + ASSERT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary)) << GetErrorMessage(); - const std::string expected_res = R"(OpCapability Kernel + const std::string expected_res = R"(OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpModuleProcessed "Linked by SPIR-V Tools Linker" OpDecorate %1 FuncParamAttr Zext %1 = OpDecorationGroup @@ -394,15 +473,17 @@ OpFunctionEnd )"; std::string res_body; SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER); - EXPECT_EQ(SPV_SUCCESS, Disassemble(linked_binary, &res_body)) + ASSERT_EQ(SPV_SUCCESS, Disassemble(linked_binary, &res_body)) << GetErrorMessage(); EXPECT_EQ(expected_res, res_body); } TEST_F(MatchingImportsToExports, NamesAndDecorations) { const std::string body1 = R"( -OpCapability Kernel OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpName %1 "foo" OpName %3 "param" OpDecorate %1 LinkageAttributes "foo" Import @@ -422,8 +503,10 @@ OpFunctionEnd OpFunctionEnd )"; const std::string body2 = R"( -OpCapability Kernel OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpName %1 "foo" OpName %2 "param" OpDecorate %1 LinkageAttributes "foo" Export @@ -440,10 +523,12 @@ OpFunctionEnd )"; spvtest::Binary linked_binary; - EXPECT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary)) + ASSERT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary)) << GetErrorMessage(); - const std::string expected_res = R"(OpCapability Kernel + const std::string expected_res = R"(OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpName %1 "foo" OpName %2 "param" OpModuleProcessed "Linked by SPIR-V Tools Linker" @@ -467,7 +552,7 @@ OpFunctionEnd )"; std::string res_body; SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER); - EXPECT_EQ(SPV_SUCCESS, Disassemble(linked_binary, &res_body)) + ASSERT_EQ(SPV_SUCCESS, Disassemble(linked_binary, &res_body)) << GetErrorMessage(); EXPECT_EQ(expected_res, res_body); } diff --git a/third_party/spirv-tools/test/link/memory_model_test.cpp b/third_party/spirv-tools/test/link/memory_model_test.cpp index 2add5046c7..280a776a08 100644 --- a/third_party/spirv-tools/test/link/memory_model_test.cpp +++ b/third_party/spirv-tools/test/link/memory_model_test.cpp @@ -50,9 +50,9 @@ OpMemoryModel Physical32 Simple spvtest::Binary linked_binary; EXPECT_EQ(SPV_ERROR_INTERNAL, AssembleAndLink({body1, body2}, &linked_binary)); - EXPECT_THAT( - GetErrorMessage(), - HasSubstr("Conflicting addressing models: Logical vs Physical32.")); + EXPECT_THAT(GetErrorMessage(), + HasSubstr("Conflicting addressing models: Logical (input modules " + "1 through 1) vs Physical32 (input module 2).")); } TEST_F(MemoryModel, MemoryMismatch) { @@ -67,7 +67,38 @@ OpMemoryModel Logical GLSL450 EXPECT_EQ(SPV_ERROR_INTERNAL, AssembleAndLink({body1, body2}, &linked_binary)); EXPECT_THAT(GetErrorMessage(), - HasSubstr("Conflicting memory models: Simple vs GLSL450.")); + HasSubstr("Conflicting memory models: Simple (input modules 1 " + "through 1) vs GLSL450 (input module 2).")); +} + +TEST_F(MemoryModel, FirstLackMemoryModel) { + const std::string body1 = R"( +)"; + const std::string body2 = R"( +OpMemoryModel Logical GLSL450 +)"; + + spvtest::Binary linked_binary; + EXPECT_EQ(SPV_ERROR_INVALID_BINARY, + AssembleAndLink({body1, body2}, &linked_binary)); + EXPECT_THAT( + GetErrorMessage(), + HasSubstr("Input module 1 is lacking an OpMemoryModel instruction.")); +} + +TEST_F(MemoryModel, SecondLackMemoryModel) { + const std::string body1 = R"( +OpMemoryModel Logical GLSL450 +)"; + const std::string body2 = R"( +)"; + + spvtest::Binary linked_binary; + EXPECT_EQ(SPV_ERROR_INVALID_BINARY, + AssembleAndLink({body1, body2}, &linked_binary)); + EXPECT_THAT( + GetErrorMessage(), + HasSubstr("Input module 2 is lacking an OpMemoryModel instruction.")); } } // namespace diff --git a/third_party/spirv-tools/test/link/partial_linkage_test.cpp b/third_party/spirv-tools/test/link/partial_linkage_test.cpp index c43b06e55a..bf4b508b6d 100644 --- a/third_party/spirv-tools/test/link/partial_linkage_test.cpp +++ b/third_party/spirv-tools/test/link/partial_linkage_test.cpp @@ -26,6 +26,9 @@ using PartialLinkage = spvtest::LinkerTest; TEST_F(PartialLinkage, Allowed) { const std::string body1 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Import OpDecorate %2 LinkageAttributes "bar" Import %3 = OpTypeFloat 32 @@ -34,6 +37,9 @@ OpDecorate %2 LinkageAttributes "bar" Import )"; const std::string body2 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "bar" Export %2 = OpTypeFloat 32 %3 = OpConstant %2 3.1415 @@ -44,9 +50,13 @@ OpDecorate %1 LinkageAttributes "bar" Export LinkerOptions linker_options; linker_options.SetAllowPartialLinkage(true); ASSERT_EQ(SPV_SUCCESS, - AssembleAndLink({body1, body2}, &linked_binary, linker_options)); + AssembleAndLink({body1, body2}, &linked_binary, linker_options)) + << GetErrorMessage(); const std::string expected_res = R"(OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpModuleProcessed "Linked by SPIR-V Tools Linker" OpDecorate %1 LinkageAttributes "foo" Import %2 = OpTypeFloat 32 @@ -64,6 +74,9 @@ OpDecorate %1 LinkageAttributes "foo" Import TEST_F(PartialLinkage, Disallowed) { const std::string body1 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "foo" Import OpDecorate %2 LinkageAttributes "bar" Import %3 = OpTypeFloat 32 @@ -72,6 +85,9 @@ OpDecorate %2 LinkageAttributes "bar" Import )"; const std::string body2 = R"( OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL OpDecorate %1 LinkageAttributes "bar" Export %2 = OpTypeFloat 32 %3 = OpConstant %2 3.1415 diff --git a/third_party/spirv-tools/test/link/type_match_test.cpp b/third_party/spirv-tools/test/link/type_match_test.cpp index dae70c163f..efc5cf7e54 100644 --- a/third_party/spirv-tools/test/link/type_match_test.cpp +++ b/third_party/spirv-tools/test/link/type_match_test.cpp @@ -66,6 +66,7 @@ using TypeMatch = spvtest::LinkerTest; "OpCapability Kernel\n" \ "OpCapability Shader\n" \ "OpCapability Addresses\n" \ + "OpMemoryModel Physical64 OpenCL\n" \ "OpDecorate %var LinkageAttributes \"foo\" " \ "{Import,Export}\n" \ "; CHECK: [[baseint:%\\w+]] = OpTypeInt 32 1\n" \ diff --git a/third_party/spirv-tools/test/link/unique_ids_test.cpp b/third_party/spirv-tools/test/link/unique_ids_test.cpp index 55c70ea670..16a9b52aba 100644 --- a/third_party/spirv-tools/test/link/unique_ids_test.cpp +++ b/third_party/spirv-tools/test/link/unique_ids_test.cpp @@ -135,7 +135,8 @@ TEST_F(UniqueIds, UniquelyMerged) { LinkerOptions options; options.SetVerifyIds(true); spv_result_t res = AssembleAndLink(bodies, &linked_binary, options); - EXPECT_EQ(SPV_SUCCESS, res); + ASSERT_EQ(SPV_SUCCESS, res) << GetErrorMessage(); + EXPECT_THAT(GetErrorMessage(), std::string()); } } // namespace diff --git a/third_party/spirv-tools/test/operand_pattern_test.cpp b/third_party/spirv-tools/test/operand_pattern_test.cpp index 1caf008fb3..a98a9d76dc 100644 --- a/third_party/spirv-tools/test/operand_pattern_test.cpp +++ b/third_party/spirv-tools/test/operand_pattern_test.cpp @@ -91,9 +91,14 @@ INSTANTIATE_TEST_SUITE_P( {SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS, 0, {PREFIX0}, {PREFIX0}}, // Unknown bits means no change. Use all bits that aren't in the // grammar. - // The last mask enum is 0x20 + // The used mask bits are: + // 1 through... + // 0x20 SpvMemoryAccessNonPrivatePointerMask + // also + // 0x10000 SpvMemoryAccessAliasScopeINTELMaskShift + // 0x20000 SpvMemoryAccessNoAliasINTELMaskMask {SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS, - 0xffffffc0, + 0xffffffc0 ^ (0x10000) ^ (0x20000), {PREFIX1}, {PREFIX1}}, // Volatile has no operands. @@ -111,6 +116,7 @@ INSTANTIATE_TEST_SUITE_P( SpvMemoryAccessVolatileMask | SpvMemoryAccessAlignedMask, {PREFIX1}, {PREFIX1, SPV_OPERAND_TYPE_LITERAL_INTEGER}}, + // Newer masks are not tested })); #undef PREFIX0 #undef PREFIX1 diff --git a/third_party/spirv-tools/test/opt/CMakeLists.txt b/third_party/spirv-tools/test/opt/CMakeLists.txt index bc44e8d6e6..15966c1840 100644 --- a/third_party/spirv-tools/test/opt/CMakeLists.txt +++ b/third_party/spirv-tools/test/opt/CMakeLists.txt @@ -42,8 +42,10 @@ add_spvtools_unittest(TARGET opt desc_sroa_test.cpp eliminate_dead_const_test.cpp eliminate_dead_functions_test.cpp + eliminate_dead_input_components_test.cpp eliminate_dead_member_test.cpp feature_manager_test.cpp + fix_func_call_arguments_test.cpp fix_storage_class_test.cpp flatten_decoration_test.cpp fold_spec_const_op_composite_test.cpp @@ -60,6 +62,7 @@ add_spvtools_unittest(TARGET opt inst_debug_printf_test.cpp instruction_list_test.cpp instruction_test.cpp + interface_var_sroa_test.cpp interp_fixup_test.cpp ir_builder.cpp ir_context_test.cpp @@ -82,7 +85,8 @@ add_spvtools_unittest(TARGET opt propagator_test.cpp reduce_load_size_test.cpp redundancy_elimination_test.cpp - remove_unused_interface_variables_test.cpp + remove_dontinline_test.cpp + remove_unused_interface_variables_test.cpp register_liveness.cpp relax_float_ops_test.cpp replace_desc_array_access_using_var_index_test.cpp @@ -91,9 +95,10 @@ add_spvtools_unittest(TARGET opt scalar_replacement_test.cpp set_spec_const_default_value_test.cpp simplification_test.cpp + spread_volatile_semantics_test.cpp strength_reduction_test.cpp strip_debug_info_test.cpp - strip_reflect_info_test.cpp + strip_nonsemantic_info_test.cpp struct_cfg_analysis_test.cpp type_manager_test.cpp types_test.cpp diff --git a/third_party/spirv-tools/test/opt/aggressive_dead_code_elim_test.cpp b/third_party/spirv-tools/test/opt/aggressive_dead_code_elim_test.cpp index f228c8cb24..25f8541670 100644 --- a/third_party/spirv-tools/test/opt/aggressive_dead_code_elim_test.cpp +++ b/third_party/spirv-tools/test/opt/aggressive_dead_code_elim_test.cpp @@ -38,55 +38,45 @@ TEST_F(AggressiveDCETest, EliminateExtendedInst) { // vec4 dv = sqrt(Dead); // gl_FragColor = v; // } - - const std::string predefs1 = - R"(OpCapability Shader + const std::string spirv = R"( +OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 +; CHECK: OpEntryPoint Fragment %main "main" %BaseColor %gl_FragColor OpEntryPoint Fragment %main "main" %BaseColor %Dead %gl_FragColor OpExecutionMode %main OriginUpperLeft OpSource GLSL 140 -)"; - - const std::string names_before = - R"(OpName %main "main" +OpName %main "main" OpName %v "v" OpName %BaseColor "BaseColor" +; CHECK-NOT: OpName %dv "dv" OpName %dv "dv" +; CHECK-NOT: OpName %Dead "Dead" OpName %Dead "Dead" OpName %gl_FragColor "gl_FragColor" -)"; - - const std::string names_after = - R"(OpName %main "main" -OpName %v "v" -OpName %BaseColor "BaseColor" -OpName %Dead "Dead" -OpName %gl_FragColor "gl_FragColor" -)"; - - const std::string predefs2 = - R"(%void = OpTypeVoid +%void = OpTypeVoid %9 = OpTypeFunction %void %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 %_ptr_Function_v4float = OpTypePointer Function %v4float %_ptr_Input_v4float = OpTypePointer Input %v4float %BaseColor = OpVariable %_ptr_Input_v4float Input +; CHECK-NOT: %Dead = OpVariable %Dead = OpVariable %_ptr_Input_v4float Input %_ptr_Output_v4float = OpTypePointer Output %v4float %gl_FragColor = OpVariable %_ptr_Output_v4float Output -)"; - - const std::string func_before = - R"(%main = OpFunction %void None %9 +%main = OpFunction %void None %9 %15 = OpLabel %v = OpVariable %_ptr_Function_v4float Function +; CHECK-NOT: %dv = OpVariable %dv = OpVariable %_ptr_Function_v4float Function %16 = OpLoad %v4float %BaseColor OpStore %v %16 +; CHECK-NOT: OpLoad %v4float %Dead %17 = OpLoad %v4float %Dead +; CHECK-NOT: OpExtInst %v4float %1 Sqrt %18 = OpExtInst %v4float %1 Sqrt %17 +; CHECK-NOT: OpStore %dv OpStore %dv %18 %19 = OpLoad %v4float %v OpStore %gl_FragColor %19 @@ -94,21 +84,7 @@ OpReturn OpFunctionEnd )"; - const std::string func_after = - R"(%main = OpFunction %void None %9 -%15 = OpLabel -%v = OpVariable %_ptr_Function_v4float Function -%16 = OpLoad %v4float %BaseColor -OpStore %v %16 -%19 = OpLoad %v4float %v -OpStore %gl_FragColor %19 -OpReturn -OpFunctionEnd -)"; - - SinglePassRunAndCheck( - predefs1 + names_before + predefs2 + func_before, - predefs1 + names_after + predefs2 + func_after, true, true); + SinglePassRunAndMatch(spirv, true); } TEST_F(AggressiveDCETest, NoEliminateFrexp) { @@ -242,35 +218,23 @@ TEST_F(AggressiveDCETest, EliminateDecorate) { // gl_FragColor = v; // } - const std::string predefs1 = - R"(OpCapability Shader + const std::string spirv = + R"( +OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %main "main" %BaseColor %Dead %gl_FragColor OpExecutionMode %main OriginUpperLeft OpSource GLSL 140 -)"; - - const std::string names_before = - R"(OpName %main "main" +OpName %main "main" OpName %v "v" OpName %BaseColor "BaseColor" OpName %dv "dv" OpName %Dead "Dead" OpName %gl_FragColor "gl_FragColor" +; CHECK-NOT: OpDecorate OpDecorate %8 RelaxedPrecision -)"; - - const std::string names_after = - R"(OpName %main "main" -OpName %v "v" -OpName %BaseColor "BaseColor" -OpName %Dead "Dead" -OpName %gl_FragColor "gl_FragColor" -)"; - - const std::string predefs2_before = - R"(%void = OpTypeVoid +%void = OpTypeVoid %10 = OpTypeFunction %void %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 @@ -281,29 +245,14 @@ OpName %gl_FragColor "gl_FragColor" %float_0_5 = OpConstant %float 0.5 %_ptr_Output_v4float = OpTypePointer Output %v4float %gl_FragColor = OpVariable %_ptr_Output_v4float Output -)"; - - const std::string predefs2_after = - R"(%void = OpTypeVoid -%10 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v4float = OpTypeVector %float 4 -%_ptr_Function_v4float = OpTypePointer Function %v4float -%_ptr_Input_v4float = OpTypePointer Input %v4float -%BaseColor = OpVariable %_ptr_Input_v4float Input -%Dead = OpVariable %_ptr_Input_v4float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%gl_FragColor = OpVariable %_ptr_Output_v4float Output -)"; - - const std::string func_before = - R"(%main = OpFunction %void None %10 +%main = OpFunction %void None %10 %17 = OpLabel %v = OpVariable %_ptr_Function_v4float Function %dv = OpVariable %_ptr_Function_v4float Function %18 = OpLoad %v4float %BaseColor OpStore %v %18 %19 = OpLoad %v4float %Dead +; CHECK-NOT: OpVectorTimesScalar %8 = OpVectorTimesScalar %v4float %19 %float_0_5 OpStore %dv %8 %20 = OpLoad %v4float %v @@ -312,21 +261,7 @@ OpReturn OpFunctionEnd )"; - const std::string func_after = - R"(%main = OpFunction %void None %10 -%17 = OpLabel -%v = OpVariable %_ptr_Function_v4float Function -%18 = OpLoad %v4float %BaseColor -OpStore %v %18 -%20 = OpLoad %v4float %v -OpStore %gl_FragColor %20 -OpReturn -OpFunctionEnd -)"; - - SinglePassRunAndCheck( - predefs1 + names_before + predefs2_before + func_before, - predefs1 + names_after + predefs2_after + func_after, true, true); + SinglePassRunAndMatch(spirv, true); } TEST_F(AggressiveDCETest, Simple) { @@ -342,53 +277,44 @@ TEST_F(AggressiveDCETest, Simple) { // gl_FragColor = v; // } - const std::string predefs1 = - R"(OpCapability Shader + const std::string spirv = + R"( +OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 +; CHECK: OpEntryPoint Fragment %main "main" %BaseColor %gl_FragColor OpEntryPoint Fragment %main "main" %BaseColor %Dead %gl_FragColor OpExecutionMode %main OriginUpperLeft OpSource GLSL 140 -)"; - - const std::string names_before = - R"(OpName %main "main" +OpName %main "main" OpName %v "v" OpName %BaseColor "BaseColor" +; CHECK-NOT: OpName %dv "dv" OpName %dv "dv" +; CHECK-NOT: OpName %Dead "Dead" OpName %Dead "Dead" OpName %gl_FragColor "gl_FragColor" -)"; - - const std::string names_after = - R"(OpName %main "main" -OpName %v "v" -OpName %BaseColor "BaseColor" -OpName %Dead "Dead" -OpName %gl_FragColor "gl_FragColor" -)"; - - const std::string predefs2 = - R"(%void = OpTypeVoid +%void = OpTypeVoid %9 = OpTypeFunction %void %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 %_ptr_Function_v4float = OpTypePointer Function %v4float %_ptr_Input_v4float = OpTypePointer Input %v4float %BaseColor = OpVariable %_ptr_Input_v4float Input +; CHECK-NOT: %Dead = OpVariable %Dead = OpVariable %_ptr_Input_v4float Input %_ptr_Output_v4float = OpTypePointer Output %v4float %gl_FragColor = OpVariable %_ptr_Output_v4float Output -)"; - - const std::string func_before = - R"(%main = OpFunction %void None %9 +%main = OpFunction %void None %9 %15 = OpLabel %v = OpVariable %_ptr_Function_v4float Function +; CHECK-NOT: %dv = OpVariable %dv = OpVariable %_ptr_Function_v4float Function %16 = OpLoad %v4float %BaseColor OpStore %v %16 +; CHECK-NOT: OpLoad %v4float %Dead %17 = OpLoad %v4float %Dead +; CHECK-NOT: OpStore %dv OpStore %dv %17 %18 = OpLoad %v4float %v OpStore %gl_FragColor %18 @@ -396,21 +322,7 @@ OpReturn OpFunctionEnd )"; - const std::string func_after = - R"(%main = OpFunction %void None %9 -%15 = OpLabel -%v = OpVariable %_ptr_Function_v4float Function -%16 = OpLoad %v4float %BaseColor -OpStore %v %16 -%18 = OpLoad %v4float %v -OpStore %gl_FragColor %18 -OpReturn -OpFunctionEnd -)"; - - SinglePassRunAndCheck( - predefs1 + names_before + predefs2 + func_before, - predefs1 + names_after + predefs2 + func_after, true, true); + SinglePassRunAndMatch(spirv, true); } TEST_F(AggressiveDCETest, OptAllowListExtension) { @@ -426,35 +338,22 @@ TEST_F(AggressiveDCETest, OptAllowListExtension) { // gl_FragColor = v; // } - const std::string predefs1 = + const std::string spirv = R"(OpCapability Shader OpExtension "SPV_AMD_gpu_shader_int16" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 +; CHECK: OpEntryPoint Fragment %main "main" %BaseColor %gl_FragColor OpEntryPoint Fragment %main "main" %BaseColor %Dead %gl_FragColor OpExecutionMode %main OriginUpperLeft OpSource GLSL 140 -)"; - - const std::string names_before = - R"(OpName %main "main" +OpName %main "main" OpName %v "v" OpName %BaseColor "BaseColor" OpName %dv "dv" OpName %Dead "Dead" OpName %gl_FragColor "gl_FragColor" -)"; - - const std::string names_after = - R"(OpName %main "main" -OpName %v "v" -OpName %BaseColor "BaseColor" -OpName %Dead "Dead" -OpName %gl_FragColor "gl_FragColor" -)"; - - const std::string predefs2 = - R"(%void = OpTypeVoid +%void = OpTypeVoid %9 = OpTypeFunction %void %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 @@ -464,10 +363,7 @@ OpName %gl_FragColor "gl_FragColor" %Dead = OpVariable %_ptr_Input_v4float Input %_ptr_Output_v4float = OpTypePointer Output %v4float %gl_FragColor = OpVariable %_ptr_Output_v4float Output -)"; - - const std::string func_before = - R"(%main = OpFunction %void None %9 +%main = OpFunction %void None %9 %15 = OpLabel %v = OpVariable %_ptr_Function_v4float Function %dv = OpVariable %_ptr_Function_v4float Function @@ -481,21 +377,7 @@ OpReturn OpFunctionEnd )"; - const std::string func_after = - R"(%main = OpFunction %void None %9 -%15 = OpLabel -%v = OpVariable %_ptr_Function_v4float Function -%16 = OpLoad %v4float %BaseColor -OpStore %v %16 -%18 = OpLoad %v4float %v -OpStore %gl_FragColor %18 -OpReturn -OpFunctionEnd -)"; - - SinglePassRunAndCheck( - predefs1 + names_before + predefs2 + func_before, - predefs1 + names_after + predefs2 + func_after, true, true); + SinglePassRunAndMatch(spirv, true); } TEST_F(AggressiveDCETest, NoOptDenyListExtension) { @@ -571,7 +453,7 @@ TEST_F(AggressiveDCETest, ElimWithCall) { // gl_FragColor = vec4(0.0); // } - const std::string defs_before = + const std::string text = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -600,54 +482,25 @@ OpName %gl_FragColor "gl_FragColor" %gl_FragColor = OpVariable %_ptr_Output_v4float Output %float_0 = OpConstant %float 0 %20 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0 -)"; - - const std::string defs_after = - R"(OpCapability Shader -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %i1 %i2 %gl_FragColor -OpExecutionMode %main OriginUpperLeft -OpSource GLSL 140 -OpName %main "main" -OpName %nothing_vf4_ "nothing(vf4;" -OpName %v "v" -OpName %v1 "v1" -OpName %i1 "i1" -OpName %i2 "i2" -OpName %param "param" -OpName %gl_FragColor "gl_FragColor" -%void = OpTypeVoid -%12 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v4float = OpTypeVector %float 4 -%_ptr_Function_v4float = OpTypePointer Function %v4float -%16 = OpTypeFunction %void %_ptr_Function_v4float -%_ptr_Input_v4float = OpTypePointer Input %v4float -%i1 = OpVariable %_ptr_Input_v4float Input -%i2 = OpVariable %_ptr_Input_v4float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%gl_FragColor = OpVariable %_ptr_Output_v4float Output -%float_0 = OpConstant %float 0 -%20 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0 -)"; - - const std::string func_before = - R"(%main = OpFunction %void None %12 +%main = OpFunction %void None %12 %21 = OpLabel %v1 = OpVariable %_ptr_Function_v4float Function %v2 = OpVariable %_ptr_Function_v4float Function %param = OpVariable %_ptr_Function_v4float Function %22 = OpLoad %v4float %i1 OpStore %v1 %22 +; CHECK-NOT: OpLoad %v4float %i2 %23 = OpLoad %v4float %i2 +; CHECK-NOT: OpStore %v2 OpStore %v2 %23 %24 = OpLoad %v4float %v1 OpStore %param %24 +; CHECK: OpFunctionCall %void %nothing_vf4_ %25 = OpFunctionCall %void %nothing_vf4_ %param OpStore %gl_FragColor %20 OpReturn OpFunctionEnd +; CHECK: %nothing_vf4_ = OpFunction %nothing_vf4_ = OpFunction %void None %16 %v = OpFunctionParameter %_ptr_Function_v4float %26 = OpLabel @@ -655,28 +508,7 @@ OpReturn OpFunctionEnd )"; - const std::string func_after = - R"(%main = OpFunction %void None %12 -%21 = OpLabel -%v1 = OpVariable %_ptr_Function_v4float Function -%param = OpVariable %_ptr_Function_v4float Function -%22 = OpLoad %v4float %i1 -OpStore %v1 %22 -%24 = OpLoad %v4float %v1 -OpStore %param %24 -%25 = OpFunctionCall %void %nothing_vf4_ %param -OpStore %gl_FragColor %20 -OpReturn -OpFunctionEnd -%nothing_vf4_ = OpFunction %void None %16 -%v = OpFunctionParameter %_ptr_Function_v4float -%26 = OpLabel -OpReturn -OpFunctionEnd -)"; - - SinglePassRunAndCheck(defs_before + func_before, - defs_after + func_after, true, true); + SinglePassRunAndMatch(text, true); } TEST_F(AggressiveDCETest, NoParamElim) { @@ -998,7 +830,7 @@ TEST_F(AggressiveDCETest, PrivateStoreElimInEntryNoCalls) { // OutColor = v; // } - const std::string predefs_before = + const std::string spirv = R"(OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1008,6 +840,7 @@ OpSource GLSL 450 OpName %main "main" OpName %v "v" OpName %BaseColor "BaseColor" +; CHECK-NOT: OpName %dv "dv" OpName %dv "dv" OpName %Dead "Dead" OpName %OutColor "OutColor" @@ -1019,49 +852,22 @@ OpDecorate %OutColor Location 0 %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 %_ptr_Function_v4float = OpTypePointer Function %v4float +; CHECK-NOT: OpTypePointer Private %_ptr_Private_v4float = OpTypePointer Private %v4float %_ptr_Input_v4float = OpTypePointer Input %v4float %BaseColor = OpVariable %_ptr_Input_v4float Input %Dead = OpVariable %_ptr_Input_v4float Input %_ptr_Output_v4float = OpTypePointer Output %v4float +; CHECK-NOT: %dv = OpVariable %dv = OpVariable %_ptr_Private_v4float Private %OutColor = OpVariable %_ptr_Output_v4float Output -)"; - - const std::string predefs_after = - R"(OpCapability Shader -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %BaseColor %Dead %OutColor -OpExecutionMode %main OriginUpperLeft -OpSource GLSL 450 -OpName %main "main" -OpName %v "v" -OpName %BaseColor "BaseColor" -OpName %Dead "Dead" -OpName %OutColor "OutColor" -OpDecorate %BaseColor Location 0 -OpDecorate %Dead Location 1 -OpDecorate %OutColor Location 0 -%void = OpTypeVoid -%9 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v4float = OpTypeVector %float 4 -%_ptr_Function_v4float = OpTypePointer Function %v4float -%_ptr_Input_v4float = OpTypePointer Input %v4float -%BaseColor = OpVariable %_ptr_Input_v4float Input -%Dead = OpVariable %_ptr_Input_v4float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%OutColor = OpVariable %_ptr_Output_v4float Output -)"; - - const std::string main_before = - R"(%main = OpFunction %void None %9 +%main = OpFunction %void None %9 %16 = OpLabel %v = OpVariable %_ptr_Function_v4float Function %17 = OpLoad %v4float %BaseColor OpStore %v %17 %18 = OpLoad %v4float %Dead +; CHECK-NOT: OpStore %dv OpStore %dv %18 %19 = OpLoad %v4float %v %20 = OpFNegate %v4float %19 @@ -1070,21 +876,7 @@ OpReturn OpFunctionEnd )"; - const std::string main_after = - R"(%main = OpFunction %void None %9 -%16 = OpLabel -%v = OpVariable %_ptr_Function_v4float Function -%17 = OpLoad %v4float %BaseColor -OpStore %v %17 -%19 = OpLoad %v4float %v -%20 = OpFNegate %v4float %19 -OpStore %OutColor %20 -OpReturn -OpFunctionEnd -)"; - - SinglePassRunAndCheck( - predefs_before + main_before, predefs_after + main_after, true, true); + SinglePassRunAndMatch(spirv, true); } TEST_F(AggressiveDCETest, NoPrivateStoreElimIfLoad) { @@ -1288,7 +1080,7 @@ TEST_F(AggressiveDCETest, WorkgroupStoreElimInEntryNoCalls) { // OutColor = v; // } - const std::string predefs_before = + const std::string spirv = R"(OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1298,6 +1090,7 @@ OpSource GLSL 450 OpName %main "main" OpName %v "v" OpName %BaseColor "BaseColor" +; CHECK-NOT: OpName %dv "dv" OpName %dv "dv" OpName %Dead "Dead" OpName %OutColor "OutColor" @@ -1309,49 +1102,22 @@ OpDecorate %OutColor Location 0 %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 %_ptr_Function_v4float = OpTypePointer Function %v4float +; CHECK-NOT: OpTypePointer Workgroup %_ptr_Workgroup_v4float = OpTypePointer Workgroup %v4float %_ptr_Input_v4float = OpTypePointer Input %v4float %BaseColor = OpVariable %_ptr_Input_v4float Input %Dead = OpVariable %_ptr_Input_v4float Input %_ptr_Output_v4float = OpTypePointer Output %v4float +; CHECK-NOT: %dv = OpVariable %dv = OpVariable %_ptr_Workgroup_v4float Workgroup %OutColor = OpVariable %_ptr_Output_v4float Output -)"; - - const std::string predefs_after = - R"(OpCapability Shader -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %BaseColor %Dead %OutColor -OpExecutionMode %main OriginUpperLeft -OpSource GLSL 450 -OpName %main "main" -OpName %v "v" -OpName %BaseColor "BaseColor" -OpName %Dead "Dead" -OpName %OutColor "OutColor" -OpDecorate %BaseColor Location 0 -OpDecorate %Dead Location 1 -OpDecorate %OutColor Location 0 -%void = OpTypeVoid -%9 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v4float = OpTypeVector %float 4 -%_ptr_Function_v4float = OpTypePointer Function %v4float -%_ptr_Input_v4float = OpTypePointer Input %v4float -%BaseColor = OpVariable %_ptr_Input_v4float Input -%Dead = OpVariable %_ptr_Input_v4float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%OutColor = OpVariable %_ptr_Output_v4float Output -)"; - - const std::string main_before = - R"(%main = OpFunction %void None %9 +%main = OpFunction %void None %9 %16 = OpLabel %v = OpVariable %_ptr_Function_v4float Function %17 = OpLoad %v4float %BaseColor OpStore %v %17 %18 = OpLoad %v4float %Dead +; CHECK-NOT: OpStore %dv OpStore %dv %18 %19 = OpLoad %v4float %v %20 = OpFNegate %v4float %19 @@ -1360,21 +1126,7 @@ OpReturn OpFunctionEnd )"; - const std::string main_after = - R"(%main = OpFunction %void None %9 -%16 = OpLabel -%v = OpVariable %_ptr_Function_v4float Function -%17 = OpLoad %v4float %BaseColor -OpStore %v %17 -%19 = OpLoad %v4float %v -%20 = OpFNegate %v4float %19 -OpStore %OutColor %20 -OpReturn -OpFunctionEnd -)"; - - SinglePassRunAndCheck( - predefs_before + main_before, predefs_after + main_after, true, true); + SinglePassRunAndMatch(spirv, true); } TEST_F(AggressiveDCETest, EliminateDeadIfThenElse) { @@ -1393,7 +1145,7 @@ TEST_F(AggressiveDCETest, EliminateDeadIfThenElse) { // OutColor = vec4(1.0,1.0,1.0,1.0); // } - const std::string predefs_before = + const std::string spirv = R"(OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1424,34 +1176,11 @@ OpDecorate %OutColor Location 0 %OutColor = OpVariable %_ptr_Output_v4float Output %float_1 = OpConstant %float 1 %21 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 -)"; - - const std::string predefs_after = - R"(OpCapability Shader -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %BaseColor %OutColor -OpExecutionMode %main OriginUpperLeft -OpSource GLSL 450 -OpName %main "main" -OpName %BaseColor "BaseColor" -OpName %OutColor "OutColor" -OpDecorate %BaseColor Location 0 -OpDecorate %OutColor Location 0 -%void = OpTypeVoid -%7 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v4float = OpTypeVector %float 4 -%_ptr_Input_v4float = OpTypePointer Input %v4float -%BaseColor = OpVariable %_ptr_Input_v4float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%OutColor = OpVariable %_ptr_Output_v4float Output -%float_1 = OpConstant %float 1 -%21 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 -)"; - - const std::string func_before = - R"(%main = OpFunction %void None %7 +; CHECK: = OpFunction %void +; CHECK-NEXT: %22 = OpLabel +; CHECK-NEXT: OpBranch %26 +; CHECK-NEXT: %26 = OpLabel +%main = OpFunction %void None %7 %22 = OpLabel %d = OpVariable %_ptr_Function_float Function %23 = OpAccessChain %_ptr_Input_float %BaseColor %uint_0 @@ -1475,18 +1204,7 @@ OpReturn OpFunctionEnd )"; - const std::string func_after = - R"(%main = OpFunction %void None %7 -%22 = OpLabel -OpBranch %26 -%26 = OpLabel -OpStore %OutColor %21 -OpReturn -OpFunctionEnd -)"; - - SinglePassRunAndCheck( - predefs_before + func_before, predefs_after + func_after, true, true); + SinglePassRunAndMatch(spirv, true); } TEST_F(AggressiveDCETest, EliminateDeadIfThen) { @@ -1503,7 +1221,7 @@ TEST_F(AggressiveDCETest, EliminateDeadIfThen) { // OutColor = vec4(1.0,1.0,1.0,1.0); // } - const std::string predefs_before = + const std::string spirv = R"(OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1533,34 +1251,11 @@ OpDecorate %OutColor Location 0 %OutColor = OpVariable %_ptr_Output_v4float Output %float_1 = OpConstant %float 1 %20 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 -)"; - - const std::string predefs_after = - R"(OpCapability Shader -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %BaseColor %OutColor -OpExecutionMode %main OriginUpperLeft -OpSource GLSL 450 -OpName %main "main" -OpName %BaseColor "BaseColor" -OpName %OutColor "OutColor" -OpDecorate %BaseColor Location 0 -OpDecorate %OutColor Location 0 -%void = OpTypeVoid -%7 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v4float = OpTypeVector %float 4 -%_ptr_Input_v4float = OpTypePointer Input %v4float -%BaseColor = OpVariable %_ptr_Input_v4float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%OutColor = OpVariable %_ptr_Output_v4float Output -%float_1 = OpConstant %float 1 -%20 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 -)"; - - const std::string func_before = - R"(%main = OpFunction %void None %7 +; CHECK: = OpFunction +; CHECK-NEXT: %21 = OpLabel +; CHECK-NEXT: OpBranch [[target:%\w+]] +; CHECK-NEXT: [[target]] = OpLabel +%main = OpFunction %void None %7 %21 = OpLabel %d = OpVariable %_ptr_Function_float Function %22 = OpAccessChain %_ptr_Input_float %BaseColor %uint_0 @@ -1579,18 +1274,7 @@ OpReturn OpFunctionEnd )"; - const std::string func_after = - R"(%main = OpFunction %void None %7 -%21 = OpLabel -OpBranch %25 -%25 = OpLabel -OpStore %OutColor %20 -OpReturn -OpFunctionEnd -)"; - - SinglePassRunAndCheck( - predefs_before + func_before, predefs_after + func_after, true, true); + SinglePassRunAndMatch(spirv, true); } TEST_F(AggressiveDCETest, EliminateDeadSwitch) { @@ -1609,7 +1293,7 @@ TEST_F(AggressiveDCETest, EliminateDeadSwitch) { // } // OutColor = vec4(1.0,1.0,1.0,1.0); // } - const std::string before = + const std::string spirv = R"(OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1642,6 +1326,10 @@ TEST_F(AggressiveDCETest, EliminateDeadSwitch) { %OutColor = OpVariable %_ptr_Output_v4float Output %float_1 = OpConstant %float 1 %27 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +; CHECK: = OpFunction +; CHECK-NEXT: = OpLabel +; CHECK-NEXT: OpBranch [[target:%\w+]] +; CHECK-NEXT: [[target]] = OpLabel %main = OpFunction %void None %3 %5 = OpLabel %d = OpVariable %_ptr_Function_float Function @@ -1658,45 +1346,7 @@ TEST_F(AggressiveDCETest, EliminateDeadSwitch) { OpReturn OpFunctionEnd)"; - const std::string after = - R"(OpCapability Shader -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %x %BaseColor %OutColor -OpExecutionMode %main OriginUpperLeft -OpSource GLSL 450 -OpName %main "main" -OpName %x "x" -OpName %BaseColor "BaseColor" -OpName %OutColor "OutColor" -OpDecorate %x Flat -OpDecorate %x Location 1 -OpDecorate %BaseColor Location 0 -OpDecorate %OutColor Location 0 -%void = OpTypeVoid -%3 = OpTypeFunction %void -%int = OpTypeInt 32 1 -%_ptr_Input_int = OpTypePointer Input %int -%x = OpVariable %_ptr_Input_int Input -%float = OpTypeFloat 32 -%v4float = OpTypeVector %float 4 -%_ptr_Input_v4float = OpTypePointer Input %v4float -%BaseColor = OpVariable %_ptr_Input_v4float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%OutColor = OpVariable %_ptr_Output_v4float Output -%float_1 = OpConstant %float 1 -%27 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 -%main = OpFunction %void None %3 -%5 = OpLabel -OpBranch %11 -%11 = OpLabel -OpStore %OutColor %27 -OpReturn -OpFunctionEnd -)"; - - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndCheck(before, after, true, true); + SinglePassRunAndMatch(spirv, true); } TEST_F(AggressiveDCETest, EliminateDeadIfThenElseNested) { @@ -1721,7 +1371,7 @@ TEST_F(AggressiveDCETest, EliminateDeadIfThenElseNested) { // OutColor = vec4(1.0,1.0,1.0,1.0); // } - const std::string predefs_before = + const std::string spirv = R"(OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1754,34 +1404,14 @@ OpDecorate %OutColor Location 0 %OutColor = OpVariable %_ptr_Output_v4float Output %float_1 = OpConstant %float 1 %23 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 -)"; - const std::string predefs_after = - R"(OpCapability Shader -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %BaseColor %OutColor -OpExecutionMode %main OriginUpperLeft -OpSource GLSL 450 -OpName %main "main" -OpName %BaseColor "BaseColor" -OpName %OutColor "OutColor" -OpDecorate %BaseColor Location 0 -OpDecorate %OutColor Location 0 -%void = OpTypeVoid -%7 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v4float = OpTypeVector %float 4 -%_ptr_Input_v4float = OpTypePointer Input %v4float -%BaseColor = OpVariable %_ptr_Input_v4float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%OutColor = OpVariable %_ptr_Output_v4float Output -%float_1 = OpConstant %float 1 -%23 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 -)"; +; CHECK: = OpFunction +; CHECK-NEXT: = OpLabel +; CHECK-NEXT: OpBranch [[target:%\w+]] +; CHECK-NEXT: [[target]] = OpLabel +; CHECK-NOT: OpLabel - const std::string func_before = - R"(%main = OpFunction %void None %7 +%main = OpFunction %void None %7 %24 = OpLabel %d = OpVariable %_ptr_Function_float Function %25 = OpAccessChain %_ptr_Input_float %BaseColor %uint_0 @@ -1823,18 +1453,7 @@ OpReturn OpFunctionEnd )"; - const std::string func_after = - R"(%main = OpFunction %void None %7 -%24 = OpLabel -OpBranch %28 -%28 = OpLabel -OpStore %OutColor %23 -OpReturn -OpFunctionEnd -)"; - - SinglePassRunAndCheck( - predefs_before + func_before, predefs_after + func_after, true, true); + SinglePassRunAndMatch(spirv, true); } TEST_F(AggressiveDCETest, NoEliminateLiveIfThenElse) { @@ -2578,7 +2197,7 @@ TEST_F(AggressiveDCETest, EliminateEntireFunctionBody) { // d = BaseColor.z; // } - const std::string predefs_before = + const std::string spirv = R"(OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -2607,32 +2226,15 @@ OpDecorate %OutColor Location 0 %uint_2 = OpConstant %uint 2 %_ptr_Output_v4float = OpTypePointer Output %v4float %OutColor = OpVariable %_ptr_Output_v4float Output -)"; - const std::string predefs_after = - R"(OpCapability Shader -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %BaseColor %OutColor -OpExecutionMode %main OriginUpperLeft -OpSource GLSL 450 -OpName %main "main" -OpName %BaseColor "BaseColor" -OpName %OutColor "OutColor" -OpDecorate %BaseColor Location 0 -OpDecorate %OutColor Location 0 -%void = OpTypeVoid -%7 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v4float = OpTypeVector %float 4 -%_ptr_Input_v4float = OpTypePointer Input %v4float -%BaseColor = OpVariable %_ptr_Input_v4float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%OutColor = OpVariable %_ptr_Output_v4float Output -)"; +; CHECK: = OpFunction +; CHECK-NEXT: = OpLabel +; CHECK-NEXT: OpBranch [[target:%\w+]] +; CHECK-NEXT: [[target]] = OpLabel +; CHECK-NEXT: OpReturn +; CHECK-NEXT: OpFunctionEnd - const std::string func_before = - R"(%main = OpFunction %void None %7 +%main = OpFunction %void None %7 %20 = OpLabel %d = OpVariable %_ptr_Function_float Function %21 = OpAccessChain %_ptr_Input_float %BaseColor %uint_0 @@ -2655,17 +2257,7 @@ OpReturn OpFunctionEnd )"; - const std::string func_after = - R"(%main = OpFunction %void None %7 -%20 = OpLabel -OpBranch %24 -%24 = OpLabel -OpReturn -OpFunctionEnd -)"; - - SinglePassRunAndCheck( - predefs_before + func_before, predefs_after + func_after, true, true); + SinglePassRunAndMatch(spirv, true); } TEST_F(AggressiveDCETest, EliminateUselessInnerLoop) { @@ -4731,7 +4323,7 @@ INSTANTIATE_TEST_SUITE_P( }, // Uint vector type spec constants. One vector has all component dead, - // another vector has one dead unsigend integer and one used unsigned + // another vector has one dead unsigned integer and one used unsigned // integer. { /* .used_consts = */ @@ -5521,10 +5113,9 @@ OpCapability ImageBuffer OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %2 "min" %gl_GlobalInvocationID +OpEntryPoint GLCompute %2 "min" OpExecutionMode %2 LocalSize 64 1 1 OpSource HLSL 600 -OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId OpDecorate %4 DescriptorSet 4 OpDecorate %4 Binding 70 %uint = OpTypeInt 32 0 @@ -5535,12 +5126,9 @@ OpDecorate %4 Binding 70 %10 = OpTypeFunction %void %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 -%v3uint = OpTypeVector %uint 3 -%_ptr_Input_v3uint = OpTypePointer Input %v3uint %_ptr_Image_uint = OpTypePointer Image %uint %4 = OpVariable %_ptr_UniformConstant_6 UniformConstant %16 = OpVariable %_ptr_Private_6 Private -%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input %2 = OpFunction %void None %10 %17 = OpLabel %18 = OpLoad %6 %4 @@ -6393,8 +5981,8 @@ OpFunctionEnd TEST_F(AggressiveDCETest, DeadInputInterfaceV13) { const std::string spirv = R"( -; CHECK: OpEntryPoint GLCompute %main "main" [[var:%\w+]] -; CHECK: [[var]] = OpVariable +; CHECK: OpEntryPoint GLCompute %main "main" +; CHECK-NOT: OpVariable OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %main "main" %dead @@ -6417,8 +6005,8 @@ OpFunctionEnd TEST_F(AggressiveDCETest, DeadInputInterfaceV14) { const std::string spirv = R"( -; CHECK: OpEntryPoint GLCompute %main "main" [[var:%\w+]] -; CHECK: [[var]] = OpVariable +; CHECK: OpEntryPoint GLCompute %main "main" +; CHECK-NOT: OpVariable OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %main "main" %dead diff --git a/third_party/spirv-tools/test/opt/assembly_builder.h b/third_party/spirv-tools/test/opt/assembly_builder.h index 1673c092be..b94e90f5d9 100644 --- a/third_party/spirv-tools/test/opt/assembly_builder.h +++ b/third_party/spirv-tools/test/opt/assembly_builder.h @@ -70,7 +70,7 @@ class AssemblyBuilder { static const uint32_t SPEC_ID_BASE = 200; public: - // Initalize a minimal SPIR-V assembly code as the template. The minimal + // Initialize a minimal SPIR-V assembly code as the template. The minimal // module contains an empty main function and some predefined names for the // main function. AssemblyBuilder() @@ -102,7 +102,7 @@ class AssemblyBuilder { }); } - // Appends OpName instructions to this builder. Instrcution strings that do + // Appends OpName instructions to this builder. Instruction strings that do // not start with 'OpName ' will be skipped. Returns the references of this // assembly builder. AssemblyBuilder& AppendNames(const std::vector& vec_asm_code) { diff --git a/third_party/spirv-tools/test/opt/block_merge_test.cpp b/third_party/spirv-tools/test/opt/block_merge_test.cpp index 6903c4e70f..9698fed23d 100644 --- a/third_party/spirv-tools/test/opt/block_merge_test.cpp +++ b/third_party/spirv-tools/test/opt/block_merge_test.cpp @@ -884,7 +884,7 @@ TEST_F(BlockMergeTest, MergeHeaders) { ; CHECK-NEXT: [[header]] = OpLabel ; CHECK-NEXT: OpSelectionMerge [[merge:%\w+]] ; CHECK: [[merge]] = OpLabel -; CHEKC: OpReturn +; CHECK: OpReturn OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %func "func" diff --git a/third_party/spirv-tools/test/opt/ccp_test.cpp b/third_party/spirv-tools/test/opt/ccp_test.cpp index 212e05140b..f0f2436240 100644 --- a/third_party/spirv-tools/test/opt/ccp_test.cpp +++ b/third_party/spirv-tools/test/opt/ccp_test.cpp @@ -582,6 +582,35 @@ TEST_F(CCPTest, SkipSpecConstantInstrucitons) { EXPECT_EQ(std::get<1>(res), Pass::Status::SuccessWithoutChange); } +TEST_F(CCPTest, FoldConstantCompositeInstrucitonsWithSpecConst) { + const std::string spv_asm = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %1 "main" + OpExecutionMode %1 OriginUpperLeft + %void = OpTypeVoid + %4 = OpTypeFunction %void + %bool = OpTypeBool + %v3bool = OpTypeVector %bool 3 + %_struct_8 = OpTypeStruct %v3bool + %true = OpConstantTrue %bool +; CHECK: [[spec_const:%\w+]] = OpSpecConstantComposite %v3bool + %11 = OpSpecConstantComposite %v3bool %true %true %true + %12 = OpConstantComposite %_struct_8 %11 +; CHECK: OpFunction + %1 = OpFunction %void None %4 + %29 = OpLabel + %31 = OpCompositeExtract %v3bool %12 0 +; CHECK: OpCompositeExtract %bool [[spec_const]] 0 + %32 = OpCompositeExtract %bool %31 0 + OpReturn + OpFunctionEnd + )"; + + auto result = SinglePassRunAndMatch(spv_asm, true); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + TEST_F(CCPTest, UpdateSubsequentPhisToVarying) { const std::string text = R"( OpCapability Shader @@ -1234,6 +1263,86 @@ OpFunctionEnd SinglePassRunAndCheck(text, text, false); } + +// Test from https://github.com/KhronosGroup/SPIRV-Tools/issues/4462. +// The test was causing a lateral movement in the constant lattice, which was +// not being detected as varying by CCP. In this test, FClamp is evaluated +// twice. On the first evaluation, if computes FClamp(0.5, 0.5, -1) which +// returns -1. On the second evaluation, it computes FClamp(0.5, 0.5, VARYING) +// which returns 0.5. +// +// Both fold() computations are correct given the semantics of FClamp() but +// this causes a lateral transition in the constant lattice which was not being +// considered VARYING by CCP. +TEST_F(CCPTest, LateralLatticeTransition) { + const std::string text = R"(OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %gl_FragCoord %outColor + OpExecutionMode %main OriginUpperLeft + OpSource ESSL 310 + OpName %main "main" + OpName %gl_FragCoord "gl_FragCoord" + OpName %outColor "outColor" + OpDecorate %gl_FragCoord BuiltIn FragCoord + OpDecorate %outColor Location 0 + %void = OpTypeVoid + %6 = OpTypeFunction %void + %float = OpTypeFloat 32 + %float_0_5 = OpConstant %float 0.5 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%gl_FragCoord = OpVariable %_ptr_Input_v4float Input + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_Input_float = OpTypePointer Input %float + %float_0 = OpConstant %float 0 + %bool = OpTypeBool + %float_n1 = OpConstant %float -1 + %float_1 = OpConstant %float 1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %outColor = OpVariable %_ptr_Output_v4float Output + +; This constant is created during the first evaluation of the CompositeConstruct +; CHECK: [[new_constant:%\d+]] = OpConstantComposite %v4float %float_n1 %float_0_5 %float_0 %float_1 + + %main = OpFunction %void None %6 + %19 = OpLabel + %20 = OpAccessChain %_ptr_Input_float %gl_FragCoord %uint_0 + %21 = OpLoad %float %20 + %22 = OpFOrdLessThan %bool %21 %float_0 + OpSelectionMerge %23 None + OpBranchConditional %22 %24 %25 + %24 = OpLabel + OpBranch %23 + %25 = OpLabel + OpBranch %26 + %26 = OpLabel + OpBranch %23 + %23 = OpLabel + %27 = OpPhi %float %float_n1 %24 %float_0_5 %26 + %28 = OpExtInst %float %1 FClamp %float_0_5 %float_0_5 %27 + + ; On first evaluation, the result from FClamp will return 0.5. + ; But on second evaluation, FClamp should return VARYING. Check + ; that CCP is not keeping the first result. + ; CHECK-NOT: %29 = OpCompositeConstruct %v4float %float_0_5 %float_0_5 %float_0 %float_1 + %29 = OpCompositeConstruct %v4float %28 %float_0_5 %float_0 %float_1 + + ; CHECK-NOT: OpCopyObject %v4float [[new_constant]] + %42 = OpCopyObject %v4float %29 + + ; CHECK-NOT: OpStore %outColor [[new_constant]] + OpStore %outColor %42 + + OpReturn + OpFunctionEnd +)"; + + auto result = SinglePassRunAndMatch(text, true); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + } // namespace } // namespace opt } // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/code_sink_test.cpp b/third_party/spirv-tools/test/opt/code_sink_test.cpp index f1bd12756a..bf5029b67c 100644 --- a/third_party/spirv-tools/test/opt/code_sink_test.cpp +++ b/third_party/spirv-tools/test/opt/code_sink_test.cpp @@ -378,7 +378,7 @@ TEST_F(CodeSinkTest, MoveReadOnlyLoadWithSync) { %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_4 = OpConstant %uint 4 -%mem_semantics = OpConstant %uint 0x42 ; Uniform memeory arquire +%mem_semantics = OpConstant %uint 0x42 ; Uniform memory arquire %_arr_uint_uint_4 = OpTypeArray %uint %uint_4 %_ptr_Uniform_uint = OpTypePointer Uniform %uint %_ptr_Uniform__arr_uint_uint_4 = OpTypePointer Uniform %_arr_uint_uint_4 @@ -419,7 +419,7 @@ TEST_F(CodeSinkTest, DontMoveBecauseOfSync) { %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_4 = OpConstant %uint 4 -%mem_semantics = OpConstant %uint 0x42 ; Uniform memeory arquire +%mem_semantics = OpConstant %uint 0x42 ; Uniform memory arquire %_arr_uint_uint_4 = OpTypeStruct %uint %_ptr_Uniform_uint = OpTypePointer Uniform %uint %_ptr_Uniform__arr_uint_uint_4 = OpTypePointer Uniform %_arr_uint_uint_4 @@ -460,7 +460,7 @@ TEST_F(CodeSinkTest, DontMoveBecauseOfAtomicWithSync) { %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_4 = OpConstant %uint 4 -%mem_semantics = OpConstant %uint 0x42 ; Uniform memeory arquire +%mem_semantics = OpConstant %uint 0x42 ; Uniform memory arquire %_arr_uint_uint_4 = OpTypeStruct %uint %_ptr_Uniform_uint = OpTypePointer Uniform %uint %_ptr_Uniform__arr_uint_uint_4 = OpTypePointer Uniform %_arr_uint_uint_4 diff --git a/third_party/spirv-tools/test/opt/compact_ids_test.cpp b/third_party/spirv-tools/test/opt/compact_ids_test.cpp index ba31d84bcc..7c232fe4c3 100644 --- a/third_party/spirv-tools/test/opt/compact_ids_test.cpp +++ b/third_party/spirv-tools/test/opt/compact_ids_test.cpp @@ -310,6 +310,41 @@ OpFunctionEnd EXPECT_THAT(disassembly, ::testing::Eq(expected)); } +TEST(CompactIds, ResetIdBound) { + const std::string input(R"(OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %1 "main" +OpExecutionMode %1 OriginUpperLeft +%void = OpTypeVoid +%3 = OpTypeFunction %void +%1 = OpFunction %void None %3 +%4 = OpLabel +OpReturn +OpFunctionEnd +)"); + + spvtools::SpirvTools tools(SPV_ENV_UNIVERSAL_1_1); + std::unique_ptr context = + BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, input, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + ASSERT_NE(context, nullptr); + + CompactIdsPass compact_id_pass; + context->module()->SetIdBound(20000); + const auto status = compact_id_pass.Run(context.get()); + EXPECT_EQ(status, Pass::Status::SuccessWithChange); + EXPECT_EQ(context->module()->id_bound(), 5); + + // Test output just in case + std::vector binary; + context->module()->ToBinary(&binary, false); + std::string disassembly; + tools.Disassemble(binary, &disassembly, + SpirvTools::kDefaultDisassembleOption); + + EXPECT_THAT(disassembly, ::testing::Eq(input)); +} + } // namespace } // namespace opt } // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/dead_branch_elim_test.cpp b/third_party/spirv-tools/test/opt/dead_branch_elim_test.cpp index 9c1ef2a317..b04c8f5e1a 100644 --- a/third_party/spirv-tools/test/opt/dead_branch_elim_test.cpp +++ b/third_party/spirv-tools/test/opt/dead_branch_elim_test.cpp @@ -1613,7 +1613,7 @@ OpBranch %7 %11 = OpLogicalOr %bool %true %false OpBranch %7 %7 = OpLabel -; This phi is in a block preceeding the merge %14! +; This phi is in a block preceding the merge %14! %8 = OpPhi %bool %10 %5 %11 %6 OpBranch %14 %14 = OpLabel diff --git a/third_party/spirv-tools/test/opt/decoration_manager_test.cpp b/third_party/spirv-tools/test/opt/decoration_manager_test.cpp index fcfbff0600..c9fabe7894 100644 --- a/third_party/spirv-tools/test/opt/decoration_manager_test.cpp +++ b/third_party/spirv-tools/test/opt/decoration_manager_test.cpp @@ -118,7 +118,7 @@ class DecorationManagerTest : public ::testing::Test { TEST_F(DecorationManagerTest, ComparingDecorationsWithDiffOpcodesDecorateDecorateId) { IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer()); - // This parameter can be interprated both as { SpvDecorationConstant } + // This parameter can be interpreted both as { SpvDecorationConstant } // and also as a list of IDs: { 22 } const std::vector param{SpvDecorationConstant}; // OpDecorate %1 Constant @@ -137,7 +137,7 @@ TEST_F(DecorationManagerTest, TEST_F(DecorationManagerTest, ComparingDecorationsWithDiffOpcodesDecorateDecorateString) { IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer()); - // This parameter can be interprated both as { SpvDecorationConstant } + // This parameter can be interpreted both as { SpvDecorationConstant } // and also as a null-terminated string with a single character with value 22. const std::vector param{SpvDecorationConstant}; // OpDecorate %1 Constant diff --git a/third_party/spirv-tools/test/opt/def_use_test.cpp b/third_party/spirv-tools/test/opt/def_use_test.cpp index cfdad74a15..48a485e898 100644 --- a/third_party/spirv-tools/test/opt/def_use_test.cpp +++ b/third_party/spirv-tools/test/opt/def_use_test.cpp @@ -950,6 +950,369 @@ INSTANTIATE_TEST_SUITE_P( ); // clang-format on +// We re-use the same replace usecases, we need to similarly exercise the +// DefUseManager by replacing instructions and uses. +using CompactIdempotence = ::testing::TestWithParam; + +TEST_P(CompactIdempotence, Case) { + const auto& tc = GetParam(); + + // Build module. + const std::vector text = {tc.before}; + std::unique_ptr context = + BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, JoinAllInsts(text), + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + ASSERT_NE(nullptr, context); + + // Force a re-build of def-use manager. + context->InvalidateAnalyses(IRContext::Analysis::kAnalysisDefUse); + (void)context->get_def_use_mgr(); + + // Do the substitution. + for (const auto& candidate : tc.candidates) { + context->ReplaceAllUsesWith(candidate.first, candidate.second); + } + + // Ensure new/uncompacted managers produce the same result + EXPECT_TRUE(CompareAndPrintDifferences(*context->get_def_use_mgr(), + DefUseManager(context->module()))); + + EXPECT_EQ(tc.after, DisassembleModule(context->module())); + CheckDef(tc.du, context->get_def_use_mgr()->id_to_defs()); + CheckUse(tc.du, context->get_def_use_mgr(), context->module()->IdBound()); + + // Compare again after compacting the defuse manager's storage + context->get_def_use_mgr()->CompactStorage(); + + CheckDef(tc.du, context->get_def_use_mgr()->id_to_defs()); + CheckUse(tc.du, context->get_def_use_mgr(), context->module()->IdBound()); + + EXPECT_TRUE(CompareAndPrintDifferences(*context->get_def_use_mgr(), + DefUseManager(context->module()))); +} + +// clang-format off +INSTANTIATE_TEST_SUITE_P( + TestCase, CompactIdempotence, + ::testing::ValuesIn(std::vector{ + { // no use, no replace request + "", {}, "", {}, + }, + { // replace one use + "%1 = OpTypeBool " + "%2 = OpTypeVector %1 3 " + "%3 = OpTypeInt 32 0 ", + {{1, 3}}, + "%1 = OpTypeBool\n" + "%2 = OpTypeVector %3 3\n" + "%3 = OpTypeInt 32 0", + { + { // defs + {1, "%1 = OpTypeBool"}, + {2, "%2 = OpTypeVector %3 3"}, + {3, "%3 = OpTypeInt 32 0"}, + }, + { // uses + {3, {"%2 = OpTypeVector %3 3"}}, + }, + }, + }, + { // replace and then replace back + "%1 = OpTypeBool " + "%2 = OpTypeVector %1 3 " + "%3 = OpTypeInt 32 0", + {{1, 3}, {3, 1}}, + "%1 = OpTypeBool\n" + "%2 = OpTypeVector %1 3\n" + "%3 = OpTypeInt 32 0", + { + { // defs + {1, "%1 = OpTypeBool"}, + {2, "%2 = OpTypeVector %1 3"}, + {3, "%3 = OpTypeInt 32 0"}, + }, + { // uses + {1, {"%2 = OpTypeVector %1 3"}}, + }, + }, + }, + { // replace with the same id + "%1 = OpTypeBool " + "%2 = OpTypeVector %1 3", + {{1, 1}, {2, 2}, {3, 3}}, + "%1 = OpTypeBool\n" + "%2 = OpTypeVector %1 3", + { + { // defs + {1, "%1 = OpTypeBool"}, + {2, "%2 = OpTypeVector %1 3"}, + }, + { // uses + {1, {"%2 = OpTypeVector %1 3"}}, + }, + }, + }, + { // replace in sequence + "%1 = OpTypeBool " + "%2 = OpTypeVector %1 3 " + "%3 = OpTypeInt 32 0 " + "%4 = OpTypeInt 32 1 ", + {{1, 3}, {3, 4}}, + "%1 = OpTypeBool\n" + "%2 = OpTypeVector %4 3\n" + "%3 = OpTypeInt 32 0\n" + "%4 = OpTypeInt 32 1", + { + { // defs + {1, "%1 = OpTypeBool"}, + {2, "%2 = OpTypeVector %4 3"}, + {3, "%3 = OpTypeInt 32 0"}, + {4, "%4 = OpTypeInt 32 1"}, + }, + { // uses + {4, {"%2 = OpTypeVector %4 3"}}, + }, + }, + }, + { // replace multiple uses + "%1 = OpTypeBool " + "%2 = OpTypeVector %1 2 " + "%3 = OpTypeVector %1 3 " + "%4 = OpTypeVector %1 4 " + "%5 = OpTypeMatrix %2 2 " + "%6 = OpTypeMatrix %3 3 " + "%7 = OpTypeMatrix %4 4 " + "%8 = OpTypeInt 32 0 " + "%9 = OpTypeInt 32 1 " + "%10 = OpTypeInt 64 0", + {{1, 8}, {2, 9}, {4, 10}}, + "%1 = OpTypeBool\n" + "%2 = OpTypeVector %8 2\n" + "%3 = OpTypeVector %8 3\n" + "%4 = OpTypeVector %8 4\n" + "%5 = OpTypeMatrix %9 2\n" + "%6 = OpTypeMatrix %3 3\n" + "%7 = OpTypeMatrix %10 4\n" + "%8 = OpTypeInt 32 0\n" + "%9 = OpTypeInt 32 1\n" + "%10 = OpTypeInt 64 0", + { + { // defs + {1, "%1 = OpTypeBool"}, + {2, "%2 = OpTypeVector %8 2"}, + {3, "%3 = OpTypeVector %8 3"}, + {4, "%4 = OpTypeVector %8 4"}, + {5, "%5 = OpTypeMatrix %9 2"}, + {6, "%6 = OpTypeMatrix %3 3"}, + {7, "%7 = OpTypeMatrix %10 4"}, + {8, "%8 = OpTypeInt 32 0"}, + {9, "%9 = OpTypeInt 32 1"}, + {10, "%10 = OpTypeInt 64 0"}, + }, + { // uses + {8, + { + "%2 = OpTypeVector %8 2", + "%3 = OpTypeVector %8 3", + "%4 = OpTypeVector %8 4", + } + }, + {9, {"%5 = OpTypeMatrix %9 2"}}, + {3, {"%6 = OpTypeMatrix %3 3"}}, + {10, {"%7 = OpTypeMatrix %10 4"}}, + }, + }, + }, + { // OpPhi. + kOpPhiTestFunction, + // replace one id used by OpPhi, replace one id generated by OpPhi + {{9, 13}, {11, 9}}, + "%1 = OpTypeVoid\n" + "%6 = OpTypeInt 32 0\n" + "%10 = OpTypeFloat 32\n" + "%16 = OpTypeBool\n" + "%3 = OpTypeFunction %1\n" + "%8 = OpConstant %6 0\n" + "%18 = OpConstant %6 1\n" + "%12 = OpConstant %10 1\n" + "%2 = OpFunction %1 None %3\n" + "%4 = OpLabel\n" + "OpBranch %5\n" + + "%5 = OpLabel\n" + "%7 = OpPhi %6 %8 %4 %13 %5\n" // %9 -> %13 + "%11 = OpPhi %10 %12 %4 %13 %5\n" + "%9 = OpIAdd %6 %7 %8\n" + "%13 = OpFAdd %10 %9 %12\n" // %11 -> %9 + "%17 = OpSLessThan %16 %7 %18\n" + "OpLoopMerge %19 %5 None\n" + "OpBranchConditional %17 %5 %19\n" + + "%19 = OpLabel\n" + "OpReturn\n" + "OpFunctionEnd", + { + { // defs. + {1, "%1 = OpTypeVoid"}, + {2, "%2 = OpFunction %1 None %3"}, + {3, "%3 = OpTypeFunction %1"}, + {4, "%4 = OpLabel"}, + {5, "%5 = OpLabel"}, + {6, "%6 = OpTypeInt 32 0"}, + {7, "%7 = OpPhi %6 %8 %4 %13 %5"}, + {8, "%8 = OpConstant %6 0"}, + {9, "%9 = OpIAdd %6 %7 %8"}, + {10, "%10 = OpTypeFloat 32"}, + {11, "%11 = OpPhi %10 %12 %4 %13 %5"}, + {12, "%12 = OpConstant %10 1.0"}, + {13, "%13 = OpFAdd %10 %9 %12"}, + {16, "%16 = OpTypeBool"}, + {17, "%17 = OpSLessThan %16 %7 %18"}, + {18, "%18 = OpConstant %6 1"}, + {19, "%19 = OpLabel"}, + }, + { // uses + {1, + { + "%2 = OpFunction %1 None %3", + "%3 = OpTypeFunction %1", + } + }, + {3, {"%2 = OpFunction %1 None %3"}}, + {4, + { + "%7 = OpPhi %6 %8 %4 %13 %5", + "%11 = OpPhi %10 %12 %4 %13 %5", + } + }, + {5, + { + "OpBranch %5", + "%7 = OpPhi %6 %8 %4 %13 %5", + "%11 = OpPhi %10 %12 %4 %13 %5", + "OpLoopMerge %19 %5 None", + "OpBranchConditional %17 %5 %19", + } + }, + {6, + { + // Can't properly check constants + // "%8 = OpConstant %6 0", + // "%18 = OpConstant %6 1", + "%7 = OpPhi %6 %8 %4 %13 %5", + "%9 = OpIAdd %6 %7 %8" + } + }, + {7, + { + "%9 = OpIAdd %6 %7 %8", + "%17 = OpSLessThan %16 %7 %18", + } + }, + {8, + { + "%7 = OpPhi %6 %8 %4 %13 %5", + "%9 = OpIAdd %6 %7 %8", + } + }, + {9, {"%13 = OpFAdd %10 %9 %12"}}, // uses of %9 changed from %7 to %13 + {10, + { + "%11 = OpPhi %10 %12 %4 %13 %5", + // "%12 = OpConstant %10 1", + "%13 = OpFAdd %10 %9 %12" + } + }, + // no more uses of %11 + {12, + { + "%11 = OpPhi %10 %12 %4 %13 %5", + "%13 = OpFAdd %10 %9 %12" + } + }, + {13, { + "%7 = OpPhi %6 %8 %4 %13 %5", + "%11 = OpPhi %10 %12 %4 %13 %5", + } + }, + {16, {"%17 = OpSLessThan %16 %7 %18"}}, + {17, {"OpBranchConditional %17 %5 %19"}}, + {18, {"%17 = OpSLessThan %16 %7 %18"}}, + {19, + { + "OpLoopMerge %19 %5 None", + "OpBranchConditional %17 %5 %19", + } + }, + }, + }, + }, + { // OpPhi defining and referencing the same id. + "%1 = OpTypeBool " + "%3 = OpTypeFunction %1 " + "%2 = OpConstantTrue %1 " + + "%4 = OpFunction %3 None %1 " + "%6 = OpLabel " + " OpBranch %7 " + "%7 = OpLabel " + "%8 = OpPhi %1 %8 %7 %2 %6 " // both defines and uses %8 + " OpBranch %7 " + " OpFunctionEnd", + {{8, 2}}, + "%1 = OpTypeBool\n" + "%3 = OpTypeFunction %1\n" + "%2 = OpConstantTrue %1\n" + + "%4 = OpFunction %3 None %1\n" + "%6 = OpLabel\n" + "OpBranch %7\n" + "%7 = OpLabel\n" + "%8 = OpPhi %1 %2 %7 %2 %6\n" // use of %8 changed to %2 + "OpBranch %7\n" + "OpFunctionEnd", + { + { // defs + {1, "%1 = OpTypeBool"}, + {2, "%2 = OpConstantTrue %1"}, + {3, "%3 = OpTypeFunction %1"}, + {4, "%4 = OpFunction %3 None %1"}, + {6, "%6 = OpLabel"}, + {7, "%7 = OpLabel"}, + {8, "%8 = OpPhi %1 %2 %7 %2 %6"}, + }, + { // uses + {1, + { + "%2 = OpConstantTrue %1", + "%3 = OpTypeFunction %1", + "%4 = OpFunction %3 None %1", + "%8 = OpPhi %1 %2 %7 %2 %6", + } + }, + {2, + { + // Only checking users + "%8 = OpPhi %1 %2 %7 %2 %6", + } + }, + {3, {"%4 = OpFunction %3 None %1"}}, + {6, {"%8 = OpPhi %1 %2 %7 %2 %6"}}, + {7, + { + "OpBranch %7", + "%8 = OpPhi %1 %2 %7 %2 %6", + "OpBranch %7", + } + }, + // {8, {"%8 = OpPhi %1 %8 %7 %2 %6"}}, + }, + }, + }, + }) +); +// clang-format on + struct KillDefCase { const char* before; std::vector ids_to_kill; @@ -1656,7 +2019,7 @@ INSTANTIATE_TEST_SUITE_P( "OpGroupDecorate %1 %2 %3", }, }, - // memeber decorate + // member decorate { // code "OpMemberDecorate %1 0 RelaxedPrecision " @@ -1707,9 +2070,10 @@ TEST_F(UpdateUsesTest, KeepOldUses) { def->SetInOperands({{SPV_OPERAND_TYPE_ID, {25}}}); context->UpdateDefUse(def); - auto users = def_use_mgr->id_to_users(); - UserEntry entry = {def, use}; - EXPECT_THAT(users, Contains(entry)); + auto scanUser = [&](Instruction* user) { return user != use; }; + bool userFound = !def_use_mgr->WhileEachUser(def, scanUser); + + EXPECT_TRUE(userFound); } // clang-format on diff --git a/third_party/spirv-tools/test/opt/desc_sroa_test.cpp b/third_party/spirv-tools/test/opt/desc_sroa_test.cpp index dcb625d6d4..91c950e88e 100644 --- a/third_party/spirv-tools/test/opt/desc_sroa_test.cpp +++ b/third_party/spirv-tools/test/opt/desc_sroa_test.cpp @@ -833,6 +833,93 @@ TEST_F(DescriptorScalarReplacementTest, MemberDecorationForResourceStruct) { SinglePassRunAndMatch(shader, true); } +TEST_F(DescriptorScalarReplacementTest, DecorateStringForReflect) { + // Check that an OpDecorateString instruction is correctly cloned to new + // variable. + + const std::string shader = R"( +; CHECK: OpName %g_testTextures_0_ "g_testTextures[0]" +; CHECK: OpDecorate %g_testTextures_0_ DescriptorSet 0 +; CHECK: OpDecorate %g_testTextures_0_ Binding 0 +; CHECK: OpDecorateString %g_testTextures_0_ UserTypeGOOGLE "texture2d" + OpCapability Shader + OpExtension "SPV_GOOGLE_hlsl_functionality1" + OpExtension "SPV_GOOGLE_user_type" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %gl_FragCoord %out_var_SV_Target + OpExecutionMode %main OriginUpperLeft + OpSource HLSL 600 + OpName %type_2d_image "type.2d.image" + OpName %g_testTextures "g_testTextures" + OpName %out_var_SV_Target "out.var.SV_Target" + OpName %main "main" + OpName %param_var_vPixelPos "param.var.vPixelPos" + OpName %src_main "src.main" + OpName %vPixelPos "vPixelPos" + OpName %bb_entry "bb.entry" + OpDecorate %gl_FragCoord BuiltIn FragCoord + OpDecorateString %gl_FragCoord UserSemantic "SV_Position" + OpDecorateString %out_var_SV_Target UserSemantic "SV_Target" + OpDecorate %out_var_SV_Target Location 0 + OpDecorate %g_testTextures DescriptorSet 0 + OpDecorate %g_testTextures Binding 0 + OpDecorateString %g_testTextures UserTypeGOOGLE "texture2d" + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %uint_2 = OpConstant %uint 2 + %float = OpTypeFloat 32 +%type_2d_image = OpTypeImage %float 2D 2 0 0 1 Unknown +%_arr_type_2d_image_uint_2 = OpTypeArray %type_2d_image %uint_2 +%_ptr_UniformConstant__arr_type_2d_image_uint_2 = OpTypePointer UniformConstant %_arr_type_2d_image_uint_2 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Output_v4float = OpTypePointer Output %v4float + %void = OpTypeVoid + %18 = OpTypeFunction %void +%_ptr_Function_v4float = OpTypePointer Function %v4float + %25 = OpTypeFunction %v4float %_ptr_Function_v4float + %v2float = OpTypeVector %float 2 + %v3uint = OpTypeVector %uint 3 + %v3int = OpTypeVector %int 3 + %v2int = OpTypeVector %int 2 +%_ptr_UniformConstant_type_2d_image = OpTypePointer UniformConstant %type_2d_image +%g_testTextures = OpVariable %_ptr_UniformConstant__arr_type_2d_image_uint_2 UniformConstant +%gl_FragCoord = OpVariable %_ptr_Input_v4float Input +%out_var_SV_Target = OpVariable %_ptr_Output_v4float Output + %main = OpFunction %void None %18 + %19 = OpLabel +%param_var_vPixelPos = OpVariable %_ptr_Function_v4float Function + %22 = OpLoad %v4float %gl_FragCoord + OpStore %param_var_vPixelPos %22 + %23 = OpFunctionCall %v4float %src_main %param_var_vPixelPos + OpStore %out_var_SV_Target %23 + OpReturn + OpFunctionEnd + %src_main = OpFunction %v4float None %25 + %vPixelPos = OpFunctionParameter %_ptr_Function_v4float + %bb_entry = OpLabel + %28 = OpLoad %v4float %vPixelPos + %30 = OpVectorShuffle %v2float %28 %28 0 1 + %31 = OpCompositeExtract %float %30 0 + %32 = OpCompositeExtract %float %30 1 + %33 = OpConvertFToU %uint %31 + %34 = OpConvertFToU %uint %32 + %36 = OpCompositeConstruct %v3uint %33 %34 %uint_0 + %38 = OpBitcast %v3int %36 + %40 = OpVectorShuffle %v2int %38 %38 0 1 + %41 = OpCompositeExtract %int %38 2 + %43 = OpAccessChain %_ptr_UniformConstant_type_2d_image %g_testTextures %int_0 + %44 = OpLoad %type_2d_image %43 + %45 = OpImageFetch %v4float %44 %40 Lod %41 + OpReturnValue %45 + OpFunctionEnd +)"; + + SinglePassRunAndMatch(shader, true); +} + } // namespace } // namespace opt } // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/dominator_tree/generated.cpp b/third_party/spirv-tools/test/opt/dominator_tree/generated.cpp index 534f770b5b..4fccef0527 100644 --- a/third_party/spirv-tools/test/opt/dominator_tree/generated.cpp +++ b/third_party/spirv-tools/test/opt/dominator_tree/generated.cpp @@ -57,7 +57,7 @@ void check_dominance(const DominatorAnalysisBase& dom_tree, const Function* fn, } } -// Check that x does not dominates y and vise versa +// Check that x does not dominates y and vice versa void check_no_dominance(const DominatorAnalysisBase& dom_tree, const Function* fn, uint32_t x, uint32_t y) { SCOPED_TRACE("Check no domination for Basic Block " + std::to_string(x) + diff --git a/third_party/spirv-tools/test/opt/eliminate_dead_const_test.cpp b/third_party/spirv-tools/test/opt/eliminate_dead_const_test.cpp index 59f06f9f25..87aab54511 100644 --- a/third_party/spirv-tools/test/opt/eliminate_dead_const_test.cpp +++ b/third_party/spirv-tools/test/opt/eliminate_dead_const_test.cpp @@ -547,7 +547,7 @@ INSTANTIATE_TEST_SUITE_P( }, // Uint vector type spec constants. One vector has all component dead, - // another vector has one dead unsigend integer and one used unsigned + // another vector has one dead unsigned integer and one used unsigned // integer. { /* .used_consts = */ diff --git a/third_party/spirv-tools/test/opt/eliminate_dead_input_components_test.cpp b/third_party/spirv-tools/test/opt/eliminate_dead_input_components_test.cpp new file mode 100644 index 0000000000..b0098f733a --- /dev/null +++ b/third_party/spirv-tools/test/opt/eliminate_dead_input_components_test.cpp @@ -0,0 +1,404 @@ +// Copyright (c) 2022 The Khronos Group Inc. +// Copyright (c) 2022 LunarG Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "gmock/gmock.h" +#include "test/opt/pass_fixture.h" +#include "test/opt/pass_utils.h" + +namespace spvtools { +namespace opt { +namespace { + +using ElimDeadInputComponentsTest = PassTest<::testing::Test>; + +TEST_F(ElimDeadInputComponentsTest, ElimOneConstantIndex) { + // Should reduce to uv[2] + // + // #version 450 + // + // layout(location = 0) in vec4 uv[8]; + // + // out gl_PerVertex { + // vec4 gl_Position; + // }; + // + // void main() + // { + // gl_Position = uv[1]; + // } + const std::string text = R"( + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %_ %uv + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpName %_ "" + OpName %uv "uv" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpDecorate %gl_PerVertex Block + OpDecorate %uv Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%gl_PerVertex = OpTypeStruct %v4float +%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex + %_ = OpVariable %_ptr_Output_gl_PerVertex Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %uint = OpTypeInt 32 0 + %uint_8 = OpConstant %uint 8 +%_arr_v4float_uint_8 = OpTypeArray %v4float %uint_8 +%_ptr_Input__arr_v4float_uint_8 = OpTypePointer Input %_arr_v4float_uint_8 + %uv = OpVariable %_ptr_Input__arr_v4float_uint_8 Input + %int_1 = OpConstant %int 1 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Output_v4float = OpTypePointer Output %v4float +;CHECK-NOT: %uv = OpVariable %_ptr_Input__arr_v4float_uint_8 Input +;CHECK: %uv = OpVariable %_ptr_Input__arr_v4float_uint_2 Input + %main = OpFunction %void None %3 + %5 = OpLabel + %20 = OpAccessChain %_ptr_Input_v4float %uv %int_1 + %21 = OpLoad %v4float %20 + %23 = OpAccessChain %_ptr_Output_v4float %_ %int_0 + OpStore %23 %21 + OpReturn + OpFunctionEnd +)"; + + SetTargetEnv(SPV_ENV_VULKAN_1_3); + SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + SinglePassRunAndMatch(text, true); +} + +TEST_F(ElimDeadInputComponentsTest, ElimOneConstantIndexInBounds) { + // Same as ElimOneConstantIndex but with OpInBoundsAccessChain + const std::string text = R"( + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %_ %uv + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpName %_ "" + OpName %uv "uv" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpDecorate %gl_PerVertex Block + OpDecorate %uv Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%gl_PerVertex = OpTypeStruct %v4float +%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex + %_ = OpVariable %_ptr_Output_gl_PerVertex Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %uint = OpTypeInt 32 0 + %uint_8 = OpConstant %uint 8 +%_arr_v4float_uint_8 = OpTypeArray %v4float %uint_8 +%_ptr_Input__arr_v4float_uint_8 = OpTypePointer Input %_arr_v4float_uint_8 + %uv = OpVariable %_ptr_Input__arr_v4float_uint_8 Input + %int_1 = OpConstant %int 1 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Output_v4float = OpTypePointer Output %v4float +;CHECK-NOT: %uv = OpVariable %_ptr_Input__arr_v4float_uint_8 Input +;CHECK: %uv = OpVariable %_ptr_Input__arr_v4float_uint_2 Input + %main = OpFunction %void None %3 + %5 = OpLabel + %20 = OpInBoundsAccessChain %_ptr_Input_v4float %uv %int_1 + %21 = OpLoad %v4float %20 + %23 = OpAccessChain %_ptr_Output_v4float %_ %int_0 + OpStore %23 %21 + OpReturn + OpFunctionEnd +)"; + + SetTargetEnv(SPV_ENV_VULKAN_1_3); + SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + SinglePassRunAndMatch(text, true); +} + +TEST_F(ElimDeadInputComponentsTest, ElimTwoConstantIndices) { + // Should reduce to uv[4] + // + // #version 450 + // + // layout(location = 0) in vec4 uv[8]; + // + // out gl_PerVertex { + // vec4 gl_Position; + // }; + // + // void main() + // { + // gl_Position = uv[1] + uv[3]; + // } + const std::string text = R"( + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %_ %uv + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpName %_ "" + OpName %uv "uv" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpDecorate %gl_PerVertex Block + OpDecorate %uv Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%gl_PerVertex = OpTypeStruct %v4float +%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex + %_ = OpVariable %_ptr_Output_gl_PerVertex Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %uint = OpTypeInt 32 0 + %uint_8 = OpConstant %uint 8 +%_arr_v4float_uint_8 = OpTypeArray %v4float %uint_8 +%_ptr_Input__arr_v4float_uint_8 = OpTypePointer Input %_arr_v4float_uint_8 + %uv = OpVariable %_ptr_Input__arr_v4float_uint_8 Input + %int_1 = OpConstant %int 1 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %int_3 = OpConstant %int 3 +%_ptr_Output_v4float = OpTypePointer Output %v4float +;CHECK-NOT: %uv = OpVariable %_ptr_Input__arr_v4float_uint_8 Input +;CHECK: %uv = OpVariable %_ptr_Input__arr_v4float_uint_4 Input + %main = OpFunction %void None %3 + %5 = OpLabel + %20 = OpAccessChain %_ptr_Input_v4float %uv %int_1 + %21 = OpLoad %v4float %20 + %23 = OpAccessChain %_ptr_Input_v4float %uv %int_3 + %24 = OpLoad %v4float %23 + %25 = OpFAdd %v4float %21 %24 + %27 = OpAccessChain %_ptr_Output_v4float %_ %int_0 + OpStore %27 %25 + OpReturn + OpFunctionEnd +)"; + + SetTargetEnv(SPV_ENV_VULKAN_1_3); + SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + SinglePassRunAndMatch(text, true); +} + +TEST_F(ElimDeadInputComponentsTest, NoElimMaxConstantIndex) { + // Should not reduce uv[8] because of max index of 7 + // + // #version 450 + // + // layout(location = 0) in vec4 uv[8]; + // + // out gl_PerVertex { + // vec4 gl_Position; + // }; + // + // void main() + // { + // gl_Position = uv[1] + uv[7]; + // } + const std::string text = R"( + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %_ %uv + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpName %_ "" + OpName %uv "uv" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpDecorate %gl_PerVertex Block + OpDecorate %uv Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%gl_PerVertex = OpTypeStruct %v4float +%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex + %_ = OpVariable %_ptr_Output_gl_PerVertex Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %uint = OpTypeInt 32 0 + %uint_8 = OpConstant %uint 8 +%_arr_v4float_uint_8 = OpTypeArray %v4float %uint_8 +%_ptr_Input__arr_v4float_uint_8 = OpTypePointer Input %_arr_v4float_uint_8 + %uv = OpVariable %_ptr_Input__arr_v4float_uint_8 Input + %int_1 = OpConstant %int 1 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %int_7 = OpConstant %int 7 +%_ptr_Output_v4float = OpTypePointer Output %v4float +;CHECK: %uv = OpVariable %_ptr_Input__arr_v4float_uint_8 Input + %main = OpFunction %void None %3 + %5 = OpLabel + %20 = OpAccessChain %_ptr_Input_v4float %uv %int_1 + %21 = OpLoad %v4float %20 + %23 = OpAccessChain %_ptr_Input_v4float %uv %int_7 + %24 = OpLoad %v4float %23 + %25 = OpFAdd %v4float %21 %24 + %27 = OpAccessChain %_ptr_Output_v4float %_ %int_0 + OpStore %27 %25 + OpReturn + OpFunctionEnd +)"; + + SetTargetEnv(SPV_ENV_VULKAN_1_3); + SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + SinglePassRunAndMatch(text, true); +} + +TEST_F(ElimDeadInputComponentsTest, NoElimNonConstantIndex) { + // Should not reduce uv[8] because of non-constant index of ui + // + // #version 450 + // + // layout(location = 0) in vec4 uv[8]; + // + // out gl_PerVertex { + // vec4 gl_Position; + // }; + // + // uniform ubname { + // int ui; + // } ubinst; + // + // void main() + // { + // gl_Position = uv[1] + uv[ubinst.ui]; + // } + const std::string text = R"( + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %_ %uv %ubinst + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpName %_ "" + OpName %uv "uv" + OpName %ubname "ubname" + OpMemberName %ubname 0 "ui" + OpName %ubinst "ubinst" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpDecorate %gl_PerVertex Block + OpDecorate %uv Location 0 + OpMemberDecorate %ubname 0 Offset 0 + OpDecorate %ubname Block + OpDecorate %ubinst DescriptorSet 0 + OpDecorate %ubinst Binding 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%gl_PerVertex = OpTypeStruct %v4float +%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex + %_ = OpVariable %_ptr_Output_gl_PerVertex Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %uint = OpTypeInt 32 0 + %uint_8 = OpConstant %uint 8 +%_arr_v4float_uint_8 = OpTypeArray %v4float %uint_8 +%_ptr_Input__arr_v4float_uint_8 = OpTypePointer Input %_arr_v4float_uint_8 + %uv = OpVariable %_ptr_Input__arr_v4float_uint_8 Input + %int_1 = OpConstant %int 1 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %ubname = OpTypeStruct %int +%_ptr_Uniform_ubname = OpTypePointer Uniform %ubname + %ubinst = OpVariable %_ptr_Uniform_ubname Uniform +%_ptr_Uniform_int = OpTypePointer Uniform %int +%_ptr_Output_v4float = OpTypePointer Output %v4float +;CHECK: %uv = OpVariable %_ptr_Input__arr_v4float_uint_8 Input + %main = OpFunction %void None %3 + %5 = OpLabel + %20 = OpAccessChain %_ptr_Input_v4float %uv %int_1 + %21 = OpLoad %v4float %20 + %26 = OpAccessChain %_ptr_Uniform_int %ubinst %int_0 + %27 = OpLoad %int %26 + %28 = OpAccessChain %_ptr_Input_v4float %uv %27 + %29 = OpLoad %v4float %28 + %30 = OpFAdd %v4float %21 %29 + %32 = OpAccessChain %_ptr_Output_v4float %_ %int_0 + OpStore %32 %30 + OpReturn + OpFunctionEnd +)"; + + SetTargetEnv(SPV_ENV_VULKAN_1_3); + SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + SinglePassRunAndMatch(text, true); +} + +TEST_F(ElimDeadInputComponentsTest, NoElimNonIndexedAccessChain) { + // Should not change due to non-indexed access chain + const std::string text = R"( + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %_ %uv + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpName %_ "" + OpName %uv "uv" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpDecorate %gl_PerVertex Block + OpDecorate %uv Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%gl_PerVertex = OpTypeStruct %v4float +%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex + %_ = OpVariable %_ptr_Output_gl_PerVertex Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %uint = OpTypeInt 32 0 + %uint_8 = OpConstant %uint 8 +%_arr_v4float_uint_8 = OpTypeArray %v4float %uint_8 +%_ptr_Input__arr_v4float_uint_8 = OpTypePointer Input %_arr_v4float_uint_8 + %uv = OpVariable %_ptr_Input__arr_v4float_uint_8 Input + %int_1 = OpConstant %int 1 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Output_v4float = OpTypePointer Output %v4float +;CHECK: %uv = OpVariable %_ptr_Input__arr_v4float_uint_8 Input + %main = OpFunction %void None %3 + %5 = OpLabel + %20 = OpAccessChain %_ptr_Input__arr_v4float_uint_8 %uv + OpReturn + OpFunctionEnd +)"; + + SetTargetEnv(SPV_ENV_VULKAN_1_3); + SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + SinglePassRunAndMatch(text, true); +} + +} // namespace +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/fix_func_call_arguments_test.cpp b/third_party/spirv-tools/test/opt/fix_func_call_arguments_test.cpp new file mode 100644 index 0000000000..ecd13a866d --- /dev/null +++ b/third_party/spirv-tools/test/opt/fix_func_call_arguments_test.cpp @@ -0,0 +1,152 @@ +// Copyright (c) 2022 Advanced Micro Devices, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "gmock/gmock.h" +#include "test/opt/pass_fixture.h" +#include "test/opt/pass_utils.h" + +namespace spvtools { +namespace opt { +namespace { + +using FixFuncCallArgumentsTest = PassTest<::testing::Test>; +TEST_F(FixFuncCallArgumentsTest, Simple) { + const std::string text = R"( +; +; CHECK: [[v0:%\w+]] = OpVariable %_ptr_Function_float Function +; CHECK: [[v1:%\w+]] = OpVariable %_ptr_Function_float Function +; CHECK: [[v2:%\w+]] = OpVariable %_ptr_Function_T Function +; CHECK: [[ac0:%\w+]] = OpAccessChain %_ptr_Function_float %t %int_0 +; CHECK: [[ac1:%\w+]] = OpAccessChain %_ptr_Uniform_float %r1 %int_0 %uint_0 +; CHECK: [[ld0:%\w+]] = OpLoad %float [[ac0]] +; CHECK: OpStore [[v1]] [[ld0]] +; CHECK: [[ld1:%\w+]] = OpLoad %float [[ac1]] +; CHECK: OpStore [[v0]] [[ld1]] +; CHECK: [[func:%\w+]] = OpFunctionCall %void %fn [[v1]] [[v0]] +; CHECK: [[ld2:%\w+]] = OpLoad %float [[v0]] +; CHECK: OpStore [[ac1]] [[ld2]] +; CHECK: [[ld3:%\w+]] = OpLoad %float [[v1]] +; CHECK: OpStore [[ac0]] [[ld3]] +; +OpCapability Shader +OpCapability Linkage +OpMemoryModel Logical GLSL450 +OpSource HLSL 630 +OpName %type_RWStructuredBuffer_float "type.RWStructuredBuffer.float" +OpName %r1 "r1" +OpName %type_ACSBuffer_counter "type.ACSBuffer.counter" +OpMemberName %type_ACSBuffer_counter 0 "counter" +OpName %counter_var_r1 "counter.var.r1" +OpName %main "main" +OpName %bb_entry "bb.entry" +OpName %T "T" +OpMemberName %T 0 "t0" +OpName %t "t" +OpName %fn "fn" +OpName %p0 "p0" +OpName %p2 "p2" +OpName %bb_entry_0 "bb.entry" +OpDecorate %main LinkageAttributes "main" Export +OpDecorate %r1 DescriptorSet 0 +OpDecorate %r1 Binding 0 +OpDecorate %counter_var_r1 DescriptorSet 0 +OpDecorate %counter_var_r1 Binding 1 +OpDecorate %_runtimearr_float ArrayStride 4 +OpMemberDecorate %type_RWStructuredBuffer_float 0 Offset 0 +OpDecorate %type_RWStructuredBuffer_float BufferBlock +OpMemberDecorate %type_ACSBuffer_counter 0 Offset 0 +OpDecorate %type_ACSBuffer_counter BufferBlock +%int = OpTypeInt 32 1 +%int_0 = OpConstant %int 0 +%uint = OpTypeInt 32 0 +%uint_0 = OpConstant %uint 0 +%int_1 = OpConstant %int 1 +%float = OpTypeFloat 32 +%_runtimearr_float = OpTypeRuntimeArray %float +%type_RWStructuredBuffer_float = OpTypeStruct %_runtimearr_float +%_ptr_Uniform_type_RWStructuredBuffer_float = OpTypePointer Uniform %type_RWStructuredBuffer_float +%type_ACSBuffer_counter = OpTypeStruct %int +%_ptr_Uniform_type_ACSBuffer_counter = OpTypePointer Uniform %type_ACSBuffer_counter +%15 = OpTypeFunction %int +%T = OpTypeStruct %float +%_ptr_Function_T = OpTypePointer Function %T +%_ptr_Function_float = OpTypePointer Function %float +%_ptr_Uniform_float = OpTypePointer Uniform %float +%void = OpTypeVoid +%27 = OpTypeFunction %void %_ptr_Function_float %_ptr_Function_float +%r1 = OpVariable %_ptr_Uniform_type_RWStructuredBuffer_float Uniform +%counter_var_r1 = OpVariable %_ptr_Uniform_type_ACSBuffer_counter Uniform +%main = OpFunction %int None %15 +%bb_entry = OpLabel +%t = OpVariable %_ptr_Function_T Function +%21 = OpAccessChain %_ptr_Function_float %t %int_0 +%23 = OpAccessChain %_ptr_Uniform_float %r1 %int_0 %uint_0 +%25 = OpFunctionCall %void %fn %21 %23 +OpReturnValue %int_1 +OpFunctionEnd +%fn = OpFunction %void DontInline %27 +%p0 = OpFunctionParameter %_ptr_Function_float +%p2 = OpFunctionParameter %_ptr_Function_float +%bb_entry_0 = OpLabel +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, true); +} + +TEST_F(FixFuncCallArgumentsTest, NotAccessChainInput) { + const std::string text = R"( +; +; CHECK: [[o:%\w+]] = OpCopyObject %_ptr_Function_float %t +; CHECK: [[func:%\w+]] = OpFunctionCall %void %fn [[o]] +; +OpCapability Shader +OpCapability Linkage +OpMemoryModel Logical GLSL450 +OpSource HLSL 630 +OpName %main "main" +OpName %bb_entry "bb.entry" +OpName %t "t" +OpName %fn "fn" +OpName %p0 "p0" +OpName %bb_entry_0 "bb.entry" +OpDecorate %main LinkageAttributes "main" Export +%int = OpTypeInt 32 1 +%int_1 = OpConstant %int 1 +%4 = OpTypeFunction %int +%float = OpTypeFloat 32 +%_ptr_Function_float = OpTypePointer Function %float +%void = OpTypeVoid +%12 = OpTypeFunction %void %_ptr_Function_float +%main = OpFunction %int None %4 +%bb_entry = OpLabel +%t = OpVariable %_ptr_Function_float Function +%t1 = OpCopyObject %_ptr_Function_float %t +%10 = OpFunctionCall %void %fn %t1 +OpReturnValue %int_1 +OpFunctionEnd +%fn = OpFunction %void DontInline %12 +%p0 = OpFunctionParameter %_ptr_Function_float +%bb_entry_0 = OpLabel +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, false); +} + +} // namespace +} // namespace opt +} // namespace spvtools \ No newline at end of file diff --git a/third_party/spirv-tools/test/opt/flatten_decoration_test.cpp b/third_party/spirv-tools/test/opt/flatten_decoration_test.cpp index d8d8867715..63207fd21f 100644 --- a/third_party/spirv-tools/test/opt/flatten_decoration_test.cpp +++ b/third_party/spirv-tools/test/opt/flatten_decoration_test.cpp @@ -43,7 +43,7 @@ OpName %Camera "Camera" )"; } -// Retuns types +// Returns types std::string TypesAndFunctionsAssembly() { return R"(%void = OpTypeVoid diff --git a/third_party/spirv-tools/test/opt/fold_test.cpp b/third_party/spirv-tools/test/opt/fold_test.cpp index 0487e78cc8..e2240b8375 100644 --- a/third_party/spirv-tools/test/opt/fold_test.cpp +++ b/third_party/spirv-tools/test/opt/fold_test.cpp @@ -147,6 +147,7 @@ OpName %main "main" %v2double = OpTypeVector %double 2 %v2half = OpTypeVector %half 2 %v2bool = OpTypeVector %bool 2 +%m2x2int = OpTypeMatrix %v2int 2 %struct_v2int_int_int = OpTypeStruct %v2int %int %int %_ptr_int = OpTypePointer Function %int %_ptr_uint = OpTypePointer Function %uint @@ -218,12 +219,15 @@ OpName %main "main" %struct_v2int_int_int_null = OpConstantNull %struct_v2int_int_int %v2int_null = OpConstantNull %v2int %102 = OpConstantComposite %v2int %103 %103 +%v4int_undef = OpUndef %v4int %v4int_0_0_0_0 = OpConstantComposite %v4int %int_0 %int_0 %int_0 %int_0 +%m2x2int_undef = OpUndef %m2x2int %struct_undef_0_0 = OpConstantComposite %struct_v2int_int_int %v2int_undef %int_0 %int_0 %float_n1 = OpConstant %float -1 %104 = OpConstant %float 0 ; Need a def with an numerical id to define id maps. %float_null = OpConstantNull %float %float_0 = OpConstant %float 0 +%float_n0 = OpConstant %float -0.0 %float_1 = OpConstant %float 1 %float_2 = OpConstant %float 2 %float_3 = OpConstant %float 3 @@ -249,6 +253,7 @@ OpName %main "main" %105 = OpConstant %double 0 ; Need a def with an numerical id to define id maps. %double_null = OpConstantNull %double %double_0 = OpConstant %double 0 +%double_n0 = OpConstant %double -0.0 %double_1 = OpConstant %double 1 %double_2 = OpConstant %double 2 %double_3 = OpConstant %double 3 @@ -1987,7 +1992,39 @@ INSTANTIATE_TEST_SUITE_P(FloatConstantFoldingTest, FloatInstructionFoldingTest, "%2 = OpExtInst %float %1 Pow %float_2 %float_3\n" + "OpReturn\n" + "OpFunctionEnd", - 2, 8.0) + 2, 8.0), + // Test case 43: Fold 1.0 / -0.0. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpFDiv %float %float_1 %float_n0\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, -std::numeric_limits::infinity()), + // Test case 44: Fold -1.0 / -0.0 + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpFDiv %float %float_n1 %float_n0\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, std::numeric_limits::infinity()), + // Test case 45: Fold 0.0 / 0.0 + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpFDiv %float %float_0 %float_0\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, std::numeric_limits::quiet_NaN()), + // Test case 46: Fold 0.0 / -0.0 + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpFDiv %float %float_0 %float_n0\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, std::numeric_limits::quiet_NaN()) )); // clang-format on @@ -2019,7 +2056,11 @@ TEST_P(DoubleInstructionFoldingTest, Case) { const_mrg->GetConstantFromInst(inst)->AsFloatConstant(); EXPECT_NE(result, nullptr); if (result != nullptr) { - EXPECT_EQ(result->GetDoubleValue(), tc.expected_result); + if (!std::isnan(tc.expected_result)) { + EXPECT_EQ(result->GetDoubleValue(), tc.expected_result); + } else { + EXPECT_TRUE(std::isnan(result->GetDoubleValue())); + } } } } @@ -2222,7 +2263,39 @@ INSTANTIATE_TEST_SUITE_P(DoubleConstantFoldingTest, DoubleInstructionFoldingTest "%2 = OpExtInst %double %1 Pow %double_2 %double_3\n" + "OpReturn\n" + "OpFunctionEnd", - 2, 8.0) + 2, 8.0), + // Test case 23: Fold 1.0 / -0.0. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpFDiv %double %double_1 %double_n0\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, -std::numeric_limits::infinity()), + // Test case 24: Fold -1.0 / -0.0 + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpFDiv %double %double_n1 %double_n0\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, std::numeric_limits::infinity()), + // Test case 25: Fold 0.0 / 0.0 + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpFDiv %double %double_0 %double_0\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, std::numeric_limits::quiet_NaN()), + // Test case 26: Fold 0.0 / -0.0 + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpFDiv %double %double_0 %double_n0\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, std::numeric_limits::quiet_NaN()) )); // clang-format on @@ -6792,7 +6865,7 @@ INSTANTIATE_TEST_SUITE_P(SelectFoldingTest, MatchingInstructionFoldingTest, 4, true) )); -INSTANTIATE_TEST_SUITE_P(CompositeExtractMatchingTest, MatchingInstructionFoldingTest, +INSTANTIATE_TEST_SUITE_P(CompositeExtractOrInsertMatchingTest, MatchingInstructionFoldingTest, ::testing::Values( // Test case 0: Extracting from result of consecutive shuffles of differing // size. @@ -6932,7 +7005,145 @@ INSTANTIATE_TEST_SUITE_P(CompositeExtractMatchingTest, MatchingInstructionFoldin "%4 = OpCompositeExtract %int %3 1\n" + "OpReturn\n" + "OpFunctionEnd", - 4, true) + 4, true), + // Test case 8: Inserting every element of a vector turns into a composite construct. + InstructionFoldingCase( + Header() + + "; CHECK: [[int:%\\w+]] = OpTypeInt 32 1\n" + + "; CHECK-DAG: [[v4:%\\w+]] = OpTypeVector [[int]] 4\n" + + "; CHECK-DAG: [[int1:%\\w+]] = OpConstant [[int]] 1\n" + + "; CHECK-DAG: [[int2:%\\w+]] = OpConstant [[int]] 2\n" + + "; CHECK-DAG: [[int3:%\\w+]] = OpConstant [[int]] 3\n" + + "; CHECK: [[construct:%\\w+]] = OpCompositeConstruct [[v4]] %100 [[int1]] [[int2]] [[int3]]\n" + + "; CHECK: %5 = OpCopyObject [[v4]] [[construct]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpCompositeInsert %v4int %100 %v4int_undef 0\n" + + "%3 = OpCompositeInsert %v4int %int_1 %2 1\n" + + "%4 = OpCompositeInsert %v4int %int_2 %3 2\n" + + "%5 = OpCompositeInsert %v4int %int_3 %4 3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 5, true), + // Test case 9: Inserting every element of a vector turns into a composite construct in a different order. + InstructionFoldingCase( + Header() + + "; CHECK: [[int:%\\w+]] = OpTypeInt 32 1\n" + + "; CHECK-DAG: [[v4:%\\w+]] = OpTypeVector [[int]] 4\n" + + "; CHECK-DAG: [[int1:%\\w+]] = OpConstant [[int]] 1\n" + + "; CHECK-DAG: [[int2:%\\w+]] = OpConstant [[int]] 2\n" + + "; CHECK-DAG: [[int3:%\\w+]] = OpConstant [[int]] 3\n" + + "; CHECK: [[construct:%\\w+]] = OpCompositeConstruct [[v4]] %100 [[int1]] [[int2]] [[int3]]\n" + + "; CHECK: %5 = OpCopyObject [[v4]] [[construct]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpCompositeInsert %v4int %100 %v4int_undef 0\n" + + "%4 = OpCompositeInsert %v4int %int_2 %2 2\n" + + "%3 = OpCompositeInsert %v4int %int_1 %4 1\n" + + "%5 = OpCompositeInsert %v4int %int_3 %3 3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 5, true), + // Test case 10: Check multiple inserts to the same position are handled correctly. + InstructionFoldingCase( + Header() + + "; CHECK: [[int:%\\w+]] = OpTypeInt 32 1\n" + + "; CHECK-DAG: [[v4:%\\w+]] = OpTypeVector [[int]] 4\n" + + "; CHECK-DAG: [[int1:%\\w+]] = OpConstant [[int]] 1\n" + + "; CHECK-DAG: [[int2:%\\w+]] = OpConstant [[int]] 2\n" + + "; CHECK-DAG: [[int3:%\\w+]] = OpConstant [[int]] 3\n" + + "; CHECK: [[construct:%\\w+]] = OpCompositeConstruct [[v4]] %100 [[int1]] [[int2]] [[int3]]\n" + + "; CHECK: %6 = OpCopyObject [[v4]] [[construct]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpCompositeInsert %v4int %100 %v4int_undef 0\n" + + "%3 = OpCompositeInsert %v4int %int_2 %2 2\n" + + "%4 = OpCompositeInsert %v4int %int_4 %3 1\n" + + "%5 = OpCompositeInsert %v4int %int_1 %4 1\n" + + "%6 = OpCompositeInsert %v4int %int_3 %5 3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 6, true), + // Test case 11: The last indexes are 0 and 1, but they have different first indexes. This should not be folded. + InstructionFoldingCase( + Header() + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpCompositeInsert %m2x2int %100 %m2x2int_undef 0 0\n" + + "%3 = OpCompositeInsert %m2x2int %int_1 %2 1 1\n" + + "OpReturn\n" + + "OpFunctionEnd", + 3, false), + // Test case 12: Don't fold when there is a partial insertion. + InstructionFoldingCase( + Header() + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpCompositeInsert %m2x2int %v2int_1_0 %m2x2int_undef 0\n" + + "%3 = OpCompositeInsert %m2x2int %int_4 %2 0 0\n" + + "%4 = OpCompositeInsert %m2x2int %v2int_2_3 %3 1\n" + + "OpReturn\n" + + "OpFunctionEnd", + 4, false), + // Test case 13: Insert into a column of a matrix + InstructionFoldingCase( + Header() + + "; CHECK: [[int:%\\w+]] = OpTypeInt 32 1\n" + + "; CHECK-DAG: [[v2:%\\w+]] = OpTypeVector [[int]] 2\n" + + "; CHECK: [[m2x2:%\\w+]] = OpTypeMatrix [[v2]] 2\n" + + "; CHECK-DAG: [[m2x2_undef:%\\w+]] = OpUndef [[m2x2]]\n" + + "; CHECK-DAG: [[int1:%\\w+]] = OpConstant [[int]] 1\n" + +// We keep this insert in the chain. DeadInsertElimPass should remove it. + "; CHECK: [[insert:%\\w+]] = OpCompositeInsert [[m2x2]] %100 [[m2x2_undef]] 0 0\n" + + "; CHECK: [[construct:%\\w+]] = OpCompositeConstruct [[v2]] %100 [[int1]]\n" + + "; CHECK: %3 = OpCompositeInsert [[m2x2]] [[construct]] [[insert]] 0\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpCompositeInsert %m2x2int %100 %m2x2int_undef 0 0\n" + + "%3 = OpCompositeInsert %m2x2int %int_1 %2 0 1\n" + + "OpReturn\n" + + "OpFunctionEnd", + 3, true), + // Test case 14: Insert all elements of the matrix. + InstructionFoldingCase( + Header() + + "; CHECK: [[int:%\\w+]] = OpTypeInt 32 1\n" + + "; CHECK-DAG: [[v2:%\\w+]] = OpTypeVector [[int]] 2\n" + + "; CHECK: [[m2x2:%\\w+]] = OpTypeMatrix [[v2]] 2\n" + + "; CHECK-DAG: [[m2x2_undef:%\\w+]] = OpUndef [[m2x2]]\n" + + "; CHECK-DAG: [[int1:%\\w+]] = OpConstant [[int]] 1\n" + + "; CHECK-DAG: [[int2:%\\w+]] = OpConstant [[int]] 2\n" + + "; CHECK-DAG: [[int3:%\\w+]] = OpConstant [[int]] 3\n" + + "; CHECK: [[c0:%\\w+]] = OpCompositeConstruct [[v2]] %100 [[int1]]\n" + + "; CHECK: [[c1:%\\w+]] = OpCompositeConstruct [[v2]] [[int2]] [[int3]]\n" + + "; CHECK: [[matrix:%\\w+]] = OpCompositeConstruct [[m2x2]] [[c0]] [[c1]]\n" + + "; CHECK: %5 = OpCopyObject [[m2x2]] [[matrix]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpCompositeConstruct %v2int %100 %int_1\n" + + "%3 = OpCompositeInsert %m2x2int %2 %m2x2int_undef 0\n" + + "%4 = OpCompositeInsert %m2x2int %int_2 %3 1 0\n" + + "%5 = OpCompositeInsert %m2x2int %int_3 %4 1 1\n" + + "OpReturn\n" + + "OpFunctionEnd", + 5, true), + // Test case 15: Replace construct with extract when reconstructing a member + // of another object. + InstructionFoldingCase( + Header() + + "; CHECK: [[int:%\\w+]] = OpTypeInt 32 1\n" + + "; CHECK: [[v2:%\\w+]] = OpTypeVector [[int]] 2\n" + + "; CHECK: [[m2x2:%\\w+]] = OpTypeMatrix [[v2]] 2\n" + + "; CHECK: [[m2x2_undef:%\\w+]] = OpUndef [[m2x2]]\n" + + "; CHECK: %5 = OpCompositeExtract [[v2]] [[m2x2_undef]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%3 = OpCompositeExtract %int %m2x2int_undef 1 0\n" + + "%4 = OpCompositeExtract %int %m2x2int_undef 1 1\n" + + "%5 = OpCompositeConstruct %v2int %3 %4\n" + + "OpReturn\n" + + "OpFunctionEnd", + 5, true) )); INSTANTIATE_TEST_SUITE_P(DotProductMatchingTest, MatchingInstructionFoldingTest, @@ -7017,12 +7228,241 @@ INSTANTIATE_TEST_SUITE_P(DotProductMatchingTest, MatchingInstructionFoldingTest, 3, true) )); +INSTANTIATE_TEST_SUITE_P(VectorShuffleMatchingTest, MatchingInstructionFoldingTest, +::testing::Values( + // Test case 0: Using OpDot to extract last element. + InstructionFoldingCase( + Header() + + "; CHECK: [[int:%\\w+]] = OpTypeInt 32 1\n" + + "; CHECK: [[v2int:%\\w+]] = OpTypeVector [[int]] 2{{[[:space:]]}}\n" + + "; CHECK: [[null:%\\w+]] = OpConstantNull [[v2int]]\n" + + "; CHECK: OpVectorShuffle\n" + + "; CHECK: %3 = OpVectorShuffle [[v2int]] [[null]] {{%\\w+}} 4294967295 2\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpVectorShuffle %v2int %v2int_null %v2int_2_3 3 0xFFFFFFFF \n" + + "%3 = OpVectorShuffle %v2int %2 %v2int_2_3 1 2 \n" + + "OpReturn\n" + + "OpFunctionEnd", + 3, true) + )); + +INSTANTIATE_TEST_SUITE_P(FmaGenerationMatchingTest, MatchingInstructionFoldingTest, +::testing::Values( + // Test case 0: (x * y) + a = Fma(x, y, a) + InstructionFoldingCase( + Header() + + "; CHECK: [[ext:%\\w+]] = OpExtInstImport \"GLSL.std.450\"\n" + + "; CHECK: OpFunction\n" + + "; CHECK: [[x:%\\w+]] = OpVariable {{%\\w+}} Function\n" + + "; CHECK: [[y:%\\w+]] = OpVariable {{%\\w+}} Function\n" + + "; CHECK: [[a:%\\w+]] = OpVariable {{%\\w+}} Function\n" + + "; CHECK: [[lx:%\\w+]] = OpLoad {{%\\w+}} [[x]]\n" + + "; CHECK: [[ly:%\\w+]] = OpLoad {{%\\w+}} [[y]]\n" + + "; CHECK: [[la:%\\w+]] = OpLoad {{%\\w+}} [[a]]\n" + + "; CHECK: [[fma:%\\w+]] = OpExtInst {{%\\w+}} [[ext]] Fma [[lx]] [[ly]] [[la]]\n" + + "; CHECK: OpStore {{%\\w+}} [[fma]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%x = OpVariable %_ptr_float Function\n" + + "%y = OpVariable %_ptr_float Function\n" + + "%a = OpVariable %_ptr_float Function\n" + + "%lx = OpLoad %float %x\n" + + "%ly = OpLoad %float %y\n" + + "%mul = OpFMul %float %lx %ly\n" + + "%la = OpLoad %float %a\n" + + "%3 = OpFAdd %float %mul %la\n" + + "OpStore %a %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 3, true), + // Test case 1: a + (x * y) = Fma(x, y, a) + InstructionFoldingCase( + Header() + + "; CHECK: [[ext:%\\w+]] = OpExtInstImport \"GLSL.std.450\"\n" + + "; CHECK: OpFunction\n" + + "; CHECK: [[x:%\\w+]] = OpVariable {{%\\w+}} Function\n" + + "; CHECK: [[y:%\\w+]] = OpVariable {{%\\w+}} Function\n" + + "; CHECK: [[a:%\\w+]] = OpVariable {{%\\w+}} Function\n" + + "; CHECK: [[lx:%\\w+]] = OpLoad {{%\\w+}} [[x]]\n" + + "; CHECK: [[ly:%\\w+]] = OpLoad {{%\\w+}} [[y]]\n" + + "; CHECK: [[la:%\\w+]] = OpLoad {{%\\w+}} [[a]]\n" + + "; CHECK: [[fma:%\\w+]] = OpExtInst {{%\\w+}} [[ext]] Fma [[lx]] [[ly]] [[la]]\n" + + "; CHECK: OpStore {{%\\w+}} [[fma]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%x = OpVariable %_ptr_float Function\n" + + "%y = OpVariable %_ptr_float Function\n" + + "%a = OpVariable %_ptr_float Function\n" + + "%lx = OpLoad %float %x\n" + + "%ly = OpLoad %float %y\n" + + "%mul = OpFMul %float %lx %ly\n" + + "%la = OpLoad %float %a\n" + + "%3 = OpFAdd %float %la %mul\n" + + "OpStore %a %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 3, true), + // Test case 2: (x * y) + a = Fma(x, y, a) with vectors + InstructionFoldingCase( + Header() + + "; CHECK: [[ext:%\\w+]] = OpExtInstImport \"GLSL.std.450\"\n" + + "; CHECK: OpFunction\n" + + "; CHECK: [[x:%\\w+]] = OpVariable {{%\\w+}} Function\n" + + "; CHECK: [[y:%\\w+]] = OpVariable {{%\\w+}} Function\n" + + "; CHECK: [[a:%\\w+]] = OpVariable {{%\\w+}} Function\n" + + "; CHECK: [[lx:%\\w+]] = OpLoad {{%\\w+}} [[x]]\n" + + "; CHECK: [[ly:%\\w+]] = OpLoad {{%\\w+}} [[y]]\n" + + "; CHECK: [[la:%\\w+]] = OpLoad {{%\\w+}} [[a]]\n" + + "; CHECK: [[fma:%\\w+]] = OpExtInst {{%\\w+}} [[ext]] Fma [[lx]] [[ly]] [[la]]\n" + + "; CHECK: OpStore {{%\\w+}} [[fma]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%x = OpVariable %_ptr_v4float Function\n" + + "%y = OpVariable %_ptr_v4float Function\n" + + "%a = OpVariable %_ptr_v4float Function\n" + + "%lx = OpLoad %v4float %x\n" + + "%ly = OpLoad %v4float %y\n" + + "%mul = OpFMul %v4float %lx %ly\n" + + "%la = OpLoad %v4float %a\n" + + "%3 = OpFAdd %v4float %mul %la\n" + + "OpStore %a %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 3, true), + // Test case 3: a + (x * y) = Fma(x, y, a) with vectors + InstructionFoldingCase( + Header() + + "; CHECK: [[ext:%\\w+]] = OpExtInstImport \"GLSL.std.450\"\n" + + "; CHECK: OpFunction\n" + + "; CHECK: [[x:%\\w+]] = OpVariable {{%\\w+}} Function\n" + + "; CHECK: [[y:%\\w+]] = OpVariable {{%\\w+}} Function\n" + + "; CHECK: [[a:%\\w+]] = OpVariable {{%\\w+}} Function\n" + + "; CHECK: [[lx:%\\w+]] = OpLoad {{%\\w+}} [[x]]\n" + + "; CHECK: [[ly:%\\w+]] = OpLoad {{%\\w+}} [[y]]\n" + + "; CHECK: [[la:%\\w+]] = OpLoad {{%\\w+}} [[a]]\n" + + "; CHECK: [[fma:%\\w+]] = OpExtInst {{%\\w+}} [[ext]] Fma [[lx]] [[ly]] [[la]]\n" + + "; CHECK: OpStore {{%\\w+}} [[fma]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%x = OpVariable %_ptr_float Function\n" + + "%y = OpVariable %_ptr_float Function\n" + + "%a = OpVariable %_ptr_float Function\n" + + "%lx = OpLoad %float %x\n" + + "%ly = OpLoad %float %y\n" + + "%mul = OpFMul %float %lx %ly\n" + + "%la = OpLoad %float %a\n" + + "%3 = OpFAdd %float %la %mul\n" + + "OpStore %a %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 3, true), + // Test 5: that the OpExtInstImport instruction is generated if it is missing. + InstructionFoldingCase( + std::string() + + "; CHECK: [[ext:%\\w+]] = OpExtInstImport \"GLSL.std.450\"\n" + + "; CHECK: OpFunction\n" + + "; CHECK: [[x:%\\w+]] = OpVariable {{%\\w+}} Function\n" + + "; CHECK: [[y:%\\w+]] = OpVariable {{%\\w+}} Function\n" + + "; CHECK: [[a:%\\w+]] = OpVariable {{%\\w+}} Function\n" + + "; CHECK: [[lx:%\\w+]] = OpLoad {{%\\w+}} [[x]]\n" + + "; CHECK: [[ly:%\\w+]] = OpLoad {{%\\w+}} [[y]]\n" + + "; CHECK: [[la:%\\w+]] = OpLoad {{%\\w+}} [[a]]\n" + + "; CHECK: [[fma:%\\w+]] = OpExtInst {{%\\w+}} [[ext]] Fma [[lx]] [[ly]] [[la]]\n" + + "; CHECK: OpStore {{%\\w+}} [[fma]]\n" + + "OpCapability Shader\n" + + "OpMemoryModel Logical GLSL450\n" + + "OpEntryPoint Fragment %main \"main\"\n" + + "OpExecutionMode %main OriginUpperLeft\n" + + "OpSource GLSL 140\n" + + "OpName %main \"main\"\n" + + "%void = OpTypeVoid\n" + + "%void_func = OpTypeFunction %void\n" + + "%bool = OpTypeBool\n" + + "%float = OpTypeFloat 32\n" + + "%_ptr_float = OpTypePointer Function %float\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%x = OpVariable %_ptr_float Function\n" + + "%y = OpVariable %_ptr_float Function\n" + + "%a = OpVariable %_ptr_float Function\n" + + "%lx = OpLoad %float %x\n" + + "%ly = OpLoad %float %y\n" + + "%mul = OpFMul %float %lx %ly\n" + + "%la = OpLoad %float %a\n" + + "%3 = OpFAdd %float %mul %la\n" + + "OpStore %a %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 3, true), + // Test 5: Don't fold if the multiple is marked no contract. + InstructionFoldingCase( + std::string() + + "OpCapability Shader\n" + + "OpMemoryModel Logical GLSL450\n" + + "OpEntryPoint Fragment %main \"main\"\n" + + "OpExecutionMode %main OriginUpperLeft\n" + + "OpSource GLSL 140\n" + + "OpName %main \"main\"\n" + + "OpDecorate %mul NoContraction\n" + + "%void = OpTypeVoid\n" + + "%void_func = OpTypeFunction %void\n" + + "%bool = OpTypeBool\n" + + "%float = OpTypeFloat 32\n" + + "%_ptr_float = OpTypePointer Function %float\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%x = OpVariable %_ptr_float Function\n" + + "%y = OpVariable %_ptr_float Function\n" + + "%a = OpVariable %_ptr_float Function\n" + + "%lx = OpLoad %float %x\n" + + "%ly = OpLoad %float %y\n" + + "%mul = OpFMul %float %lx %ly\n" + + "%la = OpLoad %float %a\n" + + "%3 = OpFAdd %float %mul %la\n" + + "OpStore %a %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 3, false), + // Test 6: Don't fold if the add is marked no contract. + InstructionFoldingCase( + std::string() + + "OpCapability Shader\n" + + "OpMemoryModel Logical GLSL450\n" + + "OpEntryPoint Fragment %main \"main\"\n" + + "OpExecutionMode %main OriginUpperLeft\n" + + "OpSource GLSL 140\n" + + "OpName %main \"main\"\n" + + "OpDecorate %3 NoContraction\n" + + "%void = OpTypeVoid\n" + + "%void_func = OpTypeFunction %void\n" + + "%bool = OpTypeBool\n" + + "%float = OpTypeFloat 32\n" + + "%_ptr_float = OpTypePointer Function %float\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%x = OpVariable %_ptr_float Function\n" + + "%y = OpVariable %_ptr_float Function\n" + + "%a = OpVariable %_ptr_float Function\n" + + "%lx = OpLoad %float %x\n" + + "%ly = OpLoad %float %y\n" + + "%mul = OpFMul %float %lx %ly\n" + + "%la = OpLoad %float %a\n" + + "%3 = OpFAdd %float %mul %la\n" + + "OpStore %a %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 3, false) +)); + using MatchingInstructionWithNoResultFoldingTest = ::testing::TestWithParam>; // Test folding instructions that do not have a result. The instruction // that will be folded is the last instruction before the return. If there -// are multiple returns, there is not guarentee which one is used. +// are multiple returns, there is not guarantee which one is used. TEST_P(MatchingInstructionWithNoResultFoldingTest, Case) { const auto& tc = GetParam(); diff --git a/third_party/spirv-tools/test/opt/freeze_spec_const_test.cpp b/third_party/spirv-tools/test/opt/freeze_spec_const_test.cpp index e5999cec63..ad0fc32ea0 100644 --- a/third_party/spirv-tools/test/opt/freeze_spec_const_test.cpp +++ b/third_party/spirv-tools/test/opt/freeze_spec_const_test.cpp @@ -128,6 +128,51 @@ TEST_F(FreezeSpecConstantValueRemoveDecorationTest, /* skip_nop = */ true); } +TEST_F(FreezeSpecConstantValueRemoveDecorationTest, + RemoveDecorationForLocalSizeIdWithSpecId) { + std::vector text = { + // clang-format off + "OpCapability Shader", + "%1 = OpExtInstImport \"GLSL.std.450\"", + "OpMemoryModel Logical GLSL450", + "OpEntryPoint GLCompute %2 \"main\"", + "OpExecutionModeId %2 LocalSizeId %uint_32 %uint_1 %uint_1_0", + "OpSource GLSL 450", + "OpDecorate %3 SpecId 18", + "OpDecorate %5 SpecId 19", + "%void = OpTypeVoid", + "%9 = OpTypeFunction %void", + "%uint = OpTypeInt 32 0", + "%uint_32 = OpSpecConstant %uint 32", + "%uint_1 = OpConstant %uint 1", + "%uint_1_0 = OpSpecConstant %uint 1", + "%2 = OpFunction %void None %9", + "%11 = OpLabel", + "OpReturn", + "OpFunctionEnd", + // clang-format on + }; + std::string expected_disassembly = SelectiveJoin(text, [](const char* line) { + return std::string(line).find("SpecId") != std::string::npos; + }); + std::vector> replacement_pairs = { + {"%uint_32 = OpSpecConstant %uint 32", "%uint_32 = OpConstant %uint 32"}, + {"%uint_1_0 = OpSpecConstant %uint 1", "%uint_1_0 = OpConstant %uint 1"}, + }; + for (auto& p : replacement_pairs) { + EXPECT_TRUE(FindAndReplace(&expected_disassembly, p.first, p.second)) + << "text:\n" + << expected_disassembly << "\n" + << "find_str:\n" + << p.first << "\n" + << "replace_str:\n" + << p.second << "\n"; + } + SinglePassRunAndCheck(JoinAllInsts(text), + expected_disassembly, + /* skip_nop = */ true); +} + } // namespace } // namespace opt } // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/graphics_robust_access_test.cpp b/third_party/spirv-tools/test/opt/graphics_robust_access_test.cpp index 3c23347d02..057b909def 100644 --- a/third_party/spirv-tools/test/opt/graphics_robust_access_test.cpp +++ b/third_party/spirv-tools/test/opt/graphics_robust_access_test.cpp @@ -1242,7 +1242,7 @@ TEST_F(GraphicsRobustAccessTest, ACArrayRTArrayStructVectorElem) { ; CHECK-DAG: %int_9 = OpConstant %int 9 ; CHECK-DAG: %[[intmax:\w+]] = OpConstant %int 2147483647 ; CHECK: OpLabel - ; This access chain is manufatured only so we can compute the array length. + ; This access chain is manufactured only so we can compute the array length. ; Note that the %int_9 is already clamped ; CHECK: %[[ssbo_base:\w+]] = )" << ac << R"( %[[ssbo_p]] %var %int_9 diff --git a/third_party/spirv-tools/test/opt/if_conversion_test.cpp b/third_party/spirv-tools/test/opt/if_conversion_test.cpp index dee15c3148..81e9bb2ef6 100644 --- a/third_party/spirv-tools/test/opt/if_conversion_test.cpp +++ b/third_party/spirv-tools/test/opt/if_conversion_test.cpp @@ -328,6 +328,40 @@ OpFunctionEnd SinglePassRunAndCheck(text, text, true, true); } +TEST_F(IfConversionTest, DontFlatten) { + const std::string text = R"(OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %1 "func" %2 +%void = OpTypeVoid +%bool = OpTypeBool +%true = OpConstantTrue %bool +%uint = OpTypeInt 32 0 +%uint_0 = OpConstant %uint 0 +%uint_1 = OpConstant %uint 1 +%v2uint = OpTypeVector %uint 2 +%10 = OpConstantComposite %v2uint %uint_0 %uint_1 +%11 = OpConstantComposite %v2uint %uint_1 %uint_0 +%_ptr_Output_v2uint = OpTypePointer Output %v2uint +%2 = OpVariable %_ptr_Output_v2uint Output +%13 = OpTypeFunction %void +%1 = OpFunction %void None %13 +%14 = OpLabel +OpSelectionMerge %15 DontFlatten +OpBranchConditional %true %16 %17 +%16 = OpLabel +OpBranch %15 +%17 = OpLabel +OpBranch %15 +%15 = OpLabel +%18 = OpPhi %v2uint %10 %16 %11 %17 +OpStore %2 %18 +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndCheck(text, text, true, true); +} + TEST_F(IfConversionTest, LoopUntouched) { const std::string text = R"(OpCapability Shader OpMemoryModel Logical GLSL450 diff --git a/third_party/spirv-tools/test/opt/inline_test.cpp b/third_party/spirv-tools/test/opt/inline_test.cpp index d22f027c56..cefd8e54ab 100644 --- a/third_party/spirv-tools/test/opt/inline_test.cpp +++ b/third_party/spirv-tools/test/opt/inline_test.cpp @@ -4238,7 +4238,7 @@ TEST_F(InlineTest, CreateConstantForInlinedAt) { // This shader causes CreateDebugInlinedAt to generate a constant. // Using the Constant manager would attempt to build the invalidated // DefUse manager during inlining which could cause an assert because - // the function is in an inconsistant state. This test verifies that + // the function is in an inconsistent state. This test verifies that // CreateDebugInlinedAt detects that the DefUse manager is disabled // and creates a duplicate constant safely without the Constant manager. // diff --git a/third_party/spirv-tools/test/opt/inst_bindless_check_test.cpp b/third_party/spirv-tools/test/opt/inst_bindless_check_test.cpp index 1a42329b04..4c271dee88 100644 --- a/third_party/spirv-tools/test/opt/inst_bindless_check_test.cpp +++ b/third_party/spirv-tools/test/opt/inst_bindless_check_test.cpp @@ -9984,8 +9984,8 @@ TEST_F(InstBindlessTest, SamplerBufferConstructorOOBFetch) { // // Compute shader // Geometry shader -// Tesselation control shader -// Tesselation eval shader +// Tessellation control shader +// Tessellation eval shader // OpImage // SampledImage variable diff --git a/third_party/spirv-tools/test/opt/inst_debug_printf_test.cpp b/third_party/spirv-tools/test/opt/inst_debug_printf_test.cpp index 8123ffbbec..c5fd6799af 100644 --- a/third_party/spirv-tools/test/opt/inst_debug_printf_test.cpp +++ b/third_party/spirv-tools/test/opt/inst_debug_printf_test.cpp @@ -206,8 +206,8 @@ OpFunctionEnd // // Compute shader // Geometry shader -// Tesselation control shader -// Tesselation eval shader +// Tessellation control shader +// Tessellation eval shader // Vertex shader } // namespace diff --git a/third_party/spirv-tools/test/opt/instruction_test.cpp b/third_party/spirv-tools/test/opt/instruction_test.cpp index c5b92efb2e..2a48134d90 100644 --- a/third_party/spirv-tools/test/opt/instruction_test.cpp +++ b/third_party/spirv-tools/test/opt/instruction_test.cpp @@ -62,12 +62,6 @@ TEST(InstructionTest, CreateWithOpcodeAndNoOperands) { EXPECT_EQ(inst.end(), inst.begin()); } -TEST(InstructionTest, OperandAsCString) { - Operand::OperandData abcde{0x64636261, 0x65}; - Operand operand(SPV_OPERAND_TYPE_LITERAL_STRING, std::move(abcde)); - EXPECT_STREQ("abcde", operand.AsCString()); -} - TEST(InstructionTest, OperandAsString) { Operand::OperandData abcde{0x64636261, 0x65}; Operand operand(SPV_OPERAND_TYPE_LITERAL_STRING, std::move(abcde)); diff --git a/third_party/spirv-tools/test/opt/interface_var_sroa_test.cpp b/third_party/spirv-tools/test/opt/interface_var_sroa_test.cpp new file mode 100644 index 0000000000..77624587bf --- /dev/null +++ b/third_party/spirv-tools/test/opt/interface_var_sroa_test.cpp @@ -0,0 +1,410 @@ +// Copyright (c) 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "gmock/gmock.h" +#include "test/opt/assembly_builder.h" +#include "test/opt/pass_fixture.h" +#include "test/opt/pass_utils.h" + +namespace spvtools { +namespace opt { +namespace { + +using InterfaceVariableScalarReplacementTest = PassTest<::testing::Test>; + +TEST_F(InterfaceVariableScalarReplacementTest, + ReplaceInterfaceVarsWithScalars) { + const std::string spirv = R"( + OpCapability Shader + OpCapability Tessellation + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %func "shader" %x %y %z %w %u %v + +; CHECK: OpName [[x:%\w+]] "x" +; CHECK-NOT: OpName {{%\w+}} "x" +; CHECK: OpName [[y:%\w+]] "y" +; CHECK-NOT: OpName {{%\w+}} "y" +; CHECK: OpName [[z0:%\w+]] "z" +; CHECK: OpName [[z1:%\w+]] "z" +; CHECK: OpName [[w0:%\w+]] "w" +; CHECK: OpName [[w1:%\w+]] "w" +; CHECK: OpName [[u0:%\w+]] "u" +; CHECK: OpName [[u1:%\w+]] "u" +; CHECK: OpName [[v0:%\w+]] "v" +; CHECK: OpName [[v1:%\w+]] "v" +; CHECK: OpName [[v2:%\w+]] "v" +; CHECK: OpName [[v3:%\w+]] "v" +; CHECK: OpName [[v4:%\w+]] "v" +; CHECK: OpName [[v5:%\w+]] "v" + OpName %x "x" + OpName %y "y" + OpName %z "z" + OpName %w "w" + OpName %u "u" + OpName %v "v" + +; CHECK-DAG: OpDecorate [[x]] Location 2 +; CHECK-DAG: OpDecorate [[y]] Location 0 +; CHECK-DAG: OpDecorate [[z0]] Location 0 +; CHECK-DAG: OpDecorate [[z0]] Component 0 +; CHECK-DAG: OpDecorate [[z1]] Location 1 +; CHECK-DAG: OpDecorate [[z1]] Component 0 +; CHECK-DAG: OpDecorate [[z0]] Patch +; CHECK-DAG: OpDecorate [[z1]] Patch +; CHECK-DAG: OpDecorate [[w0]] Location 2 +; CHECK-DAG: OpDecorate [[w0]] Component 0 +; CHECK-DAG: OpDecorate [[w1]] Location 3 +; CHECK-DAG: OpDecorate [[w1]] Component 0 +; CHECK-DAG: OpDecorate [[w0]] Patch +; CHECK-DAG: OpDecorate [[w1]] Patch +; CHECK-DAG: OpDecorate [[u0]] Location 3 +; CHECK-DAG: OpDecorate [[u0]] Component 2 +; CHECK-DAG: OpDecorate [[u1]] Location 4 +; CHECK-DAG: OpDecorate [[u1]] Component 2 +; CHECK-DAG: OpDecorate [[v0]] Location 3 +; CHECK-DAG: OpDecorate [[v0]] Component 3 +; CHECK-DAG: OpDecorate [[v1]] Location 4 +; CHECK-DAG: OpDecorate [[v1]] Component 3 +; CHECK-DAG: OpDecorate [[v2]] Location 5 +; CHECK-DAG: OpDecorate [[v2]] Component 3 +; CHECK-DAG: OpDecorate [[v3]] Location 6 +; CHECK-DAG: OpDecorate [[v3]] Component 3 +; CHECK-DAG: OpDecorate [[v4]] Location 7 +; CHECK-DAG: OpDecorate [[v4]] Component 3 +; CHECK-DAG: OpDecorate [[v5]] Location 8 +; CHECK-DAG: OpDecorate [[v5]] Component 3 + OpDecorate %z Patch + OpDecorate %w Patch + OpDecorate %z Location 0 + OpDecorate %x Location 2 + OpDecorate %v Location 3 + OpDecorate %v Component 3 + OpDecorate %y Location 0 + OpDecorate %w Location 2 + OpDecorate %u Location 3 + OpDecorate %u Component 2 + + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 +%_arr_uint_uint_2 = OpTypeArray %uint %uint_2 +%_ptr_Output__arr_uint_uint_2 = OpTypePointer Output %_arr_uint_uint_2 +%_ptr_Input__arr_uint_uint_2 = OpTypePointer Input %_arr_uint_uint_2 +%_ptr_Input_uint = OpTypePointer Input %uint +%_ptr_Output_uint = OpTypePointer Output %uint +%_arr_arr_uint_uint_2_3 = OpTypeArray %_arr_uint_uint_2 %uint_3 +%_ptr_Input__arr_arr_uint_uint_2_3 = OpTypePointer Input %_arr_arr_uint_uint_2_3 +%_arr_arr_arr_uint_uint_2_3_4 = OpTypeArray %_arr_arr_uint_uint_2_3 %uint_4 +%_ptr_Output__arr_arr_arr_uint_uint_2_3_4 = OpTypePointer Output %_arr_arr_arr_uint_uint_2_3_4 +%_ptr_Output__arr_arr_uint_uint_2_3 = OpTypePointer Output %_arr_arr_uint_uint_2_3 + %z = OpVariable %_ptr_Output__arr_uint_uint_2 Output + %x = OpVariable %_ptr_Output__arr_uint_uint_2 Output + %y = OpVariable %_ptr_Input__arr_uint_uint_2 Input + %w = OpVariable %_ptr_Input__arr_uint_uint_2 Input + %u = OpVariable %_ptr_Input__arr_arr_uint_uint_2_3 Input + %v = OpVariable %_ptr_Output__arr_arr_arr_uint_uint_2_3_4 Output + +; CHECK-DAG: [[x]] = OpVariable %_ptr_Output__arr_uint_uint_2 Output +; CHECK-DAG: [[y]] = OpVariable %_ptr_Input__arr_uint_uint_2 Input +; CHECK-DAG: [[z0]] = OpVariable %_ptr_Output_uint Output +; CHECK-DAG: [[z1]] = OpVariable %_ptr_Output_uint Output +; CHECK-DAG: [[w0]] = OpVariable %_ptr_Input_uint Input +; CHECK-DAG: [[w1]] = OpVariable %_ptr_Input_uint Input +; CHECK-DAG: [[u0]] = OpVariable %_ptr_Input__arr_uint_uint_3 Input +; CHECK-DAG: [[u1]] = OpVariable %_ptr_Input__arr_uint_uint_3 Input +; CHECK-DAG: [[v0]] = OpVariable %_ptr_Output__arr_uint_uint_4 Output +; CHECK-DAG: [[v1]] = OpVariable %_ptr_Output__arr_uint_uint_4 Output +; CHECK-DAG: [[v2]] = OpVariable %_ptr_Output__arr_uint_uint_4 Output +; CHECK-DAG: [[v3]] = OpVariable %_ptr_Output__arr_uint_uint_4 Output +; CHECK-DAG: [[v4]] = OpVariable %_ptr_Output__arr_uint_uint_4 Output +; CHECK-DAG: [[v5]] = OpVariable %_ptr_Output__arr_uint_uint_4 Output + + %void = OpTypeVoid + %void_f = OpTypeFunction %void + %func = OpFunction %void None %void_f + %label = OpLabel + +; CHECK: [[w0_value:%\w+]] = OpLoad %uint [[w0]] +; CHECK: [[w1_value:%\w+]] = OpLoad %uint [[w1]] +; CHECK: [[w_value:%\w+]] = OpCompositeConstruct %_arr_uint_uint_2 [[w0_value]] [[w1_value]] +; CHECK: [[w0:%\w+]] = OpCompositeExtract %uint [[w_value]] 0 +; CHECK: OpStore [[z0]] [[w0]] +; CHECK: [[w1:%\w+]] = OpCompositeExtract %uint [[w_value]] 1 +; CHECK: OpStore [[z1]] [[w1]] + %w_value = OpLoad %_arr_uint_uint_2 %w + OpStore %z %w_value + +; CHECK: [[u00_ptr:%\w+]] = OpAccessChain %_ptr_Input_uint [[u0]] %uint_0 +; CHECK: [[u00:%\w+]] = OpLoad %uint [[u00_ptr]] +; CHECK: [[u10_ptr:%\w+]] = OpAccessChain %_ptr_Input_uint [[u1]] %uint_0 +; CHECK: [[u10:%\w+]] = OpLoad %uint [[u10_ptr]] +; CHECK: [[u01_ptr:%\w+]] = OpAccessChain %_ptr_Input_uint [[u0]] %uint_1 +; CHECK: [[u01:%\w+]] = OpLoad %uint [[u01_ptr]] +; CHECK: [[u11_ptr:%\w+]] = OpAccessChain %_ptr_Input_uint [[u1]] %uint_1 +; CHECK: [[u11:%\w+]] = OpLoad %uint [[u11_ptr]] +; CHECK: [[u02_ptr:%\w+]] = OpAccessChain %_ptr_Input_uint [[u0]] %uint_2 +; CHECK: [[u02:%\w+]] = OpLoad %uint [[u02_ptr]] +; CHECK: [[u12_ptr:%\w+]] = OpAccessChain %_ptr_Input_uint [[u1]] %uint_2 +; CHECK: [[u12:%\w+]] = OpLoad %uint [[u12_ptr]] + +; CHECK-DAG: [[u0_val:%\w+]] = OpCompositeConstruct %_arr_uint_uint_2 [[u00]] [[u10]] +; CHECK-DAG: [[u1_val:%\w+]] = OpCompositeConstruct %_arr_uint_uint_2 [[u01]] [[u11]] +; CHECK-DAG: [[u2_val:%\w+]] = OpCompositeConstruct %_arr_uint_uint_2 [[u02]] [[u12]] + +; CHECK: [[u_val:%\w+]] = OpCompositeConstruct %_arr__arr_uint_uint_2_uint_3 [[u0_val]] [[u1_val]] [[u2_val]] + +; CHECK: [[ptr:%\w+]] = OpAccessChain %_ptr_Output_uint [[v0]] %uint_1 +; CHECK: [[val:%\w+]] = OpCompositeExtract %uint [[u_val]] 0 0 +; CHECK: OpStore [[ptr]] [[val]] +; CHECK: [[ptr:%\w+]] = OpAccessChain %_ptr_Output_uint [[v1]] %uint_1 +; CHECK: [[val:%\w+]] = OpCompositeExtract %uint [[u_val]] 0 1 +; CHECK: OpStore [[ptr]] [[val]] +; CHECK: [[ptr:%\w+]] = OpAccessChain %_ptr_Output_uint [[v2]] %uint_1 +; CHECK: [[val:%\w+]] = OpCompositeExtract %uint [[u_val]] 1 0 +; CHECK: OpStore [[ptr]] [[val]] +; CHECK: [[ptr:%\w+]] = OpAccessChain %_ptr_Output_uint [[v3]] %uint_1 +; CHECK: [[val:%\w+]] = OpCompositeExtract %uint [[u_val]] 1 1 +; CHECK: OpStore [[ptr]] [[val]] +; CHECK: [[ptr:%\w+]] = OpAccessChain %_ptr_Output_uint [[v4]] %uint_1 +; CHECK: [[val:%\w+]] = OpCompositeExtract %uint [[u_val]] 2 0 +; CHECK: OpStore [[ptr]] [[val]] +; CHECK: [[ptr:%\w+]] = OpAccessChain %_ptr_Output_uint [[v5]] %uint_1 +; CHECK: [[val:%\w+]] = OpCompositeExtract %uint [[u_val]] 2 1 +; CHECK: OpStore [[ptr]] [[val]] + %v_ptr = OpAccessChain %_ptr_Output__arr_arr_uint_uint_2_3 %v %uint_1 + %u_val = OpLoad %_arr_arr_uint_uint_2_3 %u + OpStore %v_ptr %u_val + + OpReturn + OpFunctionEnd + )"; + + SinglePassRunAndMatch(spirv, true); +} + +TEST_F(InterfaceVariableScalarReplacementTest, + CheckPatchDecorationPreservation) { + // Make sure scalars for the variables with the extra arrayness have the extra + // arrayness after running the pass while others do not have it. + // Only "y" does not have the extra arrayness in the following SPIR-V. + const std::string spirv = R"( + OpCapability Shader + OpCapability Tessellation + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationEvaluation %func "shader" %x %y %z %w + OpDecorate %z Patch + OpDecorate %w Patch + OpDecorate %z Location 0 + OpDecorate %x Location 2 + OpDecorate %y Location 0 + OpDecorate %w Location 1 + OpName %x "x" + OpName %y "y" + OpName %z "z" + OpName %w "w" + + ; CHECK: OpName [[y:%\w+]] "y" + ; CHECK-NOT: OpName {{%\w+}} "y" + ; CHECK-DAG: OpName [[z0:%\w+]] "z" + ; CHECK-DAG: OpName [[z1:%\w+]] "z" + ; CHECK-DAG: OpName [[w0:%\w+]] "w" + ; CHECK-DAG: OpName [[w1:%\w+]] "w" + ; CHECK-DAG: OpName [[x0:%\w+]] "x" + ; CHECK-DAG: OpName [[x1:%\w+]] "x" + + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 +%_arr_uint_uint_2 = OpTypeArray %uint %uint_2 +%_ptr_Output__arr_uint_uint_2 = OpTypePointer Output %_arr_uint_uint_2 +%_ptr_Input__arr_uint_uint_2 = OpTypePointer Input %_arr_uint_uint_2 + %z = OpVariable %_ptr_Output__arr_uint_uint_2 Output + %x = OpVariable %_ptr_Output__arr_uint_uint_2 Output + %y = OpVariable %_ptr_Input__arr_uint_uint_2 Input + %w = OpVariable %_ptr_Input__arr_uint_uint_2 Input + + ; CHECK-DAG: [[y]] = OpVariable %_ptr_Input__arr_uint_uint_2 Input + ; CHECK-DAG: [[z0]] = OpVariable %_ptr_Output_uint Output + ; CHECK-DAG: [[z1]] = OpVariable %_ptr_Output_uint Output + ; CHECK-DAG: [[w0]] = OpVariable %_ptr_Input_uint Input + ; CHECK-DAG: [[w1]] = OpVariable %_ptr_Input_uint Input + ; CHECK-DAG: [[x0]] = OpVariable %_ptr_Output_uint Output + ; CHECK-DAG: [[x1]] = OpVariable %_ptr_Output_uint Output + + %void = OpTypeVoid + %void_f = OpTypeFunction %void + %func = OpFunction %void None %void_f + %label = OpLabel + OpReturn + OpFunctionEnd + )"; + + SinglePassRunAndMatch(spirv, true); +} + +TEST_F(InterfaceVariableScalarReplacementTest, + CheckEntryPointInterfaceOperands) { + const std::string spirv = R"( + OpCapability Shader + OpCapability Tessellation + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationEvaluation %tess "tess" %x %y + OpEntryPoint Vertex %vert "vert" %w + OpDecorate %z Location 0 + OpDecorate %x Location 2 + OpDecorate %y Location 0 + OpDecorate %w Location 1 + OpName %x "x" + OpName %y "y" + OpName %z "z" + OpName %w "w" + + ; CHECK: OpName [[y:%\w+]] "y" + ; CHECK-NOT: OpName {{%\w+}} "y" + ; CHECK-DAG: OpName [[x0:%\w+]] "x" + ; CHECK-DAG: OpName [[x1:%\w+]] "x" + ; CHECK-DAG: OpName [[w0:%\w+]] "w" + ; CHECK-DAG: OpName [[w1:%\w+]] "w" + ; CHECK-DAG: OpName [[z:%\w+]] "z" + ; CHECK-NOT: OpName {{%\w+}} "z" + + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 +%_arr_uint_uint_2 = OpTypeArray %uint %uint_2 +%_ptr_Output__arr_uint_uint_2 = OpTypePointer Output %_arr_uint_uint_2 +%_ptr_Input__arr_uint_uint_2 = OpTypePointer Input %_arr_uint_uint_2 + %z = OpVariable %_ptr_Output__arr_uint_uint_2 Output + %x = OpVariable %_ptr_Output__arr_uint_uint_2 Output + %y = OpVariable %_ptr_Input__arr_uint_uint_2 Input + %w = OpVariable %_ptr_Input__arr_uint_uint_2 Input + + ; CHECK-DAG: [[y]] = OpVariable %_ptr_Input__arr_uint_uint_2 Input + ; CHECK-DAG: [[z]] = OpVariable %_ptr_Output__arr_uint_uint_2 Output + ; CHECK-DAG: [[w0]] = OpVariable %_ptr_Input_uint Input + ; CHECK-DAG: [[w1]] = OpVariable %_ptr_Input_uint Input + ; CHECK-DAG: [[x0]] = OpVariable %_ptr_Output_uint Output + ; CHECK-DAG: [[x1]] = OpVariable %_ptr_Output_uint Output + + %void = OpTypeVoid + %void_f = OpTypeFunction %void + %tess = OpFunction %void None %void_f + %bb0 = OpLabel + OpReturn + OpFunctionEnd + %vert = OpFunction %void None %void_f + %bb1 = OpLabel + OpReturn + OpFunctionEnd + )"; + + SinglePassRunAndMatch(spirv, true); +} + +class InterfaceVarSROAErrorTest : public PassTest<::testing::Test> { + public: + InterfaceVarSROAErrorTest() + : consumer_([this](spv_message_level_t level, const char*, + const spv_position_t& position, const char* message) { + if (!error_message_.empty()) error_message_ += "\n"; + switch (level) { + case SPV_MSG_FATAL: + case SPV_MSG_INTERNAL_ERROR: + case SPV_MSG_ERROR: + error_message_ += "ERROR"; + break; + case SPV_MSG_WARNING: + error_message_ += "WARNING"; + break; + case SPV_MSG_INFO: + error_message_ += "INFO"; + break; + case SPV_MSG_DEBUG: + error_message_ += "DEBUG"; + break; + } + error_message_ += + ": " + std::to_string(position.index) + ": " + message; + }) {} + + Pass::Status RunPass(const std::string& text) { + std::unique_ptr context_ = + spvtools::BuildModule(SPV_ENV_UNIVERSAL_1_2, consumer_, text); + if (!context_.get()) return Pass::Status::Failure; + + PassManager manager; + manager.SetMessageConsumer(consumer_); + manager.AddPass(); + + return manager.Run(context_.get()); + } + + std::string GetErrorMessage() const { return error_message_; } + + void TearDown() override { error_message_.clear(); } + + private: + spvtools::MessageConsumer consumer_; + std::string error_message_; +}; + +TEST_F(InterfaceVarSROAErrorTest, CheckConflictOfExtraArraynessBetweenEntries) { + const std::string spirv = R"( + OpCapability Shader + OpCapability Tessellation + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %tess "tess" %x %y %z + OpEntryPoint Vertex %vert "vert" %z %w + OpDecorate %z Location 0 + OpDecorate %x Location 2 + OpDecorate %y Location 0 + OpDecorate %w Location 1 + OpName %x "x" + OpName %y "y" + OpName %z "z" + OpName %w "w" + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 +%_arr_uint_uint_2 = OpTypeArray %uint %uint_2 +%_ptr_Output__arr_uint_uint_2 = OpTypePointer Output %_arr_uint_uint_2 +%_ptr_Input__arr_uint_uint_2 = OpTypePointer Input %_arr_uint_uint_2 + %z = OpVariable %_ptr_Output__arr_uint_uint_2 Output + %x = OpVariable %_ptr_Output__arr_uint_uint_2 Output + %y = OpVariable %_ptr_Input__arr_uint_uint_2 Input + %w = OpVariable %_ptr_Input__arr_uint_uint_2 Input + %void = OpTypeVoid + %void_f = OpTypeFunction %void + %tess = OpFunction %void None %void_f + %bb0 = OpLabel + OpReturn + OpFunctionEnd + %vert = OpFunction %void None %void_f + %bb1 = OpLabel + OpReturn + OpFunctionEnd + )"; + + EXPECT_EQ(RunPass(spirv), Pass::Status::Failure); + const char expected_error[] = + "ERROR: 0: A variable is arrayed for an entry point but it is not " + "arrayed for another entry point\n" + " %z = OpVariable %_ptr_Output__arr_uint_uint_2 Output"; + EXPECT_STREQ(GetErrorMessage().c_str(), expected_error); +} + +} // namespace +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/ir_context_test.cpp b/third_party/spirv-tools/test/opt/ir_context_test.cpp index b6866d019b..ece04796f7 100644 --- a/third_party/spirv-tools/test/opt/ir_context_test.cpp +++ b/third_party/spirv-tools/test/opt/ir_context_test.cpp @@ -90,6 +90,21 @@ TEST_F(IRContextTest, IndividualValidAfterBuild) { } } +TEST_F(IRContextTest, DontRebuildValidAnalysis) { + std::unique_ptr module(new Module()); + IRContext localContext(SPV_ENV_UNIVERSAL_1_2, std::move(module), + spvtools::MessageConsumer()); + + auto* oldCfg = localContext.cfg(); + auto* oldDefUse = localContext.get_def_use_mgr(); + localContext.BuildInvalidAnalyses(IRContext::kAnalysisCFG | + IRContext::kAnalysisDefUse); + auto* newCfg = localContext.cfg(); + auto* newDefUse = localContext.get_def_use_mgr(); + EXPECT_EQ(oldCfg, newCfg); + EXPECT_EQ(oldDefUse, newDefUse); +} + TEST_F(IRContextTest, AllValidAfterBuild) { std::unique_ptr module = MakeUnique(); IRContext localContext(SPV_ENV_UNIVERSAL_1_2, std::move(module), diff --git a/third_party/spirv-tools/test/opt/local_access_chain_convert_test.cpp b/third_party/spirv-tools/test/opt/local_access_chain_convert_test.cpp index 6fcf23fb84..2b3231c61b 100644 --- a/third_party/spirv-tools/test/opt/local_access_chain_convert_test.cpp +++ b/third_party/spirv-tools/test/opt/local_access_chain_convert_test.cpp @@ -1156,6 +1156,101 @@ TEST_F(LocalAccessChainConvertTest, AccessChainWithNoIndex) { SinglePassRunAndMatch(before, true); } +TEST_F(LocalAccessChainConvertTest, AccessChainWithLongIndex) { + // The access chain take a value that is larger than 32-bit. The index cannot + // be encoded in an OpCompositeExtract, so nothing should be done. + const std::string before = + R"(OpCapability Shader +OpCapability Int64 +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %2 "main_0004f4d4_85b2f584" +OpExecutionMode %2 OriginUpperLeft +%ulong = OpTypeInt 64 0 +%ulong_8589934592 = OpConstant %ulong 8589934592 +%ulong_8589934591 = OpConstant %ulong 8589934591 +%_arr_ulong_ulong_8589934592 = OpTypeArray %ulong %ulong_8589934592 +%_ptr_Function__arr_ulong_ulong_8589934592 = OpTypePointer Function %_arr_ulong_ulong_8589934592 +%_ptr_Function_ulong = OpTypePointer Function %ulong +%void = OpTypeVoid +%10 = OpTypeFunction %void +%2 = OpFunction %void None %10 +%11 = OpLabel +%12 = OpVariable %_ptr_Function__arr_ulong_ulong_8589934592 Function +%13 = OpAccessChain %_ptr_Function_ulong %12 %ulong_8589934591 +%14 = OpLoad %ulong %13 +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndCheck(before, before, false, + true); +} + +TEST_F(LocalAccessChainConvertTest, AccessChainWith32BitIndexInLong) { + // The access chain has a value that is 32-bits, but it is stored in a 64-bit + // variable. This access change can be converted to an extract. + const std::string before = + R"( +; CHECK: OpFunction +; CHECK: [[var:%\w+]] = OpVariable +; CHECK: [[ld:%\w+]] = OpLoad {{%\w+}} [[var]] +; CHECK: OpCompositeExtract %ulong [[ld]] 3 + OpCapability Shader + OpCapability Int64 + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main_0004f4d4_85b2f584" + OpExecutionMode %2 OriginUpperLeft + %ulong = OpTypeInt 64 0 +%ulong_8589934592 = OpConstant %ulong 8589934592 +%ulong_3 = OpConstant %ulong 3 +%_arr_ulong_ulong_8589934592 = OpTypeArray %ulong %ulong_8589934592 +%_ptr_Function__arr_ulong_ulong_8589934592 = OpTypePointer Function %_arr_ulong_ulong_8589934592 +%_ptr_Function_ulong = OpTypePointer Function %ulong + %void = OpTypeVoid + %10 = OpTypeFunction %void + %2 = OpFunction %void None %10 + %11 = OpLabel + %12 = OpVariable %_ptr_Function__arr_ulong_ulong_8589934592 Function + %13 = OpAccessChain %_ptr_Function_ulong %12 %ulong_3 + %14 = OpLoad %ulong %13 + OpReturn + OpFunctionEnd +)"; + + SinglePassRunAndMatch(before, true); +} + +TEST_F(LocalAccessChainConvertTest, AccessChainWithVarIndex) { + // The access chain has a value that is not constant, so there should not be + // any changes. + const std::string before = + R"(OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %2 "main_0004f4d4_85b2f584" +OpExecutionMode %2 OriginUpperLeft +%uint = OpTypeInt 32 0 +%uint_5 = OpConstant %uint 5 +%_arr_uint_uint_5 = OpTypeArray %uint %uint_5 +%_ptr_Function__arr_uint_uint_5 = OpTypePointer Function %_arr_uint_uint_5 +%_ptr_Function_uint = OpTypePointer Function %uint +%8 = OpUndef %uint +%void = OpTypeVoid +%10 = OpTypeFunction %void +%2 = OpFunction %void None %10 +%11 = OpLabel +%12 = OpVariable %_ptr_Function__arr_uint_uint_5 Function +%13 = OpAccessChain %_ptr_Function_uint %12 %8 +%14 = OpLoad %uint %13 +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndCheck(before, before, false, + true); +} // TODO(greg-lunarg): Add tests to verify handling of these cases: // diff --git a/third_party/spirv-tools/test/opt/loop_optimizations/loop_descriptions.cpp b/third_party/spirv-tools/test/opt/loop_optimizations/loop_descriptions.cpp index 4d2f989a58..b3f4f440cd 100644 --- a/third_party/spirv-tools/test/opt/loop_optimizations/loop_descriptions.cpp +++ b/third_party/spirv-tools/test/opt/loop_optimizations/loop_descriptions.cpp @@ -298,7 +298,7 @@ TEST_F(PassClassTest, NoLoop) { /* Generated from following GLSL with latch block artificially inserted to be -seperate from continue. +separate from continue. #version 430 void main(void) { float x[10]; diff --git a/third_party/spirv-tools/test/opt/loop_optimizations/loop_fission.cpp b/third_party/spirv-tools/test/opt/loop_optimizations/loop_fission.cpp index 55b9c26371..bc3ec39bdf 100644 --- a/third_party/spirv-tools/test/opt/loop_optimizations/loop_fission.cpp +++ b/third_party/spirv-tools/test/opt/loop_optimizations/loop_fission.cpp @@ -692,7 +692,7 @@ SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER); SinglePassRunAndCheck(source, expected, true); // By passing 1 as argument we are using the constructor which makes the -// critera to split the loop be if the registers in the loop exceede 1. By +// criteria to split the loop be if the registers in the loop exceede 1. By // using this constructor we are also enabling multiple passes (disabled by // default). SinglePassRunAndCheck(source, expected_multiple_passes, true, diff --git a/third_party/spirv-tools/test/opt/loop_optimizations/unroll_simple.cpp b/third_party/spirv-tools/test/opt/loop_optimizations/unroll_simple.cpp index ac0dfde787..299fb2d5c3 100644 --- a/third_party/spirv-tools/test/opt/loop_optimizations/unroll_simple.cpp +++ b/third_party/spirv-tools/test/opt/loop_optimizations/unroll_simple.cpp @@ -886,7 +886,7 @@ OpFunctionEnd LoopUnroller loop_unroller; SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER); // By unrolling by a factor that doesn't divide evenly into the number of loop - // iterations we perfom an additional transform when partially unrolling to + // iterations we perform an additional transform when partially unrolling to // account for the remainder. SinglePassRunAndCheck>(text, output, false); } @@ -3118,7 +3118,7 @@ OpFunctionEnd /* Generated from following GLSL with latch block artificially inserted to be -seperate from continue. +separate from continue. #version 430 void main(void) { float x[10]; @@ -3789,6 +3789,40 @@ TEST_F(PassClassTest, PartialUnrollWithPhiReferencesPhi) { SinglePassRunAndMatch>(text, true); } +TEST_F(PassClassTest, DontUnrollInfiteLoop) { + // This is an infinite loop that because the step is 0. We want to make sure + // the unroller does not try to unroll it. + const std::string text = R"(OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %2 "main" +OpExecutionMode %2 OriginUpperLeft +%void = OpTypeVoid +%4 = OpTypeFunction %void +%int = OpTypeInt 32 1 +%int_0 = OpConstant %int 0 +%int_50 = OpConstant %int 50 +%bool = OpTypeBool +%int_0_0 = OpConstant %int 0 +%2 = OpFunction %void None %4 +%10 = OpLabel +OpBranch %11 +%11 = OpLabel +%12 = OpPhi %int %int_0 %10 %13 %14 +%15 = OpSLessThan %bool %12 %int_50 +OpLoopMerge %16 %14 Unroll +OpBranchConditional %15 %14 %16 +%14 = OpLabel +%13 = OpIAdd %int %12 %int_0_0 +OpBranch %11 +%16 = OpLabel +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndCheck(text, text, false); +} + } // namespace } // namespace opt } // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/module_test.cpp b/third_party/spirv-tools/test/opt/module_test.cpp index a3c2eed77d..17a13650f5 100644 --- a/third_party/spirv-tools/test/opt/module_test.cpp +++ b/third_party/spirv-tools/test/opt/module_test.cpp @@ -52,7 +52,7 @@ inline std::unique_ptr BuildModule(std::string text) { } TEST(ModuleTest, ComputeIdBound) { - // Emtpy module case. + // Empty module case. EXPECT_EQ(1u, BuildModule("")->module()->ComputeIdBound()); // Sensitive to result id EXPECT_EQ(2u, BuildModule("%void = OpTypeVoid")->module()->ComputeIdBound()); diff --git a/third_party/spirv-tools/test/opt/optimizer_test.cpp b/third_party/spirv-tools/test/opt/optimizer_test.cpp index a51638a1ea..0171c09b9c 100644 --- a/third_party/spirv-tools/test/opt/optimizer_test.cpp +++ b/third_party/spirv-tools/test/opt/optimizer_test.cpp @@ -147,7 +147,7 @@ TEST(Optimizer, CanRegisterPassesFromFlags) { std::vector pass_flags = { "--strip-debug", - "--strip-reflect", + "--strip-nonsemantic", "--set-spec-const-default-value=23:42 21:12", "--if-conversion", "--freeze-spec-const", diff --git a/third_party/spirv-tools/test/opt/pass_manager_test.cpp b/third_party/spirv-tools/test/opt/pass_manager_test.cpp index 22d5e22ec3..4f36d5b267 100644 --- a/third_party/spirv-tools/test/opt/pass_manager_test.cpp +++ b/third_party/spirv-tools/test/opt/pass_manager_test.cpp @@ -30,7 +30,7 @@ namespace { using spvtest::GetIdBound; using ::testing::Eq; -// A null pass whose construtors accept arguments +// A null pass whose constructors accept arguments class NullPassWithArgs : public NullPass { public: NullPassWithArgs(uint32_t) {} diff --git a/third_party/spirv-tools/test/opt/remove_dontinline_test.cpp b/third_party/spirv-tools/test/opt/remove_dontinline_test.cpp new file mode 100644 index 0000000000..c5425e8c38 --- /dev/null +++ b/third_party/spirv-tools/test/opt/remove_dontinline_test.cpp @@ -0,0 +1,127 @@ +// Copyright (c) 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "test/opt/pass_fixture.h" +#include "test/opt/pass_utils.h" + +namespace spvtools { +namespace opt { +namespace { + +using StrengthReductionBasicTest = PassTest<::testing::Test>; + +TEST_F(StrengthReductionBasicTest, ClearDontInline) { + const std::vector text = { + // clang-format off + "OpCapability Shader", + "%1 = OpExtInstImport \"GLSL.std.450\"", + "OpMemoryModel Logical GLSL450", + "OpEntryPoint Vertex %main \"main\"", + "%void = OpTypeVoid", + "%4 = OpTypeFunction %void", +"; CHECK: OpFunction %void None", + "%main = OpFunction %void DontInline %4", + "%8 = OpLabel", + "OpReturn", + "OpFunctionEnd" + // clang-format on + }; + + SinglePassRunAndMatch(JoinAllInsts(text), true); +} + +TEST_F(StrengthReductionBasicTest, LeaveUnchanged1) { + const std::vector text = { + // clang-format off + "OpCapability Shader", + "%1 = OpExtInstImport \"GLSL.std.450\"", + "OpMemoryModel Logical GLSL450", + "OpEntryPoint Vertex %main \"main\"", + "%void = OpTypeVoid", + "%4 = OpTypeFunction %void", + "%main = OpFunction %void None %4", + "%8 = OpLabel", + "OpReturn", + "OpFunctionEnd" + // clang-format on + }; + + EXPECT_EQ(Pass::Status::SuccessWithoutChange, + std::get<1>(SinglePassRunAndDisassemble( + JoinAllInsts(text), false, true))); +} + +TEST_F(StrengthReductionBasicTest, LeaveUnchanged2) { + const std::vector text = { + // clang-format off + "OpCapability Shader", + "%1 = OpExtInstImport \"GLSL.std.450\"", + "OpMemoryModel Logical GLSL450", + "OpEntryPoint Vertex %main \"main\"", + "%void = OpTypeVoid", + "%4 = OpTypeFunction %void", + "%main = OpFunction %void Inline %4", + "%8 = OpLabel", + "OpReturn", + "OpFunctionEnd" + // clang-format on + }; + + EXPECT_EQ(Pass::Status::SuccessWithoutChange, + std::get<1>(SinglePassRunAndDisassemble( + JoinAllInsts(text), false, true))); +} + +TEST_F(StrengthReductionBasicTest, ClearMultipleDontInline) { + const std::vector text = { + // clang-format off + "OpCapability Shader", + "%1 = OpExtInstImport \"GLSL.std.450\"", + "OpMemoryModel Logical GLSL450", + "OpEntryPoint Vertex %main1 \"main1\"", + "OpEntryPoint Vertex %main2 \"main2\"", + "OpEntryPoint Vertex %main3 \"main3\"", + "OpEntryPoint Vertex %main4 \"main4\"", + "%void = OpTypeVoid", + "%4 = OpTypeFunction %void", + "; CHECK: OpFunction %void None", + "%main1 = OpFunction %void DontInline %4", + "%8 = OpLabel", + "OpReturn", + "OpFunctionEnd", + "; CHECK: OpFunction %void Inline", + "%main2 = OpFunction %void Inline %4", + "%9 = OpLabel", + "OpReturn", + "OpFunctionEnd", + "; CHECK: OpFunction %void Pure", + "%main3 = OpFunction %void DontInline|Pure %4", + "%10 = OpLabel", + "OpReturn", + "OpFunctionEnd", + "; CHECK: OpFunction %void None", + "%main4 = OpFunction %void None %4", + "%11 = OpLabel", + "OpReturn", + "OpFunctionEnd" + // clang-format on + }; + + SinglePassRunAndMatch(JoinAllInsts(text), true); +} +} // namespace +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/replace_desc_array_access_using_var_index_test.cpp b/third_party/spirv-tools/test/opt/replace_desc_array_access_using_var_index_test.cpp index ca62581265..9ab9eb1148 100644 --- a/third_party/spirv-tools/test/opt/replace_desc_array_access_using_var_index_test.cpp +++ b/third_party/spirv-tools/test/opt/replace_desc_array_access_using_var_index_test.cpp @@ -406,6 +406,171 @@ TEST_F(ReplaceDescArrayAccessUsingVarIndexTest, SinglePassRunAndMatch(text, true); } +TEST_F(ReplaceDescArrayAccessUsingVarIndexTest, ReplaceMultipleAccessChains) { + const std::string text = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %1 "TestFragment" %2 + OpExecutionMode %1 OriginUpperLeft + OpName %11 "type.ConstantBuffer.TestStruct" + OpMemberName %11 0 "val1" + OpMemberName %11 1 "val2" + OpName %3 "TestResources" + OpName %13 "type.2d.image" + OpName %4 "OutBuffer" + OpName %2 "in.var.SV_INSTANCEID" + OpName %1 "TestFragment" + OpDecorate %2 Flat + OpDecorate %2 Location 0 + OpDecorate %3 DescriptorSet 0 + OpDecorate %3 Binding 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 1 + OpMemberDecorate %11 0 Offset 0 + OpMemberDecorate %11 1 Offset 4 + OpDecorate %11 Block + %9 = OpTypeInt 32 0 + %10 = OpConstant %9 2 + %11 = OpTypeStruct %9 %9 + %8 = OpTypeArray %11 %10 + %7 = OpTypePointer Uniform %8 + %13 = OpTypeImage %9 2D 2 0 0 2 R32ui + %12 = OpTypePointer UniformConstant %13 + %14 = OpTypePointer Input %9 + %15 = OpTypeVoid + %16 = OpTypeFunction %15 + %40 = OpTypeVector %9 2 + %3 = OpVariable %7 Uniform + %4 = OpVariable %12 UniformConstant + %2 = OpVariable %14 Input + %57 = OpTypePointer Uniform %11 + %61 = OpTypePointer Uniform %9 + %62 = OpConstant %9 0 + %1 = OpFunction %15 None %16 + %17 = OpLabel + %20 = OpLoad %9 %2 + %47 = OpAccessChain %57 %3 %20 + %63 = OpAccessChain %61 %47 %62 + %64 = OpLoad %9 %63 + +; CHECK: [[null_value:%\w+]] = OpConstantNull %uint + +; CHECK: [[var_index:%\w+]] = OpLoad %uint %in_var_SV_INSTANCEID +; CHECK: OpSelectionMerge [[merge:%\w+]] None +; CHECK: OpSwitch [[var_index]] [[default:%\w+]] 0 [[case0:%\w+]] 1 [[case1:%\w+]] +; CHECK: [[case0]] = OpLabel +; CHECK: OpAccessChain +; CHECK: OpAccessChain +; CHECK: [[result0:%\w+]] = OpLoad +; CHECK: OpBranch [[merge]] +; CHECK: [[case1]] = OpLabel +; CHECK: OpAccessChain +; CHECK: OpAccessChain +; CHECK: [[result1:%\w+]] = OpLoad +; CHECK: OpBranch [[merge]] +; CHECK: [[default]] = OpLabel +; CHECK: OpBranch [[merge]] +; CHECK: [[merge]] = OpLabel +; CHECK: OpPhi %uint [[result0]] [[case0]] [[result1]] [[case1]] [[null_value]] [[default]] + + %55 = OpCompositeConstruct %40 %20 %20 + %56 = OpLoad %13 %4 + OpImageWrite %56 %55 %64 None + OpReturn + OpFunctionEnd + )"; + + SinglePassRunAndMatch(text, true); +} + +TEST_F(ReplaceDescArrayAccessUsingVarIndexTest, + ReplaceAccessChainToTextureArrayWithNonUniformIndex) { + const std::string text = R"( + OpCapability Shader + OpCapability ShaderNonUniform + OpCapability SampledImageArrayNonUniformIndexing + OpExtension "SPV_EXT_descriptor_indexing" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %PSMain "PSMain" %in_var_TEXCOORD0 %in_var_MATERIAL_ID %out_var_SV_TARGET + OpExecutionMode %PSMain OriginUpperLeft + OpSource HLSL 610 + OpName %type_sampler "type.sampler" + OpName %sampler_ "sampler_" + OpName %type_2d_image "type.2d.image" + OpName %texture_2d "texture_2d" + OpName %in_var_TEXCOORD0 "in.var.TEXCOORD0" + OpName %in_var_MATERIAL_ID "in.var.MATERIAL_ID" + OpName %out_var_SV_TARGET "out.var.SV_TARGET" + OpName %PSMain "PSMain" + OpName %type_sampled_image "type.sampled.image" + OpDecorate %in_var_MATERIAL_ID Flat + OpDecorate %in_var_TEXCOORD0 Location 0 + OpDecorate %in_var_MATERIAL_ID Location 1 + OpDecorate %out_var_SV_TARGET Location 0 + OpDecorate %sampler_ DescriptorSet 1 + OpDecorate %sampler_ Binding 1 + OpDecorate %texture_2d DescriptorSet 0 + OpDecorate %texture_2d Binding 0 + +; CHECK: OpDecorate [[v0:%\w+]] NonUniform +; CHECK: OpDecorate [[v1:%\w+]] NonUniform +; CHECK: OpDecorate [[v2:%\w+]] NonUniform +; CHECK: OpDecorate [[v3:%\w+]] NonUniform + + OpDecorate %10 NonUniform + OpDecorate %11 NonUniform + OpDecorate %12 NonUniform + OpDecorate %13 NonUniform +%type_sampler = OpTypeSampler +%_ptr_UniformConstant_type_sampler = OpTypePointer UniformConstant %type_sampler + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 + %float = OpTypeFloat 32 +%type_2d_image = OpTypeImage %float 2D 2 0 0 1 Unknown +%_arr_type_2d_image_uint_4 = OpTypeArray %type_2d_image %uint_4 +%_ptr_UniformConstant__arr_type_2d_image_uint_4 = OpTypePointer UniformConstant %_arr_type_2d_image_uint_4 + %v2float = OpTypeVector %float 2 +%_ptr_Input_v2float = OpTypePointer Input %v2float +%_ptr_Input_uint = OpTypePointer Input %uint + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %void = OpTypeVoid + %26 = OpTypeFunction %void +%_ptr_UniformConstant_type_2d_image = OpTypePointer UniformConstant %type_2d_image +%type_sampled_image = OpTypeSampledImage %type_2d_image + %sampler_ = OpVariable %_ptr_UniformConstant_type_sampler UniformConstant + %texture_2d = OpVariable %_ptr_UniformConstant__arr_type_2d_image_uint_4 UniformConstant +%in_var_TEXCOORD0 = OpVariable %_ptr_Input_v2float Input +%in_var_MATERIAL_ID = OpVariable %_ptr_Input_uint Input +%out_var_SV_TARGET = OpVariable %_ptr_Output_v4float Output + +; CHECK: %uint_0 = OpConstant %uint 0 +; CHECK: %uint_1 = OpConstant %uint 1 +; CHECK: %uint_2 = OpConstant %uint 2 +; CHECK: %uint_3 = OpConstant %uint 3 + + %PSMain = OpFunction %void None %26 + %28 = OpLabel + %29 = OpLoad %v2float %in_var_TEXCOORD0 + %30 = OpLoad %uint %in_var_MATERIAL_ID +; CHECK: [[v0]] = OpCopyObject %uint {{%\w+}} + %10 = OpCopyObject %uint %30 +; CHECK: [[v1]] = OpAccessChain %_ptr_UniformConstant_type_2d_image %texture_2d [[v0]] + %11 = OpAccessChain %_ptr_UniformConstant_type_2d_image %texture_2d %10 +; CHECK: [[v2]] = OpLoad %type_2d_image [[v1]] + %12 = OpLoad %type_2d_image %11 + %31 = OpLoad %type_sampler %sampler_ +; CHECK: [[v3]] = OpSampledImage %type_sampled_image [[v2]] {{%\w+}} + %13 = OpSampledImage %type_sampled_image %12 %31 + %32 = OpImageSampleImplicitLod %v4float %13 %29 None + OpStore %out_var_SV_TARGET %32 + OpReturn + OpFunctionEnd + )"; + + SinglePassRunAndMatch(text, true); +} + } // namespace } // namespace opt } // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/scalar_replacement_test.cpp b/third_party/spirv-tools/test/opt/scalar_replacement_test.cpp index 8cb888c93e..7db997d4a3 100644 --- a/third_party/spirv-tools/test/opt/scalar_replacement_test.cpp +++ b/third_party/spirv-tools/test/opt/scalar_replacement_test.cpp @@ -470,9 +470,9 @@ TEST_F(ScalarReplacementTest, NonUniformCompositeInitialization) { ; CHECK: [[const_array:%\w+]] = OpConstantComposite [[array]] ; CHECK: [[const_matrix:%\w+]] = OpConstantNull [[matrix]] ; CHECK: [[const_struct1:%\w+]] = OpConstantComposite [[struct1]] -; CHECK: OpConstantNull [[uint]] -; CHECK: OpConstantNull [[vector]] -; CHECK: OpConstantNull [[long]] +; CHECK: OpUndef [[uint]] +; CHECK: OpUndef [[vector]] +; CHECK: OpUndef [[long]] ; CHECK: OpFunction ; CHECK-NOT: OpVariable [[struct2_ptr]] Function ; CHECK: OpVariable [[uint_ptr]] Function @@ -654,11 +654,10 @@ TEST_F(ScalarReplacementTest, ReplaceWholeLoadCopyMemoryAccess) { ; CHECK: [[uint:%\w+]] = OpTypeInt 32 0 ; CHECK: [[struct1:%\w+]] = OpTypeStruct [[uint]] [[uint]] ; CHECK: [[uint_ptr:%\w+]] = OpTypePointer Function [[uint]] -; CHECK: [[const:%\w+]] = OpConstant [[uint]] 0 -; CHECK: [[null:%\w+]] = OpConstantNull [[uint]] +; CHECK: [[undef:%\w+]] = OpUndef [[uint]] ; CHECK: [[var0:%\w+]] = OpVariable [[uint_ptr]] Function ; CHECK: [[l0:%\w+]] = OpLoad [[uint]] [[var0]] Nontemporal -; CHECK: OpCompositeConstruct [[struct1]] [[l0]] [[null]] +; CHECK: OpCompositeConstruct [[struct1]] [[l0]] [[undef]] ; OpCapability Shader OpCapability Linkage @@ -1267,16 +1266,16 @@ TEST_F(ScalarReplacementTest, ReplaceWholeLoadAndStore) { ; CHECK: [[struct1:%\w+]] = OpTypeStruct [[uint]] [[uint]] ; CHECK: [[uint_ptr:%\w+]] = OpTypePointer Function [[uint]] ; CHECK: [[const:%\w+]] = OpConstant [[uint]] 0 -; CHECK: [[null:%\w+]] = OpConstantNull [[uint]] +; CHECK: [[undef:%\w+]] = OpUndef [[uint]] ; CHECK: [[var0:%\w+]] = OpVariable [[uint_ptr]] Function ; CHECK: [[var1:%\w+]] = OpVariable [[uint_ptr]] Function ; CHECK-NOT: OpVariable ; CHECK: [[l0:%\w+]] = OpLoad [[uint]] [[var0]] -; CHECK: [[c0:%\w+]] = OpCompositeConstruct [[struct1]] [[l0]] [[null]] +; CHECK: [[c0:%\w+]] = OpCompositeConstruct [[struct1]] [[l0]] [[undef]] ; CHECK: [[e0:%\w+]] = OpCompositeExtract [[uint]] [[c0]] 0 ; CHECK: OpStore [[var1]] [[e0]] ; CHECK: [[l1:%\w+]] = OpLoad [[uint]] [[var1]] -; CHECK: [[c1:%\w+]] = OpCompositeConstruct [[struct1]] [[l1]] [[null]] +; CHECK: [[c1:%\w+]] = OpCompositeConstruct [[struct1]] [[l1]] [[undef]] ; CHECK: [[e1:%\w+]] = OpCompositeExtract [[uint]] [[c1]] 0 ; OpCapability Shader @@ -1314,7 +1313,7 @@ TEST_F(ScalarReplacementTest, ReplaceWholeLoadAndStore2) { ; CHECK: [[struct1:%\w+]] = OpTypeStruct [[uint]] [[uint]] ; CHECK: [[uint_ptr:%\w+]] = OpTypePointer Function [[uint]] ; CHECK: [[const:%\w+]] = OpConstant [[uint]] 0 -; CHECK: [[null:%\w+]] = OpConstantNull [[uint]] +; CHECK: [[undef:%\w+]] = OpUndef [[uint]] ; CHECK: [[var1:%\w+]] = OpVariable [[uint_ptr]] Function ; CHECK: [[var0a:%\w+]] = OpVariable [[uint_ptr]] Function ; CHECK: [[var0b:%\w+]] = OpVariable [[uint_ptr]] Function @@ -1325,7 +1324,7 @@ TEST_F(ScalarReplacementTest, ReplaceWholeLoadAndStore2) { ; CHECK: [[e0:%\w+]] = OpCompositeExtract [[uint]] [[c0]] 0 ; CHECK: OpStore [[var1]] [[e0]] ; CHECK: [[l1:%\w+]] = OpLoad [[uint]] [[var1]] -; CHECK: [[c1:%\w+]] = OpCompositeConstruct [[struct1]] [[l1]] [[null]] +; CHECK: [[c1:%\w+]] = OpCompositeConstruct [[struct1]] [[l1]] [[undef]] ; CHECK: [[e1:%\w+]] = OpCompositeExtract [[uint]] [[c1]] 0 ; OpCapability Shader @@ -1362,14 +1361,14 @@ TEST_F(ScalarReplacementTest, CreateAmbiguousNullConstant1) { ; CHECK: [[struct1:%\w+]] = OpTypeStruct [[uint]] [[struct_member:%\w+]] ; CHECK: [[uint_ptr:%\w+]] = OpTypePointer Function [[uint]] ; CHECK: [[const:%\w+]] = OpConstant [[uint]] 0 -; CHECK: [[null:%\w+]] = OpConstantNull [[struct_member]] +; CHECK: [[undef:%\w+]] = OpUndef [[struct_member]] ; CHECK: [[var0a:%\w+]] = OpVariable [[uint_ptr]] Function ; CHECK: [[var1:%\w+]] = OpVariable [[uint_ptr]] Function ; CHECK: [[var0b:%\w+]] = OpVariable [[uint_ptr]] Function ; CHECK-NOT: OpVariable ; CHECK: OpStore [[var1]] ; CHECK: [[l1:%\w+]] = OpLoad [[uint]] [[var1]] -; CHECK: [[c1:%\w+]] = OpCompositeConstruct [[struct1]] [[l1]] [[null]] +; CHECK: [[c1:%\w+]] = OpCompositeConstruct [[struct1]] [[l1]] [[undef]] ; CHECK: [[e1:%\w+]] = OpCompositeExtract [[uint]] [[c1]] 0 ; OpCapability Shader @@ -1444,13 +1443,13 @@ TEST_F(ScalarReplacementTest, CreateAmbiguousNullConstant2) { ; CHECK: [[struct1:%\w+]] = OpTypeStruct [[uint]] [[struct_member:%\w+]] ; CHECK: [[uint_ptr:%\w+]] = OpTypePointer Function [[uint]] ; CHECK: [[const:%\w+]] = OpConstant [[uint]] 0 -; CHECK: [[null:%\w+]] = OpConstantNull [[struct_member]] +; CHECK: [[undef:%\w+]] = OpUndef [[struct_member]] ; CHECK: [[var0a:%\w+]] = OpVariable [[uint_ptr]] Function ; CHECK: [[var1:%\w+]] = OpVariable [[uint_ptr]] Function ; CHECK: [[var0b:%\w+]] = OpVariable [[uint_ptr]] Function ; CHECK: OpStore [[var1]] ; CHECK: [[l1:%\w+]] = OpLoad [[uint]] [[var1]] -; CHECK: [[c1:%\w+]] = OpCompositeConstruct [[struct1]] [[l1]] [[null]] +; CHECK: [[c1:%\w+]] = OpCompositeConstruct [[struct1]] [[l1]] [[undef]] ; CHECK: [[e1:%\w+]] = OpCompositeExtract [[uint]] [[c1]] 0 ; OpCapability Shader @@ -2263,6 +2262,40 @@ OpFunctionEnd SinglePassRunAndCheck(text, text, false); } +TEST_F(ScalarReplacementTest, UndefImageMember) { + // Test that scalar replacement creates an undef for a type that cannot have + // and OpConstantNull. + const std::string text = R"( +; CHECK: [[image_type:%\w+]] = OpTypeSampledImage {{%\w+}} +; CHECK: [[struct_type:%\w+]] = OpTypeStruct [[image_type]] +; CHECK: [[undef:%\w+]] = OpUndef [[image_type]] +; CHECK: {{%\w+}} = OpCompositeConstruct [[struct_type]] [[undef]] + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" + OpExecutionMode %2 OriginUpperLeft + %void = OpTypeVoid + %4 = OpTypeFunction %void + %float = OpTypeFloat 32 + %6 = OpTypeImage %float 2D 0 0 0 1 Unknown + %7 = OpTypeSampledImage %6 + %_struct_8 = OpTypeStruct %7 + %9 = OpTypeFunction %_struct_8 + %10 = OpUndef %_struct_8 +%_ptr_Function__struct_8 = OpTypePointer Function %_struct_8 + %2 = OpFunction %void None %4 + %11 = OpLabel + %16 = OpVariable %_ptr_Function__struct_8 Function + OpStore %16 %10 + %12 = OpLoad %_struct_8 %16 + OpReturn + OpFunctionEnd + )"; + + SinglePassRunAndMatch(text, true); +} + } // namespace } // namespace opt } // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/set_spec_const_default_value_test.cpp b/third_party/spirv-tools/test/opt/set_spec_const_default_value_test.cpp index f1dd50eee3..10f805b66f 100644 --- a/third_party/spirv-tools/test/opt/set_spec_const_default_value_test.cpp +++ b/third_party/spirv-tools/test/opt/set_spec_const_default_value_test.cpp @@ -618,7 +618,7 @@ INSTANTIATE_TEST_SUITE_P( {"", SpecIdToValueBitPatternMap{}, ""}, // 1. Empty with non-empty values to set. {"", SpecIdToValueBitPatternMap{{1, {100}}, {2, {200}}}, ""}, - // 2. Baisc bool type. + // 2. Basic bool type. { // code "OpDecorate %1 SpecId 100\n" diff --git a/third_party/spirv-tools/test/opt/spread_volatile_semantics_test.cpp b/third_party/spirv-tools/test/opt/spread_volatile_semantics_test.cpp new file mode 100644 index 0000000000..dbb889c090 --- /dev/null +++ b/third_party/spirv-tools/test/opt/spread_volatile_semantics_test.cpp @@ -0,0 +1,1267 @@ +// Copyright (c) 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "gmock/gmock.h" +#include "test/opt/pass_fixture.h" +#include "test/opt/pass_utils.h" + +namespace spvtools { +namespace opt { +namespace { + +struct ExecutionModelAndBuiltIn { + const char* execution_model; + const char* built_in; + const bool use_v4uint; +}; + +using AddVolatileDecorationTest = + PassTest<::testing::TestWithParam>; + +TEST_P(AddVolatileDecorationTest, InMain) { + const auto& tc = GetParam(); + const std::string execution_model(tc.execution_model); + const std::string built_in(tc.built_in); + const std::string var_type = + tc.use_v4uint ? "%_ptr_Input_v4uint" : "%_ptr_Input_uint"; + const std::string var_load_type = tc.use_v4uint ? "%v4uint" : "%uint"; + + const std::string text = + std::string(R"(OpCapability RuntimeDescriptorArray +OpCapability RayTracingKHR +OpCapability SubgroupBallotKHR +OpExtension "SPV_EXT_descriptor_indexing" +OpExtension "SPV_KHR_ray_tracing" +OpExtension "SPV_KHR_shader_ballot" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint )") + + execution_model + std::string(R"( %main "main" %var +OpSource GLSL 460 +OpSourceExtension "GL_EXT_nonuniform_qualifier" +OpSourceExtension "GL_KHR_ray_tracing" +OpName %main "main" +OpName %fn "fn" +OpName %StorageBuffer "StorageBuffer" +OpMemberName %StorageBuffer 0 "index" +OpMemberName %StorageBuffer 1 "red" +OpName %sbo "sbo" +OpName %images "images" +OpMemberDecorate %StorageBuffer 0 Offset 0 +OpMemberDecorate %StorageBuffer 1 Offset 4 +OpDecorate %StorageBuffer BufferBlock +OpDecorate %sbo DescriptorSet 0 +OpDecorate %sbo Binding 0 +OpDecorate %images DescriptorSet 0 +OpDecorate %images Binding 1 +OpDecorate %images NonWritable +)") + std::string(R"( +; CHECK: OpDecorate [[var:%\w+]] BuiltIn )") + + built_in + std::string(R"( +; CHECK: OpDecorate [[var]] Volatile +OpDecorate %var BuiltIn )") + built_in + std::string(R"( +%void = OpTypeVoid +%3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%float = OpTypeFloat 32 +%StorageBuffer = OpTypeStruct %uint %float +%_ptr_Uniform_StorageBuffer = OpTypePointer Uniform %StorageBuffer +%sbo = OpVariable %_ptr_Uniform_StorageBuffer Uniform +%int = OpTypeInt 32 1 +%int_1 = OpConstant %int 1 +%13 = OpTypeImage %float 2D 0 0 0 2 Rgba32f +%_runtimearr_13 = OpTypeRuntimeArray %13 +%_ptr_UniformConstant__runtimearr_13 = OpTypePointer UniformConstant %_runtimearr_13 +%images = OpVariable %_ptr_UniformConstant__runtimearr_13 UniformConstant +%_ptr_Input_uint = OpTypePointer Input %uint +%v4uint = OpTypeVector %uint 4 +%_ptr_Input_v4uint = OpTypePointer Input %v4uint +%var = OpVariable )") + + var_type + std::string(R"( Input +%int_0 = OpConstant %int 0 +%_ptr_Uniform_uint = OpTypePointer Uniform %uint +%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 +%v2int = OpTypeVector %int 2 +%25 = OpConstantComposite %v2int %int_0 %int_0 +%v4float = OpTypeVector %float 4 +%uint_0 = OpConstant %uint 0 +%_ptr_Uniform_float = OpTypePointer Uniform %float +%main = OpFunction %void None %3 +%5 = OpLabel +%19 = OpAccessChain %_ptr_Uniform_uint %sbo %int_0 +%20 = OpLoad %uint %19 +%load = OpLoad )") + var_load_type + std::string(R"( %var +%22 = OpAccessChain %_ptr_UniformConstant_13 %images %20 +%23 = OpLoad %13 %22 +%27 = OpImageRead %v4float %23 %25 +%29 = OpCompositeExtract %float %27 0 +%31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 +OpStore %31 %29 +%32 = OpFunctionCall %void %fn +OpReturn +OpFunctionEnd +%fn = OpFunction %void None %3 +%33 = OpLabel +OpReturn +OpFunctionEnd +)"); + + SinglePassRunAndMatch(text, true); +} + +INSTANTIATE_TEST_SUITE_P( + AddVolatileDecoration, AddVolatileDecorationTest, + ::testing::ValuesIn(std::vector{ + {"RayGenerationKHR", "SubgroupSize", false}, + {"RayGenerationKHR", "SubgroupLocalInvocationId", false}, + {"RayGenerationKHR", "SubgroupEqMask", true}, + {"ClosestHitKHR", "SubgroupLocalInvocationId", true}, + {"IntersectionKHR", "SubgroupEqMask", true}, + {"MissKHR", "SubgroupGeMask", true}, + {"CallableKHR", "SubgroupGtMask", true}, + {"RayGenerationKHR", "SubgroupLeMask", true}, + })); + +using SetLoadVolatileTest = + PassTest<::testing::TestWithParam>; + +TEST_P(SetLoadVolatileTest, InMain) { + const auto& tc = GetParam(); + const std::string execution_model(tc.execution_model); + const std::string built_in(tc.built_in); + + const std::string var_type = + tc.use_v4uint ? "%_ptr_Input_v4uint" : "%_ptr_Input_uint"; + const std::string var_value = tc.use_v4uint ? std::string(R"( +; CHECK: [[ptr:%\w+]] = OpAccessChain %_ptr_Input_uint [[var]] %int_0 +; CHECK: OpLoad {{%\w+}} [[ptr]] Volatile +%ptr = OpAccessChain %_ptr_Input_uint %var %int_0 +%var_value = OpLoad %uint %ptr)") + : std::string(R"( +; CHECK: OpLoad {{%\w+}} [[var]] Volatile +%var_value = OpLoad %uint %var)"); + + const std::string text = std::string(R"(OpCapability RuntimeDescriptorArray +OpCapability RayTracingKHR +OpCapability SubgroupBallotKHR +OpCapability VulkanMemoryModel +OpExtension "SPV_KHR_vulkan_memory_model" +OpExtension "SPV_EXT_descriptor_indexing" +OpExtension "SPV_KHR_ray_tracing" +OpExtension "SPV_KHR_shader_ballot" +OpMemoryModel Logical Vulkan +OpEntryPoint )") + execution_model + + std::string(R"( %main "main" %var +OpName %main "main" +OpName %StorageBuffer "StorageBuffer" +OpMemberName %StorageBuffer 0 "index" +OpMemberName %StorageBuffer 1 "red" +OpName %sbo "sbo" +OpName %images "images" +OpMemberDecorate %StorageBuffer 0 Offset 0 +OpMemberDecorate %StorageBuffer 1 Offset 4 +OpDecorate %StorageBuffer BufferBlock +OpDecorate %sbo DescriptorSet 0 +OpDecorate %sbo Binding 0 +OpDecorate %images DescriptorSet 0 +OpDecorate %images Binding 1 +OpDecorate %images NonWritable +)") + std::string(R"( +; CHECK: OpDecorate [[var:%\w+]] BuiltIn )") + + built_in + std::string(R"( +OpDecorate %var BuiltIn )") + built_in + + std::string(R"( +%void = OpTypeVoid +%3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%float = OpTypeFloat 32 +%StorageBuffer = OpTypeStruct %uint %float +%_ptr_Uniform_StorageBuffer = OpTypePointer Uniform %StorageBuffer +%sbo = OpVariable %_ptr_Uniform_StorageBuffer Uniform +%int = OpTypeInt 32 1 +%int_1 = OpConstant %int 1 +%13 = OpTypeImage %float 2D 0 0 0 2 Rgba32f +%_runtimearr_13 = OpTypeRuntimeArray %13 +%_ptr_UniformConstant__runtimearr_13 = OpTypePointer UniformConstant %_runtimearr_13 +%images = OpVariable %_ptr_UniformConstant__runtimearr_13 UniformConstant +%_ptr_Input_uint = OpTypePointer Input %uint +%v4uint = OpTypeVector %uint 4 +%_ptr_Input_v4uint = OpTypePointer Input %v4uint +%var = OpVariable )") + var_type + + std::string(R"( Input +%int_0 = OpConstant %int 0 +%_ptr_Uniform_uint = OpTypePointer Uniform %uint +%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 +%v2int = OpTypeVector %int 2 +%25 = OpConstantComposite %v2int %int_0 %int_0 +%v4float = OpTypeVector %float 4 +%uint_0 = OpConstant %uint 0 +%_ptr_Uniform_float = OpTypePointer Uniform %float +%main = OpFunction %void None %3 +%5 = OpLabel +%19 = OpAccessChain %_ptr_Uniform_uint %sbo %int_0 +%20 = OpLoad %uint %19 +)") + var_value + std::string(R"( +%test = OpIAdd %uint %var_value %20 +%22 = OpAccessChain %_ptr_UniformConstant_13 %images %test +%23 = OpLoad %13 %22 +%27 = OpImageRead %v4float %23 %25 +%29 = OpCompositeExtract %float %27 0 +%31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 +OpStore %31 %29 +OpReturn +OpFunctionEnd +)"); + + SinglePassRunAndMatch(text, true); +} + +INSTANTIATE_TEST_SUITE_P( + SetLoadVolatile, SetLoadVolatileTest, + ::testing::ValuesIn(std::vector{ + {"RayGenerationKHR", "SubgroupSize", false}, + {"RayGenerationKHR", "SubgroupLocalInvocationId", false}, + {"RayGenerationKHR", "SubgroupEqMask", true}, + {"ClosestHitKHR", "SubgroupLocalInvocationId", true}, + {"IntersectionKHR", "SubgroupEqMask", true}, + {"MissKHR", "SubgroupGeMask", true}, + {"CallableKHR", "SubgroupGtMask", true}, + {"RayGenerationKHR", "SubgroupLeMask", true}, + })); + +using VolatileSpreadTest = PassTest<::testing::Test>; + +TEST_F(VolatileSpreadTest, SpreadVolatileForHelperInvocation) { + const std::string text = + R"( +OpCapability Shader +OpCapability DemoteToHelperInvocation +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" %var +OpExecutionMode %main OriginUpperLeft + +; CHECK: OpDecorate [[var:%\w+]] BuiltIn HelperInvocation +; CHECK: OpDecorate [[var]] Volatile +OpDecorate %var BuiltIn HelperInvocation + +%bool = OpTypeBool +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%_ptr_Input_bool = OpTypePointer Input %bool +%var = OpVariable %_ptr_Input_bool Input +%main = OpFunction %void None %void_fn +%entry = OpLabel +%load = OpLoad %bool %var +OpDemoteToHelperInvocation +OpReturn +OpFunctionEnd +)"; + + SetTargetEnv(SPV_ENV_UNIVERSAL_1_6); + SinglePassRunAndMatch(text, true); +} + +TEST_F(VolatileSpreadTest, MultipleExecutionModel) { + const std::string text = + R"( +OpCapability RuntimeDescriptorArray +OpCapability RayTracingKHR +OpCapability SubgroupBallotKHR +OpExtension "SPV_EXT_descriptor_indexing" +OpExtension "SPV_KHR_ray_tracing" +OpExtension "SPV_KHR_shader_ballot" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint RayGenerationKHR %RayGeneration "RayGeneration" %var +OpEntryPoint GLCompute %compute "Compute" %gl_LocalInvocationIndex +OpExecutionMode %compute LocalSize 16 16 1 +OpSource GLSL 460 +OpSourceExtension "GL_EXT_nonuniform_qualifier" +OpSourceExtension "GL_KHR_ray_tracing" +OpName %RayGeneration "RayGeneration" +OpName %StorageBuffer "StorageBuffer" +OpMemberName %StorageBuffer 0 "index" +OpMemberName %StorageBuffer 1 "red" +OpName %sbo "sbo" +OpName %images "images" +OpMemberDecorate %StorageBuffer 0 Offset 0 +OpMemberDecorate %StorageBuffer 1 Offset 4 +OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex +OpDecorate %StorageBuffer BufferBlock +OpDecorate %sbo DescriptorSet 0 +OpDecorate %sbo Binding 0 +OpDecorate %images DescriptorSet 0 +OpDecorate %images Binding 1 +OpDecorate %images NonWritable + +; CHECK: OpEntryPoint RayGenerationNV {{%\w+}} "RayGeneration" [[var:%\w+]] +; CHECK: OpDecorate [[var]] BuiltIn SubgroupSize +; CHECK: OpDecorate [[var]] Volatile +; CHECK-NOT: OpDecorate {{%\w+}} Volatile +OpDecorate %var BuiltIn SubgroupSize + +%void = OpTypeVoid +%3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%float = OpTypeFloat 32 +%StorageBuffer = OpTypeStruct %uint %float +%_ptr_Uniform_StorageBuffer = OpTypePointer Uniform %StorageBuffer +%sbo = OpVariable %_ptr_Uniform_StorageBuffer Uniform +%int = OpTypeInt 32 1 +%int_1 = OpConstant %int 1 +%13 = OpTypeImage %float 2D 0 0 0 2 Rgba32f +%_runtimearr_13 = OpTypeRuntimeArray %13 +%_ptr_UniformConstant__runtimearr_13 = OpTypePointer UniformConstant %_runtimearr_13 +%images = OpVariable %_ptr_UniformConstant__runtimearr_13 UniformConstant +%_ptr_Input_uint = OpTypePointer Input %uint +%var = OpVariable %_ptr_Input_uint Input +%int_0 = OpConstant %int 0 +%_ptr_Uniform_uint = OpTypePointer Uniform %uint +%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 +%v2int = OpTypeVector %int 2 +%25 = OpConstantComposite %v2int %int_0 %int_0 +%v4float = OpTypeVector %float 4 +%uint_0 = OpConstant %uint 0 +%uint_1 = OpConstant %uint 1 +%_ptr_Uniform_float = OpTypePointer Uniform %float +%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint +%shared = OpVariable %_ptr_Workgroup_uint Workgroup + +%RayGeneration = OpFunction %void None %3 +%5 = OpLabel +%19 = OpAccessChain %_ptr_Uniform_uint %sbo %int_0 +%20 = OpLoad %uint %var +%22 = OpAccessChain %_ptr_UniformConstant_13 %images %20 +%23 = OpLoad %13 %22 +%27 = OpImageRead %v4float %23 %25 +%29 = OpCompositeExtract %float %27 0 +%31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 +OpStore %31 %29 +OpReturn +OpFunctionEnd + +%compute = OpFunction %void None %3 +%66 = OpLabel +%62 = OpLoad %uint %gl_LocalInvocationIndex +%61 = OpAtomicIAdd %uint %shared %uint_1 %uint_0 %62 +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, true); +} + +TEST_F(VolatileSpreadTest, VarUsedInMultipleEntryPoints) { + const std::string text = + R"( +OpCapability RuntimeDescriptorArray +OpCapability RayTracingKHR +OpCapability SubgroupBallotKHR +OpExtension "SPV_EXT_descriptor_indexing" +OpExtension "SPV_KHR_ray_tracing" +OpExtension "SPV_KHR_shader_ballot" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint RayGenerationKHR %RayGeneration "RayGeneration" %var +OpEntryPoint ClosestHitKHR %ClosestHit "ClosestHit" %var +OpSource GLSL 460 +OpSourceExtension "GL_EXT_nonuniform_qualifier" +OpSourceExtension "GL_KHR_ray_tracing" +OpName %RayGeneration "RayGeneration" +OpName %ClosestHit "ClosestHit" +OpName %StorageBuffer "StorageBuffer" +OpMemberName %StorageBuffer 0 "index" +OpMemberName %StorageBuffer 1 "red" +OpName %sbo "sbo" +OpName %images "images" +OpMemberDecorate %StorageBuffer 0 Offset 0 +OpMemberDecorate %StorageBuffer 1 Offset 4 +OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex +OpDecorate %StorageBuffer BufferBlock +OpDecorate %sbo DescriptorSet 0 +OpDecorate %sbo Binding 0 +OpDecorate %images DescriptorSet 0 +OpDecorate %images Binding 1 +OpDecorate %images NonWritable + +; CHECK: OpEntryPoint RayGenerationNV {{%\w+}} "RayGeneration" [[var:%\w+]] +; CHECK: OpEntryPoint ClosestHitNV {{%\w+}} "ClosestHit" [[var]] +; CHECK: OpDecorate [[var]] BuiltIn SubgroupSize +; CHECK: OpDecorate [[var]] Volatile +; CHECK-NOT: OpDecorate {{%\w+}} Volatile +OpDecorate %var BuiltIn SubgroupSize + +%void = OpTypeVoid +%3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%float = OpTypeFloat 32 +%StorageBuffer = OpTypeStruct %uint %float +%_ptr_Uniform_StorageBuffer = OpTypePointer Uniform %StorageBuffer +%sbo = OpVariable %_ptr_Uniform_StorageBuffer Uniform +%int = OpTypeInt 32 1 +%int_1 = OpConstant %int 1 +%13 = OpTypeImage %float 2D 0 0 0 2 Rgba32f +%_runtimearr_13 = OpTypeRuntimeArray %13 +%_ptr_UniformConstant__runtimearr_13 = OpTypePointer UniformConstant %_runtimearr_13 +%images = OpVariable %_ptr_UniformConstant__runtimearr_13 UniformConstant +%_ptr_Input_uint = OpTypePointer Input %uint +%var = OpVariable %_ptr_Input_uint Input +%int_0 = OpConstant %int 0 +%_ptr_Uniform_uint = OpTypePointer Uniform %uint +%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 +%v2int = OpTypeVector %int 2 +%25 = OpConstantComposite %v2int %int_0 %int_0 +%v4float = OpTypeVector %float 4 +%uint_0 = OpConstant %uint 0 +%uint_1 = OpConstant %uint 1 +%_ptr_Uniform_float = OpTypePointer Uniform %float +%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint +%shared = OpVariable %_ptr_Workgroup_uint Workgroup + +%RayGeneration = OpFunction %void None %3 +%5 = OpLabel +%19 = OpAccessChain %_ptr_Uniform_uint %sbo %int_0 +%20 = OpLoad %uint %var +%22 = OpAccessChain %_ptr_UniformConstant_13 %images %20 +%23 = OpLoad %13 %22 +%27 = OpImageRead %v4float %23 %25 +%29 = OpCompositeExtract %float %27 0 +%31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 +OpStore %31 %29 +OpReturn +OpFunctionEnd + +%ClosestHit = OpFunction %void None %3 +%45 = OpLabel +%49 = OpAccessChain %_ptr_Uniform_uint %sbo %int_0 +%40 = OpLoad %uint %var +%42 = OpAccessChain %_ptr_UniformConstant_13 %images %40 +%43 = OpLoad %13 %42 +%47 = OpImageRead %v4float %43 %25 +%59 = OpCompositeExtract %float %47 0 +%51 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 +OpStore %51 %59 +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, true); +} + +class VolatileSpreadErrorTest : public PassTest<::testing::Test> { + public: + VolatileSpreadErrorTest() + : consumer_([this](spv_message_level_t level, const char*, + const spv_position_t& position, const char* message) { + if (!error_message_.empty()) error_message_ += "\n"; + switch (level) { + case SPV_MSG_FATAL: + case SPV_MSG_INTERNAL_ERROR: + case SPV_MSG_ERROR: + error_message_ += "ERROR"; + break; + case SPV_MSG_WARNING: + error_message_ += "WARNING"; + break; + case SPV_MSG_INFO: + error_message_ += "INFO"; + break; + case SPV_MSG_DEBUG: + error_message_ += "DEBUG"; + break; + } + error_message_ += + ": " + std::to_string(position.index) + ": " + message; + }) {} + + Pass::Status RunPass(const std::string& text) { + std::unique_ptr context_ = + spvtools::BuildModule(SPV_ENV_UNIVERSAL_1_2, consumer_, text); + if (!context_.get()) return Pass::Status::Failure; + + PassManager manager; + manager.SetMessageConsumer(consumer_); + manager.AddPass(); + + return manager.Run(context_.get()); + } + + std::string GetErrorMessage() const { return error_message_; } + + void TearDown() override { error_message_.clear(); } + + private: + spvtools::MessageConsumer consumer_; + std::string error_message_; +}; + +TEST_F(VolatileSpreadErrorTest, VarUsedInMultipleExecutionModelError) { + const std::string text = + R"( +OpCapability RuntimeDescriptorArray +OpCapability RayTracingKHR +OpCapability SubgroupBallotKHR +OpExtension "SPV_EXT_descriptor_indexing" +OpExtension "SPV_KHR_ray_tracing" +OpExtension "SPV_KHR_shader_ballot" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint RayGenerationKHR %RayGeneration "RayGeneration" %var +OpEntryPoint GLCompute %compute "Compute" %gl_LocalInvocationIndex %var +OpExecutionMode %compute LocalSize 16 16 1 +OpSource GLSL 460 +OpSourceExtension "GL_EXT_nonuniform_qualifier" +OpSourceExtension "GL_KHR_ray_tracing" +OpName %RayGeneration "RayGeneration" +OpName %StorageBuffer "StorageBuffer" +OpMemberName %StorageBuffer 0 "index" +OpMemberName %StorageBuffer 1 "red" +OpName %sbo "sbo" +OpName %images "images" +OpMemberDecorate %StorageBuffer 0 Offset 0 +OpMemberDecorate %StorageBuffer 1 Offset 4 +OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex +OpDecorate %StorageBuffer BufferBlock +OpDecorate %sbo DescriptorSet 0 +OpDecorate %sbo Binding 0 +OpDecorate %images DescriptorSet 0 +OpDecorate %images Binding 1 +OpDecorate %images NonWritable +OpDecorate %var BuiltIn SubgroupSize +%void = OpTypeVoid +%3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%float = OpTypeFloat 32 +%StorageBuffer = OpTypeStruct %uint %float +%_ptr_Uniform_StorageBuffer = OpTypePointer Uniform %StorageBuffer +%sbo = OpVariable %_ptr_Uniform_StorageBuffer Uniform +%int = OpTypeInt 32 1 +%int_1 = OpConstant %int 1 +%13 = OpTypeImage %float 2D 0 0 0 2 Rgba32f +%_runtimearr_13 = OpTypeRuntimeArray %13 +%_ptr_UniformConstant__runtimearr_13 = OpTypePointer UniformConstant %_runtimearr_13 +%images = OpVariable %_ptr_UniformConstant__runtimearr_13 UniformConstant +%_ptr_Input_uint = OpTypePointer Input %uint +%var = OpVariable %_ptr_Input_uint Input +%int_0 = OpConstant %int 0 +%_ptr_Uniform_uint = OpTypePointer Uniform %uint +%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 +%v2int = OpTypeVector %int 2 +%25 = OpConstantComposite %v2int %int_0 %int_0 +%v4float = OpTypeVector %float 4 +%uint_0 = OpConstant %uint 0 +%uint_1 = OpConstant %uint 1 +%_ptr_Uniform_float = OpTypePointer Uniform %float +%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint +%shared = OpVariable %_ptr_Workgroup_uint Workgroup + +%RayGeneration = OpFunction %void None %3 +%5 = OpLabel +%19 = OpAccessChain %_ptr_Uniform_uint %sbo %int_0 +%20 = OpLoad %uint %var +%22 = OpAccessChain %_ptr_UniformConstant_13 %images %20 +%23 = OpLoad %13 %22 +%27 = OpImageRead %v4float %23 %25 +%29 = OpCompositeExtract %float %27 0 +%31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 +OpStore %31 %29 +OpReturn +OpFunctionEnd + +%compute = OpFunction %void None %3 +%66 = OpLabel +%62 = OpLoad %uint %gl_LocalInvocationIndex +%63 = OpLoad %uint %var +%64 = OpIAdd %uint %62 %63 +%61 = OpAtomicIAdd %uint %shared %uint_1 %uint_0 %64 +OpReturn +OpFunctionEnd +)"; + + EXPECT_EQ(RunPass(text), Pass::Status::Failure); + const char expected_error[] = + "ERROR: 0: Variable is a target for Volatile semantics for an entry " + "point, but it is not for another entry point"; + EXPECT_STREQ(GetErrorMessage().substr(0, sizeof(expected_error) - 1).c_str(), + expected_error); +} + +TEST_F(VolatileSpreadErrorTest, + VarUsedInMultipleReverseOrderExecutionModelError) { + const std::string text = + R"( +OpCapability RuntimeDescriptorArray +OpCapability RayTracingKHR +OpCapability SubgroupBallotKHR +OpExtension "SPV_EXT_descriptor_indexing" +OpExtension "SPV_KHR_ray_tracing" +OpExtension "SPV_KHR_shader_ballot" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %compute "Compute" %gl_LocalInvocationIndex %var +OpEntryPoint RayGenerationKHR %RayGeneration "RayGeneration" %var +OpExecutionMode %compute LocalSize 16 16 1 +OpSource GLSL 460 +OpSourceExtension "GL_EXT_nonuniform_qualifier" +OpSourceExtension "GL_KHR_ray_tracing" +OpName %RayGeneration "RayGeneration" +OpName %StorageBuffer "StorageBuffer" +OpMemberName %StorageBuffer 0 "index" +OpMemberName %StorageBuffer 1 "red" +OpName %sbo "sbo" +OpName %images "images" +OpMemberDecorate %StorageBuffer 0 Offset 0 +OpMemberDecorate %StorageBuffer 1 Offset 4 +OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex +OpDecorate %StorageBuffer BufferBlock +OpDecorate %sbo DescriptorSet 0 +OpDecorate %sbo Binding 0 +OpDecorate %images DescriptorSet 0 +OpDecorate %images Binding 1 +OpDecorate %images NonWritable +OpDecorate %var BuiltIn SubgroupSize +%void = OpTypeVoid +%3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%float = OpTypeFloat 32 +%StorageBuffer = OpTypeStruct %uint %float +%_ptr_Uniform_StorageBuffer = OpTypePointer Uniform %StorageBuffer +%sbo = OpVariable %_ptr_Uniform_StorageBuffer Uniform +%int = OpTypeInt 32 1 +%int_1 = OpConstant %int 1 +%13 = OpTypeImage %float 2D 0 0 0 2 Rgba32f +%_runtimearr_13 = OpTypeRuntimeArray %13 +%_ptr_UniformConstant__runtimearr_13 = OpTypePointer UniformConstant %_runtimearr_13 +%images = OpVariable %_ptr_UniformConstant__runtimearr_13 UniformConstant +%_ptr_Input_uint = OpTypePointer Input %uint +%var = OpVariable %_ptr_Input_uint Input +%int_0 = OpConstant %int 0 +%_ptr_Uniform_uint = OpTypePointer Uniform %uint +%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 +%v2int = OpTypeVector %int 2 +%25 = OpConstantComposite %v2int %int_0 %int_0 +%v4float = OpTypeVector %float 4 +%uint_0 = OpConstant %uint 0 +%uint_1 = OpConstant %uint 1 +%_ptr_Uniform_float = OpTypePointer Uniform %float +%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint +%shared = OpVariable %_ptr_Workgroup_uint Workgroup + +%RayGeneration = OpFunction %void None %3 +%5 = OpLabel +%19 = OpAccessChain %_ptr_Uniform_uint %sbo %int_0 +%20 = OpLoad %uint %var +%22 = OpAccessChain %_ptr_UniformConstant_13 %images %20 +%23 = OpLoad %13 %22 +%27 = OpImageRead %v4float %23 %25 +%29 = OpCompositeExtract %float %27 0 +%31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 +OpStore %31 %29 +OpReturn +OpFunctionEnd + +%compute = OpFunction %void None %3 +%66 = OpLabel +%62 = OpLoad %uint %gl_LocalInvocationIndex +%63 = OpLoad %uint %var +%64 = OpIAdd %uint %62 %63 +%61 = OpAtomicIAdd %uint %shared %uint_1 %uint_0 %64 +OpReturn +OpFunctionEnd +)"; + + EXPECT_EQ(RunPass(text), Pass::Status::Failure); + const char expected_error[] = + "ERROR: 0: Variable is a target for Volatile semantics for an entry " + "point, but it is not for another entry point"; + EXPECT_STREQ(GetErrorMessage().substr(0, sizeof(expected_error) - 1).c_str(), + expected_error); +} + +TEST_F(VolatileSpreadErrorTest, FunctionNotInlined) { + const std::string text = + R"( +OpCapability RuntimeDescriptorArray +OpCapability RayTracingKHR +OpCapability SubgroupBallotKHR +OpExtension "SPV_EXT_descriptor_indexing" +OpExtension "SPV_KHR_ray_tracing" +OpExtension "SPV_KHR_shader_ballot" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint RayGenerationKHR %RayGeneration "RayGeneration" %var +OpEntryPoint ClosestHitKHR %ClosestHit "ClosestHit" %var +OpSource GLSL 460 +OpSourceExtension "GL_EXT_nonuniform_qualifier" +OpSourceExtension "GL_KHR_ray_tracing" +OpName %RayGeneration "RayGeneration" +OpName %ClosestHit "ClosestHit" +OpName %StorageBuffer "StorageBuffer" +OpMemberName %StorageBuffer 0 "index" +OpMemberName %StorageBuffer 1 "red" +OpName %sbo "sbo" +OpName %images "images" +OpMemberDecorate %StorageBuffer 0 Offset 0 +OpMemberDecorate %StorageBuffer 1 Offset 4 +OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex +OpDecorate %StorageBuffer BufferBlock +OpDecorate %sbo DescriptorSet 0 +OpDecorate %sbo Binding 0 +OpDecorate %images DescriptorSet 0 +OpDecorate %images Binding 1 +OpDecorate %images NonWritable +OpDecorate %var BuiltIn SubgroupSize +%void = OpTypeVoid +%3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%float = OpTypeFloat 32 +%StorageBuffer = OpTypeStruct %uint %float +%_ptr_Uniform_StorageBuffer = OpTypePointer Uniform %StorageBuffer +%sbo = OpVariable %_ptr_Uniform_StorageBuffer Uniform +%int = OpTypeInt 32 1 +%int_1 = OpConstant %int 1 +%13 = OpTypeImage %float 2D 0 0 0 2 Rgba32f +%_runtimearr_13 = OpTypeRuntimeArray %13 +%_ptr_UniformConstant__runtimearr_13 = OpTypePointer UniformConstant %_runtimearr_13 +%images = OpVariable %_ptr_UniformConstant__runtimearr_13 UniformConstant +%_ptr_Input_uint = OpTypePointer Input %uint +%var = OpVariable %_ptr_Input_uint Input +%int_0 = OpConstant %int 0 +%_ptr_Uniform_uint = OpTypePointer Uniform %uint +%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 +%v2int = OpTypeVector %int 2 +%25 = OpConstantComposite %v2int %int_0 %int_0 +%v4float = OpTypeVector %float 4 +%uint_0 = OpConstant %uint 0 +%uint_1 = OpConstant %uint 1 +%_ptr_Uniform_float = OpTypePointer Uniform %float +%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint +%shared = OpVariable %_ptr_Workgroup_uint Workgroup + +%RayGeneration = OpFunction %void None %3 +%5 = OpLabel +%19 = OpAccessChain %_ptr_Uniform_uint %sbo %int_0 +%20 = OpLoad %uint %19 +%22 = OpAccessChain %_ptr_UniformConstant_13 %images %20 +%23 = OpLoad %13 %22 +%27 = OpImageRead %v4float %23 %25 +%29 = OpCompositeExtract %float %27 0 +%31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 +OpStore %31 %29 +OpReturn +OpFunctionEnd + +%NotInlined = OpFunction %void None %3 +%32 = OpLabel +OpReturn +OpFunctionEnd + +%ClosestHit = OpFunction %void None %3 +%45 = OpLabel +%49 = OpAccessChain %_ptr_Uniform_uint %sbo %int_0 +%40 = OpLoad %uint %49 +%42 = OpAccessChain %_ptr_UniformConstant_13 %images %40 +%43 = OpLoad %13 %42 +%47 = OpImageRead %v4float %43 %25 +%59 = OpCompositeExtract %float %47 0 +%51 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 +OpStore %51 %59 +OpReturn +OpFunctionEnd +)"; + + EXPECT_EQ(RunPass(text), Pass::Status::SuccessWithoutChange); +} + +TEST_F(VolatileSpreadErrorTest, VarNotUsedInEntryPointForVolatile) { + const std::string text = + R"( +OpCapability RuntimeDescriptorArray +OpCapability RayTracingKHR +OpCapability SubgroupBallotKHR +OpExtension "SPV_EXT_descriptor_indexing" +OpExtension "SPV_KHR_ray_tracing" +OpExtension "SPV_KHR_shader_ballot" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint RayGenerationKHR %RayGeneration "RayGeneration" %var +OpEntryPoint GLCompute %compute "Compute" %gl_LocalInvocationIndex %var +OpExecutionMode %compute LocalSize 16 16 1 +OpSource GLSL 460 +OpSourceExtension "GL_EXT_nonuniform_qualifier" +OpSourceExtension "GL_KHR_ray_tracing" +OpName %RayGeneration "RayGeneration" +OpName %StorageBuffer "StorageBuffer" +OpMemberName %StorageBuffer 0 "index" +OpMemberName %StorageBuffer 1 "red" +OpName %sbo "sbo" +OpName %images "images" +OpMemberDecorate %StorageBuffer 0 Offset 0 +OpMemberDecorate %StorageBuffer 1 Offset 4 +OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex +OpDecorate %StorageBuffer BufferBlock +OpDecorate %sbo DescriptorSet 0 +OpDecorate %sbo Binding 0 +OpDecorate %images DescriptorSet 0 +OpDecorate %images Binding 1 +OpDecorate %images NonWritable + +; CHECK-NOT: OpDecorate {{%\w+}} Volatile + +OpDecorate %var BuiltIn SubgroupSize +%void = OpTypeVoid +%3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%float = OpTypeFloat 32 +%StorageBuffer = OpTypeStruct %uint %float +%_ptr_Uniform_StorageBuffer = OpTypePointer Uniform %StorageBuffer +%sbo = OpVariable %_ptr_Uniform_StorageBuffer Uniform +%int = OpTypeInt 32 1 +%int_1 = OpConstant %int 1 +%13 = OpTypeImage %float 2D 0 0 0 2 Rgba32f +%_runtimearr_13 = OpTypeRuntimeArray %13 +%_ptr_UniformConstant__runtimearr_13 = OpTypePointer UniformConstant %_runtimearr_13 +%images = OpVariable %_ptr_UniformConstant__runtimearr_13 UniformConstant +%_ptr_Input_uint = OpTypePointer Input %uint +%var = OpVariable %_ptr_Input_uint Input +%int_0 = OpConstant %int 0 +%_ptr_Uniform_uint = OpTypePointer Uniform %uint +%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 +%v2int = OpTypeVector %int 2 +%25 = OpConstantComposite %v2int %int_0 %int_0 +%v4float = OpTypeVector %float 4 +%uint_0 = OpConstant %uint 0 +%uint_1 = OpConstant %uint 1 +%_ptr_Uniform_float = OpTypePointer Uniform %float +%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint +%shared = OpVariable %_ptr_Workgroup_uint Workgroup + +%RayGeneration = OpFunction %void None %3 +%5 = OpLabel +%19 = OpAccessChain %_ptr_Uniform_uint %sbo %int_0 +%20 = OpLoad %uint %19 +%22 = OpAccessChain %_ptr_UniformConstant_13 %images %20 +%23 = OpLoad %13 %22 +%27 = OpImageRead %v4float %23 %25 +%29 = OpCompositeExtract %float %27 0 +%31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 +OpStore %31 %29 +OpReturn +OpFunctionEnd + +%compute = OpFunction %void None %3 +%66 = OpLabel +%62 = OpLoad %uint %gl_LocalInvocationIndex +%63 = OpLoad %uint %var +%64 = OpIAdd %uint %62 %63 +%61 = OpAtomicIAdd %uint %shared %uint_1 %uint_0 %64 +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, true); +} + +TEST_F(VolatileSpreadTest, RecursivelySpreadVolatile) { + const std::string text = + R"( +OpCapability RuntimeDescriptorArray +OpCapability RayTracingKHR +OpCapability SubgroupBallotKHR +OpCapability VulkanMemoryModel +OpExtension "SPV_KHR_vulkan_memory_model" +OpExtension "SPV_EXT_descriptor_indexing" +OpExtension "SPV_KHR_ray_tracing" +OpExtension "SPV_KHR_shader_ballot" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical Vulkan +OpEntryPoint RayGenerationKHR %RayGeneration "RayGeneration" %var0 %var1 +OpSource GLSL 460 +OpSourceExtension "GL_EXT_nonuniform_qualifier" +OpSourceExtension "GL_KHR_ray_tracing" +OpName %RayGeneration "RayGeneration" +OpName %StorageBuffer "StorageBuffer" +OpMemberName %StorageBuffer 0 "index" +OpMemberName %StorageBuffer 1 "red" +OpName %sbo "sbo" +OpName %images "images" +OpMemberDecorate %StorageBuffer 0 Offset 0 +OpMemberDecorate %StorageBuffer 1 Offset 4 +OpDecorate %StorageBuffer BufferBlock +OpDecorate %sbo DescriptorSet 0 +OpDecorate %sbo Binding 0 +OpDecorate %images DescriptorSet 0 +OpDecorate %images Binding 1 +OpDecorate %images NonWritable + +; CHECK: OpDecorate [[var0:%\w+]] BuiltIn SubgroupEqMask +; CHECK: OpDecorate [[var1:%\w+]] BuiltIn SubgroupGeMask +OpDecorate %var0 BuiltIn SubgroupEqMask +OpDecorate %var1 BuiltIn SubgroupGeMask + +%void = OpTypeVoid +%3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%float = OpTypeFloat 32 +%StorageBuffer = OpTypeStruct %uint %float +%_ptr_Uniform_StorageBuffer = OpTypePointer Uniform %StorageBuffer +%sbo = OpVariable %_ptr_Uniform_StorageBuffer Uniform +%int = OpTypeInt 32 1 +%int_1 = OpConstant %int 1 +%13 = OpTypeImage %float 2D 0 0 0 2 Rgba32f +%_runtimearr_13 = OpTypeRuntimeArray %13 +%_ptr_UniformConstant__runtimearr_13 = OpTypePointer UniformConstant %_runtimearr_13 +%images = OpVariable %_ptr_UniformConstant__runtimearr_13 UniformConstant +%v4uint = OpTypeVector %uint 4 +%_ptr_Input_v4uint = OpTypePointer Input %v4uint +%_ptr_Input_uint = OpTypePointer Input %uint +%var0 = OpVariable %_ptr_Input_v4uint Input +%var1 = OpVariable %_ptr_Input_v4uint Input +%int_0 = OpConstant %int 0 +%_ptr_Uniform_uint = OpTypePointer Uniform %uint +%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 +%v2int = OpTypeVector %int 2 +%25 = OpConstantComposite %v2int %int_0 %int_0 +%v4float = OpTypeVector %float 4 +%uint_0 = OpConstant %uint 0 +%uint_1 = OpConstant %uint 1 +%_ptr_Uniform_float = OpTypePointer Uniform %float + +%RayGeneration = OpFunction %void None %3 +%5 = OpLabel + +; CHECK: [[ptr0:%\w+]] = OpAccessChain %_ptr_Input_uint [[var0]] %int_0 +; CHECK: OpLoad {{%\w+}} [[ptr0]] Volatile +%19 = OpAccessChain %_ptr_Input_uint %var0 %int_0 +%20 = OpLoad %uint %19 + +%22 = OpAccessChain %_ptr_UniformConstant_13 %images %20 +%23 = OpLoad %13 %22 +%27 = OpImageRead %v4float %23 %25 +%29 = OpCompositeExtract %float %27 0 +%31 = OpAccessChain %_ptr_Uniform_float %sbo %uint_1 + +; CHECK: OpLoad {{%\w+}} [[ptr0]] Volatile +%24 = OpLoad %uint %19 + +; CHECK: [[var2:%\w+]] = OpCopyObject %_ptr_Input_v4uint [[var0]] +; CHECK: [[ptr2:%\w+]] = OpAccessChain %_ptr_Input_uint [[var2]] %int_1 +; CHECK: OpLoad {{%\w+}} [[ptr2]] Volatile +%18 = OpCopyObject %_ptr_Input_v4uint %var0 +%21 = OpAccessChain %_ptr_Input_uint %18 %int_1 +%26 = OpLoad %uint %21 + +%28 = OpIAdd %uint %24 %26 +%30 = OpConvertUToF %float %28 + +; CHECK: [[ptr1:%\w+]] = OpAccessChain %_ptr_Input_uint [[var1]] %int_1 +; CHECK: OpLoad {{%\w+}} [[ptr1]] Volatile +%32 = OpAccessChain %_ptr_Input_uint %var1 %int_1 +%33 = OpLoad %uint %32 + +%34 = OpConvertUToF %float %33 +%35 = OpFAdd %float %34 %30 +%36 = OpFAdd %float %35 %29 +OpStore %31 %36 +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, true); +} + +TEST_F(VolatileSpreadTest, SpreadVolatileOnlyForTargetEntryPoints) { + const std::string text = + R"( +OpCapability RuntimeDescriptorArray +OpCapability RayTracingKHR +OpCapability SubgroupBallotKHR +OpCapability VulkanMemoryModel +OpCapability VulkanMemoryModelDeviceScopeKHR +OpExtension "SPV_KHR_vulkan_memory_model" +OpExtension "SPV_EXT_descriptor_indexing" +OpExtension "SPV_KHR_ray_tracing" +OpExtension "SPV_KHR_shader_ballot" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical Vulkan +OpEntryPoint RayGenerationKHR %RayGeneration "RayGeneration" %var0 %var1 +OpEntryPoint GLCompute %compute "Compute" %var0 %var1 +OpExecutionMode %compute LocalSize 16 16 1 +OpSource GLSL 460 +OpSourceExtension "GL_EXT_nonuniform_qualifier" +OpSourceExtension "GL_KHR_ray_tracing" +OpName %RayGeneration "RayGeneration" +OpName %StorageBuffer "StorageBuffer" +OpMemberName %StorageBuffer 0 "index" +OpMemberName %StorageBuffer 1 "red" +OpName %sbo "sbo" +OpName %images "images" +OpMemberDecorate %StorageBuffer 0 Offset 0 +OpMemberDecorate %StorageBuffer 1 Offset 4 +OpDecorate %StorageBuffer BufferBlock +OpDecorate %sbo DescriptorSet 0 +OpDecorate %sbo Binding 0 +OpDecorate %images DescriptorSet 0 +OpDecorate %images Binding 1 +OpDecorate %images NonWritable + +; CHECK: OpDecorate [[var0:%\w+]] BuiltIn SubgroupEqMask +; CHECK: OpDecorate [[var1:%\w+]] BuiltIn SubgroupGeMask +OpDecorate %var0 BuiltIn SubgroupEqMask +OpDecorate %var1 BuiltIn SubgroupGeMask + +%void = OpTypeVoid +%3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%float = OpTypeFloat 32 +%StorageBuffer = OpTypeStruct %uint %float +%_ptr_Uniform_StorageBuffer = OpTypePointer Uniform %StorageBuffer +%sbo = OpVariable %_ptr_Uniform_StorageBuffer Uniform +%int = OpTypeInt 32 1 +%int_1 = OpConstant %int 1 +%13 = OpTypeImage %float 2D 0 0 0 2 Rgba32f +%_runtimearr_13 = OpTypeRuntimeArray %13 +%_ptr_UniformConstant__runtimearr_13 = OpTypePointer UniformConstant %_runtimearr_13 +%images = OpVariable %_ptr_UniformConstant__runtimearr_13 UniformConstant +%v4uint = OpTypeVector %uint 4 +%_ptr_Input_v4uint = OpTypePointer Input %v4uint +%_ptr_Input_uint = OpTypePointer Input %uint +%var0 = OpVariable %_ptr_Input_v4uint Input +%var1 = OpVariable %_ptr_Input_v4uint Input +%int_0 = OpConstant %int 0 +%_ptr_Uniform_uint = OpTypePointer Uniform %uint +%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 +%v2int = OpTypeVector %int 2 +%25 = OpConstantComposite %v2int %int_0 %int_0 +%v4float = OpTypeVector %float 4 +%uint_0 = OpConstant %uint 0 +%uint_1 = OpConstant %uint 1 +%_ptr_Uniform_float = OpTypePointer Uniform %float +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint +%shared = OpVariable %_ptr_Workgroup_uint Workgroup + +%RayGeneration = OpFunction %void None %3 +%5 = OpLabel + +; CHECK: [[ptr0:%\w+]] = OpAccessChain %_ptr_Input_uint [[var0]] %int_0 +; CHECK: OpLoad {{%\w+}} [[ptr0]] Volatile +%19 = OpAccessChain %_ptr_Input_uint %var0 %int_0 +%20 = OpLoad %uint %19 + +%22 = OpAccessChain %_ptr_UniformConstant_13 %images %20 +%23 = OpLoad %13 %22 +%27 = OpImageRead %v4float %23 %25 +%29 = OpCompositeExtract %float %27 0 +%31 = OpAccessChain %_ptr_Uniform_float %sbo %uint_1 + +; CHECK: OpLoad {{%\w+}} [[ptr0]] Volatile +%24 = OpLoad %uint %19 + +; CHECK: [[var2:%\w+]] = OpCopyObject %_ptr_Input_v4uint [[var0]] +; CHECK: [[ptr2:%\w+]] = OpAccessChain %_ptr_Input_uint [[var2]] %int_1 +; CHECK: OpLoad {{%\w+}} [[ptr2]] Volatile +%18 = OpCopyObject %_ptr_Input_v4uint %var0 +%21 = OpAccessChain %_ptr_Input_uint %18 %int_1 +%26 = OpLoad %uint %21 + +%28 = OpIAdd %uint %24 %26 +%30 = OpConvertUToF %float %28 + +; CHECK: [[ptr1:%\w+]] = OpAccessChain %_ptr_Input_uint [[var1]] %int_1 +; CHECK: OpLoad {{%\w+}} [[ptr1]] Volatile +%32 = OpAccessChain %_ptr_Input_uint %var1 %int_1 +%33 = OpLoad %uint %32 + +%34 = OpConvertUToF %float %33 +%35 = OpFAdd %float %34 %30 +%36 = OpFAdd %float %35 %29 +OpStore %31 %36 +OpReturn +OpFunctionEnd + +%compute = OpFunction %void None %3 +%66 = OpLabel + +; CHECK-NOT: OpLoad {{%\w+}} {{%\w+}} Volatile +%62 = OpLoad %v4uint %var0 +%63 = OpLoad %v4uint %var1 +%64 = OpIAdd %v4uint %62 %63 +%65 = OpCompositeExtract %uint %64 0 +%61 = OpAtomicIAdd %uint %shared %uint_1 %uint_0 %65 +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, true); +} + +TEST_F(VolatileSpreadTest, SkipIfItHasNoExecutionModel) { + const std::string text = R"( +OpCapability Shader +OpCapability Linkage +OpMemoryModel Logical GLSL450 +%2 = OpTypeVoid +%3 = OpTypeFunction %2 +%4 = OpFunction %2 None %3 +%5 = OpLabel +OpReturn +OpFunctionEnd +)"; + + Pass::Status status; + std::tie(std::ignore, status) = + SinglePassRunToBinary(text, + /* skip_nop = */ false); + EXPECT_EQ(status, Pass::Status::SuccessWithoutChange); +} + +TEST_F(VolatileSpreadTest, NoInlinedfuncCalls) { + const std::string text = R"( +OpCapability RayTracingNV +OpCapability VulkanMemoryModel +OpCapability GroupNonUniform +OpExtension "SPV_NV_ray_tracing" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical Vulkan +OpEntryPoint RayGenerationNV %main "main" %SubgroupSize +OpSource HLSL 630 +OpName %main "main" +OpName %src_main "src.main" +OpName %bb_entry "bb.entry" +OpName %func0 "func0" +OpName %bb_entry_0 "bb.entry" +OpName %func2 "func2" +OpName %bb_entry_1 "bb.entry" +OpName %param_var_count "param.var.count" +OpName %func1 "func1" +OpName %bb_entry_2 "bb.entry" +OpName %func3 "func3" +OpName %count "count" +OpName %bb_entry_3 "bb.entry" +OpDecorate %SubgroupSize BuiltIn SubgroupSize +%uint = OpTypeInt 32 0 +%_ptr_Input_uint = OpTypePointer Input %uint +%void = OpTypeVoid +%6 = OpTypeFunction %void +%_ptr_Function_uint = OpTypePointer Function %uint +%25 = OpTypeFunction %void %_ptr_Function_uint +%SubgroupSize = OpVariable %_ptr_Input_uint Input +%main = OpFunction %void None %6 +%7 = OpLabel +%8 = OpFunctionCall %void %src_main +OpReturn +OpFunctionEnd +%src_main = OpFunction %void None %6 +%bb_entry = OpLabel +%11 = OpFunctionCall %void %func0 +OpReturn +OpFunctionEnd +%func0 = OpFunction %void DontInline %6 +%bb_entry_0 = OpLabel +%14 = OpFunctionCall %void %func2 +%16 = OpFunctionCall %void %func1 +OpReturn +OpFunctionEnd +%func2 = OpFunction %void DontInline %6 +%bb_entry_1 = OpLabel +%param_var_count = OpVariable %_ptr_Function_uint Function +; CHECK: {{%\w+}} = OpLoad %uint %SubgroupSize Volatile +%21 = OpLoad %uint %SubgroupSize +OpStore %param_var_count %21 +%22 = OpFunctionCall %void %func3 %param_var_count +OpReturn +OpFunctionEnd +%func1 = OpFunction %void DontInline %6 +%bb_entry_2 = OpLabel +OpReturn +OpFunctionEnd +%func3 = OpFunction %void DontInline %25 +%count = OpFunctionParameter %_ptr_Function_uint +%bb_entry_3 = OpLabel +OpReturn +OpFunctionEnd +)"; + SinglePassRunAndMatch(text, true); +} + +TEST_F(VolatileSpreadErrorTest, NoInlinedMultiEntryfuncCalls) { + const std::string text = R"( +OpCapability RayTracingNV +OpCapability SubgroupBallotKHR +OpExtension "SPV_NV_ray_tracing" +OpExtension "SPV_KHR_shader_ballot" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint RayGenerationNV %main "main" %SubgroupSize +OpEntryPoint GLCompute %main2 "main2" %gl_LocalInvocationIndex %SubgroupSize +OpSource HLSL 630 +OpName %main "main" +OpName %bb_entry "bb.entry" +OpName %main2 "main2" +OpName %bb_entry_0 "bb.entry" +OpName %func "func" +OpName %count "count" +OpName %bb_entry_1 "bb.entry" +OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex +OpDecorate %SubgroupSize BuiltIn SubgroupSize +%uint = OpTypeInt 32 0 +%uint_0 = OpConstant %uint 0 +%_ptr_Input_uint = OpTypePointer Input %uint +%float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%void = OpTypeVoid +%12 = OpTypeFunction %void +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Function_v4float = OpTypePointer Function %v4float +%29 = OpTypeFunction %void %_ptr_Function_v4float +%34 = OpTypeFunction %void %_ptr_Function_uint +%SubgroupSize = OpVariable %_ptr_Input_uint Input +%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input +%main = OpFunction %void None %12 +%bb_entry = OpLabel +%20 = OpFunctionCall %void %func +OpReturn +OpFunctionEnd +%main2 = OpFunction %void None %12 +%bb_entry_0 = OpLabel +%33 = OpFunctionCall %void %func +OpReturn +OpFunctionEnd +%func = OpFunction %void DontInline %12 +%bb_entry_1 = OpLabel +%count = OpVariable %_ptr_Function_uint Function +%35 = OpLoad %uint %SubgroupSize +OpStore %count %35 +OpReturn +OpFunctionEnd +)"; + EXPECT_EQ(RunPass(text), Pass::Status::Failure); + const char expected_error[] = + "ERROR: 0: Variable is a target for Volatile semantics for an entry " + "point, but it is not for another entry point"; + EXPECT_STREQ(GetErrorMessage().substr(0, sizeof(expected_error) - 1).c_str(), + expected_error); +} + +} // namespace +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/strip_reflect_info_test.cpp b/third_party/spirv-tools/test/opt/strip_nonsemantic_info_test.cpp similarity index 64% rename from third_party/spirv-tools/test/opt/strip_reflect_info_test.cpp rename to third_party/spirv-tools/test/opt/strip_nonsemantic_info_test.cpp index f3fc115a04..3aacffa343 100644 --- a/third_party/spirv-tools/test/opt/strip_reflect_info_test.cpp +++ b/third_party/spirv-tools/test/opt/strip_nonsemantic_info_test.cpp @@ -13,10 +13,9 @@ // limitations under the License. #include + #include "gmock/gmock.h" - #include "spirv-tools/optimizer.hpp" - #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" @@ -24,7 +23,6 @@ namespace spvtools { namespace opt { namespace { -using StripLineReflectInfoTest = PassTest<::testing::Test>; using StripNonSemanticInfoTest = PassTest<::testing::Test>; // This test acts as an end-to-end code example on how to strip @@ -33,7 +31,7 @@ using StripNonSemanticInfoTest = PassTest<::testing::Test>; // option -fhlsl_functionality1 to insert reflection information, // but then want to filter out the extra instructions before sending // it to a driver that does not implement VK_GOOGLE_hlsl_functionality1. -TEST_F(StripLineReflectInfoTest, StripReflectEnd2EndExample) { +TEST_F(StripNonSemanticInfoTest, StripReflectEnd2EndExample) { // This is a non-sensical example, but exercises the instructions. std::string before = R"(OpCapability Shader OpCapability Linkage @@ -49,11 +47,11 @@ OpDecorateStringGOOGLE %void HlslSemanticGOOGLE "my goodness" std::vector binary_in; tools.Assemble(before, &binary_in); - // Instantiate the optimizer, and run the strip-reflection-info + // Instantiate the optimizer, and run the strip-nonsemantic-info // pass over the |binary_in| module, and place the modified module // into |binary_out|. spvtools::Optimizer optimizer(SPV_ENV_UNIVERSAL_1_1); - optimizer.RegisterPass(spvtools::CreateStripReflectInfoPass()); + optimizer.RegisterPass(spvtools::CreateStripNonSemanticInfoPass()); std::vector binary_out; optimizer.Run(binary_in.data(), binary_in.size(), &binary_out); @@ -71,7 +69,7 @@ OpMemoryModel Logical Simple // This test is functionally the same as the end-to-end test above, // but uses the test SinglePassRunAndCheck test fixture instead. -TEST_F(StripLineReflectInfoTest, StripHlslSemantic) { +TEST_F(StripNonSemanticInfoTest, StripHlslSemantic) { // This is a non-sensical example, but exercises the instructions. std::string before = R"(OpCapability Shader OpCapability Linkage @@ -90,10 +88,10 @@ OpMemoryModel Logical Simple %float = OpTypeFloat 32 )"; - SinglePassRunAndCheck(before, after, false); + SinglePassRunAndCheck(before, after, false); } -TEST_F(StripLineReflectInfoTest, StripHlslCounterBuffer) { +TEST_F(StripNonSemanticInfoTest, StripHlslCounterBuffer) { std::string before = R"(OpCapability Shader OpCapability Linkage OpExtension "SPV_GOOGLE_hlsl_functionality1" @@ -109,10 +107,10 @@ OpMemoryModel Logical Simple %float = OpTypeFloat 32 )"; - SinglePassRunAndCheck(before, after, false); + SinglePassRunAndCheck(before, after, false); } -TEST_F(StripLineReflectInfoTest, StripHlslSemanticOnMember) { +TEST_F(StripNonSemanticInfoTest, StripHlslSemanticOnMember) { // This is a non-sensical example, but exercises the instructions. std::string before = R"(OpCapability Shader OpCapability Linkage @@ -130,7 +128,7 @@ OpMemoryModel Logical Simple %_struct_3 = OpTypeStruct %float )"; - SinglePassRunAndCheck(before, after, false); + SinglePassRunAndCheck(before, after, false); } TEST_F(StripNonSemanticInfoTest, StripNonSemanticImport) { @@ -144,7 +142,7 @@ OpExtension "SPV_KHR_non_semantic_info" OpMemoryModel Logical GLSL450 )"; - SinglePassRunAndMatch(text, true); + SinglePassRunAndMatch(text, true); } TEST_F(StripNonSemanticInfoTest, StripNonSemanticGlobal) { @@ -159,7 +157,7 @@ OpMemoryModel Logical GLSL450 %1 = OpExtInst %void %ext 1 )"; - SinglePassRunAndMatch(text, true); + SinglePassRunAndMatch(text, true); } TEST_F(StripNonSemanticInfoTest, StripNonSemanticInFunction) { @@ -179,7 +177,7 @@ OpReturn OpFunctionEnd )"; - SinglePassRunAndMatch(text, true); + SinglePassRunAndMatch(text, true); } TEST_F(StripNonSemanticInfoTest, StripNonSemanticAfterFunction) { @@ -199,7 +197,7 @@ OpFunctionEnd %1 = OpExtInst %void %ext 1 %foo )"; - SinglePassRunAndMatch(text, true); + SinglePassRunAndMatch(text, true); } TEST_F(StripNonSemanticInfoTest, StripNonSemanticBetweenFunctions) { @@ -223,7 +221,74 @@ OpReturn OpFunctionEnd )"; - SinglePassRunAndMatch(text, true); + SinglePassRunAndMatch(text, true); +} + +// Make sure that strip reflect does not remove the debug info (OpString and +// OpLine). +TEST_F(StripNonSemanticInfoTest, DontStripDebug) { + std::string text = R"(OpCapability Shader +OpMemoryModel Logical Simple +OpEntryPoint Fragment %1 "main" +OpExecutionMode %1 OriginUpperLeft +%2 = OpString "file" +%void = OpTypeVoid +%4 = OpTypeFunction %void +%1 = OpFunction %void None %4 +%5 = OpLabel +OpLine %2 1 1 +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndCheck(text, text, false); +} + +TEST_F(StripNonSemanticInfoTest, RemovedNonSemanticDebugInfo) { + const std::string text = R"( +;CHECK-NOT: OpExtension "SPV_KHR_non_semantic_info +;CHECK-NOT: OpExtInstImport "NonSemantic.Shader.DebugInfo.100 +;CHECK-NOT: OpExtInst %void {{%\w+}} DebugSource +;CHECK-NOT: OpExtInst %void {{%\w+}} DebugLine + OpCapability Shader + OpExtension "SPV_KHR_non_semantic_info" + %1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %PSMain "PSMain" %in_var_COLOR %out_var_SV_TARGET + OpExecutionMode %PSMain OriginUpperLeft + %5 = OpString "t.hlsl" + %6 = OpString "float" + %7 = OpString "color" + %8 = OpString "PSInput" + %9 = OpString "PSMain" + %10 = OpString "" + %11 = OpString "input" + OpName %in_var_COLOR "in.var.COLOR" + OpName %out_var_SV_TARGET "out.var.SV_TARGET" + OpName %PSMain "PSMain" + OpDecorate %in_var_COLOR Location 0 + OpDecorate %out_var_SV_TARGET Location 0 + %uint = OpTypeInt 32 0 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Output_v4float = OpTypePointer Output %v4float + %void = OpTypeVoid + %uint_1 = OpConstant %uint 1 + %uint_9 = OpConstant %uint 9 + %21 = OpTypeFunction %void +%in_var_COLOR = OpVariable %_ptr_Input_v4float Input +%out_var_SV_TARGET = OpVariable %_ptr_Output_v4float Output + %13 = OpExtInst %void %1 DebugSource %5 + %PSMain = OpFunction %void None %21 + %22 = OpLabel + %23 = OpLoad %v4float %in_var_COLOR + OpStore %out_var_SV_TARGET %23 + %24 = OpExtInst %void %1 DebugLine %13 %uint_9 %uint_9 %uint_1 %uint_1 + OpReturn + OpFunctionEnd +)"; + SinglePassRunAndMatch(text, true); } } // namespace diff --git a/third_party/spirv-tools/test/opt/type_manager_test.cpp b/third_party/spirv-tools/test/opt/type_manager_test.cpp index fdae2efc40..df216bc92e 100644 --- a/third_party/spirv-tools/test/opt/type_manager_test.cpp +++ b/third_party/spirv-tools/test/opt/type_manager_test.cpp @@ -167,10 +167,25 @@ std::vector> GenerateAllTypes() { types.emplace_back(new NamedBarrier()); types.emplace_back(new AccelerationStructureNV()); types.emplace_back(new CooperativeMatrixNV(f32, 24, 24, 24)); + types.emplace_back(new RayQueryKHR()); return types; } +TEST(TypeManager, GenerateAllTypesGeneratesAllTypes) { + std::set generated_types; + for (auto& type : GenerateAllTypes()) { + generated_types.insert(type->kind()); + } + + std::vector all_types; + for (uint32_t kind = 0; kind != Type::Kind::kLast; ++kind) { + all_types.push_back(static_cast(kind)); + } + + EXPECT_THAT(generated_types, testing::UnorderedElementsAreArray(all_types)); +} + TEST(TypeManager, TypeStrings) { const std::string text = R"( OpDecorate %spec_const_with_id SpecId 99 @@ -1065,6 +1080,7 @@ TEST(TypeManager, GetTypeInstructionAllTypes) { ; CHECK: OpTypeNamedBarrier ; CHECK: OpTypeAccelerationStructureKHR ; CHECK: OpTypeCooperativeMatrixNV [[f32]] [[uint24]] [[uint24]] [[uint24]] +; CHECK: OpTypeRayQueryKHR OpCapability Shader OpCapability Int64 OpCapability Linkage diff --git a/third_party/spirv-tools/test/opt/unify_const_test.cpp b/third_party/spirv-tools/test/opt/unify_const_test.cpp index 6ed2173486..0d7c30b04c 100644 --- a/third_party/spirv-tools/test/opt/unify_const_test.cpp +++ b/third_party/spirv-tools/test/opt/unify_const_test.cpp @@ -263,7 +263,7 @@ TEST_F(UnifyFrontEndConstantSingleTest, UnifyWithDecorationOnTypes) { // decorated flat struct "%flat_d = OpTypeStruct %int %float", "%_pf_flat_d = OpTypePointer Function %flat_d", - // perserved contants. %flat_1 and %flat_d has same members, but + // preserved constants. %flat_1 and %flat_d has same members, but // their type are different in decorations, so they should not be // used to replace each other. "%int_1 = OpConstant %int 1", @@ -682,7 +682,7 @@ INSTANTIATE_TEST_SUITE_P( // zero-valued composite constant built from zero-valued constant // component. inner_zero should not be replace by null_inner. "%inner_zero = OpConstantComposite %inner_struct %bool_zero %float_zero", - // zero-valued composite contant built from zero-valued constants + // zero-valued composite constant built from zero-valued constants // and null constants. "%outer_zero = OpConstantComposite %outer_struct %inner_zero %int_null %double_null", // outer_struct type null constant, it should not be replaced by @@ -820,7 +820,7 @@ INSTANTIATE_TEST_SUITE_P( { "%spec_signed_add_duplicate = OpSpecConstantOp %int IAdd %spec_signed_1 %spec_signed_2", }, - // use duplicated contants in main + // use duplicated constants in main { "%int_var = OpVariable %_pf_int Function", "OpStore %int_var %spec_signed_add_duplicate", diff --git a/third_party/spirv-tools/test/target_env_test.cpp b/third_party/spirv-tools/test/target_env_test.cpp index 4acb8ff295..7917cbfb44 100644 --- a/third_party/spirv-tools/test/target_env_test.cpp +++ b/third_party/spirv-tools/test/target_env_test.cpp @@ -135,7 +135,8 @@ INSTANTIATE_TEST_SUITE_P( {VK(1, 0), SPV(1, 3), true, SPV_ENV_VULKAN_1_1}, {VK(1, 0), SPV(1, 4), true, SPV_ENV_VULKAN_1_1_SPIRV_1_4}, {VK(1, 0), SPV(1, 5), true, SPV_ENV_VULKAN_1_2}, - {VK(1, 0), SPV(1, 6), false, SPV_ENV_UNIVERSAL_1_0}, + {VK(1, 0), SPV(1, 6), true, SPV_ENV_VULKAN_1_3}, + {VK(1, 0), SPV(1, 7), false, SPV_ENV_UNIVERSAL_1_0}, // Vulkan 1.1 cases {VK(1, 1), SPV(1, 0), true, SPV_ENV_VULKAN_1_1}, {VK(1, 1), SPV(1, 1), true, SPV_ENV_VULKAN_1_1}, @@ -143,7 +144,8 @@ INSTANTIATE_TEST_SUITE_P( {VK(1, 1), SPV(1, 3), true, SPV_ENV_VULKAN_1_1}, {VK(1, 1), SPV(1, 4), true, SPV_ENV_VULKAN_1_1_SPIRV_1_4}, {VK(1, 1), SPV(1, 5), true, SPV_ENV_VULKAN_1_2}, - {VK(1, 1), SPV(1, 6), false, SPV_ENV_UNIVERSAL_1_0}, + {VK(1, 1), SPV(1, 6), true, SPV_ENV_VULKAN_1_3}, + {VK(1, 1), SPV(1, 7), false, SPV_ENV_UNIVERSAL_1_0}, // Vulkan 1.2 cases {VK(1, 2), SPV(1, 0), true, SPV_ENV_VULKAN_1_2}, {VK(1, 2), SPV(1, 1), true, SPV_ENV_VULKAN_1_2}, @@ -151,9 +153,17 @@ INSTANTIATE_TEST_SUITE_P( {VK(1, 2), SPV(1, 3), true, SPV_ENV_VULKAN_1_2}, {VK(1, 2), SPV(1, 4), true, SPV_ENV_VULKAN_1_2}, {VK(1, 2), SPV(1, 5), true, SPV_ENV_VULKAN_1_2}, - {VK(1, 2), SPV(1, 6), false, SPV_ENV_UNIVERSAL_1_0}, + {VK(1, 2), SPV(1, 6), true, SPV_ENV_VULKAN_1_3}, + {VK(1, 2), SPV(1, 7), false, SPV_ENV_UNIVERSAL_1_0}, // Vulkan 1.3 cases - {VK(1, 3), SPV(1, 0), false, SPV_ENV_UNIVERSAL_1_0}, + {VK(1, 3), SPV(1, 0), true, SPV_ENV_VULKAN_1_3}, + {VK(1, 3), SPV(1, 1), true, SPV_ENV_VULKAN_1_3}, + {VK(1, 3), SPV(1, 2), true, SPV_ENV_VULKAN_1_3}, + {VK(1, 3), SPV(1, 3), true, SPV_ENV_VULKAN_1_3}, + {VK(1, 3), SPV(1, 4), true, SPV_ENV_VULKAN_1_3}, + {VK(1, 3), SPV(1, 5), true, SPV_ENV_VULKAN_1_3}, + {VK(1, 3), SPV(1, 6), true, SPV_ENV_VULKAN_1_3}, + {VK(1, 3), SPV(1, 7), false, SPV_ENV_UNIVERSAL_1_0}, // Vulkan 2.0 cases {VK(2, 0), SPV(1, 0), false, SPV_ENV_UNIVERSAL_1_0}, // Vulkan 99.0 cases diff --git a/third_party/spirv-tools/test/test_fixture.h b/third_party/spirv-tools/test/test_fixture.h index 0c5bfc9c3b..029fc8543b 100644 --- a/third_party/spirv-tools/test/test_fixture.h +++ b/third_party/spirv-tools/test/test_fixture.h @@ -15,6 +15,7 @@ #ifndef TEST_TEST_FIXTURE_H_ #define TEST_TEST_FIXTURE_H_ +#include #include #include @@ -91,12 +92,26 @@ class TextToBinaryTestBase : public T { return diagnostic->error; } + // Potentially flip the words in the binary representation to the other + // endianness + template + void MaybeFlipWords(bool flip_words, It begin, It end) { + SCOPED_TRACE(flip_words ? "Flipped Endianness" : "Normal Endianness"); + if (flip_words) { + std::transform(begin, end, begin, [](const uint32_t raw_word) { + return spvFixWord(raw_word, I32_ENDIAN_HOST == I32_ENDIAN_BIG + ? SPV_ENDIANNESS_LITTLE + : SPV_ENDIANNESS_BIG); + }); + } + } + // Encodes SPIR-V text into binary and then decodes the binary using // given options. Returns the decoded text. std::string EncodeAndDecodeSuccessfully( const std::string& txt, uint32_t disassemble_options = SPV_BINARY_TO_TEXT_OPTION_NONE, - spv_target_env env = SPV_ENV_UNIVERSAL_1_0) { + spv_target_env env = SPV_ENV_UNIVERSAL_1_0, bool flip_words = false) { DestroyBinary(); DestroyDiagnostic(); ScopedContext context(env); @@ -110,6 +125,8 @@ class TextToBinaryTestBase : public T { EXPECT_EQ(SPV_SUCCESS, error); if (!binary) return ""; + MaybeFlipWords(flip_words, binary->code, binary->code + binary->wordCount); + spv_text decoded_text; error = spvBinaryToText(context.context, binary->code, binary->wordCount, disassemble_options, &decoded_text, &diagnostic); diff --git a/third_party/spirv-tools/test/text_to_binary.annotation_test.cpp b/third_party/spirv-tools/test/text_to_binary.annotation_test.cpp index 61bdf64c8b..76776de94c 100644 --- a/third_party/spirv-tools/test/text_to_binary.annotation_test.cpp +++ b/third_party/spirv-tools/test/text_to_binary.annotation_test.cpp @@ -398,7 +398,8 @@ TEST_F(TextToBinaryTest, GroupMemberDecorateGoodTwoTargets) { TEST_F(TextToBinaryTest, GroupMemberDecorateMissingGroupId) { EXPECT_THAT(CompileFailure("OpGroupMemberDecorate"), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpGroupMemberDecorate instruction, but " + "found the end of the stream.")); } TEST_F(TextToBinaryTest, GroupMemberDecorateInvalidGroupId) { @@ -413,7 +414,8 @@ TEST_F(TextToBinaryTest, GroupMemberDecorateInvalidTargetId) { TEST_F(TextToBinaryTest, GroupMemberDecorateMissingTargetMemberNumber) { EXPECT_THAT(CompileFailure("OpGroupMemberDecorate %group %id0"), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpGroupMemberDecorate instruction, but " + "found the end of the stream.")); } TEST_F(TextToBinaryTest, GroupMemberDecorateInvalidTargetMemberNumber) { @@ -428,7 +430,8 @@ TEST_F(TextToBinaryTest, GroupMemberDecorateInvalidSecondTargetId) { TEST_F(TextToBinaryTest, GroupMemberDecorateMissingSecondTargetMemberNumber) { EXPECT_THAT(CompileFailure("OpGroupMemberDecorate %group %id0 42 %id1"), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpGroupMemberDecorate instruction, but " + "found the end of the stream.")); } TEST_F(TextToBinaryTest, GroupMemberDecorateInvalidSecondTargetMemberNumber) { diff --git a/third_party/spirv-tools/test/text_to_binary.barrier_test.cpp b/third_party/spirv-tools/test/text_to_binary.barrier_test.cpp index 545d26ff29..f1cb4fbe3e 100644 --- a/third_party/spirv-tools/test/text_to_binary.barrier_test.cpp +++ b/third_party/spirv-tools/test/text_to_binary.barrier_test.cpp @@ -44,7 +44,8 @@ TEST_F(OpMemoryBarrier, Good) { TEST_F(OpMemoryBarrier, BadMissingScopeId) { const std::string input = "OpMemoryBarrier\n"; EXPECT_THAT(CompileFailure(input), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpMemoryBarrier instruction, but found " + "the end of the stream.")); } TEST_F(OpMemoryBarrier, BadInvalidScopeId) { @@ -55,7 +56,8 @@ TEST_F(OpMemoryBarrier, BadInvalidScopeId) { TEST_F(OpMemoryBarrier, BadMissingMemorySemanticsId) { const std::string input = "OpMemoryBarrier %scope\n"; EXPECT_THAT(CompileFailure(input), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpMemoryBarrier instruction, but found " + "the end of the stream.")); } TEST_F(OpMemoryBarrier, BadInvalidMemorySemanticsId) { @@ -92,13 +94,16 @@ TEST_F(NamedMemoryBarrierTest, OpcodeAssemblesInV10) { TEST_F(NamedMemoryBarrierTest, ArgumentCount) { EXPECT_THAT(CompileFailure("OpMemoryNamedBarrier", SPV_ENV_UNIVERSAL_1_1), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpMemoryNamedBarrier instruction, but " + "found the end of the stream.")); EXPECT_THAT( CompileFailure("OpMemoryNamedBarrier %bar", SPV_ENV_UNIVERSAL_1_1), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpMemoryNamedBarrier instruction, but found the " + "end of the stream.")); EXPECT_THAT( CompileFailure("OpMemoryNamedBarrier %bar %scope", SPV_ENV_UNIVERSAL_1_1), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpMemoryNamedBarrier instruction, but found the " + "end of the stream.")); EXPECT_THAT( CompiledInstructions("OpMemoryNamedBarrier %bar %scope %semantics", SPV_ENV_UNIVERSAL_1_1), @@ -151,10 +156,12 @@ TEST_F(NamedBarrierInitializeTest, OpcodeAssemblesInV10) { TEST_F(NamedBarrierInitializeTest, ArgumentCount) { EXPECT_THAT( CompileFailure("%bar = OpNamedBarrierInitialize", SPV_ENV_UNIVERSAL_1_1), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpNamedBarrierInitialize instruction, but found " + "the end of the stream.")); EXPECT_THAT(CompileFailure("%bar = OpNamedBarrierInitialize %ype", SPV_ENV_UNIVERSAL_1_1), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpNamedBarrierInitialize instruction, " + "but found the end of the stream.")); EXPECT_THAT( CompiledInstructions("%bar = OpNamedBarrierInitialize %type %count", SPV_ENV_UNIVERSAL_1_1), diff --git a/third_party/spirv-tools/test/text_to_binary.control_flow_test.cpp b/third_party/spirv-tools/test/text_to_binary.control_flow_test.cpp index 3e117b8f11..472cb6dac8 100644 --- a/third_party/spirv-tools/test/text_to_binary.control_flow_test.cpp +++ b/third_party/spirv-tools/test/text_to_binary.control_flow_test.cpp @@ -163,7 +163,8 @@ TEST_F(TextToBinaryTest, SwitchGoodTwoTargets) { TEST_F(TextToBinaryTest, SwitchBadMissingSelector) { EXPECT_THAT(CompileFailure("OpSwitch"), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpSwitch instruction, but found the end " + "of the stream.")); } TEST_F(TextToBinaryTest, SwitchBadInvalidSelector) { @@ -173,7 +174,8 @@ TEST_F(TextToBinaryTest, SwitchBadInvalidSelector) { TEST_F(TextToBinaryTest, SwitchBadMissingDefault) { EXPECT_THAT(CompileFailure("OpSwitch %selector"), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpSwitch instruction, but found the end " + "of the stream.")); } TEST_F(TextToBinaryTest, SwitchBadInvalidDefault) { @@ -195,7 +197,8 @@ TEST_F(TextToBinaryTest, SwitchBadMissingTarget) { EXPECT_THAT(CompileFailure("%1 = OpTypeInt 32 0\n" "%2 = OpConstant %1 52\n" "OpSwitch %2 %default 12"), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpSwitch instruction, but found the end " + "of the stream.")); } // A test case for an OpSwitch. @@ -379,7 +382,7 @@ INSTANTIATE_TEST_SUITE_P( "OpTypeQueue", "OpTypePipe ReadOnly", - // Skip OpTypeForwardPointer becasuse it doesn't even produce a result + // Skip OpTypeForwardPointer because it doesn't even produce a result // ID. // At least one thing that isn't a type at all diff --git a/third_party/spirv-tools/test/text_to_binary.device_side_enqueue_test.cpp b/third_party/spirv-tools/test/text_to_binary.device_side_enqueue_test.cpp index 03d7e7419f..2f4dd7057f 100644 --- a/third_party/spirv-tools/test/text_to_binary.device_side_enqueue_test.cpp +++ b/third_party/spirv-tools/test/text_to_binary.device_side_enqueue_test.cpp @@ -83,7 +83,8 @@ TEST_F(OpKernelEnqueueBad, MissingLastOperand) { CompileFailure( "%result = OpEnqueueKernel %type %queue %flags %NDRange %num_events" " %wait_events %ret_event %invoke %param %param_size"), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpEnqueueKernel instruction, but found the end " + "of the stream.")); } TEST_F(OpKernelEnqueueBad, InvalidLastOperand) { diff --git a/third_party/spirv-tools/test/text_to_binary.extension_test.cpp b/third_party/spirv-tools/test/text_to_binary.extension_test.cpp index 1324206c79..cf4919acca 100644 --- a/third_party/spirv-tools/test/text_to_binary.extension_test.cpp +++ b/third_party/spirv-tools/test/text_to_binary.extension_test.cpp @@ -197,7 +197,7 @@ INSTANTIATE_TEST_SUITE_P( SpvBuiltInSubgroupLtMask})}, }))); -// The old builtin names (with KHR suffix) still work in the assmebler, and +// The old builtin names (with KHR suffix) still work in the assembler, and // map to the enums without the KHR. INSTANTIATE_TEST_SUITE_P( SPV_KHR_shader_ballot_vulkan_1_1_alias_check, ExtensionAssemblyTest, @@ -957,61 +957,62 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( SPV_KHR_integer_dot_product, ExtensionRoundTripTest, Combine( - Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_0, - SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2), + Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_5, + SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1, + SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_3), ValuesIn(std::vector{ {"OpExtension \"SPV_KHR_integer_dot_product\"\n", MakeInstruction(SpvOpExtension, MakeVector("SPV_KHR_integer_dot_product"))}, - {"OpCapability DotProductInputAllKHR\n", + {"OpCapability DotProductInputAll\n", MakeInstruction(SpvOpCapability, {SpvCapabilityDotProductInputAllKHR})}, - {"OpCapability DotProductInput4x8BitKHR\n", + {"OpCapability DotProductInput4x8Bit\n", MakeInstruction(SpvOpCapability, {SpvCapabilityDotProductInput4x8BitKHR})}, - {"OpCapability DotProductInput4x8BitPackedKHR\n", + {"OpCapability DotProductInput4x8BitPacked\n", MakeInstruction(SpvOpCapability, {SpvCapabilityDotProductInput4x8BitPackedKHR})}, - {"OpCapability DotProductKHR\n", + {"OpCapability DotProduct\n", MakeInstruction(SpvOpCapability, {SpvCapabilityDotProductKHR})}, - {"%2 = OpSDotKHR %1 %3 %4\n", + {"%2 = OpSDot %1 %3 %4\n", MakeInstruction(SpvOpSDotKHR, {1, 2, 3, 4})}, - {"%2 = OpSDotKHR %1 %3 %4 PackedVectorFormat4x8BitKHR\n", + {"%2 = OpSDot %1 %3 %4 PackedVectorFormat4x8Bit\n", MakeInstruction( SpvOpSDotKHR, {1, 2, 3, 4, SpvPackedVectorFormatPackedVectorFormat4x8BitKHR})}, - {"%2 = OpUDotKHR %1 %3 %4\n", + {"%2 = OpUDot %1 %3 %4\n", MakeInstruction(SpvOpUDotKHR, {1, 2, 3, 4})}, - {"%2 = OpUDotKHR %1 %3 %4 PackedVectorFormat4x8BitKHR\n", + {"%2 = OpUDot %1 %3 %4 PackedVectorFormat4x8Bit\n", MakeInstruction( SpvOpUDotKHR, {1, 2, 3, 4, SpvPackedVectorFormatPackedVectorFormat4x8BitKHR})}, - {"%2 = OpSUDotKHR %1 %3 %4\n", + {"%2 = OpSUDot %1 %3 %4\n", MakeInstruction(SpvOpSUDotKHR, {1, 2, 3, 4})}, - {"%2 = OpSUDotKHR %1 %3 %4 PackedVectorFormat4x8BitKHR\n", + {"%2 = OpSUDot %1 %3 %4 PackedVectorFormat4x8Bit\n", MakeInstruction( SpvOpSUDotKHR, {1, 2, 3, 4, SpvPackedVectorFormatPackedVectorFormat4x8BitKHR})}, - {"%2 = OpSDotAccSatKHR %1 %3 %4 %5\n", + {"%2 = OpSDotAccSat %1 %3 %4 %5\n", MakeInstruction(SpvOpSDotAccSatKHR, {1, 2, 3, 4, 5})}, - {"%2 = OpSDotAccSatKHR %1 %3 %4 %5 PackedVectorFormat4x8BitKHR\n", + {"%2 = OpSDotAccSat %1 %3 %4 %5 PackedVectorFormat4x8Bit\n", MakeInstruction( SpvOpSDotAccSatKHR, {1, 2, 3, 4, 5, SpvPackedVectorFormatPackedVectorFormat4x8BitKHR})}, - {"%2 = OpUDotAccSatKHR %1 %3 %4 %5\n", + {"%2 = OpUDotAccSat %1 %3 %4 %5\n", MakeInstruction(SpvOpUDotAccSatKHR, {1, 2, 3, 4, 5})}, - {"%2 = OpUDotAccSatKHR %1 %3 %4 %5 PackedVectorFormat4x8BitKHR\n", + {"%2 = OpUDotAccSat %1 %3 %4 %5 PackedVectorFormat4x8Bit\n", MakeInstruction( SpvOpUDotAccSatKHR, {1, 2, 3, 4, 5, SpvPackedVectorFormatPackedVectorFormat4x8BitKHR})}, - {"%2 = OpSUDotAccSatKHR %1 %3 %4 %5\n", + {"%2 = OpSUDotAccSat %1 %3 %4 %5\n", MakeInstruction(SpvOpSUDotAccSatKHR, {1, 2, 3, 4, 5})}, - {"%2 = OpSUDotAccSatKHR %1 %3 %4 %5 PackedVectorFormat4x8BitKHR\n", + {"%2 = OpSUDotAccSat %1 %3 %4 %5 PackedVectorFormat4x8Bit\n", MakeInstruction( SpvOpSUDotAccSatKHR, {1, 2, 3, 4, 5, @@ -1033,5 +1034,68 @@ INSTANTIATE_TEST_SUITE_P( {SpvCapabilityBitInstructions})}, }))); +// SPV_KHR_uniform_group_instructions + +INSTANTIATE_TEST_SUITE_P( + SPV_KHR_uniform_group_instructions, ExtensionRoundTripTest, + Combine( + Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_5, + SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1, + SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_3), + ValuesIn(std::vector{ + {"OpExtension \"SPV_KHR_uniform_group_instructions\"\n", + MakeInstruction(SpvOpExtension, + MakeVector("SPV_KHR_uniform_group_instructions"))}, + {"OpCapability GroupUniformArithmeticKHR\n", + MakeInstruction(SpvOpCapability, + {SpvCapabilityGroupUniformArithmeticKHR})}, + {"%2 = OpGroupIMulKHR %1 %3 Reduce %4\n", + MakeInstruction(SpvOpGroupIMulKHR, + {1, 2, 3, SpvGroupOperationReduce, 4})}, + {"%2 = OpGroupFMulKHR %1 %3 Reduce %4\n", + MakeInstruction(SpvOpGroupFMulKHR, + {1, 2, 3, SpvGroupOperationReduce, 4})}, + {"%2 = OpGroupBitwiseAndKHR %1 %3 Reduce %4\n", + MakeInstruction(SpvOpGroupBitwiseAndKHR, + {1, 2, 3, SpvGroupOperationReduce, 4})}, + {"%2 = OpGroupBitwiseOrKHR %1 %3 Reduce %4\n", + MakeInstruction(SpvOpGroupBitwiseOrKHR, + {1, 2, 3, SpvGroupOperationReduce, 4})}, + {"%2 = OpGroupBitwiseXorKHR %1 %3 Reduce %4\n", + MakeInstruction(SpvOpGroupBitwiseXorKHR, + {1, 2, 3, SpvGroupOperationReduce, 4})}, + {"%2 = OpGroupLogicalAndKHR %1 %3 Reduce %4\n", + MakeInstruction(SpvOpGroupLogicalAndKHR, + {1, 2, 3, SpvGroupOperationReduce, 4})}, + {"%2 = OpGroupLogicalOrKHR %1 %3 Reduce %4\n", + MakeInstruction(SpvOpGroupLogicalOrKHR, + {1, 2, 3, SpvGroupOperationReduce, 4})}, + {"%2 = OpGroupLogicalXorKHR %1 %3 Reduce %4\n", + MakeInstruction(SpvOpGroupLogicalXorKHR, + {1, 2, 3, SpvGroupOperationReduce, 4})}, + }))); + +// SPV_KHR_subgroup_rotate + +INSTANTIATE_TEST_SUITE_P( + SPV_KHR_subgroup_rotate, ExtensionRoundTripTest, + Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_6, + SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2, + SPV_ENV_VULKAN_1_3, SPV_ENV_OPENCL_2_1), + ValuesIn(std::vector{ + {"OpExtension \"SPV_KHR_subgroup_rotate\"\n", + MakeInstruction(SpvOpExtension, + MakeVector("SPV_KHR_subgroup_rotate"))}, + {"OpCapability GroupNonUniformRotateKHR\n", + MakeInstruction(SpvOpCapability, + {SpvCapabilityGroupNonUniformRotateKHR})}, + {"%2 = OpGroupNonUniformRotateKHR %1 %3 %4 %5\n", + MakeInstruction(SpvOpGroupNonUniformRotateKHR, + {1, 2, 3, 4, 5})}, + {"%2 = OpGroupNonUniformRotateKHR %1 %3 %4 %5 %6\n", + MakeInstruction(SpvOpGroupNonUniformRotateKHR, + {1, 2, 3, 4, 5, 6})}, + }))); + } // namespace } // namespace spvtools diff --git a/third_party/spirv-tools/test/text_to_binary.image_test.cpp b/third_party/spirv-tools/test/text_to_binary.image_test.cpp index d445369c2b..8d8ff43284 100644 --- a/third_party/spirv-tools/test/text_to_binary.image_test.cpp +++ b/third_party/spirv-tools/test/text_to_binary.image_test.cpp @@ -123,7 +123,8 @@ TEST_F(OpImageTest, InvalidTypeOperand) { TEST_F(OpImageTest, MissingSampledImageOperand) { EXPECT_THAT(CompileFailure("%2 = OpImage %1"), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpImage instruction, but found the end " + "of the stream.")); } TEST_F(OpImageTest, InvalidSampledImageOperand) { @@ -222,7 +223,8 @@ TEST_F(OpImageSparseReadTest, InvalidTypeOperand) { TEST_F(OpImageSparseReadTest, MissingImageOperand) { EXPECT_THAT(CompileFailure("%2 = OpImageSparseRead %1"), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpImageSparseRead instruction, but " + "found the end of the stream.")); } TEST_F(OpImageSparseReadTest, InvalidImageOperand) { @@ -232,7 +234,8 @@ TEST_F(OpImageSparseReadTest, InvalidImageOperand) { TEST_F(OpImageSparseReadTest, MissingCoordinateOperand) { EXPECT_THAT(CompileFailure("%2 = OpImageSparseRead %1 %2"), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpImageSparseRead instruction, but " + "found the end of the stream.")); } TEST_F(OpImageSparseReadTest, InvalidCoordinateOperand) { diff --git a/third_party/spirv-tools/test/text_to_binary.memory_test.cpp b/third_party/spirv-tools/test/text_to_binary.memory_test.cpp index 7b09ed5877..f94c134a0b 100644 --- a/third_party/spirv-tools/test/text_to_binary.memory_test.cpp +++ b/third_party/spirv-tools/test/text_to_binary.memory_test.cpp @@ -166,7 +166,8 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryNoMemAccessGood) { TEST_F(MemoryRoundTripTest, OpCopyMemoryTooFewArgsBad) { std::string spirv = "OpCopyMemory %1\n"; std::string err = CompileFailure(spirv); - EXPECT_THAT(err, HasSubstr("Expected operand, found end of stream")); + EXPECT_THAT(err, HasSubstr("Expected operand for OpCopyMemory instruction, " + "but found the end of the stream.")); } TEST_F(MemoryRoundTripTest, OpCopyMemoryTooManyArgsBad) { @@ -295,7 +296,8 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedNoMemAccessGood) { TEST_F(MemoryRoundTripTest, OpCopyMemorySizedTooFewArgsBad) { std::string spirv = "OpCopyMemorySized %1 %2\n"; std::string err = CompileFailure(spirv); - EXPECT_THAT(err, HasSubstr("Expected operand, found end of stream")); + EXPECT_THAT(err, HasSubstr("Expected operand for OpCopyMemorySized " + "instruction, but found the end of the stream.")); } TEST_F(MemoryRoundTripTest, OpCopyMemorySizedTooManyArgsBad) { diff --git a/third_party/spirv-tools/test/text_to_binary.mode_setting_test.cpp b/third_party/spirv-tools/test/text_to_binary.mode_setting_test.cpp index 647bb3d933..7f15c8b4fa 100644 --- a/third_party/spirv-tools/test/text_to_binary.mode_setting_test.cpp +++ b/third_party/spirv-tools/test/text_to_binary.mode_setting_test.cpp @@ -290,7 +290,8 @@ using TextToBinaryCapability = spvtest::TextToBinaryTest; TEST_F(TextToBinaryCapability, BadMissingCapability) { EXPECT_THAT(CompileFailure("OpCapability"), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpCapability instruction, but found the " + "end of the stream.")); } TEST_F(TextToBinaryCapability, BadInvalidCapability) { diff --git a/third_party/spirv-tools/test/text_to_binary.pipe_storage_test.cpp b/third_party/spirv-tools/test/text_to_binary.pipe_storage_test.cpp index f74dbcfdfe..955f5ef803 100644 --- a/third_party/spirv-tools/test/text_to_binary.pipe_storage_test.cpp +++ b/third_party/spirv-tools/test/text_to_binary.pipe_storage_test.cpp @@ -59,10 +59,12 @@ TEST_F(OpConstantPipeStorageTest, ArgumentCount) { "'OpConstantPipeStorage'.")); EXPECT_THAT( CompileFailure("%1 = OpConstantPipeStorage", SPV_ENV_UNIVERSAL_1_1), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpConstantPipeStorage instruction, but found " + "the end of the stream.")); EXPECT_THAT(CompileFailure("%1 = OpConstantPipeStorage %2 3 4", SPV_ENV_UNIVERSAL_1_1), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpConstantPipeStorage instruction, but " + "found the end of the stream.")); EXPECT_THAT(CompiledInstructions("%1 = OpConstantPipeStorage %2 3 4 5", SPV_ENV_UNIVERSAL_1_1), Eq(MakeInstruction(SpvOpConstantPipeStorage, {1, 2, 3, 4, 5}))); @@ -101,10 +103,12 @@ TEST_F(OpCreatePipeFromPipeStorageTest, ArgumentCount) { "'OpCreatePipeFromPipeStorage'.")); EXPECT_THAT( CompileFailure("%1 = OpCreatePipeFromPipeStorage", SPV_ENV_UNIVERSAL_1_1), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpCreatePipeFromPipeStorage instruction, but " + "found the end of the stream.")); EXPECT_THAT(CompileFailure("%1 = OpCreatePipeFromPipeStorage %2 OpNop", SPV_ENV_UNIVERSAL_1_1), - Eq("Expected operand, found next instruction instead.")); + Eq("Expected operand for OpCreatePipeFromPipeStorage " + "instruction, but found the next instruction instead.")); EXPECT_THAT(CompiledInstructions("%1 = OpCreatePipeFromPipeStorage %2 %3", SPV_ENV_UNIVERSAL_1_1), Eq(MakeInstruction(SpvOpCreatePipeFromPipeStorage, {1, 2, 3}))); diff --git a/third_party/spirv-tools/test/text_to_binary.subgroup_dispatch_test.cpp b/third_party/spirv-tools/test/text_to_binary.subgroup_dispatch_test.cpp index 967e3c38b1..8c40445776 100644 --- a/third_party/spirv-tools/test/text_to_binary.subgroup_dispatch_test.cpp +++ b/third_party/spirv-tools/test/text_to_binary.subgroup_dispatch_test.cpp @@ -46,11 +46,13 @@ TEST_F(OpGetKernelLocalSizeForSubgroupCountTest, ArgumentCount) { "found 'OpGetKernelLocalSizeForSubgroupCount'.")); EXPECT_THAT(CompileFailure("%res = OpGetKernelLocalSizeForSubgroupCount", SPV_ENV_UNIVERSAL_1_1), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpGetKernelLocalSizeForSubgroupCount " + "instruction, but found the end of the stream.")); EXPECT_THAT( CompileFailure("%1 = OpGetKernelLocalSizeForSubgroupCount %2 %3 %4 %5 %6", SPV_ENV_UNIVERSAL_1_1), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpGetKernelLocalSizeForSubgroupCount " + "instruction, but found the end of the stream.")); EXPECT_THAT( CompiledInstructions("%res = OpGetKernelLocalSizeForSubgroupCount %type " "%sgcount %invoke %param %param_size %param_align", @@ -93,10 +95,12 @@ TEST_F(OpGetKernelMaxNumSubgroupsTest, ArgumentCount) { "'OpGetKernelMaxNumSubgroups'.")); EXPECT_THAT(CompileFailure("%res = OpGetKernelMaxNumSubgroups", SPV_ENV_UNIVERSAL_1_1), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpGetKernelMaxNumSubgroups instruction, " + "but found the end of the stream.")); EXPECT_THAT(CompileFailure("%1 = OpGetKernelMaxNumSubgroups %2 %3 %4 %5", SPV_ENV_UNIVERSAL_1_1), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpGetKernelMaxNumSubgroups instruction, " + "but found the end of the stream.")); EXPECT_THAT( CompiledInstructions("%res = OpGetKernelMaxNumSubgroups %type " "%invoke %param %param_size %param_align", diff --git a/third_party/spirv-tools/test/text_to_binary.type_declaration_test.cpp b/third_party/spirv-tools/test/text_to_binary.type_declaration_test.cpp index 1589188fda..65a23554a4 100644 --- a/third_party/spirv-tools/test/text_to_binary.type_declaration_test.cpp +++ b/third_party/spirv-tools/test/text_to_binary.type_declaration_test.cpp @@ -223,12 +223,14 @@ TEST_F(OpTypeForwardPointerTest, ValidStorageClass) { TEST_F(OpTypeForwardPointerTest, MissingType) { EXPECT_THAT(CompileFailure("OpTypeForwardPointer"), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpTypeForwardPointer instruction, but " + "found the end of the stream.")); } TEST_F(OpTypeForwardPointerTest, MissingClass) { EXPECT_THAT(CompileFailure("OpTypeForwardPointer %pt"), - Eq("Expected operand, found end of stream.")); + Eq("Expected operand for OpTypeForwardPointer instruction, but " + "found the end of the stream.")); } TEST_F(OpTypeForwardPointerTest, WrongClass) { @@ -252,7 +254,8 @@ TEST_F(OpSizeOfTest, ArgumentCount) { Eq("Expected at the beginning of an instruction, found " "'OpSizeOf'.")); EXPECT_THAT(CompileFailure("%res = OpSizeOf OpNop", SPV_ENV_UNIVERSAL_1_1), - Eq("Expected operand, found next instruction instead.")); + Eq("Expected operand for OpSizeOf instruction, but found the " + "next instruction instead.")); EXPECT_THAT( CompiledInstructions("%1 = OpSizeOf %2 %3", SPV_ENV_UNIVERSAL_1_1), Eq(MakeInstruction(SpvOpSizeOf, {1, 2, 3}))); diff --git a/third_party/spirv-tools/test/text_to_binary_test.cpp b/third_party/spirv-tools/test/text_to_binary_test.cpp index 99d9ed6869..0b348e87b1 100644 --- a/third_party/spirv-tools/test/text_to_binary_test.cpp +++ b/third_party/spirv-tools/test/text_to_binary_test.cpp @@ -65,7 +65,7 @@ INSTANTIATE_TEST_SUITE_P( {SPV_OPERAND_TYPE_FP_FAST_MATH_MODE, 1, "NotNaN"}, {SPV_OPERAND_TYPE_FP_FAST_MATH_MODE, 2, "NotInf"}, {SPV_OPERAND_TYPE_FP_FAST_MATH_MODE, 3, "NotNaN|NotInf"}, - // Mask experssions are symmetric. + // Mask expressions are symmetric. {SPV_OPERAND_TYPE_FP_FAST_MATH_MODE, 3, "NotInf|NotNaN"}, // Repeating a value has no effect. {SPV_OPERAND_TYPE_FP_FAST_MATH_MODE, 3, "NotInf|NotNaN|NotInf"}, diff --git a/third_party/spirv-tools/test/tools/expect.py b/third_party/spirv-tools/test/tools/expect.py index 0b51adc9c2..7351c02951 100755 --- a/third_party/spirv-tools/test/tools/expect.py +++ b/third_party/spirv-tools/test/tools/expect.py @@ -285,6 +285,21 @@ class ValidObjectFile1_5(ReturnCodeIsZero, CorrectObjectFilePreamble): return True, '' +class ValidObjectFile1_6(ReturnCodeIsZero, CorrectObjectFilePreamble): + """Mixin class for checking that every input file generates a valid SPIR-V 1.6 + object file following the object file naming rule, and there is no output on + stdout/stderr.""" + + def check_object_file_preamble(self, status): + for input_filename in status.input_filenames: + object_filename = get_object_filename(input_filename) + success, message = self.verify_object_file_preamble( + os.path.join(status.directory, object_filename), 0x10600) + if not success: + return False, message + return True, '' + + class ValidObjectFileWithAssemblySubstr(SuccessfulReturn, CorrectObjectFilePreamble): """Mixin class for checking that every input file generates a valid object diff --git a/third_party/spirv-tools/test/tools/opt/flags.py b/third_party/spirv-tools/test/tools/opt/flags.py index c79f68073f..52a43c51af 100644 --- a/third_party/spirv-tools/test/tools/opt/flags.py +++ b/third_party/spirv-tools/test/tools/opt/flags.py @@ -34,7 +34,7 @@ def empty_main_assembly(): @inside_spirv_testsuite('SpirvOptBase') -class TestAssemblyFileAsOnlyParameter(expect.ValidObjectFile1_5): +class TestAssemblyFileAsOnlyParameter(expect.ValidObjectFile1_6): """Tests that spirv-opt accepts a SPIR-V object file.""" shader = placeholder.FileSPIRVShader(empty_main_assembly(), '.spvasm') @@ -52,7 +52,7 @@ class TestHelpFlag(expect.ReturnCodeIsZero, expect.StdoutMatch): @inside_spirv_testsuite('SpirvOptFlags') -class TestValidPassFlags(expect.ValidObjectFile1_5, +class TestValidPassFlags(expect.ValidObjectFile1_6, expect.ExecutedListOfPasses): """Tests that spirv-opt accepts all valid optimization flags.""" @@ -72,7 +72,7 @@ class TestValidPassFlags(expect.ValidObjectFile1_5, '--private-to-local', '--reduce-load-size', '--redundancy-elimination', '--remove-duplicates', '--replace-invalid-opcode', '--ssa-rewrite', '--scalar-replacement', '--scalar-replacement=42', '--strength-reduction', - '--strip-debug', '--strip-reflect', '--vector-dce', '--workaround-1209', + '--strip-debug', '--strip-nonsemantic', '--vector-dce', '--workaround-1209', '--unify-const', '--graphics-robust-access', '--wrap-opkill', '--amd-ext-to-khr' ] expected_passes = [ @@ -117,7 +117,7 @@ class TestValidPassFlags(expect.ValidObjectFile1_5, 'scalar-replacement=42', 'strength-reduction', 'strip-debug', - 'strip-reflect', + 'strip-nonsemantic', 'vector-dce', 'workaround-1209', 'unify-const', @@ -132,7 +132,7 @@ class TestValidPassFlags(expect.ValidObjectFile1_5, @inside_spirv_testsuite('SpirvOptFlags') -class TestPerformanceOptimizationPasses(expect.ValidObjectFile1_5, +class TestPerformanceOptimizationPasses(expect.ValidObjectFile1_6, expect.ExecutedListOfPasses): """Tests that spirv-opt schedules all the passes triggered by -O.""" @@ -190,7 +190,7 @@ class TestPerformanceOptimizationPasses(expect.ValidObjectFile1_5, @inside_spirv_testsuite('SpirvOptFlags') -class TestSizeOptimizationPasses(expect.ValidObjectFile1_5, +class TestSizeOptimizationPasses(expect.ValidObjectFile1_6, expect.ExecutedListOfPasses): """Tests that spirv-opt schedules all the passes triggered by -Os.""" @@ -237,7 +237,7 @@ class TestSizeOptimizationPasses(expect.ValidObjectFile1_5, @inside_spirv_testsuite('SpirvOptFlags') -class TestLegalizationPasses(expect.ValidObjectFile1_5, +class TestLegalizationPasses(expect.ValidObjectFile1_6, expect.ExecutedListOfPasses): """Tests that spirv-opt schedules all the passes triggered by --legalize-hlsl. """ diff --git a/third_party/spirv-tools/test/util/CMakeLists.txt b/third_party/spirv-tools/test/util/CMakeLists.txt index 6679dba7c6..68087836c4 100644 --- a/third_party/spirv-tools/test/util/CMakeLists.txt +++ b/third_party/spirv-tools/test/util/CMakeLists.txt @@ -16,6 +16,8 @@ add_spvtools_unittest(TARGET utils SRCS ilist_test.cpp bit_vector_test.cpp bitutils_test.cpp + hash_combine_test.cpp + pooled_linked_list_test.cpp small_vector_test.cpp LIBS SPIRV-Tools-opt ) diff --git a/third_party/spirv-tools/test/util/hash_combine_test.cpp b/third_party/spirv-tools/test/util/hash_combine_test.cpp new file mode 100644 index 0000000000..9cd1d870a8 --- /dev/null +++ b/third_party/spirv-tools/test/util/hash_combine_test.cpp @@ -0,0 +1,43 @@ +// Copyright (c) 2022 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include + +#include "gmock/gmock.h" +#include "source/util/hash_combine.h" + +namespace spvtools { +namespace utils { +namespace { + +using HashCombineTest = ::testing::Test; + +TEST(HashCombineTest, Identity) { EXPECT_EQ(hash_combine(0), 0); } + +TEST(HashCombineTest, Variadic) { + // Expect manual and variadic template versions be the same. + EXPECT_EQ(hash_combine(hash_combine(hash_combine(0, 1), 2), 3), + hash_combine(0, 1, 2, 3)); +} + +TEST(HashCombineTest, Vector) { + // Expect variadic and vector versions be the same. + EXPECT_EQ(hash_combine(0, std::vector({1, 2, 3})), + hash_combine(0, 1, 2, 3)); +} + +} // namespace +} // namespace utils +} // namespace spvtools diff --git a/third_party/spirv-tools/test/util/pooled_linked_list_test.cpp b/third_party/spirv-tools/test/util/pooled_linked_list_test.cpp new file mode 100644 index 0000000000..82fb4acb7e --- /dev/null +++ b/third_party/spirv-tools/test/util/pooled_linked_list_test.cpp @@ -0,0 +1,185 @@ +// Copyright (c) 2021 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include +#include + +#include "gmock/gmock.h" +#include "source/util/pooled_linked_list.h" + +namespace spvtools { +namespace utils { +namespace { + +using PooledLinkedListTest = ::testing::Test; + +template +static std::vector ToVector(const PooledLinkedList& list) { + std::vector vec; + for (auto it = list.begin(); it != list.end(); ++it) { + vec.push_back(*it); + } + return vec; +} + +template +static void AppendVector(PooledLinkedList& list, const std::vector& vec) { + for (const T& t : vec) { + list.push_back(t); + } +} + +TEST(PooledLinkedListTest, Empty) { + PooledLinkedListNodes pool; + PooledLinkedList ll(&pool); + EXPECT_TRUE(ll.empty()); + + ll.push_back(1u); + EXPECT_TRUE(!ll.empty()); +} + +TEST(PooledLinkedListTest, Iterator) { + PooledLinkedListNodes pool; + PooledLinkedList ll(&pool); + + EXPECT_EQ(ll.begin(), ll.end()); + + ll.push_back(1); + EXPECT_NE(ll.begin(), ll.end()); + + auto it = ll.begin(); + EXPECT_EQ(*it, 1); + ++it; + EXPECT_EQ(it, ll.end()); +} + +TEST(PooledLinkedListTest, Iterator_algorithms) { + PooledLinkedListNodes pool; + PooledLinkedList ll(&pool); + + AppendVector(ll, {3, 2, 0, 1}); + EXPECT_EQ(std::distance(ll.begin(), ll.end()), 4); + EXPECT_EQ(*std::min_element(ll.begin(), ll.end()), 0); + EXPECT_EQ(*std::max_element(ll.begin(), ll.end()), 3); +} + +TEST(PooledLinkedListTest, FrontBack) { + PooledLinkedListNodes pool; + PooledLinkedList ll(&pool); + + ll.push_back(1); + EXPECT_EQ(ll.front(), 1); + EXPECT_EQ(ll.back(), 1); + + ll.push_back(2); + EXPECT_EQ(ll.front(), 1); + EXPECT_EQ(ll.back(), 2); +} + +TEST(PooledLinkedListTest, PushBack) { + const std::vector vec = {1, 2, 3, 4, 5, 6}; + + PooledLinkedListNodes pool; + PooledLinkedList ll(&pool); + + AppendVector(ll, vec); + EXPECT_EQ(vec, ToVector(ll)); +} + +TEST(PooledLinkedListTest, RemoveFirst) { + const std::vector vec = {1, 2, 3, 4, 5, 6}; + + PooledLinkedListNodes pool; + PooledLinkedList ll(&pool); + + EXPECT_FALSE(ll.remove_first(0)); + AppendVector(ll, vec); + EXPECT_FALSE(ll.remove_first(0)); + + std::vector tmp = vec; + while (!tmp.empty()) { + size_t mid = tmp.size() / 2; + uint32_t elt = tmp[mid]; + tmp.erase(tmp.begin() + mid); + + EXPECT_TRUE(ll.remove_first(elt)); + EXPECT_FALSE(ll.remove_first(elt)); + EXPECT_EQ(tmp, ToVector(ll)); + } + EXPECT_TRUE(ll.empty()); +} + +TEST(PooledLinkedListTest, RemoveFirst_Duplicates) { + const std::vector vec = {3, 1, 2, 3, 3, 3, 3, 4, 3, 5, 3, 6, 3}; + + PooledLinkedListNodes pool; + PooledLinkedList ll(&pool); + AppendVector(ll, vec); + + std::vector tmp = vec; + while (!tmp.empty()) { + size_t mid = tmp.size() / 2; + uint32_t elt = tmp[mid]; + tmp.erase(std::find(tmp.begin(), tmp.end(), elt)); + + EXPECT_TRUE(ll.remove_first(elt)); + EXPECT_EQ(tmp, ToVector(ll)); + } + EXPECT_TRUE(ll.empty()); +} + +TEST(PooledLinkedList, MoveTo) { + const std::vector vec = {1, 2, 3, 4, 5, 6}; + + PooledLinkedListNodes pool; + PooledLinkedList ll1(&pool); + PooledLinkedList ll2(&pool); + PooledLinkedList ll3(&pool); + + AppendVector(ll1, vec); + AppendVector(ll2, vec); + AppendVector(ll3, vec); + EXPECT_EQ(pool.total_nodes(), vec.size() * 3); + EXPECT_EQ(pool.total_nodes(), vec.size() * 3); + EXPECT_EQ(pool.free_nodes(), 0); + + // Move two lists to the new pool + PooledLinkedListNodes pool_new; + ll1.move_nodes(&pool_new); + ll2.move_nodes(&pool_new); + + // Moved nodes should belong to new pool + EXPECT_EQ(ll1.pool(), &pool_new); + EXPECT_EQ(ll2.pool(), &pool_new); + + // Old pool should be smaller & have free nodes. + EXPECT_EQ(pool.used_nodes(), vec.size()); + EXPECT_EQ(pool.free_nodes(), vec.size() * 2); + + // New pool should be sized exactly and no free nodes. + EXPECT_EQ(pool_new.total_nodes(), vec.size() * 2); + EXPECT_EQ(pool_new.used_nodes(), vec.size() * 2); + EXPECT_EQ(pool_new.free_nodes(), 0); + + // All lists should be preserved + EXPECT_EQ(ToVector(ll1), vec); + EXPECT_EQ(ToVector(ll2), vec); + EXPECT_EQ(ToVector(ll3), vec); +} + +} // namespace +} // namespace utils +} // namespace spvtools diff --git a/third_party/spirv-tools/test/util/small_vector_test.cpp b/third_party/spirv-tools/test/util/small_vector_test.cpp index 01d7df1857..b8f068ebaa 100644 --- a/third_party/spirv-tools/test/util/small_vector_test.cpp +++ b/third_party/spirv-tools/test/util/small_vector_test.cpp @@ -56,6 +56,18 @@ TEST(SmallVectorTest, Initialize_list2) { } } +TEST(SmallVectorTest, Initialize_list3) { + std::vector result = {0, 1, 2, 3}; + SmallVector vec(result.begin(), result.end()); + + EXPECT_FALSE(vec.empty()); + EXPECT_EQ(vec.size(), 4); + + for (uint32_t i = 0; i < vec.size(); ++i) { + EXPECT_EQ(vec[i], result[i]); + } +} + TEST(SmallVectorTest, Initialize_copy1) { SmallVector vec1 = {0, 1, 2, 3}; SmallVector vec2(vec1); @@ -593,6 +605,68 @@ TEST(SmallVectorTest, Resize6) { EXPECT_EQ(vec, result); } +TEST(SmallVectorTest, Pop_back) { + SmallVector vec = {0, 1, 2, 10, 10, 10}; + SmallVector result = {0, 1, 2}; + + EXPECT_EQ(vec.size(), 6); + vec.pop_back(); + vec.pop_back(); + vec.pop_back(); + EXPECT_EQ(vec.size(), 3); + EXPECT_EQ(vec, result); +} + +TEST(SmallVectorTest, Pop_back_TestDestructor) { + // Tracks number of constructions and destructions to ensure they are called. + struct TracksDtor { + TracksDtor& operator=(TracksDtor&&) = delete; + TracksDtor& operator=(const TracksDtor&) = delete; + + TracksDtor(int& num_ctors, int& num_dtors) + : num_ctors_(num_ctors), num_dtors_(num_dtors) { + num_ctors_++; + } + TracksDtor(const TracksDtor& that) + : TracksDtor(that.num_ctors_, that.num_dtors_) {} + TracksDtor(TracksDtor&& that) + : TracksDtor(that.num_ctors_, that.num_dtors_) {} + ~TracksDtor() { num_dtors_++; } + + int& num_ctors_; + int& num_dtors_; + }; + + constexpr int capacity = 4; + SmallVector vec; + + int num_ctors = 0; + int num_dtors = 0; + + // Make sure it works when staying within the smallvector capacity + for (int i = 0; i < capacity; ++i) { + vec.emplace_back(num_ctors, num_dtors); + } + + EXPECT_EQ(num_ctors, capacity); + while (!vec.empty()) { + vec.pop_back(); + } + + EXPECT_EQ(num_ctors, capacity); + EXPECT_EQ(num_dtors, num_ctors); + + // And when larger than builtin capacity + for (int i = 0; i < capacity * 2; ++i) { + vec.emplace_back(num_ctors, num_dtors); + } + + while (!vec.empty()) { + vec.pop_back(); + } + EXPECT_EQ(num_dtors, num_ctors); +} + } // namespace } // namespace utils } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/CMakeLists.txt b/third_party/spirv-tools/test/val/CMakeLists.txt index 64eba44616..65f27917d8 100644 --- a/third_party/spirv-tools/test/val/CMakeLists.txt +++ b/third_party/spirv-tools/test/val/CMakeLists.txt @@ -45,6 +45,7 @@ add_spvtools_unittest(TARGET val_abcde val_extension_spv_khr_integer_dot_product.cpp val_extension_spv_khr_bit_instructions.cpp val_extension_spv_khr_terminate_invocation.cpp + val_extension_spv_khr_subgroup_rotate.cpp val_ext_inst_test.cpp val_ext_inst_debug_test.cpp ${VAL_TEST_COMMON_SRCS} diff --git a/third_party/spirv-tools/test/val/val_annotation_test.cpp b/third_party/spirv-tools/test/val/val_annotation_test.cpp index 889c76caea..bb30de0a90 100644 --- a/third_party/spirv-tools/test/val/val_annotation_test.cpp +++ b/third_party/spirv-tools/test/val/val_annotation_test.cpp @@ -754,6 +754,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Location-06672")); EXPECT_THAT( getDiagnosticString(), HasSubstr("decoration must not be applied to this storage class")); @@ -793,6 +795,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("VUID-StandaloneSpirv-DescriptorSet-06491")); EXPECT_THAT(getDiagnosticString(), HasSubstr("must be in the StorageBuffer, Uniform, or " "UniformConstant storage class")); diff --git a/third_party/spirv-tools/test/val/val_arithmetics_test.cpp b/third_party/spirv-tools/test/val/val_arithmetics_test.cpp index 856ad02c18..4c093e9fd3 100644 --- a/third_party/spirv-tools/test/val/val_arithmetics_test.cpp +++ b/third_party/spirv-tools/test/val/val_arithmetics_test.cpp @@ -656,7 +656,7 @@ TEST_F(ValidateArithmetics, DotDifferentVectorSize) { EXPECT_THAT( getDiagnosticString(), HasSubstr( - "Expected operands to have the same number of componenets: Dot")); + "Expected operands to have the same number of components: Dot")); } TEST_F(ValidateArithmetics, VectorTimesScalarSuccess) { diff --git a/third_party/spirv-tools/test/val/val_atomics_test.cpp b/third_party/spirv-tools/test/val/val_atomics_test.cpp index d1a030a87a..a0308d5991 100644 --- a/third_party/spirv-tools/test/val/val_atomics_test.cpp +++ b/third_party/spirv-tools/test/val/val_atomics_test.cpp @@ -280,7 +280,7 @@ TEST_F(ValidateAtomics, AtomicLoadVulkanWrongStorageClass) { AnyVUID("VUID-StandaloneSpirv-None-04645")); EXPECT_THAT( getDiagnosticString(), - HasSubstr("in Vulkan evironment, Workgroup Storage Class is limited to " + HasSubstr("in Vulkan environment, Workgroup Storage Class is limited to " "MeshNV, TaskNV, and GLCompute execution model")); } @@ -708,7 +708,7 @@ OpAtomicStore %f32_var %device %relaxed %f32_1 AnyVUID("VUID-StandaloneSpirv-None-04645")); EXPECT_THAT( getDiagnosticString(), - HasSubstr("in Vulkan evironment, Workgroup Storage Class is limited to " + HasSubstr("in Vulkan environment, Workgroup Storage Class is limited to " "MeshNV, TaskNV, and GLCompute execution model")); } diff --git a/third_party/spirv-tools/test/val/val_bitwise_test.cpp b/third_party/spirv-tools/test/val/val_bitwise_test.cpp index 1001def8f7..bebaa84fc2 100644 --- a/third_party/spirv-tools/test/val/val_bitwise_test.cpp +++ b/third_party/spirv-tools/test/val/val_bitwise_test.cpp @@ -340,6 +340,16 @@ TEST_F(ValidateBitwise, OpBitFieldInsertSuccess) { ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } +TEST_F(ValidateBitwise, OpBitFieldInsertVulkanSuccess) { + const std::string body = R"( +%val1 = OpBitFieldInsert %u32 %u32_1 %u32_2 %s32_1 %s32_2 +%val2 = OpBitFieldInsert %s32vec2 %s32vec2_12 %s32vec2_12 %s32_1 %u32_2 +)"; + + CompileSuccessfully(GenerateShaderCode(body).c_str(), SPV_ENV_VULKAN_1_0); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); +} + TEST_F(ValidateBitwise, OpBitFieldInsertWrongResultType) { const std::string body = R"( %val1 = OpBitFieldInsert %bool %u64_1 %u64_2 %s32_1 %s32_2 @@ -350,7 +360,7 @@ TEST_F(ValidateBitwise, OpBitFieldInsertWrongResultType) { EXPECT_THAT( getDiagnosticString(), HasSubstr( - "Expected int scalar or vector type as Result Type: BitFieldInsert")); + "Expected Base Type to be equal to Result Type: BitFieldInsert")); } TEST_F(ValidateBitwise, OpBitFieldInsertWrongBaseType) { @@ -403,6 +413,20 @@ TEST_F(ValidateBitwise, OpBitFieldInsertCountNotInt) { HasSubstr("Expected Count Type to be int scalar: BitFieldInsert")); } +TEST_F(ValidateBitwise, OpBitFieldInsertNot32Vulkan) { + const std::string body = R"( +%val1 = OpBitFieldInsert %u64 %u64_1 %u64_2 %s32_1 %s32_2 +)"; + + CompileSuccessfully(GenerateShaderCode(body).c_str(), SPV_ENV_VULKAN_1_0); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Base-04781")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Expected 32-bit int type for Base operand: BitFieldInsert")); +} + TEST_F(ValidateBitwise, OpBitFieldSExtractSuccess) { const std::string body = R"( %val1 = OpBitFieldSExtract %u64 %u64_1 %s32_1 %s32_2 @@ -413,6 +437,16 @@ TEST_F(ValidateBitwise, OpBitFieldSExtractSuccess) { ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } +TEST_F(ValidateBitwise, OpBitFieldSExtractVulkanSuccess) { + const std::string body = R"( +%val1 = OpBitFieldSExtract %u32 %u32_1 %s32_1 %s32_2 +%val2 = OpBitFieldSExtract %s32vec2 %s32vec2_12 %s32_1 %u32_2 +)"; + + CompileSuccessfully(GenerateShaderCode(body).c_str(), SPV_ENV_VULKAN_1_0); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); +} + TEST_F(ValidateBitwise, OpBitFieldSExtractWrongResultType) { const std::string body = R"( %val1 = OpBitFieldSExtract %bool %u64_1 %s32_1 %s32_2 @@ -420,9 +454,10 @@ TEST_F(ValidateBitwise, OpBitFieldSExtractWrongResultType) { CompileSuccessfully(GenerateShaderCode(body).c_str()); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); - EXPECT_THAT(getDiagnosticString(), - HasSubstr("Expected int scalar or vector type as Result Type: " - "BitFieldSExtract")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Expected Base Type to be equal to Result Type: BitFieldSExtract")); } TEST_F(ValidateBitwise, OpBitFieldSExtractWrongBaseType) { @@ -462,6 +497,20 @@ TEST_F(ValidateBitwise, OpBitFieldSExtractCountNotInt) { HasSubstr("Expected Count Type to be int scalar: BitFieldSExtract")); } +TEST_F(ValidateBitwise, OpBitFieldSExtractNot32Vulkan) { + const std::string body = R"( +%val1 = OpBitFieldSExtract %u64 %u64_1 %s32_1 %s32_2 +)"; + + CompileSuccessfully(GenerateShaderCode(body).c_str(), SPV_ENV_VULKAN_1_0); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Base-04781")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Expected 32-bit int type for Base operand: BitFieldSExtract")); +} + TEST_F(ValidateBitwise, OpBitReverseSuccess) { const std::string body = R"( %val1 = OpBitReverse %u64 %u64_1 @@ -472,6 +521,16 @@ TEST_F(ValidateBitwise, OpBitReverseSuccess) { ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } +TEST_F(ValidateBitwise, OpBitReverseVulkanSuccess) { + const std::string body = R"( +%val1 = OpBitReverse %u32 %u32_1 +%val2 = OpBitReverse %s32vec2 %s32vec2_12 +)"; + + CompileSuccessfully(GenerateShaderCode(body).c_str(), SPV_ENV_VULKAN_1_0); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); +} + TEST_F(ValidateBitwise, OpBitReverseWrongResultType) { const std::string body = R"( %val1 = OpBitReverse %bool %u64_1 @@ -481,8 +540,7 @@ TEST_F(ValidateBitwise, OpBitReverseWrongResultType) { ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), - HasSubstr( - "Expected int scalar or vector type as Result Type: BitReverse")); + HasSubstr("Expected Base Type to be equal to Result Type: BitReverse")); } TEST_F(ValidateBitwise, OpBitReverseWrongBaseType) { @@ -497,16 +555,41 @@ TEST_F(ValidateBitwise, OpBitReverseWrongBaseType) { HasSubstr("Expected Base Type to be equal to Result Type: BitReverse")); } +TEST_F(ValidateBitwise, OpBitReverseNot32Vulkan) { + const std::string body = R"( +%val1 = OpBitReverse %u64 %u64_1 +)"; + + CompileSuccessfully(GenerateShaderCode(body).c_str(), SPV_ENV_VULKAN_1_0); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Base-04781")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Expected 32-bit int type for Base operand: BitReverse")); +} + TEST_F(ValidateBitwise, OpBitCountSuccess) { const std::string body = R"( %val1 = OpBitCount %s32 %u64_1 %val2 = OpBitCount %u32vec2 %s32vec2_12 +%val3 = OpBitCount %s64 %s64_1 )"; CompileSuccessfully(GenerateShaderCode(body).c_str()); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } +TEST_F(ValidateBitwise, OpBitCountVulkanSuccess) { + const std::string body = R"( +%val1 = OpBitCount %s32 %u32_1 +%val2 = OpBitCount %u32vec2 %s32vec2_12 +)"; + + CompileSuccessfully(GenerateShaderCode(body).c_str(), SPV_ENV_VULKAN_1_0); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); +} + TEST_F(ValidateBitwise, OpBitCountWrongResultType) { const std::string body = R"( %val1 = OpBitCount %bool %u64_1 @@ -524,11 +607,14 @@ TEST_F(ValidateBitwise, OpBitCountBaseNotInt) { %val1 = OpBitCount %u32 %f64_1 )"; - CompileSuccessfully(GenerateShaderCode(body).c_str()); - ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + CompileSuccessfully(GenerateShaderCode(body).c_str(), SPV_ENV_VULKAN_1_0); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Base-04781")); EXPECT_THAT( getDiagnosticString(), - HasSubstr("Expected Base Type to be int scalar or vector: BitCount")); + HasSubstr( + "Expected int scalar or vector type for Base operand: BitCount")); } TEST_F(ValidateBitwise, OpBitCountBaseWrongDimension) { @@ -544,6 +630,19 @@ TEST_F(ValidateBitwise, OpBitCountBaseWrongDimension) { "BitCount")); } +TEST_F(ValidateBitwise, OpBitCountNot32Vulkan) { + const std::string body = R"( +%val1 = OpBitCount %s64 %s64_1 +)"; + + CompileSuccessfully(GenerateShaderCode(body).c_str(), SPV_ENV_VULKAN_1_0); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Base-04781")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Expected 32-bit int type for Base operand: BitCount")); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_builtins_test.cpp b/third_party/spirv-tools/test/val/val_builtins_test.cpp index dff9adfef9..b76c163545 100644 --- a/third_party/spirv-tools/test/val/val_builtins_test.cpp +++ b/third_party/spirv-tools/test/val/val_builtins_test.cpp @@ -93,7 +93,8 @@ CodeGenerator GetInMainCodeGenerator(const char* const built_in, generator.extensions_ += extensions; } - generator.before_types_ = "OpMemberDecorate %built_in_type 0 BuiltIn "; + generator.before_types_ = R"(OpDecorate %built_in_type Block + OpMemberDecorate %built_in_type 0 BuiltIn )"; generator.before_types_ += built_in; generator.before_types_ += "\n"; @@ -251,7 +252,8 @@ CodeGenerator GetInFunctionCodeGenerator(const char* const built_in, generator.extensions_ += extensions; } - generator.before_types_ = "OpMemberDecorate %built_in_type 0 BuiltIn "; + generator.before_types_ = R"(OpDecorate %built_in_type Block + OpMemberDecorate %built_in_type 0 BuiltIn )"; generator.before_types_ += built_in; generator.before_types_ += "\n"; @@ -2370,6 +2372,67 @@ INSTANTIATE_TEST_SUITE_P( "needs to be a 32-bit int scalar", "is not an int scalar")))); +// CullMaskKHR is valid +// in IS, AH, CH, MS shaders as an input i32 scalar +INSTANTIATE_TEST_SUITE_P( + CullMaskSuccess, + ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult, + Combine(Values(SPV_ENV_VULKAN_1_2), Values("CullMaskKHR"), + Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR", "MissKHR"), + Values("Input"), Values("%u32"), + Values("OpCapability RayTracingKHR\nOpCapability RayCullMaskKHR\n"), + Values("OpExtension \"SPV_KHR_ray_tracing\"\nOpExtension " + "\"SPV_KHR_ray_cull_mask\"\n"), + Values(nullptr), Values(TestResult()))); + +INSTANTIATE_TEST_SUITE_P( + CullMaskNotExecutionMode, + ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult, + Combine(Values(SPV_ENV_VULKAN_1_2), Values("CullMaskKHR"), + Values("Vertex", "Fragment", "TessellationControl", + "TessellationEvaluation", "Geometry", "Fragment", + "GLCompute", "RayGenerationKHR", "CallableKHR"), + Values("Input"), Values("%u32"), + Values("OpCapability RayTracingKHR\nOpCapability RayCullMaskKHR\n"), + Values("OpExtension \"SPV_KHR_ray_tracing\"\nOpExtension " + "\"SPV_KHR_ray_cull_mask\"\n"), + Values("VUID-CullMaskKHR-CullMaskKHR-06735 " + "VUID-RayTmaxKHR-RayTmaxKHR-04348 " + "VUID-RayTminKHR-RayTminKHR-04351 "), + Values(TestResult(SPV_ERROR_INVALID_DATA, + "Vulkan spec does not allow BuiltIn", + "to be used with the execution model")))); + +INSTANTIATE_TEST_SUITE_P( + ICullMaskNotInput, + ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult, + Combine(Values(SPV_ENV_VULKAN_1_2), Values("CullMaskKHR"), + Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR", "MissKHR"), + Values("Output"), Values("%u32"), + Values("OpCapability RayTracingKHR\nOpCapability RayCullMaskKHR\n"), + Values("OpExtension \"SPV_KHR_ray_tracing\"\nOpExtension " + "\"SPV_KHR_ray_cull_mask\"\n"), + Values("VUID-CullMaskKHR-CullMaskKHR-06736 " + "VUID-RayTmaxKHR-RayTmaxKHR-04349 " + "VUID-RayTminKHR-RayTminKHR-04352 "), + Values(TestResult(SPV_ERROR_INVALID_DATA, "Vulkan spec allows", + "used for variables with Input storage class")))); +INSTANTIATE_TEST_SUITE_P( + CullMaskNotIntScalar, + ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult, + Combine(Values(SPV_ENV_VULKAN_1_2), Values("CullMaskKHR"), + Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR", "MissKHR"), + Values("Input"), Values("%f32", "%u32vec3"), + Values("OpCapability RayTracingKHR\nOpCapability RayCullMaskKHR\n"), + Values("OpExtension \"SPV_KHR_ray_tracing\"\nOpExtension " + "\"SPV_KHR_ray_cull_mask\"\n"), + Values("VUID-CullMaskKHR-CullMaskKHR-06737 " + "VUID-RayTmaxKHR-RayTmaxKHR-04350 " + "VUID-RayTminKHR-RayTminKHR-04353 "), + Values(TestResult(SPV_ERROR_INVALID_DATA, + "needs to be a 32-bit int scalar", + "is not an int scalar")))); + // RayTmaxKHR, RayTminKHR are all valid // in IS, AH, CH, MS shaders as input f32 scalars INSTANTIATE_TEST_SUITE_P( @@ -3098,6 +3161,8 @@ TEST_F(ValidateBuiltIns, TwoBuiltInsFirstFails) { CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator(); generator.before_types_ = R"( +OpDecorate %input_type Block +OpDecorate %output_type Block OpMemberDecorate %input_type 0 BuiltIn FragCoord OpMemberDecorate %output_type 0 BuiltIn Position )"; @@ -3138,6 +3203,8 @@ TEST_F(ValidateBuiltIns, TwoBuiltInsSecondFails) { CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator(); generator.before_types_ = R"( +OpDecorate %input_type Block +OpDecorate %output_type Block OpMemberDecorate %input_type 0 BuiltIn Position OpMemberDecorate %output_type 0 BuiltIn FragCoord )"; @@ -3201,6 +3268,7 @@ OpStore %position %f32vec4_0123 TEST_F(ValidateBuiltIns, FragmentPositionTwoEntryPoints) { CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator(); generator.before_types_ = R"( +OpDecorate %output_type Block OpMemberDecorate %output_type 0 BuiltIn Position )"; @@ -3252,6 +3320,7 @@ CodeGenerator GetNoDepthReplacingGenerator() { CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator(); generator.before_types_ = R"( +OpDecorate %output_type Block OpMemberDecorate %output_type 0 BuiltIn FragDepth )"; @@ -3303,6 +3372,7 @@ CodeGenerator GetOneMainHasDepthReplacingOtherHasntGenerator() { CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator(); generator.before_types_ = R"( +OpDecorate %output_type Block OpMemberDecorate %output_type 0 BuiltIn FragDepth )"; @@ -3374,6 +3444,7 @@ OpExtension "SPV_NV_ray_tracing" )"; generator.before_types_ = R"( +OpDecorate %input_type Block OpMemberDecorate %input_type 0 BuiltIn InstanceId )"; @@ -3609,6 +3680,7 @@ OpCapability GroupNonUniformBallot OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 +OpDecorate %struct Block OpMemberDecorate %struct 0 BuiltIn SubgroupEqMask %void = OpTypeVoid %int = OpTypeInt 32 0 @@ -3663,6 +3735,7 @@ OpCapability GroupNonUniform OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 +OpDecorate %struct Block OpMemberDecorate %struct 0 BuiltIn SubgroupSize %void = OpTypeVoid %int = OpTypeInt 32 0 @@ -3723,6 +3796,7 @@ OpCapability GroupNonUniform OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 +OpDecorate %struct Block OpMemberDecorate %struct 0 BuiltIn SubgroupId %void = OpTypeVoid %int = OpTypeInt 32 0 @@ -4052,6 +4126,71 @@ INSTANTIATE_TEST_SUITE_P( "According to the Vulkan spec BuiltIn FullyCoveredEXT variable " "needs to be a bool scalar.")))); +INSTANTIATE_TEST_SUITE_P( + BaryCoordNotFragment, + ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult, + Combine( + Values("BaryCoordKHR", "BaryCoordNoPerspKHR"), Values("Vertex"), + Values("Input"), Values("%f32vec3"), + Values("OpCapability FragmentBarycentricKHR\n"), + Values("OpExtension \"SPV_KHR_fragment_shader_barycentric\"\n"), + Values("VUID-BaryCoordKHR-BaryCoordKHR-04154 " + "VUID-BaryCoordNoPerspKHR-BaryCoordNoPerspKHR-04160 "), + Values(TestResult(SPV_ERROR_INVALID_DATA, "Vulkan spec allows BuiltIn", + "to be used only with Fragment execution model")))); + +INSTANTIATE_TEST_SUITE_P( + BaryCoordNotInput, + ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult, + Combine(Values("BaryCoordKHR", "BaryCoordNoPerspKHR"), Values("Fragment"), + Values("Output"), Values("%f32vec3"), + Values("OpCapability FragmentBarycentricKHR\n"), + Values("OpExtension \"SPV_KHR_fragment_shader_barycentric\"\n"), + Values("VUID-BaryCoordKHR-BaryCoordKHR-04155 " + "VUID-BaryCoordNoPerspKHR-BaryCoordNoPerspKHR-04161 "), + Values(TestResult( + SPV_ERROR_INVALID_DATA, "Vulkan spec allows BuiltIn", + "to be only used for variables with Input storage class")))); + +INSTANTIATE_TEST_SUITE_P( + BaryCoordNotFloatVector, + ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult, + Combine( + Values("BaryCoordKHR", "BaryCoordNoPerspKHR"), Values("Fragment"), + Values("Output"), Values("%f32arr3", "%u32vec4"), + Values("OpCapability FragmentBarycentricKHR\n"), + Values("OpExtension \"SPV_KHR_fragment_shader_barycentric\"\n"), + Values("VUID-BaryCoordKHR-BaryCoordKHR-04156 " + "VUID-BaryCoordNoPerspKHR-BaryCoordNoPerspKHR-04162 "), + Values(TestResult(SPV_ERROR_INVALID_DATA, + "needs to be a 3-component 32-bit float vector")))); + +INSTANTIATE_TEST_SUITE_P( + BaryCoordNotFloatVec3, + ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult, + Combine( + Values("BaryCoordKHR", "BaryCoordNoPerspKHR"), Values("Fragment"), + Values("Output"), Values("%f32vec2"), + Values("OpCapability FragmentBarycentricKHR\n"), + Values("OpExtension \"SPV_KHR_fragment_shader_barycentric\"\n"), + Values("VUID-BaryCoordKHR-BaryCoordKHR-04156 " + "VUID-BaryCoordNoPerspKHR-BaryCoordNoPerspKHR-04162 "), + Values(TestResult(SPV_ERROR_INVALID_DATA, + "needs to be a 3-component 32-bit float vector")))); + +INSTANTIATE_TEST_SUITE_P( + BaryCoordNotF32Vec3, + ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult, + Combine( + Values("BaryCoordKHR", "BaryCoordNoPerspKHR"), Values("Fragment"), + Values("Output"), Values("%f64vec3"), + Values("OpCapability FragmentBarycentricKHR\n"), + Values("OpExtension \"SPV_KHR_fragment_shader_barycentric\"\n"), + Values("VUID-BaryCoordKHR-BaryCoordKHR-04156 " + "VUID-BaryCoordNoPerspKHR-BaryCoordNoPerspKHR-04162 "), + Values(TestResult(SPV_ERROR_INVALID_DATA, + "needs to be a 3-component 32-bit float vector")))); + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_capability_test.cpp b/third_party/spirv-tools/test/val/val_capability_test.cpp index c432c3cfaf..0d84caa13a 100644 --- a/third_party/spirv-tools/test/val/val_capability_test.cpp +++ b/third_party/spirv-tools/test/val/val_capability_test.cpp @@ -2918,8 +2918,8 @@ std::vector CapVersionCases1_5() { "StorageTexelBufferArrayNonUniformIndexing", "SPV_EXT_descriptor_indexing"), // SPV_EXT_physical_storage_buffer - IN15("PhysicalStorageBufferAddressesEXT", - "PhysicalStorageBufferAddresses", "SPV_EXT_physical_storage_buffer"), + IN15("PhysicalStorageBufferAddresses", "PhysicalStorageBufferAddresses", + "SPV_EXT_physical_storage_buffer"), // SPV_KHR_vulkan_memory_model IN15("VulkanMemoryModelKHR", "VulkanMemoryModel", "SPV_KHR_vulkan_memory_model"), diff --git a/third_party/spirv-tools/test/val/val_cfg_test.cpp b/third_party/spirv-tools/test/val/val_cfg_test.cpp index 311cfa7713..76477468be 100644 --- a/third_party/spirv-tools/test/val/val_cfg_test.cpp +++ b/third_party/spirv-tools/test/val/val_cfg_test.cpp @@ -65,7 +65,7 @@ class Block { /// Creates a Block with a given label /// /// @param[in]: label the label id of the block - /// @param[in]: type the branch instruciton that ends the block + /// @param[in]: type the branch instruction that ends the block explicit Block(std::string label, SpvOp type = SpvOpBranch) : label_(label), body_(), type_(type), successors_() {} @@ -3523,7 +3523,7 @@ OpFunctionEnd EXPECT_THAT( getDiagnosticString(), HasSubstr( - "OpSwitch must be preceeded by an OpSelectionMerge instruction")); + "OpSwitch must be preceded by an OpSelectionMerge instruction")); } TEST_F(ValidateCFG, MissingMergeSwitchBad2) { @@ -3550,7 +3550,7 @@ OpFunctionEnd EXPECT_THAT( getDiagnosticString(), HasSubstr( - "OpSwitch must be preceeded by an OpSelectionMerge instruction")); + "OpSwitch must be preceded by an OpSelectionMerge instruction")); } TEST_F(ValidateCFG, MissingMergeOneBranchToMergeGood) { @@ -3622,7 +3622,7 @@ OpFunctionEnd EXPECT_THAT( getDiagnosticString(), HasSubstr( - "OpSwitch must be preceeded by an OpSelectionMerge instruction")); + "OpSwitch must be preceded by an OpSelectionMerge instruction")); } TEST_F(ValidateCFG, MissingMergeOneUnseenTargetSwitchBad) { @@ -3654,7 +3654,7 @@ OpFunctionEnd EXPECT_THAT( getDiagnosticString(), HasSubstr( - "OpSwitch must be preceeded by an OpSelectionMerge instruction")); + "OpSwitch must be preceded by an OpSelectionMerge instruction")); } TEST_F(ValidateCFG, MissingMergeLoopBreakGood) { @@ -4579,6 +4579,51 @@ OpFunctionEnd EXPECT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions()); } +TEST_F(ValidateCFG, BranchConditionalDifferentTargetsPre1p6) { + const std::string text = R"( +OpCapability Shader +OpCapability Linkage +OpMemoryModel Logical GLSL450 +%void = OpTypeVoid +%bool = OpTypeBool +%undef = OpUndef %bool +%void_fn = OpTypeFunction %void +%func = OpFunction %void None %void_fn +%entry = OpLabel +OpBranchConditional %undef %target %target +%target = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_5); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_5)); +} + +TEST_F(ValidateCFG, BranchConditionalDifferentTargetsPost1p6) { + const std::string text = R"( +OpCapability Shader +OpCapability Linkage +OpMemoryModel Logical GLSL450 +%void = OpTypeVoid +%bool = OpTypeBool +%undef = OpUndef %bool +%void_fn = OpTypeFunction %void +%func = OpFunction %void None %void_fn +%entry = OpLabel +OpBranchConditional %undef %target %target +%target = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_6); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_6)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("In SPIR-V 1.6 or later, True Label and False Label " + "must be different labels")); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_conversion_test.cpp b/third_party/spirv-tools/test/val/val_conversion_test.cpp index b9802ece0a..94bd27db9f 100644 --- a/third_party/spirv-tools/test/val/val_conversion_test.cpp +++ b/third_party/spirv-tools/test/val/val_conversion_test.cpp @@ -1557,7 +1557,7 @@ OpExtension "SPV_EXT_physical_storage_buffer" OpMemoryModel PhysicalStorageBuffer64 GLSL450 OpEntryPoint Fragment %main "main" OpExecutionMode %main OriginUpperLeft -OpDecorate %val1 RestrictPointerEXT +OpDecorate %val1 RestrictPointer %uint64 = OpTypeInt 64 0 %u64_1 = OpConstant %uint64 1 %ptr = OpTypePointer PhysicalStorageBuffer %uint64 @@ -1615,7 +1615,7 @@ OpExtension "SPV_EXT_physical_storage_buffer" OpMemoryModel PhysicalStorageBuffer64 GLSL450 OpEntryPoint Fragment %main "main" OpExecutionMode %main OriginUpperLeft -OpDecorate %val1 RestrictPointerEXT +OpDecorate %val1 RestrictPointer %uint32 = OpTypeInt 32 0 %uint64 = OpTypeInt 64 0 %ptr = OpTypePointer PhysicalStorageBuffer %uint64 diff --git a/third_party/spirv-tools/test/val/val_data_test.cpp b/third_party/spirv-tools/test/val/val_data_test.cpp index 1d4c0e044b..eef08a1e76 100644 --- a/third_party/spirv-tools/test/val/val_data_test.cpp +++ b/third_party/spirv-tools/test/val/val_data_test.cpp @@ -766,6 +766,8 @@ TEST_F(ValidateData, vulkan_RTA_not_at_end_of_struct) { CompileSuccessfully(str.c_str(), SPV_ENV_VULKAN_1_1); ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeRuntimeArray-04680")); EXPECT_THAT(getDiagnosticString(), HasSubstr("In Vulkan, OpTypeRuntimeArray must only be used for " "the last member of an OpTypeStruct\n %_struct_3 = " diff --git a/third_party/spirv-tools/test/val/val_decoration_test.cpp b/third_party/spirv-tools/test/val/val_decoration_test.cpp index f2953edcc4..2db44a4aca 100644 --- a/third_party/spirv-tools/test/val/val_decoration_test.cpp +++ b/third_party/spirv-tools/test/val/val_decoration_test.cpp @@ -226,6 +226,7 @@ TEST_F(ValidateDecorations, StructAllMembersHaveBuiltInDecorationsGood) { OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 + OpDecorate %_struct_1 Block OpMemberDecorate %_struct_1 0 BuiltIn Position OpMemberDecorate %_struct_1 1 BuiltIn Position OpMemberDecorate %_struct_1 2 BuiltIn Position @@ -243,6 +244,7 @@ TEST_F(ValidateDecorations, MixedBuiltInDecorationsBad) { OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 + OpDecorate %_struct_1 Block OpMemberDecorate %_struct_1 0 BuiltIn Position OpMemberDecorate %_struct_1 1 BuiltIn Position %float = OpTypeFloat 32 @@ -265,6 +267,7 @@ TEST_F(ValidateDecorations, StructContainsBuiltInStructBad) { OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 + OpDecorate %_struct_1 Block OpMemberDecorate %_struct_1 0 BuiltIn Position OpMemberDecorate %_struct_1 1 BuiltIn Position OpMemberDecorate %_struct_1 2 BuiltIn Position @@ -305,6 +308,8 @@ TEST_F(ValidateDecorations, MultipleBuiltInObjectsConsumedByOpEntryPointBad) { OpEntryPoint Geometry %main "main" %in_1 %in_2 OpExecutionMode %main InputPoints OpExecutionMode %main OutputPoints + OpDecorate %struct_1 Block + OpDecorate %struct_2 Block OpMemberDecorate %struct_1 0 BuiltIn InvocationId OpMemberDecorate %struct_2 0 BuiltIn Position %int = OpTypeInt 32 1 @@ -339,6 +344,8 @@ TEST_F(ValidateDecorations, OpEntryPoint Geometry %main "main" %in_1 %out_1 OpExecutionMode %main InputPoints OpExecutionMode %main OutputPoints + OpDecorate %struct_1 Block + OpDecorate %struct_2 Block OpMemberDecorate %struct_1 0 BuiltIn InvocationId OpMemberDecorate %struct_2 0 BuiltIn Position %int = OpTypeInt 32 1 @@ -559,6 +566,8 @@ OpFunctionEnd CompileSuccessfully(spirv, env); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(env)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Location-04915")); EXPECT_THAT(getDiagnosticString(), HasSubstr("A BuiltIn variable (id 2) cannot have any Location or " "Component decorations")); @@ -593,11 +602,355 @@ OpFunctionEnd CompileSuccessfully(spirv, env); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(env)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Location-04915")); EXPECT_THAT(getDiagnosticString(), HasSubstr("A BuiltIn variable (id 2) cannot have any Location or " "Component decorations")); } +TEST_F(ValidateDecorations, LocationDecorationOnNumericTypeBad) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %fragCoord + OpExecutionMode %main OriginUpperLeft + OpDecorate %fragCoord Location 0 + OpDecorate %v4float Location 1 + %void = OpTypeVoid + %voidfn = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%ptr_v4float = OpTypePointer Output %v4float + %fragCoord = OpVariable %ptr_v4float Output +%non_interface = OpVariable %ptr_v4float Output + %main = OpFunction %void None %voidfn + %label = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(env)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Location decoration on target '3[%v4float]' must " + "be a variable")); +} + +TEST_F(ValidateDecorations, LocationDecorationOnStructBad) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %fragCoord + OpExecutionMode %main OriginUpperLeft + OpDecorate %fragCoord Location 0 + OpDecorate %struct Location 1 + %void = OpTypeVoid + %voidfn = OpTypeFunction %void + %float = OpTypeFloat 32 + %struct = OpTypeStruct %float + %v4float = OpTypeVector %float 4 +%ptr_v4float = OpTypePointer Output %v4float + %fragCoord = OpVariable %ptr_v4float Output +%non_interface = OpVariable %ptr_v4float Output + %main = OpFunction %void None %voidfn + %label = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(env)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Location decoration on target '3[%_struct_3]' " + "must be a variable")); +} + +TEST_F(ValidateDecorations, + LocationDecorationUnusedNonInterfaceVariableVulkan_Ignored) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %fragCoord + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpDecorate %fragCoord Location 0 + OpDecorate %non_interface Location 1 + %void = OpTypeVoid + %voidfn = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%ptr_v4float = OpTypePointer Output %v4float + %fragCoord = OpVariable %ptr_v4float Output +%non_interface = OpVariable %ptr_v4float Output + %main = OpFunction %void None %voidfn + %label = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState(env)); + EXPECT_EQ(getDiagnosticString(), ""); +} + +TEST_F(ValidateDecorations, + LocationDecorationNonInterfaceStructVulkan_Ignored) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %fragCoord + OpExecutionMode %main OriginUpperLeft + OpDecorate %fragCoord Location 0 + OpMemberDecorate %block 0 Location 2 + OpMemberDecorate %block 0 Component 1 + OpDecorate %block Block + %void = OpTypeVoid + %voidfn = OpTypeFunction %void + %float = OpTypeFloat 32 + %vec3 = OpTypeVector %float 3 +%outvar_ptr = OpTypePointer Output %vec3 + %fragCoord = OpVariable %outvar_ptr Output + %block = OpTypeStruct %vec3 + %invar_ptr = OpTypePointer Input %block +%non_interface = OpVariable %invar_ptr Input + %main = OpFunction %void None %voidfn + %label = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState(env)); + EXPECT_EQ(getDiagnosticString(), ""); +} + +TEST_F(ValidateDecorations, LocationDecorationNonInterfaceStructVulkanGood) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %fragCoord %interface + OpExecutionMode %main OriginUpperLeft + OpDecorate %fragCoord Location 0 + OpMemberDecorate %block 0 Location 2 + OpMemberDecorate %block 0 Component 1 + OpDecorate %block Block + %void = OpTypeVoid + %voidfn = OpTypeFunction %void + %float = OpTypeFloat 32 + %vec3 = OpTypeVector %float 3 +%outvar_ptr = OpTypePointer Output %vec3 + %fragCoord = OpVariable %outvar_ptr Output + %block = OpTypeStruct %vec3 + %invar_ptr = OpTypePointer Input %block + %interface = OpVariable %invar_ptr Input ;; this variable is unused. Ignore it + %main = OpFunction %void None %voidfn + %label = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState(env)); +} + +TEST_F(ValidateDecorations, LocationDecorationVariableNonStructVulkanBad) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %fragCoord %nonblock_var + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpDecorate %fragCoord Location 0 + %void = OpTypeVoid + %voidfn = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%ptr_v4float = OpTypePointer Output %v4float + %fragCoord = OpVariable %ptr_v4float Output +%nonblock_var = OpVariable %ptr_v4float Output + %main = OpFunction %void None %voidfn + %label = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateAndRetrieveValidationState(env)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Location-04916")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Variable must be decorated with a location")); +} + +TEST_F(ValidateDecorations, LocationDecorationVariableStructNoBlockVulkanBad) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %fragCoord %block_var + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpDecorate %fragCoord Location 0 + %void = OpTypeVoid + %voidfn = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%ptr_v4float = OpTypePointer Output %v4float + %fragCoord = OpVariable %ptr_v4float Output + %block = OpTypeStruct %v4float + %block_ptr = OpTypePointer Output %block + %block_var = OpVariable %block_ptr Output + %main = OpFunction %void None %voidfn + %label = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateAndRetrieveValidationState(env)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Location-04917")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Variable must be decorated with a location")); +} + +TEST_F(ValidateDecorations, LocationDecorationVariableNoBlockVulkanGood) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %fragCoord %block_var + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpDecorate %fragCoord Location 0 + OpDecorate %block_var Location 1 + %void = OpTypeVoid + %voidfn = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%ptr_v4float = OpTypePointer Output %v4float + %fragCoord = OpVariable %ptr_v4float Output + %block = OpTypeStruct %v4float + %block_ptr = OpTypePointer Output %block + %block_var = OpVariable %block_ptr Output + %main = OpFunction %void None %voidfn + %label = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()); +} + +TEST_F(ValidateDecorations, LocationDecorationVariableExtraMemeberVulkan) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %fragCoord %block_var + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpDecorate %fragCoord Location 0 + OpDecorate %block Block + OpDecorate %block_var Location 1 + OpMemberDecorate %block 0 Location 1 + %void = OpTypeVoid + %voidfn = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%ptr_v4float = OpTypePointer Output %v4float + %fragCoord = OpVariable %ptr_v4float Output + %block = OpTypeStruct %v4float + %block_ptr = OpTypePointer Output %block + %block_var = OpVariable %block_ptr Output + %main = OpFunction %void None %voidfn + %label = OpLabel + OpReturn + OpFunctionEnd + +)"; + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateAndRetrieveValidationState(env)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Location-04918")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Members cannot be assigned a location")); +} + +TEST_F(ValidateDecorations, LocationDecorationVariableMissingMemeberVulkan) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %fragCoord %block_var + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpDecorate %fragCoord Location 0 + OpDecorate %block Block + OpMemberDecorate %block 0 Location 1 + %void = OpTypeVoid + %voidfn = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%ptr_v4float = OpTypePointer Output %v4float + %fragCoord = OpVariable %ptr_v4float Output + %block = OpTypeStruct %v4float %v4float + %block_ptr = OpTypePointer Output %block + %block_var = OpVariable %block_ptr Output + %main = OpFunction %void None %voidfn + %label = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateAndRetrieveValidationState(env)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Location-04919")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Member index 1 is missing a location assignment")); +} + +TEST_F(ValidateDecorations, LocationDecorationVariableOnlyMemeberVulkanGood) { + const spv_target_env env = SPV_ENV_VULKAN_1_0; + std::string spirv = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %fragCoord %block_var + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpDecorate %fragCoord Location 0 + OpDecorate %block Block + OpMemberDecorate %block 0 Location 1 + OpMemberDecorate %block 1 Location 4 + %void = OpTypeVoid + %voidfn = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%ptr_v4float = OpTypePointer Output %v4float + %fragCoord = OpVariable %ptr_v4float Output + %block = OpTypeStruct %v4float %v4float + %block_ptr = OpTypePointer Output %block + %block_var = OpVariable %block_ptr Output + %main = OpFunction %void None %voidfn + %label = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()); +} + // #version 440 // #extension GL_EXT_nonuniform_qualifier : enable // layout(binding = 1) uniform sampler2D s2d[]; @@ -2333,6 +2686,8 @@ TEST_F(ValidateDecorations, VulkanBufferBlockOnStorageBufferBad) { CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-PushConstant-06675")); EXPECT_THAT(getDiagnosticString(), HasSubstr("In Vulkan, BufferBlock is disallowed on variables in " "the StorageBuffer storage class")); @@ -2527,9 +2882,11 @@ TEST_F(ValidateDecorations, VulkanPushConstantMissingBlockBad) { CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-PushConstant-06675")); EXPECT_THAT(getDiagnosticString(), HasSubstr("PushConstant id '2' is missing Block decoration.\n" - "From Vulkan spec, section 14.5.1:\n" + "From Vulkan spec:\n" "Such variables must be identified with a Block " "decoration")); } @@ -2680,11 +3037,13 @@ TEST_F(ValidateDecorations, VulkanMultiplePushConstantsSingleEntryPointBad) { CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-06674")); EXPECT_THAT( getDiagnosticString(), HasSubstr( "Entry point id '1' uses more than one PushConstant interface.\n" - "From Vulkan spec, section 14.5.1:\n" + "From Vulkan spec:\n" "There must be no more than one push constant block " "statically used per shader entry point.")); } @@ -2791,11 +3150,13 @@ TEST_F(ValidateDecorations, CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-06674")); EXPECT_THAT( getDiagnosticString(), HasSubstr( "Entry point id '1' uses more than one PushConstant interface.\n" - "From Vulkan spec, section 14.5.1:\n" + "From Vulkan spec:\n" "There must be no more than one push constant block " "statically used per shader entry point.")); } @@ -2832,9 +3193,11 @@ TEST_F(ValidateDecorations, VulkanUniformMissingDescriptorSetBad) { CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-UniformConstant-06677")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Uniform id '3' is missing DescriptorSet decoration.\n" - "From Vulkan spec, section 14.5.2:\n" + "From Vulkan spec:\n" "These variables must have DescriptorSet and Binding " "decorations specified")); } @@ -2871,9 +3234,11 @@ TEST_F(ValidateDecorations, VulkanUniformMissingBindingBad) { CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-UniformConstant-06677")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Uniform id '3' is missing Binding decoration.\n" - "From Vulkan spec, section 14.5.2:\n" + "From Vulkan spec:\n" "These variables must have DescriptorSet and Binding " "decorations specified")); } @@ -2903,10 +3268,12 @@ TEST_F(ValidateDecorations, VulkanUniformConstantMissingDescriptorSetBad) { CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-UniformConstant-06677")); EXPECT_THAT( getDiagnosticString(), HasSubstr("UniformConstant id '2' is missing DescriptorSet decoration.\n" - "From Vulkan spec, section 14.5.2:\n" + "From Vulkan spec:\n" "These variables must have DescriptorSet and Binding " "decorations specified")); } @@ -2936,10 +3303,12 @@ TEST_F(ValidateDecorations, VulkanUniformConstantMissingBindingBad) { CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-UniformConstant-06677")); EXPECT_THAT( getDiagnosticString(), HasSubstr("UniformConstant id '2' is missing Binding decoration.\n" - "From Vulkan spec, section 14.5.2:\n" + "From Vulkan spec:\n" "These variables must have DescriptorSet and Binding " "decorations specified")); } @@ -2976,10 +3345,12 @@ TEST_F(ValidateDecorations, VulkanStorageBufferMissingDescriptorSetBad) { CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-UniformConstant-06677")); EXPECT_THAT( getDiagnosticString(), HasSubstr("StorageBuffer id '3' is missing DescriptorSet decoration.\n" - "From Vulkan spec, section 14.5.2:\n" + "From Vulkan spec:\n" "These variables must have DescriptorSet and Binding " "decorations specified")); } @@ -3016,9 +3387,11 @@ TEST_F(ValidateDecorations, VulkanStorageBufferMissingBindingBad) { CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-UniformConstant-06677")); EXPECT_THAT(getDiagnosticString(), HasSubstr("StorageBuffer id '3' is missing Binding decoration.\n" - "From Vulkan spec, section 14.5.2:\n" + "From Vulkan spec:\n" "These variables must have DescriptorSet and Binding " "decorations specified")); } @@ -3061,10 +3434,12 @@ TEST_F(ValidateDecorations, CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-UniformConstant-06677")); EXPECT_THAT( getDiagnosticString(), HasSubstr("StorageBuffer id '3' is missing DescriptorSet decoration.\n" - "From Vulkan spec, section 14.5.2:\n" + "From Vulkan spec:\n" "These variables must have DescriptorSet and Binding " "decorations specified")); } @@ -5590,16 +5965,16 @@ OpFunctionEnd TEST_F(ValidateDecorations, PSBAliasedRestrictPointerSuccess) { const std::string body = R"( -OpCapability PhysicalStorageBufferAddressesEXT +OpCapability PhysicalStorageBufferAddresses OpCapability Int64 OpCapability Shader OpExtension "SPV_EXT_physical_storage_buffer" -OpMemoryModel PhysicalStorageBuffer64EXT GLSL450 +OpMemoryModel PhysicalStorageBuffer64 GLSL450 OpEntryPoint Fragment %main "main" OpExecutionMode %main OriginUpperLeft -OpDecorate %val1 RestrictPointerEXT +OpDecorate %val1 RestrictPointer %uint64 = OpTypeInt 64 0 -%ptr = OpTypePointer PhysicalStorageBufferEXT %uint64 +%ptr = OpTypePointer PhysicalStorageBuffer %uint64 %pptr_f = OpTypePointer Function %ptr %void = OpTypeVoid %voidfn = OpTypeFunction %void @@ -5616,15 +5991,15 @@ OpFunctionEnd TEST_F(ValidateDecorations, PSBAliasedRestrictPointerMissing) { const std::string body = R"( -OpCapability PhysicalStorageBufferAddressesEXT +OpCapability PhysicalStorageBufferAddresses OpCapability Int64 OpCapability Shader OpExtension "SPV_EXT_physical_storage_buffer" -OpMemoryModel PhysicalStorageBuffer64EXT GLSL450 +OpMemoryModel PhysicalStorageBuffer64 GLSL450 OpEntryPoint Fragment %main "main" OpExecutionMode %main OriginUpperLeft %uint64 = OpTypeInt 64 0 -%ptr = OpTypePointer PhysicalStorageBufferEXT %uint64 +%ptr = OpTypePointer PhysicalStorageBuffer %uint64 %pptr_f = OpTypePointer Function %ptr %void = OpTypeVoid %voidfn = OpTypeFunction %void @@ -5638,23 +6013,23 @@ OpFunctionEnd CompileSuccessfully(body.c_str()); ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("expected AliasedPointerEXT or RestrictPointerEXT for " - "PhysicalStorageBufferEXT pointer")); + HasSubstr("expected AliasedPointer or RestrictPointer for " + "PhysicalStorageBuffer pointer")); } TEST_F(ValidateDecorations, PSBAliasedRestrictPointerBoth) { const std::string body = R"( -OpCapability PhysicalStorageBufferAddressesEXT +OpCapability PhysicalStorageBufferAddresses OpCapability Int64 OpCapability Shader OpExtension "SPV_EXT_physical_storage_buffer" -OpMemoryModel PhysicalStorageBuffer64EXT GLSL450 +OpMemoryModel PhysicalStorageBuffer64 GLSL450 OpEntryPoint Fragment %main "main" OpExecutionMode %main OriginUpperLeft -OpDecorate %val1 RestrictPointerEXT -OpDecorate %val1 AliasedPointerEXT +OpDecorate %val1 RestrictPointer +OpDecorate %val1 AliasedPointer %uint64 = OpTypeInt 64 0 -%ptr = OpTypePointer PhysicalStorageBufferEXT %uint64 +%ptr = OpTypePointer PhysicalStorageBuffer %uint64 %pptr_f = OpTypePointer Function %ptr %void = OpTypeVoid %voidfn = OpTypeFunction %void @@ -5667,24 +6042,23 @@ OpFunctionEnd CompileSuccessfully(body.c_str()); ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); - EXPECT_THAT( - getDiagnosticString(), - HasSubstr("can't specify both AliasedPointerEXT and RestrictPointerEXT " - "for PhysicalStorageBufferEXT pointer")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("can't specify both AliasedPointer and RestrictPointer " + "for PhysicalStorageBuffer pointer")); } TEST_F(ValidateDecorations, PSBAliasedRestrictFunctionParamSuccess) { const std::string body = R"( -OpCapability PhysicalStorageBufferAddressesEXT +OpCapability PhysicalStorageBufferAddresses OpCapability Int64 OpCapability Shader OpExtension "SPV_EXT_physical_storage_buffer" -OpMemoryModel PhysicalStorageBuffer64EXT GLSL450 +OpMemoryModel PhysicalStorageBuffer64 GLSL450 OpEntryPoint Fragment %main "main" OpExecutionMode %main OriginUpperLeft OpDecorate %fparam Restrict %uint64 = OpTypeInt 64 0 -%ptr = OpTypePointer PhysicalStorageBufferEXT %uint64 +%ptr = OpTypePointer PhysicalStorageBuffer %uint64 %void = OpTypeVoid %voidfn = OpTypeFunction %void %fnptr = OpTypeFunction %void %ptr @@ -5705,15 +6079,15 @@ OpFunctionEnd TEST_F(ValidateDecorations, PSBAliasedRestrictFunctionParamMissing) { const std::string body = R"( -OpCapability PhysicalStorageBufferAddressesEXT +OpCapability PhysicalStorageBufferAddresses OpCapability Int64 OpCapability Shader OpExtension "SPV_EXT_physical_storage_buffer" -OpMemoryModel PhysicalStorageBuffer64EXT GLSL450 +OpMemoryModel PhysicalStorageBuffer64 GLSL450 OpEntryPoint Fragment %main "main" OpExecutionMode %main OriginUpperLeft %uint64 = OpTypeInt 64 0 -%ptr = OpTypePointer PhysicalStorageBufferEXT %uint64 +%ptr = OpTypePointer PhysicalStorageBuffer %uint64 %void = OpTypeVoid %voidfn = OpTypeFunction %void %fnptr = OpTypeFunction %void %ptr @@ -5732,22 +6106,22 @@ OpFunctionEnd ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected Aliased or Restrict for " - "PhysicalStorageBufferEXT pointer")); + "PhysicalStorageBuffer pointer")); } TEST_F(ValidateDecorations, PSBAliasedRestrictFunctionParamBoth) { const std::string body = R"( -OpCapability PhysicalStorageBufferAddressesEXT +OpCapability PhysicalStorageBufferAddresses OpCapability Int64 OpCapability Shader OpExtension "SPV_EXT_physical_storage_buffer" -OpMemoryModel PhysicalStorageBuffer64EXT GLSL450 +OpMemoryModel PhysicalStorageBuffer64 GLSL450 OpEntryPoint Fragment %main "main" OpExecutionMode %main OriginUpperLeft OpDecorate %fparam Restrict OpDecorate %fparam Aliased %uint64 = OpTypeInt 64 0 -%ptr = OpTypePointer PhysicalStorageBufferEXT %uint64 +%ptr = OpTypePointer PhysicalStorageBuffer %uint64 %void = OpTypeVoid %voidfn = OpTypeFunction %void %fnptr = OpTypeFunction %void %ptr @@ -5766,12 +6140,12 @@ OpFunctionEnd ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("can't specify both Aliased and Restrict for " - "PhysicalStorageBufferEXT pointer")); + "PhysicalStorageBuffer pointer")); } TEST_F(ValidateDecorations, PSBFPRoundingModeSuccess) { std::string spirv = R"( -OpCapability PhysicalStorageBufferAddressesEXT +OpCapability PhysicalStorageBufferAddresses OpCapability Shader OpCapability Linkage OpCapability StorageBuffer16BitAccess @@ -5779,14 +6153,14 @@ OpExtension "SPV_EXT_physical_storage_buffer" OpExtension "SPV_KHR_storage_buffer_storage_class" OpExtension "SPV_KHR_variable_pointers" OpExtension "SPV_KHR_16bit_storage" -OpMemoryModel PhysicalStorageBuffer64EXT GLSL450 +OpMemoryModel PhysicalStorageBuffer64 GLSL450 OpEntryPoint GLCompute %main "main" OpDecorate %_ FPRoundingMode RTE -OpDecorate %half_ptr_var AliasedPointerEXT +OpDecorate %half_ptr_var AliasedPointer %half = OpTypeFloat 16 %float = OpTypeFloat 32 %float_1_25 = OpConstant %float 1.25 -%half_ptr = OpTypePointer PhysicalStorageBufferEXT %half +%half_ptr = OpTypePointer PhysicalStorageBuffer %half %half_pptr_f = OpTypePointer Function %half_ptr %void = OpTypeVoid %func = OpTypeFunction %void @@ -6806,7 +7180,9 @@ OpFunctionEnd CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); EXPECT_THAT(getDiagnosticString(), - HasSubstr("From Vulkan spec, section 14.5.2:\nSuch variables " + AnyVUID("VUID-StandaloneSpirv-PushConstant-06675")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("From Vulkan spec:\nSuch variables " "must be identified with a Block decoration")); } @@ -6834,7 +7210,9 @@ OpFunctionEnd CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); EXPECT_THAT(getDiagnosticString(), - HasSubstr("From Vulkan spec, section 14.5.2:\nSuch variables " + AnyVUID("VUID-StandaloneSpirv-PushConstant-06675")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("From Vulkan spec:\nSuch variables " "must be identified with a Block decoration")); } @@ -6863,7 +7241,9 @@ OpFunctionEnd CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); EXPECT_THAT(getDiagnosticString(), - HasSubstr("From Vulkan spec, section 14.5.2:\nSuch variables " + AnyVUID("VUID-StandaloneSpirv-PushConstant-06675")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("From Vulkan spec:\nSuch variables " "must be identified with a Block decoration")); } @@ -6935,10 +7315,11 @@ OpFunctionEnd CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); - EXPECT_THAT( - getDiagnosticString(), - HasSubstr("From Vulkan spec, section 14.5.2:\nSuch variables must be " - "identified with a Block or BufferBlock decoration")); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Uniform-06676")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("From Vulkan spec:\nSuch variables must be " + "identified with a Block or BufferBlock decoration")); } TEST_F(ValidateDecorations, VulkanUniformArrayMissingBlock) { @@ -6963,10 +7344,11 @@ OpFunctionEnd CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); - EXPECT_THAT( - getDiagnosticString(), - HasSubstr("From Vulkan spec, section 14.5.2:\nSuch variables must be " - "identified with a Block or BufferBlock decoration")); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Uniform-06676")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("From Vulkan spec:\nSuch variables must be " + "identified with a Block or BufferBlock decoration")); } TEST_F(ValidateDecorations, VulkanUniformRuntimeArrayMissingBlock) { @@ -6992,10 +7374,11 @@ OpFunctionEnd CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); - EXPECT_THAT( - getDiagnosticString(), - HasSubstr("From Vulkan spec, section 14.5.2:\nSuch variables must be " - "identified with a Block or BufferBlock decoration")); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Uniform-06676")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("From Vulkan spec:\nSuch variables must be " + "identified with a Block or BufferBlock decoration")); } TEST_F(ValidateDecorations, VulkanArrayStrideZero) { diff --git a/third_party/spirv-tools/test/val/val_ext_inst_debug_test.cpp b/third_party/spirv-tools/test/val/val_ext_inst_debug_test.cpp index 307a800959..554e78b082 100644 --- a/third_party/spirv-tools/test/val/val_ext_inst_debug_test.cpp +++ b/third_party/spirv-tools/test/val/val_ext_inst_debug_test.cpp @@ -1547,7 +1547,7 @@ OpExtension "SPV_KHR_non_semantic_info" "integer scalar type")); } -TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCountZero) { +TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayComponentCountZero) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" @@ -1574,12 +1574,7 @@ OpExtension "SPV_KHR_non_semantic_info" CompileSuccessfully(GenerateShaderCodeForDebugInfo( src, constants, dbg_inst_header, "", extension, "Vertex")); - ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); - EXPECT_THAT(getDiagnosticString(), - HasSubstr("Component Count must be OpConstant with a 32- or " - "64-bits integer scalar type or DebugGlobalVariable or " - "DebugLocalVariable with a 32- or 64-bits unsigned " - "integer scalar type")); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailVariableSizeTypeFloat) { @@ -1869,6 +1864,178 @@ OpExtension "SPV_KHR_non_semantic_info" "integer less than or equal to 4")); } +TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrix) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "main() {}" +%float_name = OpString "float" +)"; + + const std::string constants = R"( +%u32_4 = OpConstant %u32 4 +%u32_5 = OpConstant %u32 5 +%u32_32 = OpConstant %u32 32 +%true = OpConstantTrue %bool +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 +%vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 +%mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %vfloat_info %u32_4 %true +)"; + + const std::string extension = R"( +OpExtension "SPV_KHR_non_semantic_info" +%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, dbg_inst_header, "", extension, "Vertex")); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorTypeType) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "main() {}" +%float_name = OpString "float" +)"; + + const std::string constants = R"( +%u32_4 = OpConstant %u32 4 +%u32_5 = OpConstant %u32 5 +%u32_32 = OpConstant %u32 32 +%true = OpConstantTrue %bool +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 +%vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 +%mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %dbg_src %u32_4 %true +)"; + + const std::string extension = R"( +OpExtension "SPV_KHR_non_semantic_info" +%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, dbg_inst_header, "", extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("expected operand Vector Type must be a result id of " + "DebugTypeVector")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountType) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "main() {}" +%float_name = OpString "float" +)"; + + const std::string constants = R"( +%u32_4 = OpConstant %u32 4 +%u32_5 = OpConstant %u32 5 +%u32_32 = OpConstant %u32 32 +%true = OpConstantTrue %bool +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 +%vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 +%mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %vfloat_info %dbg_src %true +)"; + + const std::string extension = R"( +OpExtension "SPV_KHR_non_semantic_info" +%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, dbg_inst_header, "", extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("expected operand Vector Count must be a result id of " + "32-bit unsigned OpConstant")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountZero) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "main() {}" +%float_name = OpString "float" +)"; + + const std::string constants = R"( +%u32_4 = OpConstant %u32 4 +%u32_5 = OpConstant %u32 5 +%u32_32 = OpConstant %u32 32 +%true = OpConstantTrue %bool +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 +%vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 +%mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %vfloat_info %u32_0 %true +)"; + + const std::string extension = R"( +OpExtension "SPV_KHR_non_semantic_info" +%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, dbg_inst_header, "", extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Vector Count must be positive " + "integer less than or equal to 4")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountFive) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "main() {}" +%float_name = OpString "float" +)"; + + const std::string constants = R"( +%u32_4 = OpConstant %u32 4 +%u32_5 = OpConstant %u32 5 +%u32_32 = OpConstant %u32 32 +%true = OpConstantTrue %bool +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 +%vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 +%mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %vfloat_info %u32_5 %true +)"; + + const std::string extension = R"( +OpExtension "SPV_KHR_non_semantic_info" +%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, dbg_inst_header, "", extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Vector Count must be positive " + "integer less than or equal to 4")); +} + TEST_F(ValidateOpenCL100DebugInfo, DebugTypedef) { const std::string src = R"( %src = OpString "simple.hlsl" diff --git a/third_party/spirv-tools/test/val/val_ext_inst_test.cpp b/third_party/spirv-tools/test/val/val_ext_inst_test.cpp index 2b6df04ddd..a2109db0a4 100644 --- a/third_party/spirv-tools/test/val/val_ext_inst_test.cpp +++ b/third_party/spirv-tools/test/val/val_ext_inst_test.cpp @@ -6045,6 +6045,18 @@ OpMemoryModel Logical GLSL450 "declared without SPV_KHR_non_semantic_info")); } +TEST_F(ValidateClspvReflection, DoesNotRequiresNonSemanticExtensionPost1p6) { + const std::string text = R"( +OpCapability Shader +OpCapability Linkage +%1 = OpExtInstImport "NonSemantic.ClspvReflection.1" +OpMemoryModel Logical GLSL450 +)"; + + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_6); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_6)); +} + TEST_F(ValidateClspvReflection, MissingVersion) { const std::string text = R"( OpCapability Shader diff --git a/third_party/spirv-tools/test/val/val_extension_spv_khr_subgroup_rotate.cpp b/third_party/spirv-tools/test/val/val_extension_spv_khr_subgroup_rotate.cpp new file mode 100644 index 0000000000..4f156e8bbf --- /dev/null +++ b/third_party/spirv-tools/test/val/val_extension_spv_khr_subgroup_rotate.cpp @@ -0,0 +1,352 @@ +// Copyright (c) 2022 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include + +#include "gmock/gmock.h" +#include "test/val/val_fixtures.h" + +namespace spvtools { +namespace val { +namespace { + +using ::testing::HasSubstr; +using ::testing::Values; +using ::testing::ValuesIn; + +struct Case { + std::vector caps; + bool shader; + std::string result_type; + std::string scope; + std::string delta; + std::string cluster_size; + std::string expected_error; // empty for no error. +}; + +inline std::ostream& operator<<(std::ostream& out, Case c) { + out << "\nSPV_KHR_subgroup_rotate Case{{"; + for (auto& cap : c.caps) { + out << cap; + } + out << "} "; + out << (c.shader ? "shader " : "kernel "); + out << c.result_type + " "; + out << c.scope + " "; + out << c.delta + " "; + out << c.cluster_size + " "; + out << "err'" << c.expected_error << "'"; + out << "}"; + return out; +} + +std::string AssemblyForCase(const Case& c) { + std::ostringstream ss; + + if (c.shader) { + ss << "OpCapability Shader\n"; + } else { + ss << "OpCapability Kernel\n"; + ss << "OpCapability Addresses\n"; + } + for (auto& cap : c.caps) { + ss << "OpCapability " << cap << "\n"; + } + ss << "OpExtension \"SPV_KHR_subgroup_rotate\"\n"; + + if (c.shader) { + ss << "OpMemoryModel Logical GLSL450\n"; + ss << "OpEntryPoint GLCompute %main \"main\"\n"; + } else { + ss << "OpMemoryModel Physical32 OpenCL\n"; + ss << "OpEntryPoint Kernel %main \"main\"\n"; + } + + ss << R"( + %void = OpTypeVoid + %void_fn = OpTypeFunction %void + %u32 = OpTypeInt 32 0 + %float = OpTypeFloat 32 + %ptr = OpTypePointer Function %u32 + )"; + + if (c.shader) { + ss << "%i32 = OpTypeInt 32 1\n"; + } + + ss << R"( + %u32_0 = OpConstant %u32 0 + %u32_1 = OpConstant %u32 1 + %u32_15 = OpConstant %u32 15 + %u32_16 = OpConstant %u32 16 + %u32_undef = OpUndef %u32 + %u32_spec_1 = OpSpecConstant %u32 1 + %u32_spec_16 = OpSpecConstant %u32 16 + %f32_1 = OpConstant %float 1.0 + %subgroup = OpConstant %u32 3 + %workgroup = OpConstant %u32 2 + %invalid_scope = OpConstant %u32 1 + %val = OpConstant %u32 42 + )"; + + if (c.shader) { + ss << "%i32_1 = OpConstant %i32 1\n"; + } + + ss << R"( + %main = OpFunction %void None %void_fn + %entry = OpLabel + )"; + + ss << "%unused = OpGroupNonUniformRotateKHR "; + ss << c.result_type + " "; + ss << c.scope; + ss << " %val "; + ss << c.delta; + ss << " " + c.cluster_size; + ss << "\n"; + + ss << R"( + OpReturn + OpFunctionEnd + )"; + + return ss.str(); +} + +using ValidateSpvKHRSubgroupRotate = spvtest::ValidateBase; + +TEST_P(ValidateSpvKHRSubgroupRotate, Base) { + const auto& c = GetParam(); + const auto& assembly = AssemblyForCase(c); + CompileSuccessfully(assembly); + if (c.expected_error.empty()) { + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()) << getDiagnosticString(); + } else { + EXPECT_NE(SPV_SUCCESS, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), HasSubstr(c.expected_error)); + } +} + +INSTANTIATE_TEST_SUITE_P( + Valid, ValidateSpvKHRSubgroupRotate, + ::testing::Values( + Case{ + {"GroupNonUniformRotateKHR"}, false, "%u32", "%subgroup", "%u32_1"}, + Case{{"GroupNonUniformRotateKHR"}, true, "%u32", "%subgroup", "%u32_1"}, + Case{{"GroupNonUniformRotateKHR"}, + false, + "%u32", + "%subgroup", + "%u32_1", + "%u32_16"}, + Case{{"GroupNonUniformRotateKHR"}, + true, + "%u32", + "%subgroup", + "%u32_1", + "%u32_16"}, + Case{{"GroupNonUniformRotateKHR"}, + false, + "%u32", + "%subgroup", + "%u32_spec_1", + "%u32_16"}, + Case{{"GroupNonUniformRotateKHR"}, + true, + "%u32", + "%subgroup", + "%u32_1", + "%u32_spec_16"}, + Case{{"GroupNonUniformRotateKHR"}, + false, + "%u32", + "%workgroup", + "%u32_1"}, + Case{ + {"GroupNonUniformRotateKHR"}, true, "%u32", "%workgroup", "%u32_1"}, + Case{{"GroupNonUniformRotateKHR"}, + false, + "%u32", + "%workgroup", + "%u32_spec_1"}, + Case{{"GroupNonUniformRotateKHR"}, + true, + "%u32", + "%workgroup", + "%u32_spec_1"})); + +INSTANTIATE_TEST_SUITE_P( + RequiresCapability, ValidateSpvKHRSubgroupRotate, + ::testing::Values(Case{{}, + false, + "%u32", + "%subgroup", + "%u32_1", + "", + "Opcode GroupNonUniformRotateKHR requires one of " + "these capabilities: " + "GroupNonUniformRotateKHR"}, + Case{{}, + true, + "%u32", + "%subgroup", + "%u32_1", + "", + "Opcode GroupNonUniformRotateKHR requires one of " + "these capabilities: " + "GroupNonUniformRotateKHR"})); + +TEST_F(ValidateSpvKHRSubgroupRotate, RequiresExtension) { + const std::string str = R"( + OpCapability GroupNonUniformRotateKHR +)"; + CompileSuccessfully(str.c_str()); + EXPECT_NE(SPV_SUCCESS, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "1st operand of Capability: operand GroupNonUniformRotateKHR(6026) " + "requires one of these extensions: SPV_KHR_subgroup_rotate")); +} + +INSTANTIATE_TEST_SUITE_P( + InvalidExecutionScope, ValidateSpvKHRSubgroupRotate, + ::testing::Values( + Case{{"GroupNonUniformRotateKHR"}, + false, + "%u32", + "%invalid_scope", + "%u32_1", + "", + "Execution scope is limited to Subgroup or Workgroup"}, + Case{{"GroupNonUniformRotateKHR"}, + true, + "%u32", + "%invalid_scope", + "%u32_1", + "", + "Execution scope is limited to Subgroup or Workgroup"})); + +INSTANTIATE_TEST_SUITE_P( + InvalidResultType, ValidateSpvKHRSubgroupRotate, + ::testing::Values(Case{{"GroupNonUniformRotateKHR"}, + false, + "%ptr", + "%subgroup", + "%u32_1", + "", + "Expected Result Type to be a scalar or vector of " + "floating-point, integer or boolean type"}, + Case{{"GroupNonUniformRotateKHR"}, + true, + "%ptr", + "%subgroup", + "%u32_1", + "", + "Expected Result Type to be a scalar or vector of " + "floating-point, integer or boolean type"})); + +INSTANTIATE_TEST_SUITE_P( + MismatchedResultAndValueTypes, ValidateSpvKHRSubgroupRotate, + ::testing::Values( + Case{{"GroupNonUniformRotateKHR"}, + false, + "%float", + "%subgroup", + "%u32_1", + "", + "Result Type must be the same as the type of Value"}, + Case{{"GroupNonUniformRotateKHR"}, + true, + "%float", + "%subgroup", + "%u32_1", + "", + "Result Type must be the same as the type of Value"})); + +INSTANTIATE_TEST_SUITE_P( + InvalidDelta, ValidateSpvKHRSubgroupRotate, + ::testing::Values(Case{{"GroupNonUniformRotateKHR"}, + false, + "%u32", + "%subgroup", + "%f32_1", + "", + "Delta must be a scalar of integer type, whose " + "Signedness operand is 0"}, + Case{{"GroupNonUniformRotateKHR"}, + true, + "%u32", + "%subgroup", + "%f32_1", + "", + "Delta must be a scalar of integer type, whose " + "Signedness operand is 0"}, + Case{{"GroupNonUniformRotateKHR"}, + true, + "%u32", + "%subgroup", + "%i32_1", + "", + "Delta must be a scalar of integer type, whose " + "Signedness operand is 0"})); + +INSTANTIATE_TEST_SUITE_P( + InvalidClusterSize, ValidateSpvKHRSubgroupRotate, + ::testing::Values( + Case{{"GroupNonUniformRotateKHR"}, + false, + "%u32", + "%subgroup", + "%u32_1", + "%f32_1", + "ClusterSize must be a scalar of integer type, whose Signedness " + "operand is 0"}, + Case{{"GroupNonUniformRotateKHR"}, + true, + "%u32", + "%subgroup", + "%u32_1", + "%i32_1", + "ClusterSize must be a scalar of integer type, whose Signedness " + "operand is 0"}, + Case{{"GroupNonUniformRotateKHR"}, + true, + "%u32", + "%subgroup", + "%u32_1", + "%u32_0", + "Behavior is undefined unless ClusterSize is at least 1 and a " + "power of 2"}, + Case{{"GroupNonUniformRotateKHR"}, + true, + "%u32", + "%subgroup", + "%u32_1", + "%u32_15", + "Behavior is undefined unless ClusterSize is at least 1 and a " + "power of 2"}, + Case{{"GroupNonUniformRotateKHR"}, + true, + "%u32", + "%subgroup", + "%u32_1", + "%u32_undef", + "ClusterSize must come from a constant instruction"})); + +} // namespace +} // namespace val +} // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_extension_spv_khr_terminate_invocation.cpp b/third_party/spirv-tools/test/val/val_extension_spv_khr_terminate_invocation.cpp index 4cabf9e215..8d92414901 100644 --- a/third_party/spirv-tools/test/val/val_extension_spv_khr_terminate_invocation.cpp +++ b/third_party/spirv-tools/test/val/val_extension_spv_khr_terminate_invocation.cpp @@ -55,7 +55,7 @@ TEST_F(ValidateSpvKHRTerminateInvocation, Valid) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } -TEST_F(ValidateSpvKHRTerminateInvocation, RequiresExtension) { +TEST_F(ValidateSpvKHRTerminateInvocation, RequiresExtensionPre1p6) { const std::string str = R"( OpCapability Shader OpMemoryModel Logical Simple @@ -72,9 +72,30 @@ TEST_F(ValidateSpvKHRTerminateInvocation, RequiresExtension) { )"; CompileSuccessfully(str.c_str()); EXPECT_NE(SPV_SUCCESS, ValidateInstructions()); - EXPECT_THAT(getDiagnosticString(), - HasSubstr("TerminateInvocation requires one of the following " - "extensions: SPV_KHR_terminate_invocation")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "TerminateInvocation requires SPIR-V version 1.6 at minimum or one " + "of the following extensions: SPV_KHR_terminate_invocation")); +} + +TEST_F(ValidateSpvKHRTerminateInvocation, RequiresNoExtensionPost1p6) { + const std::string str = R"( + OpCapability Shader + OpMemoryModel Logical Simple + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + + %void = OpTypeVoid + %void_fn = OpTypeFunction %void + + %main = OpFunction %void None %void_fn + %entry = OpLabel + OpTerminateInvocation + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str(), SPV_ENV_UNIVERSAL_1_6); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_6)); } TEST_F(ValidateSpvKHRTerminateInvocation, RequiresShaderCapability) { diff --git a/third_party/spirv-tools/test/val/val_fixtures.h b/third_party/spirv-tools/test/val/val_fixtures.h index acbe0e5775..98d8d32a99 100644 --- a/third_party/spirv-tools/test/val/val_fixtures.h +++ b/third_party/spirv-tools/test/val/val_fixtures.h @@ -40,8 +40,10 @@ class ValidateBase : public ::testing::Test, // Assembles the given SPIR-V text, checks that it fails to assemble, // and returns resulting diagnostic. No internal state is updated. + // Setting the desired_result to SPV_SUCCESS is used to allow all results std::string CompileFailure(std::string code, - spv_target_env env = SPV_ENV_UNIVERSAL_1_0); + spv_target_env env = SPV_ENV_UNIVERSAL_1_0, + spv_result_t desired_result = SPV_SUCCESS); // Checks that 'code' is valid SPIR-V text representation and stores the // binary version for further method calls. @@ -108,11 +110,17 @@ void ValidateBase::TearDown() { template std::string ValidateBase::CompileFailure(std::string code, - spv_target_env env) { + spv_target_env env, + spv_result_t desired_result) { spv_diagnostic diagnostic = nullptr; - EXPECT_NE(SPV_SUCCESS, - spvTextToBinary(ScopedContext(env).context, code.c_str(), - code.size(), &binary_, &diagnostic)); + spv_result_t actual_result = + spvTextToBinary(ScopedContext(env).context, code.c_str(), code.size(), + &binary_, &diagnostic); + EXPECT_NE(SPV_SUCCESS, actual_result); + // optional check for exact result + if (desired_result != SPV_SUCCESS) { + EXPECT_EQ(actual_result, desired_result); + } std::string result(diagnostic->error); spvDiagnosticDestroy(diagnostic); return result; diff --git a/third_party/spirv-tools/test/val/val_id_test.cpp b/third_party/spirv-tools/test/val/val_id_test.cpp index ac05749333..69257a5875 100644 --- a/third_party/spirv-tools/test/val/val_id_test.cpp +++ b/third_party/spirv-tools/test/val/val_id_test.cpp @@ -1015,7 +1015,7 @@ TEST_F(ValidateIdWithMessage, OpTypeRuntimeArrayBad) { "type.")); } // TODO: Object of this type can only be created with OpVariable using the -// Unifrom Storage Class +// Uniform Storage Class TEST_F(ValidateIdWithMessage, OpTypeStructGood) { std::string spirv = kGLSL450MemoryModel + R"( @@ -2859,7 +2859,7 @@ TEST_F(ValidateIdWithMessage, OpStoreTypeRelaxedStruct) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } -// Same code as the last test excect for an extra decoration on one of the +// Same code as the last test except for an extra decoration on one of the // members. With the relaxed rules, the code is still valid. TEST_F(ValidateIdWithMessage, OpStoreTypeRelaxedStructWithExtraDecoration) { std::string spirv = kGLSL450MemoryModel + R"( diff --git a/third_party/spirv-tools/test/val/val_image_test.cpp b/third_party/spirv-tools/test/val/val_image_test.cpp index 11b14fb0ca..76af29ccb7 100644 --- a/third_party/spirv-tools/test/val/val_image_test.cpp +++ b/third_party/spirv-tools/test/val/val_image_test.cpp @@ -61,8 +61,11 @@ OpCapability ImageBuffer // In 1.4, the entry point must list all module-scope variables used. Just // list all of them. - std::string interface_vars = (env != SPV_ENV_UNIVERSAL_1_4) ? "" : - R"( + // + // For Vulkan, anything Location decoration needs to be an interface variable + std::string interface_vars = + (env != SPV_ENV_UNIVERSAL_1_4) ? "%input_flat_u32" : + R"( %uniform_image_f32_1d_0001 %uniform_image_f32_1d_0002_rgba32f %uniform_image_f32_2d_0001 @@ -243,6 +246,11 @@ OpDecorate %input_flat_u32 Location 0 %uniform_image_u32_2d_0001 = OpVariable %ptr_image_u32_2d_0001 UniformConstant %type_sampled_image_u32_2d_0001 = OpTypeSampledImage %type_image_u32_2d_0001 +%type_image_u32_3d_0001 = OpTypeImage %u32 3D 0 0 0 1 Unknown +%ptr_image_u32_3d_0001 = OpTypePointer UniformConstant %type_image_u32_3d_0001 +%uniform_image_u32_3d_0001 = OpVariable %ptr_image_u32_3d_0001 UniformConstant +%type_sampled_image_u32_3d_0001 = OpTypeSampledImage %type_image_u32_3d_0001 + %type_image_u32_2d_0002 = OpTypeImage %u32 2D 0 0 0 2 Unknown %ptr_image_u32_2d_0002 = OpTypePointer UniformConstant %type_image_u32_2d_0002 %uniform_image_u32_2d_0002 = OpVariable %ptr_image_u32_2d_0002 UniformConstant @@ -269,6 +277,11 @@ OpDecorate %input_flat_u32 Location 0 %uniform_image_f32_3d_0111 = OpVariable %ptr_image_f32_3d_0111 UniformConstant %type_sampled_image_f32_3d_0111 = OpTypeSampledImage %type_image_f32_3d_0111 +%type_image_f32_3d_0001 = OpTypeImage %f32 3D 0 0 0 1 Unknown +%ptr_image_f32_3d_0001 = OpTypePointer UniformConstant %type_image_f32_3d_0001 +%uniform_image_f32_3d_0001 = OpVariable %ptr_image_f32_3d_0001 UniformConstant +%type_sampled_image_f32_3d_0001 = OpTypeSampledImage %type_image_f32_3d_0001 + %type_image_f32_cube_0101 = OpTypeImage %f32 Cube 0 1 0 1 Unknown %ptr_image_f32_cube_0101 = OpTypePointer UniformConstant %type_image_f32_cube_0101 %uniform_image_f32_cube_0101 = OpVariable %ptr_image_f32_cube_0101 UniformConstant @@ -735,6 +748,34 @@ TEST_F(ValidateImage, TypeImageWrongSampledForSubpassData) { HasSubstr("Dim SubpassData requires Sampled to be 2")); } +TEST_F(ValidateImage, TypeImageWrongSampledForSubpassDataVulkan) { + const std::string code = GetShaderHeader("OpCapability InputAttachment\n") + + R"( +%img_type = OpTypeImage %f32 SubpassData 0 0 0 1 Unknown +)" + TrivialMain(); + + CompileSuccessfully(code.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeImage-06214")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Dim SubpassData requires Sampled to be 2")); +} + +TEST_F(ValidateImage, TypeImageWrongArrayForSubpassDataVulkan) { + const std::string code = GetShaderHeader("OpCapability InputAttachment\n") + + R"( +%img_type = OpTypeImage %f32 SubpassData 0 1 0 2 Unknown +)" + TrivialMain(); + + CompileSuccessfully(code.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeImage-06214")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Dim SubpassData requires Arrayed to be 0")); +} + TEST_F(ValidateImage, TypeImage_OpenCL_Sampled0_OK) { const std::string code = GetKernelHeader() + R"( %img_type = OpTypeImage %void 2D 0 0 0 0 Unknown ReadOnly @@ -1002,6 +1043,26 @@ TEST_F(ValidateImage, SampledImageNotSampler) { HasSubstr("Expected Sampler to be of type OpTypeSampler")); } +TEST_F(ValidateImage, SampledImageIsStorage) { + const std::string declarations = R"( +%type_sampled_image_f32_2d_0002 = OpTypeSampledImage %type_image_f32_2d_0002 +)"; + const std::string body = R"( +%img = OpLoad %type_image_f32_2d_0002 %uniform_image_f32_2d_0002 +%sampler = OpLoad %type_sampler %uniform_sampler +%simg = OpSampledImage %type_sampled_image_f32_2d_0002 %img %sampler +)"; + + CompileSuccessfully(GenerateShaderCode(body, "", "Fragment", "", + SPV_ENV_UNIVERSAL_1_0, "GLSL450", + declarations) + .c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Sampled image type requires an image type with " + "\"Sampled\" operand set to 0 or 1")); +} + TEST_F(ValidateImage, ImageTexelPointerSuccess) { const std::string body = R"( %texel_ptr = OpImageTexelPointer %ptr_Image_u32 %private_image_u32_buffer_0002_r32ui %u32_0 %u32_0 @@ -1059,7 +1120,7 @@ TEST_F(ValidateImage, ImageTexelPointerImageNotResultTypePointer) { CompileSuccessfully(GenerateShaderCode(body).c_str()); ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); - EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 136[%136] cannot be a " + EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 145[%145] cannot be a " "type")); } @@ -2290,6 +2351,24 @@ TEST_F(ValidateImage, SampleDrefImplicitLodWrongDrefType) { HasSubstr("Expected Dref to be of 32-bit float type")); } +TEST_F(ValidateImage, SampleDrefImplicitLodWrongDimVulkan) { + const std::string body = R"( +%img = OpLoad %type_image_u32_3d_0001 %uniform_image_u32_3d_0001 +%sampler = OpLoad %type_sampler %uniform_sampler +%simg = OpSampledImage %type_sampled_image_u32_3d_0001 %img %sampler +%res1 = OpImageSampleDrefImplicitLod %u32 %simg %f32vec3_hhh %f32_1 +)"; + + CompileSuccessfully( + GenerateShaderCode(body, "", "Fragment", "", SPV_ENV_VULKAN_1_0).c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpImage-04777")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("In Vulkan, OpImage*Dref* instructions must not use " + "images with a 3D Dim")); +} + TEST_F(ValidateImage, SampleDrefExplicitLodSuccess) { const std::string body = R"( %img = OpLoad %type_image_s32_3d_0001 %uniform_image_s32_3d_0001 @@ -3131,7 +3210,7 @@ TEST_F(ValidateImage, GatherConstOffsetsArrayNotVector) { CompileSuccessfully(GenerateShaderCode(body).c_str()); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("Expected Image Operand ConstOffsets array componenets " + HasSubstr("Expected Image Operand ConstOffsets array components " "to be int vectors of size 2")); } @@ -3146,7 +3225,7 @@ TEST_F(ValidateImage, GatherConstOffsetsArrayVectorWrongSize) { CompileSuccessfully(GenerateShaderCode(body).c_str()); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("Expected Image Operand ConstOffsets array componenets " + HasSubstr("Expected Image Operand ConstOffsets array components " "to be int vectors of size 2")); } @@ -3246,6 +3325,23 @@ TEST_F(ValidateImage, DrefGatherWrongDrefType) { HasSubstr("Expected Dref to be of 32-bit float type")); } +TEST_F(ValidateImage, DrefGatherWrongDimVulkan) { + const std::string body = R"( +%img = OpLoad %type_image_f32_3d_0001 %uniform_image_f32_3d_0001 +%sampler = OpLoad %type_sampler %uniform_sampler +%simg = OpSampledImage %type_sampled_image_f32_3d_0001 %img %sampler +%res1 = OpImageDrefGather %f32vec4 %simg %f32vec4_0000 %f32_0_5 +)"; + + CompileSuccessfully( + GenerateShaderCode(body, "", "Fragment", "", SPV_ENV_VULKAN_1_0).c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpImage-04777")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Expected Image 'Dim' to be 2D, Cube, or Rect")); +} + TEST_F(ValidateImage, ReadSuccess1) { const std::string body = R"( %img = OpLoad %type_image_u32_2d_0002 %uniform_image_u32_2d_0002 @@ -5464,7 +5560,8 @@ TEST_F(ValidateImage, SignExtendV13Bad) { )"; EXPECT_THAT(CompileFailure(GenerateShaderCode(body, "", "Fragment", "", - SPV_ENV_UNIVERSAL_1_3)), + SPV_ENV_UNIVERSAL_1_3), + SPV_ENV_UNIVERSAL_1_3, SPV_ERROR_WRONG_VERSION), HasSubstr("Invalid image operand 'SignExtend'")); } @@ -5475,7 +5572,8 @@ TEST_F(ValidateImage, ZeroExtendV13Bad) { )"; EXPECT_THAT(CompileFailure(GenerateShaderCode(body, "", "Fragment", "", - SPV_ENV_UNIVERSAL_1_3)), + SPV_ENV_UNIVERSAL_1_3), + SPV_ENV_UNIVERSAL_1_3, SPV_ERROR_WRONG_VERSION), HasSubstr("Invalid image operand 'ZeroExtend'")); } @@ -6099,6 +6197,57 @@ OpFunctionEnd "execution mode for GLCompute execution model")); } +TEST_F(ValidateImage, TypeSampledImageNotBufferPost1p6) { + const std::string text = R"( +OpCapability Shader +OpCapability Linkage +OpCapability SampledBuffer +OpMemoryModel Logical GLSL450 +%float = OpTypeFloat 32 +%image = OpTypeImage %float Buffer 0 0 0 1 Unknown +%sampled = OpTypeSampledImage %image +)"; + + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_6); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_6)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("In SPIR-V 1.6 or later, sampled image dimension must " + "not be Buffer")); +} + +TEST_F(ValidateImage, NonTemporalImage) { + const std::string text = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %2 " " %4 %5 +OpExecutionMode %2 OriginUpperLeft +%void = OpTypeVoid +%8 = OpTypeFunction %void +%float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%12 = OpTypeImage %float 2D 0 0 0 1 Rgba8ui +%13 = OpTypeSampledImage %12 +%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 +%5 = OpVariable %_ptr_UniformConstant_13 UniformConstant +%_ptr_Input_v4float = OpTypePointer Input %v4float +%4 = OpVariable %_ptr_Input_v4float Input +%v2float = OpTypeVector %float 2 +%float_1_35631564en19 = OpConstant %float 1.35631564e-19 +%2 = OpFunction %void None %8 +%8224 = OpLabel +%6 = OpLoad %13 %5 +%19 = OpLoad %v4float %4 +%20 = OpVectorShuffle %v2float %19 %19 0 1 +%21 = OpVectorTimesScalar %v2float %20 %float_1_35631564en19 +%65312 = OpImageSampleImplicitLod %v4float %6 %21 Nontemporal +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_6); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_6)); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_interfaces_test.cpp b/third_party/spirv-tools/test/val/val_interfaces_test.cpp index a01fc19b69..bec8d02672 100644 --- a/third_party/spirv-tools/test/val/val_interfaces_test.cpp +++ b/third_party/spirv-tools/test/val/val_interfaces_test.cpp @@ -447,6 +447,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Location-04918")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Members cannot be assigned a location")); } @@ -475,6 +477,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Location-04918")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Members cannot be assigned a location")); } @@ -1496,6 +1500,42 @@ OpFunctionEnd EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); } +TEST_F(ValidateInterfacesTest, StructWithBuiltinsMissingBlock_Bad) { + // See https://github.com/KhronosGroup/SPIRV-Registry/issues/134 + // + // When a shader input or output is a struct that does not have Block, + // then it must have a Location. + // But BuiltIns must not have locations. + const std::string text = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" %in +OpExecutionMode %main OriginUpperLeft +; %struct needs a Block decoration +OpMemberDecorate %struct 0 BuiltIn Position +%void = OpTypeVoid +%float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%struct = OpTypeStruct %v4float +%in_ptr = OpTypePointer Input %struct +%in = OpVariable %in_ptr Input +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-Location-04919")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Interface struct has no Block decoration but has BuiltIn members.")); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_limits_test.cpp b/third_party/spirv-tools/test/val/val_limits_test.cpp index 8fb80a46af..364d514edc 100644 --- a/third_party/spirv-tools/test/val/val_limits_test.cpp +++ b/third_party/spirv-tools/test/val/val_limits_test.cpp @@ -750,7 +750,7 @@ TEST_F(ValidateLimits, CustomizedControlFlowDepthBad) { } // Valid. The purpose here is to test the CFG depth calculation code when a loop -// continue target is the loop iteself. It also exercises the case where a loop +// continue target is the loop itself. It also exercises the case where a loop // is unreachable. TEST_F(ValidateLimits, ControlFlowNoEntryToLoopGood) { std::string str = header + R"( diff --git a/third_party/spirv-tools/test/val/val_literals_test.cpp b/third_party/spirv-tools/test/val/val_literals_test.cpp index 6eadf321cc..7c9aad67b2 100644 --- a/third_party/spirv-tools/test/val/val_literals_test.cpp +++ b/third_party/spirv-tools/test/val/val_literals_test.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Validation tests for ilegal literals +// Validation tests for illegal literals #include #include diff --git a/third_party/spirv-tools/test/val/val_logicals_test.cpp b/third_party/spirv-tools/test/val/val_logicals_test.cpp index b57c743371..1b76c8533e 100644 --- a/third_party/spirv-tools/test/val/val_logicals_test.cpp +++ b/third_party/spirv-tools/test/val/val_logicals_test.cpp @@ -1053,18 +1053,18 @@ TEST_F(ValidateLogicals, OpSGreaterThanDifferentBitWidth) { TEST_F(ValidateLogicals, PSBSelectSuccess) { const std::string body = R"( -OpCapability PhysicalStorageBufferAddressesEXT +OpCapability PhysicalStorageBufferAddresses OpCapability Int64 OpCapability Shader OpExtension "SPV_EXT_physical_storage_buffer" -OpMemoryModel PhysicalStorageBuffer64EXT GLSL450 +OpMemoryModel PhysicalStorageBuffer64 GLSL450 OpEntryPoint Fragment %main "main" OpExecutionMode %main OriginUpperLeft -OpDecorate %val1 AliasedPointerEXT +OpDecorate %val1 AliasedPointer %uint64 = OpTypeInt 64 0 %bool = OpTypeBool %true = OpConstantTrue %bool -%ptr = OpTypePointer PhysicalStorageBufferEXT %uint64 +%ptr = OpTypePointer PhysicalStorageBuffer %uint64 %pptr_f = OpTypePointer Function %ptr %void = OpTypeVoid %voidfn = OpTypeFunction %void diff --git a/third_party/spirv-tools/test/val/val_memory_test.cpp b/third_party/spirv-tools/test/val/val_memory_test.cpp index 2a884c4da5..5fb43f7ba0 100644 --- a/third_party/spirv-tools/test/val/val_memory_test.cpp +++ b/third_party/spirv-tools/test/val/val_memory_test.cpp @@ -833,11 +833,45 @@ TEST_F(ValidateMemory, VulkanPushConstantNotStructBad) { )"; CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); - EXPECT_THAT(getDiagnosticString(), - HasSubstr("PushConstant OpVariable '6[%6]' has illegal " - "type.\nFrom Vulkan spec, section 14.5.1:\n" - "Such variables must be typed as OpTypeStruct, " - "or an array of this type")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("PushConstant OpVariable '6[%6]' has illegal " + "type.\nFrom Vulkan spec, Push Constant Interface section:\n" + "Such variables must be typed as OpTypeStruct")); +} + +TEST_F(ValidateMemory, VulkanPushConstantArrayOfStructBad) { + std::string spirv = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %1 "main" + OpExecutionMode %1 OriginUpperLeft + + OpDecorate %struct Block + OpMemberDecorate %struct 0 Offset 0 + + %void = OpTypeVoid + %voidfn = OpTypeFunction %void + %float = OpTypeFloat 32 + %int = OpTypeInt 32 0 + %int_1 = OpConstant %int 1 + %struct = OpTypeStruct %float + %array = OpTypeArray %struct %int_1 + %ptr = OpTypePointer PushConstant %array + %pc = OpVariable %ptr PushConstant + + %1 = OpFunction %void None %voidfn + %label = OpLabel + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("PushConstant OpVariable '10[%10]' has illegal " + "type.\nFrom Vulkan spec, Push Constant Interface section:\n" + "Such variables must be typed as OpTypeStruct")); } TEST_F(ValidateMemory, VulkanPushConstant) { @@ -1563,16 +1597,16 @@ OpFunctionEnd TEST_F(ValidateMemory, PSBLoadAlignedSuccess) { const std::string body = R"( -OpCapability PhysicalStorageBufferAddressesEXT +OpCapability PhysicalStorageBufferAddresses OpCapability Int64 OpCapability Shader OpExtension "SPV_EXT_physical_storage_buffer" -OpMemoryModel PhysicalStorageBuffer64EXT GLSL450 +OpMemoryModel PhysicalStorageBuffer64 GLSL450 OpEntryPoint Fragment %main "main" OpExecutionMode %main OriginUpperLeft -OpDecorate %val1 AliasedPointerEXT +OpDecorate %val1 AliasedPointer %uint64 = OpTypeInt 64 0 -%ptr = OpTypePointer PhysicalStorageBufferEXT %uint64 +%ptr = OpTypePointer PhysicalStorageBuffer %uint64 %pptr_f = OpTypePointer Function %ptr %void = OpTypeVoid %voidfn = OpTypeFunction %void @@ -1585,22 +1619,22 @@ OpReturn OpFunctionEnd )"; - CompileSuccessfully(body.c_str()); - ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_2); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); } TEST_F(ValidateMemory, PSBLoadAlignedMissing) { const std::string body = R"( -OpCapability PhysicalStorageBufferAddressesEXT +OpCapability PhysicalStorageBufferAddresses OpCapability Int64 OpCapability Shader OpExtension "SPV_EXT_physical_storage_buffer" -OpMemoryModel PhysicalStorageBuffer64EXT GLSL450 +OpMemoryModel PhysicalStorageBuffer64 GLSL450 OpEntryPoint Fragment %main "main" OpExecutionMode %main OriginUpperLeft -OpDecorate %val1 AliasedPointerEXT +OpDecorate %val1 AliasedPointer %uint64 = OpTypeInt 64 0 -%ptr = OpTypePointer PhysicalStorageBufferEXT %uint64 +%ptr = OpTypePointer PhysicalStorageBuffer %uint64 %pptr_f = OpTypePointer Function %ptr %void = OpTypeVoid %voidfn = OpTypeFunction %void @@ -1613,27 +1647,61 @@ OpReturn OpFunctionEnd )"; - CompileSuccessfully(body.c_str()); - ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_2); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-PhysicalStorageBuffer64-04708")); EXPECT_THAT( getDiagnosticString(), - HasSubstr( - "Memory accesses with PhysicalStorageBufferEXT must use Aligned")); + HasSubstr("Memory accesses with PhysicalStorageBuffer must use Aligned")); +} + +TEST_F(ValidateMemory, PSBLoadAlignedMissingWithOtherOperand) { + const std::string body = R"( +OpCapability PhysicalStorageBufferAddresses +OpCapability Int64 +OpCapability Shader +OpExtension "SPV_EXT_physical_storage_buffer" +OpMemoryModel PhysicalStorageBuffer64 GLSL450 +OpEntryPoint Fragment %main "main" +OpExecutionMode %main OriginUpperLeft +OpDecorate %val1 AliasedPointer +%uint64 = OpTypeInt 64 0 +%ptr = OpTypePointer PhysicalStorageBuffer %uint64 +%pptr_f = OpTypePointer Function %ptr +%void = OpTypeVoid +%voidfn = OpTypeFunction %void +%main = OpFunction %void None %voidfn +%entry = OpLabel +%val1 = OpVariable %pptr_f Function +%val2 = OpLoad %ptr %val1 +%val3 = OpLoad %uint64 %val2 Volatile +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_2); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-PhysicalStorageBuffer64-04708")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Memory accesses with PhysicalStorageBuffer must use Aligned")); } TEST_F(ValidateMemory, PSBStoreAlignedSuccess) { const std::string body = R"( -OpCapability PhysicalStorageBufferAddressesEXT +OpCapability PhysicalStorageBufferAddresses OpCapability Int64 OpCapability Shader OpExtension "SPV_EXT_physical_storage_buffer" -OpMemoryModel PhysicalStorageBuffer64EXT GLSL450 +OpMemoryModel PhysicalStorageBuffer64 GLSL450 OpEntryPoint Fragment %main "main" OpExecutionMode %main OriginUpperLeft -OpDecorate %val1 AliasedPointerEXT +OpDecorate %val1 AliasedPointer %uint64 = OpTypeInt 64 0 %u64_1 = OpConstant %uint64 1 -%ptr = OpTypePointer PhysicalStorageBufferEXT %uint64 +%ptr = OpTypePointer PhysicalStorageBuffer %uint64 %pptr_f = OpTypePointer Function %ptr %void = OpTypeVoid %voidfn = OpTypeFunction %void @@ -1646,23 +1714,23 @@ OpReturn OpFunctionEnd )"; - CompileSuccessfully(body.c_str()); - ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_2); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); } TEST_F(ValidateMemory, PSBStoreAlignedMissing) { const std::string body = R"( -OpCapability PhysicalStorageBufferAddressesEXT +OpCapability PhysicalStorageBufferAddresses OpCapability Int64 OpCapability Shader OpExtension "SPV_EXT_physical_storage_buffer" -OpMemoryModel PhysicalStorageBuffer64EXT GLSL450 +OpMemoryModel PhysicalStorageBuffer64 GLSL450 OpEntryPoint Fragment %main "main" OpExecutionMode %main OriginUpperLeft -OpDecorate %val1 AliasedPointerEXT +OpDecorate %val1 AliasedPointer %uint64 = OpTypeInt 64 0 %u64_1 = OpConstant %uint64 1 -%ptr = OpTypePointer PhysicalStorageBufferEXT %uint64 +%ptr = OpTypePointer PhysicalStorageBuffer %uint64 %pptr_f = OpTypePointer Function %ptr %void = OpTypeVoid %voidfn = OpTypeFunction %void @@ -1675,27 +1743,168 @@ OpReturn OpFunctionEnd )"; - CompileSuccessfully(body.c_str()); - ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_2); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-PhysicalStorageBuffer64-04708")); EXPECT_THAT( getDiagnosticString(), - HasSubstr( - "Memory accesses with PhysicalStorageBufferEXT must use Aligned")); + HasSubstr("Memory accesses with PhysicalStorageBuffer must use Aligned")); +} + +TEST_F(ValidateMemory, PSBCopyMemoryAlignedSuccess) { + const std::string body = R"( +OpCapability PhysicalStorageBufferAddresses +OpCapability Int64 +OpCapability Shader +OpExtension "SPV_EXT_physical_storage_buffer" +OpMemoryModel PhysicalStorageBuffer64 GLSL450 +OpEntryPoint Fragment %main "main" +OpExecutionMode %main OriginUpperLeft +OpDecorate %val1 AliasedPointer +%int = OpTypeInt 32 0 +%uint64 = OpTypeInt 64 0 +%u64_1 = OpConstant %uint64 1 +%ptr = OpTypePointer PhysicalStorageBuffer %uint64 +%pptr_f = OpTypePointer Function %ptr +%void = OpTypeVoid +%voidfn = OpTypeFunction %void +%main = OpFunction %void None %voidfn +%entry = OpLabel +%val1 = OpVariable %pptr_f Function +%val2 = OpLoad %ptr %val1 +%val3 = OpLoad %ptr %val1 +OpCopyMemory %val2 %val3 Aligned 4 +OpCopyMemory %val3 %val2 Aligned 4 Aligned 4 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); +} + +TEST_F(ValidateMemory, PSBCopyMemoryAlignedMissingTarget) { + const std::string body = R"( +OpCapability PhysicalStorageBufferAddresses +OpCapability Int64 +OpCapability Shader +OpExtension "SPV_EXT_physical_storage_buffer" +OpMemoryModel PhysicalStorageBuffer64 GLSL450 +OpEntryPoint Fragment %main "main" +OpExecutionMode %main OriginUpperLeft +OpDecorate %val1 AliasedPointer +%int = OpTypeInt 32 0 +%uint64 = OpTypeInt 64 0 +%u64_1 = OpConstant %uint64 1 +%ptr = OpTypePointer PhysicalStorageBuffer %uint64 +%pptr_f = OpTypePointer Function %ptr +%void = OpTypeVoid +%voidfn = OpTypeFunction %void +%main = OpFunction %void None %voidfn +%entry = OpLabel +%val1 = OpVariable %pptr_f Function +%val2 = OpLoad %ptr %val1 +%val3 = OpLoad %ptr %val1 +OpCopyMemory %val2 %val3 Volatile Aligned 4 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_2); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-PhysicalStorageBuffer64-04708")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Memory accesses with PhysicalStorageBuffer must use Aligned")); +} + +TEST_F(ValidateMemory, PSBCopyMemoryAlignedMissingSource) { + const std::string body = R"( +OpCapability PhysicalStorageBufferAddresses +OpCapability Int64 +OpCapability Shader +OpExtension "SPV_EXT_physical_storage_buffer" +OpMemoryModel PhysicalStorageBuffer64 GLSL450 +OpEntryPoint Fragment %main "main" +OpExecutionMode %main OriginUpperLeft +OpDecorate %val1 AliasedPointer +%int = OpTypeInt 32 0 +%uint64 = OpTypeInt 64 0 +%u64_1 = OpConstant %uint64 1 +%ptr = OpTypePointer PhysicalStorageBuffer %uint64 +%pptr_f = OpTypePointer Function %ptr +%void = OpTypeVoid +%voidfn = OpTypeFunction %void +%main = OpFunction %void None %voidfn +%entry = OpLabel +%val1 = OpVariable %pptr_f Function +%val2 = OpLoad %ptr %val1 +%val3 = OpLoad %ptr %val1 +OpCopyMemory %val2 %val3 Aligned 4 Volatile +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_2); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-PhysicalStorageBuffer64-04708")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Memory accesses with PhysicalStorageBuffer must use Aligned")); +} + +TEST_F(ValidateMemory, PSBCopyMemoryAlignedMissingBoth) { + const std::string body = R"( +OpCapability PhysicalStorageBufferAddresses +OpCapability Int64 +OpCapability Shader +OpExtension "SPV_EXT_physical_storage_buffer" +OpMemoryModel PhysicalStorageBuffer64 GLSL450 +OpEntryPoint Fragment %main "main" +OpExecutionMode %main OriginUpperLeft +OpDecorate %val1 AliasedPointer +%int = OpTypeInt 32 0 +%uint64 = OpTypeInt 64 0 +%u64_1 = OpConstant %uint64 1 +%ptr = OpTypePointer PhysicalStorageBuffer %uint64 +%pptr_f = OpTypePointer Function %ptr +%void = OpTypeVoid +%voidfn = OpTypeFunction %void +%main = OpFunction %void None %voidfn +%entry = OpLabel +%val1 = OpVariable %pptr_f Function +%val2 = OpLoad %ptr %val1 +%val3 = OpLoad %ptr %val1 +OpCopyMemory %val2 %val3 Volatile +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_2); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-PhysicalStorageBuffer64-04708")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Memory accesses with PhysicalStorageBuffer must use Aligned")); } TEST_F(ValidateMemory, PSBVariable) { const std::string body = R"( -OpCapability PhysicalStorageBufferAddressesEXT +OpCapability PhysicalStorageBufferAddresses OpCapability Int64 OpCapability Shader OpExtension "SPV_EXT_physical_storage_buffer" -OpMemoryModel PhysicalStorageBuffer64EXT GLSL450 +OpMemoryModel PhysicalStorageBuffer64 GLSL450 OpEntryPoint Fragment %main "main" OpExecutionMode %main OriginUpperLeft -OpDecorate %val1 AliasedPointerEXT +OpDecorate %val1 AliasedPointer %uint64 = OpTypeInt 64 0 -%ptr = OpTypePointer PhysicalStorageBufferEXT %uint64 -%val1 = OpVariable %ptr PhysicalStorageBufferEXT +%ptr = OpTypePointer PhysicalStorageBuffer %uint64 +%val1 = OpVariable %ptr PhysicalStorageBuffer %void = OpTypeVoid %voidfn = OpTypeFunction %void %main = OpFunction %void None %voidfn @@ -1708,7 +1917,7 @@ OpFunctionEnd EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), - HasSubstr("PhysicalStorageBufferEXT must not be used with OpVariable")); + HasSubstr("PhysicalStorageBuffer must not be used with OpVariable")); } std::string GenCoopMatLoadStoreShader(const std::string& storeMemoryAccess, @@ -2097,6 +2306,8 @@ OpFunctionEnd CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeRuntimeArray-04680")); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -2162,6 +2373,8 @@ OpFunctionEnd CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeRuntimeArray-04680")); EXPECT_THAT( getDiagnosticString(), HasSubstr("For Vulkan with RuntimeDescriptorArrayEXT, a variable " @@ -2217,11 +2430,14 @@ OpFunctionEnd CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeRuntimeArray-04680")); EXPECT_THAT( getDiagnosticString(), HasSubstr( "For Vulkan, OpTypeStruct variables containing OpTypeRuntimeArray " - "must have storage class of StorageBuffer or Uniform.\n %6 = " + "must have storage class of StorageBuffer, PhysicalStorageBuffer, or " + "Uniform.\n %6 = " "OpVariable %_ptr_Workgroup__struct_4 Workgroup\n")); } @@ -2246,10 +2462,13 @@ OpFunctionEnd CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeRuntimeArray-04680")); EXPECT_THAT(getDiagnosticString(), HasSubstr("For Vulkan, an OpTypeStruct variable containing an " "OpTypeRuntimeArray must be decorated with Block if it " - "has storage class StorageBuffer.\n %6 = OpVariable " + "has storage class StorageBuffer or " + "PhysicalStorageBuffer.\n %6 = OpVariable " "%_ptr_StorageBuffer__struct_4 StorageBuffer\n")); } @@ -2300,6 +2519,8 @@ OpFunctionEnd CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeRuntimeArray-04680")); EXPECT_THAT(getDiagnosticString(), HasSubstr("For Vulkan, an OpTypeStruct variable containing an " "OpTypeRuntimeArray must be decorated with BufferBlock " @@ -2328,6 +2549,8 @@ OpFunctionEnd CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeRuntimeArray-04680")); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -2361,6 +2584,8 @@ OpFunctionEnd CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeRuntimeArray-04680")); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -2423,6 +2648,8 @@ OpFunctionEnd CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeRuntimeArray-04680")); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -2459,6 +2686,8 @@ OpFunctionEnd CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeRuntimeArray-04680")); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -2490,6 +2719,8 @@ OpFunctionEnd CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeRuntimeArray-04680")); EXPECT_THAT( getDiagnosticString(), HasSubstr("OpTypeArray Element Type '5[%_runtimearr_4]' is not " @@ -2524,6 +2755,8 @@ OpFunctionEnd CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeRuntimeArray-04680")); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -2558,6 +2791,8 @@ OpFunctionEnd CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeRuntimeArray-04680")); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -2595,6 +2830,8 @@ OpFunctionEnd CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeRuntimeArray-04680")); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -3015,8 +3252,8 @@ OpFunctionEnd EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); EXPECT_THAT(getDiagnosticString(), - HasSubstr("Instruction cannot be used without a variable " - "pointers capability")); + HasSubstr("Instruction cannot for logical addressing model be " + "used without a variable pointers capability")); } } @@ -4048,7 +4285,7 @@ TEST_F(ValidateMemory, VulkanInvariantOutputSuccess) { const std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %main "main" +OpEntryPoint Vertex %main "main" %var OpDecorate %var Location 0 OpDecorate %var Invariant %void = OpTypeVoid @@ -4070,7 +4307,7 @@ TEST_F(ValidateMemory, VulkanInvariantInputStructSuccess) { const std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" +OpEntryPoint Fragment %main "main" %var OpExecutionMode %main OriginUpperLeft OpDecorate %var Location 0 OpMemberDecorate %struct 1 Invariant @@ -4259,8 +4496,10 @@ OpFunctionEnd CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); EXPECT_THAT(getDiagnosticString(), - HasSubstr("Variable initializers in Workgroup storage class are " - "limited to OpConstantNull")); + AnyVUID(" VUID-StandaloneSpirv-OpVariable-04734")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpVariable, '5[%5]', initializers are limited to " + "OpConstantNull in Workgroup storage class")); } TEST_F(ValidateMemory, VulkanInitializerWithWorkgroupStorageClassGood) { diff --git a/third_party/spirv-tools/test/val/val_modes_test.cpp b/third_party/spirv-tools/test/val/val_modes_test.cpp index 02a61327e9..a37989b436 100644 --- a/third_party/spirv-tools/test/val/val_modes_test.cpp +++ b/third_party/spirv-tools/test/val/val_modes_test.cpp @@ -1178,6 +1178,26 @@ OpFunctionEnd HasSubstr("Expected bool scalar type as Result Type")); } +TEST_F(ValidateMode, LocalSizeIdVulkan1p3DoesNotRequireOption) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionModeId %main LocalSizeId %int_1 %int_1 %int_1 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_1 = OpConstant %int 1 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3)); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_non_semantic_test.cpp b/third_party/spirv-tools/test/val/val_non_semantic_test.cpp index b80bb1ac94..210cd1ac13 100644 --- a/third_party/spirv-tools/test/val/val_non_semantic_test.cpp +++ b/third_party/spirv-tools/test/val/val_non_semantic_test.cpp @@ -105,7 +105,7 @@ INSTANTIATE_TEST_SUITE_P(OnlyOpExtension, ValidateNonSemanticGenerated, Values(""), Values(TestResult()))); INSTANTIATE_TEST_SUITE_P( - MissingOpExtension, ValidateNonSemanticGenerated, + MissingOpExtensionPre1p6, ValidateNonSemanticGenerated, Combine(Values(false), Values(true), Values(""), Values(""), Values(TestResult( SPV_ERROR_INVALID_DATA, @@ -190,6 +190,26 @@ OpEntryPoint Vertex %main "main" HasSubstr("ID 2[%2] has not been defined")); } +TEST_F(ValidateNonSemanticString, MissingOpExtensionPost1p6) { + const std::string spirv = R"( +OpCapability Shader +%extinst = OpExtInstImport "NonSemantic.Testing.Set" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" +OpExecutionMode %main OriginUpperLeft +%void = OpTypeVoid +%test = OpExtInst %void %extinst 3 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_6); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_6)); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_storage_test.cpp b/third_party/spirv-tools/test/val/val_storage_test.cpp index 35f6a8d5ec..ae4047b9a5 100644 --- a/third_party/spirv-tools/test/val/val_storage_test.cpp +++ b/third_party/spirv-tools/test/val/val_storage_test.cpp @@ -280,7 +280,7 @@ TEST_P(ValidateStorageExecutionModel, VulkanOutsideStoreFailure) { AnyVUID("VUID-StandaloneSpirv-None-04644")); EXPECT_THAT( getDiagnosticString(), - HasSubstr("in Vulkan evironment, Output Storage Class must not be used " + HasSubstr("in Vulkan environment, Output Storage Class must not be used " "in GLCompute, RayGenerationKHR, IntersectionKHR, AnyHitKHR, " "ClosestHitKHR, MissKHR, or CallableKHR execution models")); } diff --git a/third_party/spirv-tools/test/val/val_version_test.cpp b/third_party/spirv-tools/test/val/val_version_test.cpp index 98565ddb8b..6b7c4fe840 100644 --- a/third_party/spirv-tools/test/val/val_version_test.cpp +++ b/third_party/spirv-tools/test/val/val_version_test.cpp @@ -74,6 +74,12 @@ std::string version(spv_target_env env) { case SPV_ENV_UNIVERSAL_1_4: case SPV_ENV_VULKAN_1_1_SPIRV_1_4: return "1.4"; + case SPV_ENV_UNIVERSAL_1_5: + case SPV_ENV_VULKAN_1_2: + return "1.5"; + case SPV_ENV_UNIVERSAL_1_6: + case SPV_ENV_VULKAN_1_3: + return "1.6"; default: return "0"; } @@ -103,8 +109,14 @@ INSTANTIATE_TEST_SUITE_P(Universal, ValidateVersion, std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_VULKAN_1_0, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_VULKAN_1_1_SPIRV_1_4,vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_0, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_1, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_2, vulkan_spirv, true), @@ -115,8 +127,14 @@ INSTANTIATE_TEST_SUITE_P(Universal, ValidateVersion, std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), @@ -127,8 +145,14 @@ INSTANTIATE_TEST_SUITE_P(Universal, ValidateVersion, std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), @@ -139,13 +163,73 @@ INSTANTIATE_TEST_SUITE_P(Universal, ValidateVersion, std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), - std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_5, vulkan_spirv, false) + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_5, vulkan_spirv, false), + + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_VULKAN_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_OPENGL_4_5, vulkan_spirv, false), + + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_OPENGL_4_5, vulkan_spirv, false), + + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_OPENGL_4_5, vulkan_spirv, false) ) ); @@ -156,27 +240,91 @@ INSTANTIATE_TEST_SUITE_P(Vulkan, ValidateVersion, std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_0, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_0, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_1, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_3, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_5, vulkan_spirv, true), - std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_5, vulkan_spirv, false), - std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true) + + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_VULKAN_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_OPENGL_4_5, vulkan_spirv, false), + + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_OPENGL_4_5, vulkan_spirv, false), + + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_VULKAN_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_VULKAN_1_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_OPENGL_4_5, vulkan_spirv, false) ) ); @@ -187,6 +335,9 @@ INSTANTIATE_TEST_SUITE_P(OpenCL, ValidateVersion, std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_4, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_5, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_6, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_2_0, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_2_1, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_2_2, opencl_spirv, true), @@ -199,6 +350,9 @@ INSTANTIATE_TEST_SUITE_P(OpenCL, ValidateVersion, std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_4, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_5, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_6, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_2_0, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_2_1, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_2_2, opencl_spirv, true), @@ -211,6 +365,9 @@ INSTANTIATE_TEST_SUITE_P(OpenCL, ValidateVersion, std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, false), std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_4, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_5, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_6, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_2_0, opencl_spirv, false), std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_2_1, opencl_spirv, false), std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_2_2, opencl_spirv, true), @@ -223,6 +380,9 @@ INSTANTIATE_TEST_SUITE_P(OpenCL, ValidateVersion, std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_4, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_5, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_6, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_2_0, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_2_1, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_2_2, opencl_spirv, true), diff --git a/third_party/spirv-tools/tools/CMakeLists.txt b/third_party/spirv-tools/tools/CMakeLists.txt index 6039089a07..86d0bc46a0 100644 --- a/third_party/spirv-tools/tools/CMakeLists.txt +++ b/third_party/spirv-tools/tools/CMakeLists.txt @@ -41,10 +41,11 @@ endfunction() if (NOT ${SPIRV_SKIP_EXECUTABLES}) add_spvtools_tool(TARGET spirv-as SRCS as/as.cpp LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) + add_spvtools_tool(TARGET spirv-diff SRCS diff/diff.cpp util/cli_consumer.cpp LIBS SPIRV-Tools-diff SPIRV-Tools-opt ${SPIRV_TOOLS_FULL_VISIBILITY}) add_spvtools_tool(TARGET spirv-dis SRCS dis/dis.cpp LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) add_spvtools_tool(TARGET spirv-val SRCS val/val.cpp util/cli_consumer.cpp LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) add_spvtools_tool(TARGET spirv-opt SRCS opt/opt.cpp util/cli_consumer.cpp LIBS SPIRV-Tools-opt ${SPIRV_TOOLS_FULL_VISIBILITY}) - if (NOT DEFINED IOS_PLATFORM) # iOS does not allow std::system calls which spirv-reduce requires + if(NOT (${CMAKE_SYSTEM_NAME} STREQUAL "iOS")) # iOS does not allow std::system calls which spirv-reduce requires add_spvtools_tool(TARGET spirv-reduce SRCS reduce/reduce.cpp util/cli_consumer.cpp LIBS SPIRV-Tools-reduce ${SPIRV_TOOLS_FULL_VISIBILITY}) endif() add_spvtools_tool(TARGET spirv-link SRCS link/linker.cpp LIBS SPIRV-Tools-link ${SPIRV_TOOLS_FULL_VISIBILITY}) @@ -58,7 +59,7 @@ if (NOT ${SPIRV_SKIP_EXECUTABLES}) ${SPIRV_HEADER_INCLUDE_DIR}) set(SPIRV_INSTALL_TARGETS spirv-as spirv-dis spirv-val spirv-opt spirv-cfg spirv-link spirv-lint) - if(NOT DEFINED IOS_PLATFORM) + if(NOT (${CMAKE_SYSTEM_NAME} STREQUAL "iOS")) set(SPIRV_INSTALL_TARGETS ${SPIRV_INSTALL_TARGETS} spirv-reduce) endif() @@ -68,9 +69,6 @@ if (NOT ${SPIRV_SKIP_EXECUTABLES}) endif(SPIRV_BUILD_FUZZER) if(ENABLE_SPIRV_TOOLS_INSTALL) - install(TARGETS ${SPIRV_INSTALL_TARGETS} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${SPIRV_INSTALL_TARGETS} DESTINATION ${CMAKE_INSTALL_BINDIR}) endif(ENABLE_SPIRV_TOOLS_INSTALL) endif() diff --git a/third_party/spirv-tools/tools/as/as.cpp b/third_party/spirv-tools/tools/as/as.cpp index c8a44456a9..506b058562 100644 --- a/third_party/spirv-tools/tools/as/as.cpp +++ b/third_party/spirv-tools/tools/as/as.cpp @@ -48,7 +48,7 @@ Options: argv0, argv0, target_env_list.c_str()); } -static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_5; +static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; int main(int argc, char** argv) { const char* inFile = nullptr; diff --git a/third_party/spirv-tools/tools/cfg/bin_to_dot.cpp b/third_party/spirv-tools/tools/cfg/bin_to_dot.cpp index 2561eea401..72e7693adb 100644 --- a/third_party/spirv-tools/tools/cfg/bin_to_dot.cpp +++ b/third_party/spirv-tools/tools/cfg/bin_to_dot.cpp @@ -57,13 +57,13 @@ class DotConverter { // Ends processing for the current block, emitting its dot code. void FlushBlock(const std::vector& successors); - // The ID of the current functio, or 0 if outside of a function. + // The ID of the current function, or 0 if outside of a function. uint32_t current_function_id_ = 0; // The ID of the current basic block, or 0 if outside of a block. uint32_t current_block_id_ = 0; - // Have we completed processing for the entry block to this fuction? + // Have we completed processing for the entry block to this function? bool seen_function_entry_block_ = false; // The Id of the merge block for this block if it exists, or 0 otherwise. diff --git a/third_party/spirv-tools/tools/cfg/bin_to_dot.h b/third_party/spirv-tools/tools/cfg/bin_to_dot.h index 4de2e07faf..a61c97590f 100644 --- a/third_party/spirv-tools/tools/cfg/bin_to_dot.h +++ b/third_party/spirv-tools/tools/cfg/bin_to_dot.h @@ -20,7 +20,7 @@ #include "spirv-tools/libspirv.h" // Dumps the control flow graph for the given module to the output stream. -// Returns SPV_SUCCESS on succes. +// Returns SPV_SUCCESS on success. spv_result_t BinaryToDot(const spv_const_context context, const uint32_t* words, size_t num_words, std::iostream* out, spv_diagnostic* diagnostic); diff --git a/third_party/spirv-tools/tools/cfg/cfg.cpp b/third_party/spirv-tools/tools/cfg/cfg.cpp index 6a5faa18c9..5380c21ecd 100644 --- a/third_party/spirv-tools/tools/cfg/cfg.cpp +++ b/third_party/spirv-tools/tools/cfg/cfg.cpp @@ -44,7 +44,7 @@ Options: argv0, argv0); } -static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_5; +static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; int main(int argc, char** argv) { const char* inFile = nullptr; diff --git a/third_party/spirv-tools/tools/diff/diff.cpp b/third_party/spirv-tools/tools/diff/diff.cpp new file mode 100644 index 0000000000..d3cad04b11 --- /dev/null +++ b/third_party/spirv-tools/tools/diff/diff.cpp @@ -0,0 +1,201 @@ +// Copyright (c) 2022 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) +#include +#endif + +#include "source/diff/diff.h" + +#include "source/opt/build_module.h" +#include "source/opt/ir_context.h" +#include "spirv-tools/libspirv.hpp" +#include "tools/io.h" +#include "tools/util/cli_consumer.h" + +static void print_usage(char* argv0) { + printf(R"(%s - Compare two SPIR-V files + +Usage: %s + +The SPIR-V binary is read from and . If either +file ends in .spvasm, the SPIR-V is read as text and disassembled. + +The contents of the SPIR-V modules are analyzed and a diff is produced showing a +logical transformation from src to dst, in src's id-space. + + -h, --help Print this help. + --version Display diff version information. + + --color Force color output. The default when printing to a terminal. + Overrides a previous --no-color option. + --no-color Don't print in color. Overrides a previous --color option. + The default when output goes to something other than a + terminal (e.g. a pipe, or a shell redirection). + + --no-indent Don't indent instructions. + + --no-header Don't output the header as leading comments. + + --with-id-map Also output the mapping between src and dst outputs. + + --ignore-set-binding + Don't use set/binding decorations for variable matching. + --ignore-location + Don't use location decorations for variable matching. +)", + argv0, argv0); +} + +static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; + +static bool is_assembly(const char* path) { + const char* suffix = strrchr(path, '.'); + if (suffix == nullptr) { + return false; + } + + return strcmp(suffix, ".spvasm") == 0; +} + +static std::unique_ptr load_module(const char* path) { + if (is_assembly(path)) { + std::vector contents; + if (!ReadTextFile(path, &contents)) return {}; + + return spvtools::BuildModule( + kDefaultEnvironment, spvtools::utils::CLIMessageConsumer, + std::string(contents.begin(), contents.end()), + spvtools::SpirvTools::kDefaultAssembleOption | + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + } + + std::vector contents; + if (!ReadBinaryFile(path, &contents)) return {}; + + return spvtools::BuildModule(kDefaultEnvironment, + spvtools::utils::CLIMessageConsumer, + contents.data(), contents.size()); +} + +int main(int argc, char** argv) { + const char* src_file = nullptr; + const char* dst_file = nullptr; + bool color_is_possible = +#if SPIRV_COLOR_TERMINAL + true; +#else + false; +#endif + bool force_color = false; + bool force_no_color = false; + bool allow_indent = true; + bool no_header = false; + bool dump_id_map = false; + bool ignore_set_binding = false; + bool ignore_location = false; + + for (int argi = 1; argi < argc; ++argi) { + if ('-' == argv[argi][0]) { + switch (argv[argi][1]) { + case 'h': + print_usage(argv[0]); + return 0; + case '-': { + // Long options + if (strcmp(argv[argi], "--no-color") == 0) { + force_no_color = true; + force_color = false; + } else if (strcmp(argv[argi], "--color") == 0) { + force_no_color = false; + force_color = true; + } else if (strcmp(argv[argi], "--no-indent") == 0) { + allow_indent = false; + } else if (strcmp(argv[argi], "--no-header") == 0) { + no_header = true; + } else if (strcmp(argv[argi], "--with-id-map") == 0) { + dump_id_map = true; + } else if (strcmp(argv[argi], "--ignore-set-binding") == 0) { + ignore_set_binding = true; + } else if (strcmp(argv[argi], "--ignore-location") == 0) { + ignore_location = true; + } else if (strcmp(argv[argi], "--help") == 0) { + print_usage(argv[0]); + return 0; + } else if (strcmp(argv[argi], "--version") == 0) { + printf("%s\n", spvSoftwareVersionDetailsString()); + printf("Target: %s\n", + spvTargetEnvDescription(kDefaultEnvironment)); + return 0; + } else { + print_usage(argv[0]); + return 1; + } + } break; + default: + print_usage(argv[0]); + return 1; + } + } else { + if (src_file == nullptr) { + src_file = argv[argi]; + } else if (dst_file == nullptr) { + dst_file = argv[argi]; + } else { + fprintf(stderr, "error: More than two input files specified\n"); + return 1; + } + } + } + + if (src_file == nullptr || dst_file == nullptr) { + print_usage(argv[0]); + return 1; + } + + spvtools::diff::Options options; + + if (allow_indent) options.indent = true; + if (no_header) options.no_header = true; + if (dump_id_map) options.dump_id_map = true; + if (ignore_set_binding) options.ignore_set_binding = true; + if (ignore_location) options.ignore_location = true; + + if (color_is_possible && !force_no_color) { + bool output_is_tty = true; +#if defined(_POSIX_VERSION) + output_is_tty = isatty(fileno(stdout)); +#endif + if (output_is_tty || force_color) { + options.color_output = true; + } + } + + std::unique_ptr src = load_module(src_file); + std::unique_ptr dst = load_module(dst_file); + + if (!src) { + fprintf(stderr, "error: Loading src file\n"); + } + if (!dst) { + fprintf(stderr, "error: Loading dst file\n"); + } + if (!src || !dst) { + return 1; + } + + spvtools::diff::Diff(src.get(), dst.get(), std::cout, options); + + return 0; +} diff --git a/third_party/spirv-tools/tools/fuzz/fuzz.cpp b/third_party/spirv-tools/tools/fuzz/fuzz.cpp index 306f9255b4..ca6633a6ce 100644 --- a/third_party/spirv-tools/tools/fuzz/fuzz.cpp +++ b/third_party/spirv-tools/tools/fuzz/fuzz.cpp @@ -673,19 +673,6 @@ void DumpTransformationsBinary( transformations_file.close(); } -// The Chromium project applies the following patch to the protobuf library: -// -// source.chromium.org/chromium/chromium/src/+/main:third_party/protobuf/patches/0003-remove-static-initializers.patch -// -// This affects how Status objects must be constructed. This method provides a -// convenient way to get the OK status that works both with and without the -// patch. With the patch OK is a StatusPod, from which a Status can be -// constructed. Without the patch, OK is already a Status, and we harmlessly -// copy-construct the result from it. -google::protobuf::util::Status GetProtobufOkStatus() { - return google::protobuf::util::Status(google::protobuf::util::Status::OK); -} - // Dumps |transformations| to file |filename| in JSON format. Useful for // interactive debugging. void DumpTransformationsJson( @@ -696,7 +683,7 @@ void DumpTransformationsJson( json_options.add_whitespace = true; auto json_generation_status = google::protobuf::util::MessageToJsonString( transformations, &json_string, json_options); - if (json_generation_status == GetProtobufOkStatus()) { + if (json_generation_status.ok()) { std::ofstream transformations_json_file(filename); transformations_json_file << json_string; transformations_json_file.close(); @@ -747,8 +734,9 @@ int main(int argc, const char** argv) { std::string facts_json_string((std::istreambuf_iterator(facts_input)), std::istreambuf_iterator()); facts_input.close(); - if (GetProtobufOkStatus() != google::protobuf::util::JsonStringToMessage( - facts_json_string, &initial_facts)) { + if (!google::protobuf::util::JsonStringToMessage(facts_json_string, + &initial_facts) + .ok()) { spvtools::Error(FuzzDiagnostic, nullptr, {}, "Error reading facts data"); return 1; } @@ -828,7 +816,7 @@ int main(int argc, const char** argv) { json_options.add_whitespace = true; auto json_generation_status = google::protobuf::util::MessageToJsonString( transformations_applied, &json_string, json_options); - if (json_generation_status != GetProtobufOkStatus()) { + if (!json_generation_status.ok()) { spvtools::Error(FuzzDiagnostic, nullptr, {}, "Error writing out transformations in JSON format"); return 1; diff --git a/third_party/spirv-tools/tools/link/linker.cpp b/third_party/spirv-tools/tools/link/linker.cpp index 359e803015..bdddeb899e 100644 --- a/third_party/spirv-tools/tools/link/linker.cpp +++ b/third_party/spirv-tools/tools/link/linker.cpp @@ -25,7 +25,7 @@ namespace { -const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_5; +const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; void print_usage(const char* program) { std::string target_env_list = spvTargetEnvList(16, 80); @@ -49,15 +49,18 @@ Options (in lexicographical order): --create-library Link the binaries into a library, keeping all exported symbols. -h, --help - Print this help. + Print this help. --target-env - Set the target environment. Without this flag the target - environment defaults to spv1.5. must be one of - {%s} + Set the environment used for interpreting the inputs. Without + this option the environment defaults to spv1.6. must be + one of {%s}. + NOTE: The SPIR-V version used by the linked binary module + depends only on the version of the inputs, and is not affected + by this option. --verify-ids Verify that IDs in the resulting modules are truly unique. --version - Display linker version information + Display linker version information. )", program, program, target_env_list.c_str()); } @@ -160,10 +163,11 @@ int main(int argc, char** argv) { std::vector linkingResult; spv_result_t status = Link(context, contents, &linkingResult, options); + if (status != SPV_SUCCESS && status != SPV_WARNING) return 1; if (!WriteFile(outFile, "wb", linkingResult.data(), linkingResult.size())) return 1; - return status == SPV_SUCCESS ? 0 : 1; + return 0; } diff --git a/third_party/spirv-tools/tools/lint/lint.cpp b/third_party/spirv-tools/tools/lint/lint.cpp index 5c2a82ac1d..d37df830f1 100644 --- a/third_party/spirv-tools/tools/lint/lint.cpp +++ b/third_party/spirv-tools/tools/lint/lint.cpp @@ -19,7 +19,7 @@ #include "tools/io.h" #include "tools/util/cli_consumer.h" -const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_5; +const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; namespace { // Status and actions to perform after parsing command-line arguments. diff --git a/third_party/spirv-tools/tools/opt/opt.cpp b/third_party/spirv-tools/tools/opt/opt.cpp index 04f81b8c1a..ce2103ca8a 100644 --- a/third_party/spirv-tools/tools/opt/opt.cpp +++ b/third_party/spirv-tools/tools/opt/opt.cpp @@ -44,7 +44,7 @@ struct OptStatus { // initialization and setup. Note that |source| and |position| are irrelevant // here because we are still not processing a SPIR-V input file. void opt_diagnostic(spv_message_level_t level, const char* /*source*/, - const spv_position_t& /*positon*/, const char* message) { + const spv_position_t& /*position*/, const char* message) { if (level == SPV_MSG_ERROR) { fprintf(stderr, "error: "); } @@ -59,7 +59,7 @@ std::string GetListOfPassesAsString(const spvtools::Optimizer& optimizer) { return ss.str(); } -const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_5; +const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; std::string GetLegalizationPasses() { spvtools::Optimizer optimizer(kDefaultEnvironment); @@ -157,17 +157,21 @@ Options (in lexicographical order):)", another. It will only propagate an array if the source is never written to, and the only store to the target is the copy.)"); printf(R"( - --decompose-initialized-variables - Decomposes initialized variable declarations into a declaration - followed by a store of the initial value. This is done to work - around known issues with some Vulkan drivers for initialize - variables.)"); - printf(R"( --replace-desc-array-access-using-var-index Replaces accesses to descriptor arrays based on a variable index with a switch that has a case for every possible value of the index.)"); printf(R"( + --spread-volatile-semantics + Spread Volatile semantics to variables with SMIDNV, WarpIDNV, + SubgroupSize, SubgroupLocalInvocationId, SubgroupEqMask, + SubgroupGeMask, SubgroupGtMask, SubgroupLeMask, or SubgroupLtMask + BuiltIn decorations or OpLoad for them when the shader model is + ray generation, closest hit, miss, intersection, or callable. + For the SPIR-V version is 1.6 or above, it also spreads Volatile + semantics to a variable with HelperInvocation BuiltIn decoration + in the fragement shader.)"); + printf(R"( --descriptor-scalar-replacement Replaces every array variable |desc| that has a DescriptorSet and Binding decorations with a new variable for each element of @@ -198,6 +202,10 @@ Options (in lexicographical order):)", unused stores to vector components, that are not removed by aggressive dead code elimination.)"); printf(R"( + --eliminate-dead-input-components + Deletes unused components from input variables. Currently + deletes trailing unused elements from input arrays.)"); + printf(R"( --eliminate-dead-variables Deletes module scope variables that are not referenced.)"); printf(R"( @@ -223,6 +231,10 @@ Options (in lexicographical order):)", loads and stores. Performed only on entry point call tree functions.)"); printf(R"( + --fix-func-call-param + fix non memory argument for the function call, replace + accesschain pointer argument with a variable.)"); + printf(R"( --flatten-decorations Replace decoration groups with repeated OpDecorate and OpMemberDecorate instructions.)"); @@ -473,16 +485,16 @@ Options (in lexicographical order):)", --strength-reduction Replaces instructions with equivalent and less expensive ones.)"); printf(R"( - --strip-atomic-counter-memory - Removes AtomicCountMemory bit from memory semantics values.)"); - printf(R"( --strip-debug Remove all debug instructions.)"); printf(R"( + --strip-nonsemantic + Remove all reflection and nonsemantic information.)"); + printf(R"( --strip-reflect - Remove all reflection information. For now, this covers - reflection information defined by SPV_GOOGLE_hlsl_functionality1 - and SPV_KHR_non_semantic_info)"); + DEPRECATED. Remove all reflection information. For now, this + covers reflection information defined by + SPV_GOOGLE_hlsl_functionality1 and SPV_KHR_non_semantic_info)"); printf(R"( --target-env= Set the target environment. Without this flag the target diff --git a/third_party/spirv-tools/tools/reduce/reduce.cpp b/third_party/spirv-tools/tools/reduce/reduce.cpp index 4447b3569e..37600543a8 100644 --- a/third_party/spirv-tools/tools/reduce/reduce.cpp +++ b/third_party/spirv-tools/tools/reduce/reduce.cpp @@ -262,7 +262,7 @@ void DumpShader(spvtools::opt::IRContext* context, const char* filename) { DumpShader(binary, filename); } -const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_5; +const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; int main(int argc, const char** argv) { std::string in_binary_file; diff --git a/third_party/spirv-tools/tools/sva/README.md b/third_party/spirv-tools/tools/sva/README.md index d80b4d2c3a..cd3d13c9ee 100644 --- a/third_party/spirv-tools/tools/sva/README.md +++ b/third_party/spirv-tools/tools/sva/README.md @@ -1,6 +1,6 @@ # SVA -SPIR-V Assember for WebGPU. The SPIR-V Assembler is a JavaScript library to +SPIR-V Assembler for WebGPU. The SPIR-V Assembler is a JavaScript library to convert SPIR-V assembly (as produced by spirv-dis in SPIR-V Tools) into a SPIR-V binary. The assembler assumes it is generating WebGPU SPIR-V and thus has the following limitations. diff --git a/third_party/spirv-tools/tools/sva/yarn.lock b/third_party/spirv-tools/tools/sva/yarn.lock index afa11f6c5a..e7b735e0e6 100644 --- a/third_party/spirv-tools/tools/sva/yarn.lock +++ b/third_party/spirv-tools/tools/sva/yarn.lock @@ -1260,9 +1260,9 @@ path-to-regexp@2.2.1: integrity sha512-gu9bD6Ta5bwGrrU8muHzVOBFFREpp2iRkVfhBJahwJ6p6Xw20SjT0MxLnwkjOibQmGSYhiUnf2FLe7k+jcFmGQ== pathval@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0" - integrity sha1-uULm1L3mUwBe9rcTYd74cn0GReA= + version "1.1.1" + resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d" + integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ== prelude-ls@~1.1.2: version "1.1.2" diff --git a/third_party/spirv-tools/tools/val/val.cpp b/third_party/spirv-tools/tools/val/val.cpp index 55321dab28..880ce46b3a 100644 --- a/third_party/spirv-tools/tools/val/val.cpp +++ b/third_party/spirv-tools/tools/val/val.cpp @@ -77,7 +77,7 @@ Options: int main(int argc, char** argv) { const char* inFile = nullptr; - spv_target_env target_env = SPV_ENV_UNIVERSAL_1_5; + spv_target_env target_env = SPV_ENV_UNIVERSAL_1_6; spvtools::ValidatorOptions options; bool continue_processing = true; int return_code = 0; @@ -111,17 +111,20 @@ int main(int argc, char** argv) { printf("%s\n", spvSoftwareVersionDetailsString()); printf( "Targets:\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n " - "%s\n", + "%s\n %s\n %s\n %s\n", spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_0), spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_1), spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_2), spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_3), spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_4), spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_5), + spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_6), spvTargetEnvDescription(SPV_ENV_OPENCL_2_2), spvTargetEnvDescription(SPV_ENV_VULKAN_1_0), spvTargetEnvDescription(SPV_ENV_VULKAN_1_1), - spvTargetEnvDescription(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + spvTargetEnvDescription(SPV_ENV_VULKAN_1_1_SPIRV_1_4), + spvTargetEnvDescription(SPV_ENV_VULKAN_1_2), + spvTargetEnvDescription(SPV_ENV_VULKAN_1_3)); continue_processing = false; return_code = 0; } else if (0 == strcmp(cur_arg, "--help") || 0 == strcmp(cur_arg, "-h")) { diff --git a/third_party/spirv-tools/utils/check_copyright.py b/third_party/spirv-tools/utils/check_copyright.py index 49892ee6ea..aa647af58b 100755 --- a/third_party/spirv-tools/utils/check_copyright.py +++ b/third_party/spirv-tools/utils/check_copyright.py @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """Checks for copyright notices in all the files that need them under the + current directory. Optionally insert them. When inserting, replaces an MIT or Khronos free use license with Apache 2. """ @@ -41,11 +42,28 @@ AUTHORS = ['The Khronos Group Inc.', 'Mostafa Ashraf', 'Shiyu Liu', 'ZHOU He'] -CURRENT_YEAR='2021' +CURRENT_YEAR = 2022 -YEARS = '(2014-2016|2015-2016|2015-2020|2016|2016-2017|2017|2017-2019|2018|2019|2020|2021)' -COPYRIGHT_RE = re.compile( - 'Copyright \(c\) {} ({})'.format(YEARS, '|'.join(AUTHORS))) +FIRST_YEAR = 2014 +FINAL_YEAR = CURRENT_YEAR + 5 +# A regular expression to match the valid years in the copyright information. +YEAR_REGEX = '(' + '|'.join( + str(year) for year in range(FIRST_YEAR, FINAL_YEAR + 1)) + ')' + +# A regular expression to make a range of years in the form -. +YEAR_RANGE_REGEX = '(' +for year1 in range(FIRST_YEAR, FINAL_YEAR + 1): + for year2 in range(year1 + 1, FINAL_YEAR + 1): + YEAR_RANGE_REGEX += str(year1) + '-' + str(year2) + '|' +YEAR_RANGE_REGEX = YEAR_RANGE_REGEX[:-1] + ')' + +# In the copyright info, the year can be a single year or a range. This is a +# regex to make sure it matches one of them. +YEAR_OR_RANGE_REGEX = '(' + YEAR_REGEX + '|' + YEAR_RANGE_REGEX + ')' + +# The final regular expression to match a valid copyright line. +COPYRIGHT_RE = re.compile('Copyright \(c\) {} ({})'.format( + YEAR_OR_RANGE_REGEX, '|'.join(AUTHORS))) MIT_BEGIN_RE = re.compile('Permission is hereby granted, ' 'free of charge, to any person obtaining a') diff --git a/third_party/spirv-tools/utils/generate_grammar_tables.py b/third_party/spirv-tools/utils/generate_grammar_tables.py index 9ccf410b9f..74aa28294a 100755 --- a/third_party/spirv-tools/utils/generate_grammar_tables.py +++ b/third_party/spirv-tools/utils/generate_grammar_tables.py @@ -23,7 +23,7 @@ import re PYGEN_VARIABLE_PREFIX = 'pygen_variable' # Extensions to recognize, but which don't necessarily come from the SPIR-V -# core or KHR grammar files. Get this list from the SPIR-V registery web page. +# core or KHR grammar files. Get this list from the SPIR-V registry web page. # NOTE: Only put things on this list if it is not in those grammar files. EXTENSIONS_FROM_SPIRV_REGISTRY_AND_NOT_FROM_GRAMMARS = """ SPV_AMD_gcn_shader diff --git a/third_party/spirv-tools/utils/git-sync-deps b/third_party/spirv-tools/utils/git-sync-deps index eecfbe93bb..7a7e606ff1 100755 --- a/third_party/spirv-tools/utils/git-sync-deps +++ b/third_party/spirv-tools/utils/git-sync-deps @@ -168,7 +168,7 @@ def git_checkout_to_directory(git, repo, checkoutable, directory, verbose): with open(os.devnull, 'w') as devnull: # If this fails, we will fetch before trying again. Don't spam user - # with error infomation. + # with error information. if 0 == subprocess.call([git, 'checkout', '--quiet', checkoutable], cwd=directory, stderr=devnull): # if this succeeds, skip slow `git fetch`. diff --git a/third_party/spirv-tools/utils/roll_deps.sh b/third_party/spirv-tools/utils/roll_deps.sh index f61f2a31c8..20c061fd86 100755 --- a/third_party/spirv-tools/utils/roll_deps.sh +++ b/third_party/spirv-tools/utils/roll_deps.sh @@ -23,9 +23,9 @@ set -eo pipefail effcee_dir="external/effcee/" effcee_trunk="origin/main" googletest_dir="external/googletest/" -googletest_trunk="origin/master" +googletest_trunk="origin/main" re2_dir="external/re2/" -re2_trunk="origin/master" +re2_trunk="origin/main" spirv_headers_dir="external/spirv-headers/" spirv_headers_trunk="origin/master" @@ -39,8 +39,11 @@ if [[ $(git diff --stat) != '' ]]; then exit 1 fi +echo "*** Ignore messages about running 'git cl upload' ***" + old_head=$(git rev-parse HEAD) +set +e roll-dep --ignore-dirty-tree --roll-to="${effcee_trunk}" "${effcee_dir}" roll-dep --ignore-dirty-tree --roll-to="${googletest_trunk}" "${googletest_dir}" roll-dep --ignore-dirty-tree --roll-to="${re2_trunk}" "${re2_dir}" diff --git a/third_party/spirv-tools/utils/update_build_version.py b/third_party/spirv-tools/utils/update_build_version.py index 321de74bdc..2a1ca60051 100755 --- a/third_party/spirv-tools/utils/update_build_version.py +++ b/third_party/spirv-tools/utils/update_build_version.py @@ -17,16 +17,16 @@ # Updates an output file with version info unless the new content is the same # as the existing content. # -# Args: +# Args: # # The output file will contain a line of text consisting of two C source syntax # string literals separated by a comma: -# - The software version deduced from the CHANGES file in the given directory. +# - The software version deduced from the given CHANGES file. # - A longer string with the project name, the software version number, and -# git commit information for the directory. The commit information -# is the output of "git describe" if that succeeds, or "git rev-parse HEAD" -# if that succeeds, or otherwise a message containing the phrase -# "unknown hash". +# git commit information for the CHANGES file's directory. The commit +# information is the output of "git describe" if that succeeds, or "git +# rev-parse HEAD" if that succeeds, or otherwise a message containing the +# phrase "unknown hash". # The string contents are escaped as necessary. import datetime @@ -73,9 +73,8 @@ def command_output(cmd, directory): return stdout -def deduce_software_version(directory): - """Returns a software version number parsed from the CHANGES file - in the given directory. +def deduce_software_version(changes_file): + """Returns a software version number parsed from the given CHANGES file. The CHANGES file describes most recent versions first. """ @@ -85,7 +84,6 @@ def deduce_software_version(directory): # unexpected carriage returns on a linefeed-only system such as # Linux. pattern = re.compile(r'^(v\d+\.\d+(-dev)?) \d\d\d\d-\d\d-\d\d\s*$') - changes_file = os.path.join(directory, 'CHANGES') with open(changes_file, mode='r') as f: for line in f.readlines(): match = pattern.match(line) @@ -125,16 +123,17 @@ def describe(directory): def main(): if len(sys.argv) != 3: - print('usage: {} '.format(sys.argv[0])) + print('usage: {} '.format(sys.argv[0])) sys.exit(1) output_file = sys.argv[2] mkdir_p(os.path.dirname(output_file)) software_version = deduce_software_version(sys.argv[1]) + directory = os.path.dirname(sys.argv[1]) new_content = '"{}", "SPIRV-Tools {} {}"\n'.format( software_version, software_version, - describe(sys.argv[1]).replace('"', '\\"')) + describe(directory).replace('"', '\\"')) if os.path.isfile(output_file): with open(output_file, 'r') as f: diff --git a/third_party/spirv-tools/utils/vscode/src/lsp/jsonrpc2/jsonrpc2.go b/third_party/spirv-tools/utils/vscode/src/lsp/jsonrpc2/jsonrpc2.go index b8436d27b4..44dd2205ee 100644 --- a/third_party/spirv-tools/utils/vscode/src/lsp/jsonrpc2/jsonrpc2.go +++ b/third_party/spirv-tools/utils/vscode/src/lsp/jsonrpc2/jsonrpc2.go @@ -48,7 +48,7 @@ const ( requestDone ) -// Request is sent to a server to represent a Call or Notify operaton. +// Request is sent to a server to represent a Call or Notify operation. type Request struct { conn *Conn cancel context.CancelFunc diff --git a/third_party/spirv-tools/utils/vscode/src/lsp/jsonrpc2/wire.go b/third_party/spirv-tools/utils/vscode/src/lsp/jsonrpc2/wire.go index 3e31c340d5..fed9a25bc2 100644 --- a/third_party/spirv-tools/utils/vscode/src/lsp/jsonrpc2/wire.go +++ b/third_party/spirv-tools/utils/vscode/src/lsp/jsonrpc2/wire.go @@ -44,7 +44,7 @@ const ( CodeServerOverloaded = -32000 ) -// WireRequest is sent to a server to represent a Call or Notify operaton. +// WireRequest is sent to a server to represent a Call or Notify operation. type WireRequest struct { // VersionTag is always encoded as the string "2.0" VersionTag VersionTag `json:"jsonrpc"` diff --git a/third_party/spirv-tools/utils/vscode/src/lsp/protocol/tsprotocol.go b/third_party/spirv-tools/utils/vscode/src/lsp/protocol/tsprotocol.go index 50543fc819..e0a3594674 100644 --- a/third_party/spirv-tools/utils/vscode/src/lsp/protocol/tsprotocol.go +++ b/third_party/spirv-tools/utils/vscode/src/lsp/protocol/tsprotocol.go @@ -143,7 +143,7 @@ type WorkspaceFoldersServerCapabilities struct { * change notifications. * * If a strings is provided the string is treated as a ID - * under which the notification is registed on the client + * under which the notification is registered on the client * side. The ID can be used to unregister for these events * using the `client/unregisterCapability` request. */ @@ -162,7 +162,7 @@ type WorkspaceFolder struct { /*Name defined: * The name of the workspace folder. Used to refer to this - * workspace folder in thge user interface. + * workspace folder in the user interface. */ Name string `json:"name"` } @@ -1129,7 +1129,7 @@ type ServerCapabilities struct { * change notifications. * * If a strings is provided the string is treated as a ID - * under which the notification is registed on the client + * under which the notification is registered on the client * side. The ID can be used to unregister for these events * using the `client/unregisterCapability` request. */ @@ -1803,7 +1803,7 @@ type CompletionOptions struct { /*AllCommitCharacters defined: * The list of all possible characters that commit a completion. This field can be used - * if clients don't support individual commmit characters per completion item. See + * if clients don't support individual commit characters per completion item. See * `ClientCapabilities.textDocument.completion.completionItem.commitCharactersSupport` * * @since 3.2.0 @@ -2844,7 +2844,7 @@ type LocationLink struct { /*TargetSelectionRange defined: * The range that should be selected and revealed when this link is being followed, e.g the name of a function. - * Must be contained by the the `targetRange`. See also `DocumentSymbol#range` + * Must be contained by the `targetRange`. See also `DocumentSymbol#range` */ TargetSelectionRange Range `json:"targetSelectionRange"` } @@ -2881,7 +2881,7 @@ type Color struct { type ColorInformation struct { /*Range defined: - * The range in the document where this color appers. + * The range in the document where this color appears. */ Range Range `json:"range"` @@ -3627,14 +3627,14 @@ type DocumentSymbol struct { /*Range defined: * The range enclosing this symbol not including leading/trailing whitespace but everything else - * like comments. This information is typically used to determine if the the clients cursor is + * like comments. This information is typically used to determine if the clients cursor is * inside the symbol to reveal in the symbol in the UI. */ Range Range `json:"range"` /*SelectionRange defined: * The range that should be selected and revealed when this symbol is being picked, e.g the name of a function. - * Must be contained by the the `range`. + * Must be contained by the `range`. */ SelectionRange Range `json:"selectionRange"` @@ -3652,7 +3652,7 @@ type CodeActionContext struct { /*Diagnostics defined: * An array of diagnostics known on the client side overlapping the range provided to the - * `textDocument/codeAction` request. They are provied so that the server knows which + * `textDocument/codeAction` request. They are provided so that the server knows which * errors are currently presented to the user for the given range. There is no guarantee * that these accurately reflect the error state of the resource. The primary parameter * to compute code actions is the provided range. @@ -4081,13 +4081,13 @@ const ( /*TextOnlyTransactional defined: * If the workspace edit contains only textual file changes they are executed transactional. * If resource changes (create, rename or delete file) are part of the change the failure - * handling startegy is abort. + * handling strategy is abort. */ TextOnlyTransactional FailureHandlingKind = "textOnlyTransactional" /*Undo defined: * The client tries to undo the operations already executed. But there is no - * guaruntee that this is succeeding. + * guarantee that this is succeeding. */ Undo FailureHandlingKind = "undo" diff --git a/third_party/spirv-tools/utils/vscode/src/parser/parser.go b/third_party/spirv-tools/utils/vscode/src/parser/parser.go index cc6f33324b..4c0fa8f787 100644 --- a/third_party/spirv-tools/utils/vscode/src/parser/parser.go +++ b/third_party/spirv-tools/utils/vscode/src/parser/parser.go @@ -798,7 +798,7 @@ type Identifier struct { References []*Token // all the places the identifier was referenced } -// Severity is an enumerator of diagnositc seeverities +// Severity is an enumerator of diagnostic severities type Severity int // Severity levels diff --git a/third_party/stb/tests/Makefile b/third_party/stb/tests/Makefile deleted file mode 100644 index e972cfd743..0000000000 --- a/third_party/stb/tests/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -INCLUDES = -I.. -CFLAGS = -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -DSTB_DIVIDE_TEST -CPPFLAGS = -Wno-write-strings -DSTB_DIVIDE_TEST - -all: - $(CC) $(INCLUDES) $(CFLAGS) ../stb_vorbis.c test_c_compilation.c test_c_lexer.c test_dxt.c test_easyfont.c test_image.c test_image_write.c test_perlin.c test_sprintf.c test_truetype.c test_voxel.c -lm - $(CC) $(INCLUDES) $(CPPFLAGS) test_cpp_compilation.cpp -lm -lstdc++ diff --git a/third_party/stb/tests/c_lexer_test.c b/third_party/stb/tests/c_lexer_test.c deleted file mode 100644 index a919b6c423..0000000000 --- a/third_party/stb/tests/c_lexer_test.c +++ /dev/null @@ -1,50 +0,0 @@ -#define STB_C_LEX_C_DECIMAL_INTS Y // "0|[1-9][0-9]*" CLEX_intlit -#define STB_C_LEX_C_HEX_INTS Y // "0x[0-9a-fA-F]+" CLEX_intlit -#define STB_C_LEX_C_OCTAL_INTS Y // "[0-7]+" CLEX_intlit -#define STB_C_LEX_C_DECIMAL_FLOATS Y // "[0-9]*(.[0-9]*([eE][-+]?[0-9]+)?) CLEX_floatlit -#define STB_C_LEX_C99_HEX_FLOATS Y // "0x{hex}+(.{hex}*)?[pP][-+]?{hex}+ CLEX_floatlit -#define STB_C_LEX_C_IDENTIFIERS Y // "[_a-zA-Z][_a-zA-Z0-9]*" CLEX_id -#define STB_C_LEX_C_DQ_STRINGS Y // double-quote-delimited strings with escapes CLEX_dqstring -#define STB_C_LEX_C_SQ_STRINGS Y // single-quote-delimited strings with escapes CLEX_ssstring -#define STB_C_LEX_C_CHARS Y // single-quote-delimited character with escape CLEX_charlits -#define STB_C_LEX_C_COMMENTS Y // "/* comment */" -#define STB_C_LEX_CPP_COMMENTS Y // "// comment to end of line\n" -#define STB_C_LEX_C_COMPARISONS Y // "==" CLEX_eq "!=" CLEX_noteq "<=" CLEX_lesseq ">=" CLEX_greatereq -#define STB_C_LEX_C_LOGICAL Y // "&&" CLEX_andand "||" CLEX_oror -#define STB_C_LEX_C_SHIFTS Y // "<<" CLEX_shl ">>" CLEX_shr -#define STB_C_LEX_C_INCREMENTS Y // "++" CLEX_plusplus "--" CLEX_minusminus -#define STB_C_LEX_C_ARROW Y // "->" CLEX_arrow -#define STB_C_LEX_EQUAL_ARROW Y // "=>" CLEX_eqarrow -#define STB_C_LEX_C_BITWISEEQ Y // "&=" CLEX_andeq "|=" CLEX_oreq "^=" CLEX_xoreq -#define STB_C_LEX_C_ARITHEQ Y // "+=" CLEX_pluseq "-=" CLEX_minuseq - // "*=" CLEX_muleq "/=" CLEX_diveq "%=" CLEX_modeq - // if both STB_C_LEX_SHIFTS & STB_C_LEX_ARITHEQ: - // "<<=" CLEX_shleq ">>=" CLEX_shreq - -#define STB_C_LEX_PARSE_SUFFIXES Y // letters after numbers are parsed as part of those numbers, and must be in suffix list below -#define STB_C_LEX_DECIMAL_SUFFIXES "uUlL" // decimal integer suffixes e.g. "uUlL" -- these are returned as-is in string storage -#define STB_C_LEX_HEX_SUFFIXES "lL" // e.g. "uUlL" -#define STB_C_LEX_OCTAL_SUFFIXES "lL" // e.g. "uUlL" -#define STB_C_LEX_FLOAT_SUFFIXES "uulL" // - -#define STB_C_LEX_0_IS_EOF N // if Y, ends parsing at '\0'; if N, returns '\0' as token -#define STB_C_LEX_INTEGERS_AS_DOUBLES N // parses integers as doubles so they can be larger than 'int', but only if STB_C_LEX_STDLIB==N -#define STB_C_LEX_MULTILINE_DSTRINGS Y // allow newlines in double-quoted strings -#define STB_C_LEX_MULTILINE_SSTRINGS Y // allow newlines in single-quoted strings -#define STB_C_LEX_USE_STDLIB N // use strtod,strtol for parsing #s; otherwise inaccurate hack -#define STB_C_LEX_DOLLAR_IDENTIFIER Y // allow $ as an identifier character -#define STB_C_LEX_FLOAT_NO_DECIMAL Y // allow floats that have no decimal point if they have an exponent - -#define STB_C_LEX_DEFINE_ALL_TOKEN_NAMES Y // if Y, all CLEX_ token names are defined, even if never returned - // leaving it as N should help you catch config bugs - -#define STB_C_LEX_DISCARD_PREPROCESSOR Y // discard C-preprocessor directives (e.g. after prepocess - // still have #line, #pragma, etc) - -#define STB_C_LEXER_DEFINITIONS // This line prevents the header file from replacing your definitions - - - -#define STB_C_LEXER_IMPLEMENTATION -#define STB_C_LEXER_SELF_TEST -#include "../stb_c_lexer.h" diff --git a/third_party/stb/tests/c_lexer_test.dsp b/third_party/stb/tests/c_lexer_test.dsp deleted file mode 100644 index 13f87588b7..0000000000 --- a/third_party/stb/tests/c_lexer_test.dsp +++ /dev/null @@ -1,89 +0,0 @@ -# Microsoft Developer Studio Project File - Name="c_lexer_test" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=c_lexer_test - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "c_lexer_test.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "c_lexer_test.mak" CFG="c_lexer_test - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "c_lexer_test - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "c_lexer_test - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "c_lexer_test - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "c_lexer_test - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug\c_lexer_test" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "c_lexer_test - Win32 Release" -# Name "c_lexer_test - Win32 Debug" -# Begin Source File - -SOURCE=.\c_lexer_test.c -# End Source File -# End Target -# End Project diff --git a/third_party/stb/tests/caveview/README.md b/third_party/stb/tests/caveview/README.md deleted file mode 100644 index 10da83818e..0000000000 --- a/third_party/stb/tests/caveview/README.md +++ /dev/null @@ -1,85 +0,0 @@ -# FAQ - -### How to run it? - -There's no GUI. Find a directory with Minecraft Anvil files (.mca). -Copy a Minecraft "terrain.png" into that directory (do a google -image search). Run from that directory. - -### How accurate is this as a Minecraft viewer? - -Not very. Many Minecraft blocks are not handled correctly: - -* No redstone, rails, or other "flat" blocks -* No signs, doors, fences, carpets, or other complicated geometry -* Stairs are turned into ramps -* Upper slabs turn into lower slabs -* Wood types only for blocks, not stairs, slabs, etc -* Colored glass becomes regular glass -* Glass panes become glass blocks -* Water is opaque -* Water level is incorrect -* No biome coloration -* Cactus is not shrunk, shows holes -* Chests are not shrunk -* Double-chests draw as two chests -* Pumpkins etc. are not rotated properly -* Torches are drawn hackily, do not attach to walls -* Incorrect textures for blocks that postdate terrain.png -* Transparent textures have black fringes due to non-premultiplied-alpha -* Skylight and block light are combined in a single value -* Only blocks at y=1..255 are shown (not y=0) -* If a 32x32x256 "quad-chunk" needs more than 800K quads, isn't handled (very unlikely) - -Some of these are due to engine limitations, and some of -these are because I didn't make the effort since my -goal was to make a demo for stb_voxel_render.h, not -to make a proper Minecraft viewer. - - -### Could this be turned into a proper Minecraft viewer? - -Yes and no. Yes, you could do it, but no, it wouldn't -really resemble this code that much anymore. - -You could certainly use this engine to -render the parts of Minecraft it works for, but many -of the things it doesn't handle it can't handle at all -(stairs, water, fences, carpets, etc) because it uses -low-precision coordinates to store voxel data. - -You would have to render all of the stuff it doesn't -handle through another rendering path. In a game (not -a viewer) you would need such a path for movable entities -like doors and carts anyway, so possibly handling other -things that way wouldn't be so bad. - -Rails, ladders, and redstone lines could be implemented by -using tex2 to overlay those effects, but you can't rotate -tex1 and tex2 independently, so there may be cases where -the underlying texture needs a different rotation from the -overlaid texture, which would require separate rendering. -Handling redstone's brightness being different from underlying -block's brightness would require separate rendering. - -You can use the face-color effect to do biome coloration, -but the change won't be smooth the way it is in Minecraft. - - -### Why isn't building the mesh data faster? - -Partly because converting from minecraft data is expensive. - -Here is the approximate breakdown of an older version -of this executable and lib that did the building single-threaded. - -* 25% loading & parsing minecraft files (4/5ths of this is my crappy zlib) -* 18% converting from minecraft blockids & lighting to stb blockids & lighting -* 10% reordering from data[z][y]\[x] (minecraft-style) to data[y][x]\[z] (stb-style) -* 40% building mesh data -* 7% uploading mesh data to OpenGL - -I did do significant optimizations after the above, so the -final breakdown is different, but it should give you some -sense of the costs. - diff --git a/third_party/stb/tests/caveview/cave_main.c b/third_party/stb/tests/caveview/cave_main.c deleted file mode 100644 index d345cf1e35..0000000000 --- a/third_party/stb/tests/caveview/cave_main.c +++ /dev/null @@ -1,598 +0,0 @@ -#define _WIN32_WINNT 0x400 - -#include -#include - -// stb.h -#define STB_DEFINE -#include "stb.h" - -// stb_gl.h -#define STB_GL_IMPLEMENTATION -#define STB_GLEXT_DEFINE "glext_list.h" -#include "stb_gl.h" - -// SDL -#include "sdl.h" -#include "SDL_opengl.h" - -// stb_glprog.h -#define STB_GLPROG_IMPLEMENTATION -#define STB_GLPROG_ARB_DEFINE_EXTENSIONS -#include "stb_glprog.h" - -// stb_image.h -#define STB_IMAGE_IMPLEMENTATION -#include "stb_image.h" - -// stb_easy_font.h -#include "stb_easy_font.h" // doesn't require an IMPLEMENTATION - -#include "caveview.h" - -char *game_name = "caveview"; - - -#define REVERSE_DEPTH - - - -static void print_string(float x, float y, char *text, float r, float g, float b) -{ - static char buffer[99999]; - int num_quads; - - num_quads = stb_easy_font_print(x, y, text, NULL, buffer, sizeof(buffer)); - - glColor3f(r,g,b); - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(2, GL_FLOAT, 16, buffer); - glDrawArrays(GL_QUADS, 0, num_quads*4); - glDisableClientState(GL_VERTEX_ARRAY); -} - -static float text_color[3]; -static float pos_x = 10; -static float pos_y = 10; - -static void print(char *text, ...) -{ - char buffer[999]; - va_list va; - va_start(va, text); - vsprintf(buffer, text, va); - va_end(va); - print_string(pos_x, pos_y, buffer, text_color[0], text_color[1], text_color[2]); - pos_y += 10; -} - -float camang[3], camloc[3] = { 60,22,77 }; -float player_zoom = 1.0; -float rotate_view = 0.0; - - -void camera_to_worldspace(float world[3], float cam_x, float cam_y, float cam_z) -{ - float vec[3] = { cam_x, cam_y, cam_z }; - float t[3]; - float s,c; - s = (float) sin(camang[0]*3.141592/180); - c = (float) cos(camang[0]*3.141592/180); - - t[0] = vec[0]; - t[1] = c*vec[1] - s*vec[2]; - t[2] = s*vec[1] + c*vec[2]; - - s = (float) sin(camang[2]*3.141592/180); - c = (float) cos(camang[2]*3.141592/180); - world[0] = c*t[0] - s*t[1]; - world[1] = s*t[0] + c*t[1]; - world[2] = t[2]; -} - -// camera worldspace velocity -float cam_vel[3]; - -int controls; - -#define MAX_VEL 150.0f // blocks per second -#define ACCEL 6.0f -#define DECEL 3.0f - -#define STATIC_FRICTION DECEL -#define EFFECTIVE_ACCEL (ACCEL+DECEL) - -// dynamic friction: -// -// if going at MAX_VEL, ACCEL and friction must cancel -// EFFECTIVE_ACCEL = DECEL + DYNAMIC_FRIC*MAX_VEL -#define DYNAMIC_FRICTION (ACCEL/(float)MAX_VEL) - -float view_x_vel = 0; -float view_z_vel = 0; -float pending_view_x; -float pending_view_z; -float pending_view_x; -float pending_view_z; - -void process_tick_raw(float dt) -{ - int i; - float thrust[3] = { 0,0,0 }; - float world_thrust[3]; - - // choose direction to apply thrust - - thrust[0] = (controls & 3)== 1 ? EFFECTIVE_ACCEL : (controls & 3)== 2 ? -EFFECTIVE_ACCEL : 0; - thrust[1] = (controls & 12)== 4 ? EFFECTIVE_ACCEL : (controls & 12)== 8 ? -EFFECTIVE_ACCEL : 0; - thrust[2] = (controls & 48)==16 ? EFFECTIVE_ACCEL : (controls & 48)==32 ? -EFFECTIVE_ACCEL : 0; - - // @TODO clamp thrust[0] & thrust[1] vector length to EFFECTIVE_ACCEL - - camera_to_worldspace(world_thrust, thrust[0], thrust[1], 0); - world_thrust[2] += thrust[2]; - - for (i=0; i < 3; ++i) { - float acc = world_thrust[i]; - cam_vel[i] += acc*dt; - } - - if (cam_vel[0] || cam_vel[1] || cam_vel[2]) - { - float vel = (float) sqrt(cam_vel[0]*cam_vel[0] + cam_vel[1]*cam_vel[1] + cam_vel[2]*cam_vel[2]); - float newvel = vel; - float dec = STATIC_FRICTION + DYNAMIC_FRICTION*vel; - newvel = vel - dec*dt; - if (newvel < 0) - newvel = 0; - cam_vel[0] *= newvel/vel; - cam_vel[1] *= newvel/vel; - cam_vel[2] *= newvel/vel; - } - - camloc[0] += cam_vel[0] * dt; - camloc[1] += cam_vel[1] * dt; - camloc[2] += cam_vel[2] * dt; - - view_x_vel *= (float) pow(0.75, dt); - view_z_vel *= (float) pow(0.75, dt); - - view_x_vel += (pending_view_x - view_x_vel)*dt*60; - view_z_vel += (pending_view_z - view_z_vel)*dt*60; - - pending_view_x -= view_x_vel * dt; - pending_view_z -= view_z_vel * dt; - camang[0] += view_x_vel * dt; - camang[2] += view_z_vel * dt; - camang[0] = stb_clamp(camang[0], -90, 90); - camang[2] = (float) fmod(camang[2], 360); -} - -void process_tick(float dt) -{ - while (dt > 1.0f/60) { - process_tick_raw(1.0f/60); - dt -= 1.0f/60; - } - process_tick_raw(dt); -} - -void update_view(float dx, float dy) -{ - // hard-coded mouse sensitivity, not resolution independent? - pending_view_z -= dx*300; - pending_view_x -= dy*700; -} - -extern int screen_x, screen_y; -extern int is_synchronous_debug; -float render_time; - -extern int chunk_locations, chunks_considered, chunks_in_frustum; -extern int quads_considered, quads_rendered; -extern int chunk_storage_rendered, chunk_storage_considered, chunk_storage_total; -extern int view_dist_in_chunks; -extern int num_threads_active, num_meshes_started, num_meshes_uploaded; -extern float chunk_server_activity; - -static Uint64 start_time, end_time; // render time - -float chunk_server_status[32]; -int chunk_server_pos; - -void draw_stats(void) -{ - int i; - - static Uint64 last_frame_time; - Uint64 cur_time = SDL_GetPerformanceCounter(); - float chunk_server=0; - float frame_time = (cur_time - last_frame_time) / (float) SDL_GetPerformanceFrequency(); - last_frame_time = cur_time; - - chunk_server_status[chunk_server_pos] = chunk_server_activity; - chunk_server_pos = (chunk_server_pos+1) %32; - - for (i=0; i < 32; ++i) - chunk_server += chunk_server_status[i] / 32.0f; - - stb_easy_font_spacing(-0.75); - pos_y = 10; - text_color[0] = text_color[1] = text_color[2] = 1.0f; - print("Frame time: %6.2fms, CPU frame render time: %5.2fms", frame_time*1000, render_time*1000); - print("Tris: %4.1fM drawn of %4.1fM in range", 2*quads_rendered/1000000.0f, 2*quads_considered/1000000.0f); - print("Vbuf storage: %dMB in frustum of %dMB in range of %dMB in cache", chunk_storage_rendered>>20, chunk_storage_considered>>20, chunk_storage_total>>20); - print("Num mesh builds started this frame: %d; num uploaded this frame: %d\n", num_meshes_started, num_meshes_uploaded); - print("QChunks: %3d in frustum of %3d valid of %3d in range", chunks_in_frustum, chunks_considered, chunk_locations); - print("Mesh worker threads active: %d", num_threads_active); - print("View distance: %d blocks", view_dist_in_chunks*16); - print("%s", glGetString(GL_RENDERER)); - - if (is_synchronous_debug) { - text_color[0] = 1.0; - text_color[1] = 0.5; - text_color[2] = 0.5; - print("SLOWNESS: Synchronous debug output is enabled!"); - } -} - -void draw_main(void) -{ - glEnable(GL_CULL_FACE); - glDisable(GL_TEXTURE_2D); - glDisable(GL_LIGHTING); - glEnable(GL_DEPTH_TEST); - #ifdef REVERSE_DEPTH - glDepthFunc(GL_GREATER); - glClearDepth(0); - #else - glDepthFunc(GL_LESS); - glClearDepth(1); - #endif - glDepthMask(GL_TRUE); - glDisable(GL_SCISSOR_TEST); - glClearColor(0.6f,0.7f,0.9f,0.0f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor3f(1,1,1); - glFrontFace(GL_CW); - glEnable(GL_TEXTURE_2D); - glDisable(GL_BLEND); - - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - #ifdef REVERSE_DEPTH - stbgl_Perspective(player_zoom, 90, 70, 3000, 1.0/16); - #else - stbgl_Perspective(player_zoom, 90, 70, 1.0/16, 3000); - #endif - - // now compute where the camera should be - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - stbgl_initCamera_zup_facing_y(); - - glRotatef(-camang[0],1,0,0); - glRotatef(-camang[2],0,0,1); - glTranslatef(-camloc[0], -camloc[1], -camloc[2]); - - start_time = SDL_GetPerformanceCounter(); - render_caves(camloc); - end_time = SDL_GetPerformanceCounter(); - - render_time = (end_time - start_time) / (float) SDL_GetPerformanceFrequency(); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluOrtho2D(0,screen_x/2,screen_y/2,0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glDisable(GL_TEXTURE_2D); - glDisable(GL_BLEND); - glDisable(GL_CULL_FACE); - draw_stats(); -} - - - -#pragma warning(disable:4244; disable:4305; disable:4018) - -#define SCALE 2 - -void error(char *s) -{ - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", s, NULL); - exit(0); -} - -void ods(char *fmt, ...) -{ - char buffer[1000]; - va_list va; - va_start(va, fmt); - vsprintf(buffer, fmt, va); - va_end(va); - SDL_Log("%s", buffer); -} - -#define TICKS_PER_SECOND 60 - -static SDL_Window *window; - -extern void draw_main(void); -extern void process_tick(float dt); -extern void editor_init(void); - -void draw(void) -{ - draw_main(); - SDL_GL_SwapWindow(window); -} - - -static int initialized=0; -static float last_dt; - -int screen_x,screen_y; - -float carried_dt = 0; -#define TICKRATE 60 - -float tex2_alpha = 1.0; - -int raw_level_time; - -float global_timer; -int global_hack; - -int loopmode(float dt, int real, int in_client) -{ - if (!initialized) return 0; - - if (!real) - return 0; - - // don't allow more than 6 frames to update at a time - if (dt > 0.075) dt = 0.075; - - global_timer += dt; - - carried_dt += dt; - while (carried_dt > 1.0/TICKRATE) { - if (global_hack) { - tex2_alpha += global_hack / 60.0f; - if (tex2_alpha < 0) tex2_alpha = 0; - if (tex2_alpha > 1) tex2_alpha = 1; - } - //update_input(); - // if the player is dead, stop the sim - carried_dt -= 1.0/TICKRATE; - } - - process_tick(dt); - draw(); - - return 0; -} - -static int quit; - -extern int controls; - -void active_control_set(int key) -{ - controls |= 1 << key; -} - -void active_control_clear(int key) -{ - controls &= ~(1 << key); -} - -extern void update_view(float dx, float dy); - -void process_sdl_mouse(SDL_Event *e) -{ - update_view((float) e->motion.xrel / screen_x, (float) e->motion.yrel / screen_y); -} - -void process_event(SDL_Event *e) -{ - switch (e->type) { - case SDL_MOUSEMOTION: - process_sdl_mouse(e); - break; - case SDL_MOUSEBUTTONDOWN: - case SDL_MOUSEBUTTONUP: - break; - - case SDL_QUIT: - quit = 1; - break; - - case SDL_WINDOWEVENT: - switch (e->window.event) { - case SDL_WINDOWEVENT_SIZE_CHANGED: - screen_x = e->window.data1; - screen_y = e->window.data2; - loopmode(0,1,0); - break; - } - break; - - case SDL_KEYDOWN: { - int k = e->key.keysym.sym; - int s = e->key.keysym.scancode; - SDL_Keymod mod; - mod = SDL_GetModState(); - if (k == SDLK_ESCAPE) - quit = 1; - - if (s == SDL_SCANCODE_D) active_control_set(0); - if (s == SDL_SCANCODE_A) active_control_set(1); - if (s == SDL_SCANCODE_W) active_control_set(2); - if (s == SDL_SCANCODE_S) active_control_set(3); - if (k == SDLK_SPACE) active_control_set(4); - if (s == SDL_SCANCODE_LCTRL) active_control_set(5); - if (s == SDL_SCANCODE_S) active_control_set(6); - if (s == SDL_SCANCODE_D) active_control_set(7); - if (k == '1') global_hack = !global_hack; - if (k == '2') global_hack = -1; - - #if 0 - if (game_mode == GAME_editor) { - switch (k) { - case SDLK_RIGHT: editor_key(STBTE_scroll_right); break; - case SDLK_LEFT : editor_key(STBTE_scroll_left ); break; - case SDLK_UP : editor_key(STBTE_scroll_up ); break; - case SDLK_DOWN : editor_key(STBTE_scroll_down ); break; - } - switch (s) { - case SDL_SCANCODE_S: editor_key(STBTE_tool_select); break; - case SDL_SCANCODE_B: editor_key(STBTE_tool_brush ); break; - case SDL_SCANCODE_E: editor_key(STBTE_tool_erase ); break; - case SDL_SCANCODE_R: editor_key(STBTE_tool_rectangle ); break; - case SDL_SCANCODE_I: editor_key(STBTE_tool_eyedropper); break; - case SDL_SCANCODE_L: editor_key(STBTE_tool_link); break; - case SDL_SCANCODE_G: editor_key(STBTE_act_toggle_grid); break; - } - if ((e->key.keysym.mod & KMOD_CTRL) && !(e->key.keysym.mod & ~KMOD_CTRL)) { - switch (s) { - case SDL_SCANCODE_X: editor_key(STBTE_act_cut ); break; - case SDL_SCANCODE_C: editor_key(STBTE_act_copy ); break; - case SDL_SCANCODE_V: editor_key(STBTE_act_paste); break; - case SDL_SCANCODE_Z: editor_key(STBTE_act_undo ); break; - case SDL_SCANCODE_Y: editor_key(STBTE_act_redo ); break; - } - } - } - #endif - break; - } - case SDL_KEYUP: { - int k = e->key.keysym.sym; - int s = e->key.keysym.scancode; - if (s == SDL_SCANCODE_D) active_control_clear(0); - if (s == SDL_SCANCODE_A) active_control_clear(1); - if (s == SDL_SCANCODE_W) active_control_clear(2); - if (s == SDL_SCANCODE_S) active_control_clear(3); - if (k == SDLK_SPACE) active_control_clear(4); - if (s == SDL_SCANCODE_LCTRL) active_control_clear(5); - if (s == SDL_SCANCODE_S) active_control_clear(6); - if (s == SDL_SCANCODE_D) active_control_clear(7); - break; - } - } -} - -static SDL_GLContext *context; - -static float getTimestep(float minimum_time) -{ - float elapsedTime; - double thisTime; - static double lastTime = -1; - - if (lastTime == -1) - lastTime = SDL_GetTicks() / 1000.0 - minimum_time; - - for(;;) { - thisTime = SDL_GetTicks() / 1000.0; - elapsedTime = (float) (thisTime - lastTime); - if (elapsedTime >= minimum_time) { - lastTime = thisTime; - return elapsedTime; - } - // @TODO: compute correct delay - SDL_Delay(1); - } -} - -void APIENTRY gl_debug(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *param) -{ - ods("%s\n", message); -} - -int is_synchronous_debug; -void enable_synchronous(void) -{ - glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); - is_synchronous_debug = 1; -} - -void prepare_threads(void); - -//void stbwingraph_main(void) -int SDL_main(int argc, char **argv) -{ - SDL_Init(SDL_INIT_VIDEO); - - prepare_threads(); - - SDL_GL_SetAttribute(SDL_GL_RED_SIZE , 8); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE , 8); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); - - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); - - #ifdef GL_DEBUG - SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); - #endif - - SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); - - screen_x = 1920; - screen_y = 1080; - - window = SDL_CreateWindow("caveview", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - screen_x, screen_y, - SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE - ); - if (!window) error("Couldn't create window"); - - context = SDL_GL_CreateContext(window); - if (!context) error("Couldn't create context"); - - SDL_GL_MakeCurrent(window, context); // is this true by default? - - SDL_SetRelativeMouseMode(SDL_TRUE); - #if defined(_MSC_VER) && _MSC_VER < 1300 - // work around broken behavior in VC6 debugging - if (IsDebuggerPresent()) - SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "1"); - #endif - - stbgl_initExtensions(); - - #ifdef GL_DEBUG - if (glDebugMessageCallbackARB) { - glDebugMessageCallbackARB(gl_debug, NULL); - - enable_synchronous(); - } - #endif - - SDL_GL_SetSwapInterval(1); - - render_init(); - mesh_init(); - world_init(); - - initialized = 1; - - while (!quit) { - SDL_Event e; - while (SDL_PollEvent(&e)) - process_event(&e); - - loopmode(getTimestep(0.0166f/8), 1, 1); - } - - return 0; -} diff --git a/third_party/stb/tests/caveview/cave_mesher.c b/third_party/stb/tests/caveview/cave_mesher.c deleted file mode 100644 index 1f76c89812..0000000000 --- a/third_party/stb/tests/caveview/cave_mesher.c +++ /dev/null @@ -1,933 +0,0 @@ -// This file takes minecraft chunks (decoded by cave_parse) and -// uses stb_voxel_render to turn them into vertex buffers. - -#define STB_GLEXT_DECLARE "glext_list.h" -#include "stb_gl.h" -#include "stb_image.h" -#include "stb_glprog.h" - -#include "caveview.h" -#include "cave_parse.h" -#include "stb.h" -#include "sdl.h" -#include "sdl_thread.h" -#include - -//#define VHEIGHT_TEST -//#define STBVOX_OPTIMIZED_VHEIGHT - -#define STBVOX_CONFIG_MODE 1 -#define STBVOX_CONFIG_OPENGL_MODELVIEW -#define STBVOX_CONFIG_PREFER_TEXBUFFER -//#define STBVOX_CONFIG_LIGHTING_SIMPLE -#define STBVOX_CONFIG_FOG_SMOOTHSTEP -//#define STBVOX_CONFIG_PREMULTIPLIED_ALPHA // this doesn't work properly alpha test without next #define -//#define STBVOX_CONFIG_UNPREMULTIPLY // slower, fixes alpha test makes windows & fancy leaves look better -//#define STBVOX_CONFIG_TEX1_EDGE_CLAMP -#define STBVOX_CONFIG_DISABLE_TEX2 -//#define STBVOX_CONFIG_DOWN_TEXLERP_PACKED -#define STBVOX_CONFIG_ROTATION_IN_LIGHTING - -#define STB_VOXEL_RENDER_IMPLEMENTATION -#include "stb_voxel_render.h" - -extern void ods(char *fmt, ...); - -//#define FANCY_LEAVES // nearly 2x the triangles when enabled (if underground is filled) -#define FAST_CHUNK -#define IN_PLACE - -#define SKIP_TERRAIN 0 -//#define SKIP_TERRAIN 48 // use to avoid building underground stuff - // allows you to see what perf would be like if underground was efficiently culled, - // or if you were making a game without underground - -enum -{ - C_empty, - C_solid, - C_trans, - C_cross, - C_water, - C_slab, - C_stair, - C_force, -}; - -unsigned char geom_map[] = -{ - STBVOX_GEOM_empty, - STBVOX_GEOM_solid, - STBVOX_GEOM_transp, - STBVOX_GEOM_crossed_pair, - STBVOX_GEOM_solid, - STBVOX_GEOM_slab_lower, - STBVOX_GEOM_floor_slope_north_is_top, - STBVOX_GEOM_force, -}; - -unsigned char minecraft_info[256][7] = -{ - { C_empty, 0,0,0,0,0,0 }, - { C_solid, 1,1,1,1,1,1 }, - { C_solid, 3,3,3,3,40,2 }, - { C_solid, 2,2,2,2,2,2 }, - { C_solid, 16,16,16,16,16,16 }, - { C_solid, 4,4,4,4,4,4 }, - { C_cross, 15,15,15,15 }, - { C_solid, 17,17,17,17,17,17 }, - - // 8 - { C_water, 223,223,223,223,223,223 }, - { C_water, 223,223,223,223,223,223 }, - { C_solid, 255,255,255,255,255,255 }, - { C_solid, 255,255,255,255,255,255 }, - { C_solid, 18,18,18,18,18,18 }, - { C_solid, 19,19,19,19,19,19 }, - { C_solid, 32,32,32,32,32,32 }, - { C_solid, 33,33,33,33,33,33 }, - - // 16 - { C_solid, 34,34,34,34,34,34 }, - { C_solid, 20,20,20,20,21,21 }, -#ifdef FANCY_LEAVES - { C_force, 52,52,52,52,52,52 }, // leaves -#else - { C_solid, 53,53,53,53,53,53 }, // leaves -#endif - { C_solid, 24,24,24,24,24,24 }, - { C_trans, 49,49,49,49,49,49 }, // glass - { C_solid, 160,160,160,160,160,160 }, - { C_solid, 144,144,144,144,144,144 }, - { C_solid, 46,45,45,45,62,62 }, - - // 24 - { C_solid, 192,192,192,192, 176,176 }, - { C_solid, 74,74,74,74,74,74 }, - { C_empty }, // bed - { C_empty }, // powered rail - { C_empty }, // detector rail - { C_solid, 106,108,109,108,108,108 }, - { C_empty }, // cobweb=11 - { C_cross, 39,39,39,39 }, - - // 32 - { C_cross, 55,55,55,55,0,0 }, - { C_solid, 107,108,109,108,108,108 }, - { C_empty }, // piston head - { C_solid, 64,64,64,64,64,64 }, // various colors - { C_empty }, // unused - { C_cross, 13,13,13,13,0,0 }, - { C_cross, 12,12,12,12,0,0 }, - { C_cross, 29,29,29,29,0,0 }, - - // 40 - { C_cross, 28,28,28,28,0,0 }, - { C_solid, 23,23,23,23,23,23 }, - { C_solid, 22,22,22,22,22,22 }, - { C_solid, 5,5,5,5,6,6, }, - { C_slab , 5,5,5,5,6,6, }, - { C_solid, 7,7,7,7,7,7, }, - { C_solid, 8,8,8,8,9,10 }, - { C_solid, 35,35,35,35,4,4, }, - - // 48 - //{ C_solid, 36,36,36,36,36,36 }, - { C_force, 36,36,36,36,36,36 }, - { C_solid, 37,37,37,37,37,37 }, - { C_cross, 80,80,80,80,80,80 }, // torch - { C_empty }, // fire - { C_trans, 65,65,65,65,65,65 }, - { C_stair, 4,4,4,4,4,4 }, - { C_solid, 26,26,26,27,25,25 }, - { C_empty }, // redstone - - // 56 - { C_solid, 50,50,50,50,50,50 }, - //{ C_force, 50,50,50,50,50,50 }, - { C_solid, 26,26,26,26,26,26 }, - { C_solid, 60,59,59,59,43,43 }, - { C_cross, 95,95,95,95 }, - { C_solid, 2,2,2,2,86,2 }, - { C_solid, 44,45,45,45,62,62 }, - { C_solid, 61,45,45,45,62,62 }, - { C_empty }, // sign - - // 64 - { C_empty }, // door - { C_empty }, // ladder - { C_empty }, // rail - { C_stair, 16,16,16,16,16,16 }, // cobblestone stairs - { C_empty }, // sign - { C_empty }, // lever - { C_empty }, // stone pressure plate - { C_empty }, // iron door - - // 72 - { C_empty }, // wooden pressure - { C_solid, 51,51,51,51,51,51 }, - { C_solid, 51,51,51,51,51,51 }, - { C_empty }, - { C_empty }, - { C_empty }, - { C_empty }, // snow on block below, do as half slab? - { C_solid, 67,67,67,67,67,67 }, - - // 80 - { C_solid, 66,66,66,66,66,66 }, - { C_solid, 70,70,70,70,69,71 }, - { C_solid, 72,72,72,72,72,72 }, - { C_cross, 73,73,73,73,73,73 }, - { C_solid, 74,74,74,74,75,74 }, - { C_empty }, // fence - { C_solid,119,118,118,118,102,102 }, - { C_solid,103,103,103,103,103,103 }, - - // 88 - { C_solid, 104,104,104,104,104,104 }, - { C_solid, 105,105,105,105,105,105 }, - { C_solid, 167,167,167,167,167,167 }, - { C_solid, 120,118,118,118,102,102 }, - { C_empty }, // cake - { C_empty }, // repeater - { C_empty }, // repeater - { C_solid, 49,49,49,49,49,49 }, // colored glass - - // 96 - { C_empty }, - { C_empty }, - { C_solid, 54,54,54,54,54,54 }, - { C_solid, 125,125,125,125,125,125 }, - { C_solid, 126,126,126,126,126,126 }, - { C_empty }, // bars - { C_trans, 49,49,49,49,49,49 }, // glass pane - { C_solid, 136,136,136,136,137,137 }, // melon - - // 104 - { C_empty }, // pumpkin stem - { C_empty }, // melon stem - { C_empty }, // vines - { C_empty }, // gate - { C_stair, 7,7,7,7,7,7, }, // brick stairs - { C_stair, 54,54,54,54,54,54 }, // stone brick stairs - { C_empty }, // mycelium - { C_empty }, // lily pad - - // 112 - { C_solid, 224,224,224,224,224,224 }, - { C_empty }, // nether brick fence - { C_stair, 224,224,224,224,224,224 }, // nether brick stairs - { C_empty }, // nether wart - { C_solid, 182,182,182,182,166,183 }, - { C_empty }, // brewing stand - { C_empty }, // cauldron - { C_empty }, // end portal - - // 120 - { C_solid, 159,159,159,159,158,158 }, - { C_solid, 175,175,175,175,175,175 }, - { C_empty }, // dragon egg - { C_solid, 211,211,211,211,211,211 }, - { C_solid, 212,212,212,212,212,212 }, - { C_solid, 4,4,4,4,4,4, }, // wood double-slab - { C_slab , 4,4,4,4,4,4, }, // wood slab - { C_empty }, // cocoa - - // 128 - { C_solid, 192,192,192,192,176,176 }, // sandstone stairs - { C_solid, 32,32,32,32,32,32 }, // emerald ore - { C_solid, 26,26,26,27,25,25 }, // ender chest - { C_empty }, - { C_empty }, - { C_solid, 23,23,23,23,23,23 }, // emerald block - { C_solid, 198,198,198,198,198,198 }, // spruce stairs - { C_solid, 214,214,214,214,214,214 }, // birch stairs - - // 136 - { C_stair, 199,199,199,199,199,199 }, // jungle stairs - { C_empty }, // command block - { C_empty }, // beacon - { C_slab, 16,16,16,16,16,16 }, // cobblestone wall - { C_empty }, // flower pot - { C_empty }, // carrot - { C_empty }, // potatoes - { C_empty }, // wooden button - - // 144 - { C_empty }, // mob head - { C_empty }, // anvil - { C_solid, 26,26,26,27,25,25 }, // trapped chest - { C_empty }, // weighted pressure plate light - { C_empty }, // weighted pressure plat eheavy - { C_empty }, // comparator inactive - { C_empty }, // comparator active - { C_empty }, // daylight sensor - - // 152 - { C_solid, 135,135,135,135,135,135 }, // redstone block - { C_solid, 0,0,0,0,0,0, }, // nether quartz ore - { C_empty }, // hopper - { C_solid, 22,22,22,22,22,22 }, // quartz block - { C_stair, 22,22,22,22,22,22 }, // quartz stairs - { C_empty }, // activator rail - { C_solid, 46,45,45,45,62,62 }, // dropper - { C_solid, 72,72,72,72,72,72 }, // stained clay - - // 160 - { C_trans, 49,49,49,49,49,49 }, // stained glass pane - #ifdef FANCY_LEAVES - { C_force, 52,52,52,52,52,52 }, // leaves - #else - { C_solid, 53,53,53,53,53,53 }, // acacia leaves - #endif - { C_solid, 20,20,20,20,21,21 }, // acacia tree - { C_solid, 199,199,199,199,199,199 }, // acacia wood stairs - { C_solid, 198,198,198,198,198,198 }, // dark oak stairs - { C_solid, 146,146,146,146,146,146 }, // slime block - - { C_solid, 176,176,176,176,176,176 }, // red sandstone - { C_solid, 176,176,176,176,176,176 }, // red sandstone - - // 168 - { C_empty }, - { C_empty }, - { C_empty }, - { C_empty }, - { C_solid, 72,72,72,72,72,72 }, // hardened clay - { C_empty }, - { C_empty }, - { C_empty }, - - // 176 - { C_empty }, - { C_empty }, - { C_solid, 176,176,176,176,176,176 }, // red sandstone -}; - -unsigned char minecraft_tex1_for_blocktype[256][6]; -unsigned char effective_blocktype[256]; -unsigned char minecraft_color_for_blocktype[256][6]; -unsigned char minecraft_geom_for_blocktype[256]; - -uint8 build_buffer[BUILD_BUFFER_SIZE]; -uint8 face_buffer[FACE_BUFFER_SIZE]; - -//GLuint vbuf, fbuf, fbuf_tex; - -//unsigned char tex1_for_blocktype[256][6]; - -//unsigned char blocktype[34][34][257]; -//unsigned char lighting[34][34][257]; - -// a superchunk is 64x64x256, with the border blocks computed as well, -// which means we need 4x4 chunks plus 16 border chunks plus 4 corner chunks - -#define SUPERCHUNK_X 4 -#define SUPERCHUNK_Y 4 - -unsigned char remap_data[16][16]; -unsigned char remap[256]; -unsigned char rotate_data[4] = { 1,3,2,0 }; - -void convert_fastchunk_inplace(fast_chunk *fc) -{ - int i; - int num_blocks=0, step=0; - unsigned char rot[4096]; - #ifndef IN_PLACE - unsigned char *storage; - #endif - - memset(rot, 0, 4096); - - for (i=0; i < 16; ++i) - num_blocks += fc->blockdata[i] != NULL; - - #ifndef IN_PLACE - storage = malloc(16*16*16*2 * num_blocks); - #endif - - for (i=0; i < 16; ++i) { - if (fc->blockdata[i]) { - int o=0; - unsigned char *bd,*dd,*lt,*sky; - unsigned char *out, *outb; - - // this ordering allows us to determine which data we can safely overwrite for in-place processing - bd = fc->blockdata[i]; - dd = fc->data[i]; - lt = fc->light[i]; - sky = fc->skylight[i]; - - #ifdef IN_PLACE - out = bd; - #else - out = storage + 16*16*16*2*step; - #endif - - // bd is written in place, but also reads from dd - for (o=0; o < 16*16*16/2; o += 1) { - unsigned char v1,v2; - unsigned char d = dd[o]; - v1 = bd[o*2+0]; - v2 = bd[o*2+1]; - - if (remap[v1]) - { - //unsigned char d = bd[o] & 15; - v1 = remap_data[remap[v1]][d&15]; - rot[o*2+0] = rotate_data[d&3]; - } else - v1 = effective_blocktype[v1]; - - if (remap[v2]) - { - //unsigned char d = bd[o] >> 4; - v2 = remap_data[remap[v2]][d>>4]; - rot[o*2+1] = rotate_data[(d>>4)&3]; - } else - v2 = effective_blocktype[v2]; - - out[o*2+0] = v1; - out[o*2+1] = v2; - } - - // this reads from lt & sky - #ifndef IN_PLACE - outb = out + 16*16*16; - ++step; - #endif - - // MC used to write in this order and it makes it possible to compute in-place - if (dd < sky && sky < lt) { - // @TODO go this path always if !IN_PLACE - #ifdef IN_PLACE - outb = dd; - #endif - - for (o=0; o < 16*16*16/2; ++o) { - int bright; - bright = (lt[o]&15)*12 + 15 + (sky[o]&15)*16; - if (bright > 255) bright = 255; - if (bright < 32) bright = 32; - outb[o*2+0] = STBVOX_MAKE_LIGHTING_EXT((unsigned char) bright, (rot[o*2+0]&3)); - - bright = (lt[o]>>4)*12 + 15 + (sky[o]>>4)*16; - if (bright > 255) bright = 255; - if (bright < 32) bright = 32; - outb[o*2+1] = STBVOX_MAKE_LIGHTING_EXT((unsigned char) bright, (rot[o*2+1]&3)); - } - } else { - // @TODO: if blocktype is in between others, this breaks; need to find which side has two pointers, and use that - // overwrite rot[] array, then copy out - #ifdef IN_PLACE - outb = (dd < sky) ? dd : sky; - if (lt < outb) lt = outb; - #endif - - for (o=0; o < 16*16*16/2; ++o) { - int bright; - bright = (lt[o]&15)*12 + 15 + (sky[o]&15)*16; - if (bright > 255) bright = 255; - if (bright < 32) bright = 32; - rot[o*2+0] = STBVOX_MAKE_LIGHTING_EXT((unsigned char) bright, (rot[o*2+0]&3)); - - bright = (lt[o]>>4)*12 + 15 + (sky[o]>>4)*16; - if (bright > 255) bright = 255; - if (bright < 32) bright = 32; - rot[o*2+1] = STBVOX_MAKE_LIGHTING_EXT((unsigned char) bright, (rot[o*2+1]&3)); - } - - memcpy(outb, rot, 4096); - fc->data[i] = outb; - } - - #ifndef IN_PLACE - fc->blockdata[i] = out; - fc->data[i] = outb; - #endif - } - } - - #ifndef IN_PLACE - free(fc->pointer_to_free); - fc->pointer_to_free = storage; - #endif -} - -void make_converted_fastchunk(fast_chunk *fc, int x, int y, int segment, uint8 *sv_blocktype, uint8 *sv_lighting) -{ - int z; - assert(fc == NULL || (fc->refcount > 0 && fc->refcount < 64)); - if (fc == NULL || fc->blockdata[segment] == NULL) { - for (z=0; z < 16; ++z) { - sv_blocktype[z] = C_empty; - sv_lighting[z] = 255; - } - } else { - unsigned char *block = fc->blockdata[segment]; - unsigned char *data = fc->data[segment]; - y = 15-y; - for (z=0; z < 16; ++z) { - sv_blocktype[z] = block[z*256 + y*16 + x]; - sv_lighting [z] = data [z*256 + y*16 + x]; - } - } -} - - -#define CHUNK_CACHE 64 -typedef struct -{ - int valid; - int chunk_x, chunk_y; - fast_chunk *fc; -} cached_converted_chunk; - -cached_converted_chunk chunk_cache[CHUNK_CACHE][CHUNK_CACHE]; -int cache_size = CHUNK_CACHE; - -void reset_cache_size(int size) -{ - int i,j; - for (j=size; j < cache_size; ++j) { - for (i=size; i < cache_size; ++i) { - cached_converted_chunk *ccc = &chunk_cache[j][i]; - if (ccc->valid) { - if (ccc->fc) { - free(ccc->fc->pointer_to_free); - free(ccc->fc); - ccc->fc = NULL; - } - ccc->valid = 0; - } - } - } - cache_size = size; -} - -// this must be called inside mutex -void deref_fastchunk(fast_chunk *fc) -{ - if (fc) { - assert(fc->refcount > 0); - --fc->refcount; - if (fc->refcount == 0) { - free(fc->pointer_to_free); - free(fc); - } - } -} - -SDL_mutex * chunk_cache_mutex; -SDL_mutex * chunk_get_mutex; - -void lock_chunk_get_mutex(void) -{ - SDL_LockMutex(chunk_get_mutex); -} -void unlock_chunk_get_mutex(void) -{ - SDL_UnlockMutex(chunk_get_mutex); -} - -fast_chunk *get_converted_fastchunk(int chunk_x, int chunk_y) -{ - int slot_x = (chunk_x & (cache_size-1)); - int slot_y = (chunk_y & (cache_size-1)); - fast_chunk *fc; - cached_converted_chunk *ccc; - SDL_LockMutex(chunk_cache_mutex); - ccc = &chunk_cache[slot_y][slot_x]; - if (ccc->valid) { - if (ccc->chunk_x == chunk_x && ccc->chunk_y == chunk_y) { - fast_chunk *fc = ccc->fc; - if (fc) - ++fc->refcount; - SDL_UnlockMutex(chunk_cache_mutex); - return fc; - } - if (ccc->fc) { - deref_fastchunk(ccc->fc); - ccc->fc = NULL; - ccc->valid = 0; - } - } - SDL_UnlockMutex(chunk_cache_mutex); - - fc = get_decoded_fastchunk_uncached(chunk_x, -chunk_y); - if (fc) - convert_fastchunk_inplace(fc); - - SDL_LockMutex(chunk_cache_mutex); - // another thread might have updated it, so before we overwrite it... - if (ccc->fc) { - deref_fastchunk(ccc->fc); - ccc->fc = NULL; - } - - if (fc) - fc->refcount = 1; // 1 in the cache - - ccc->chunk_x = chunk_x; - ccc->chunk_y = chunk_y; - ccc->valid = 1; - if (fc) - ++fc->refcount; - ccc->fc = fc; - SDL_UnlockMutex(chunk_cache_mutex); - return fc; -} - -void make_map_segment_for_superchunk_preconvert(int chunk_x, int chunk_y, int segment, fast_chunk *fc_table[4][4], uint8 sv_blocktype[34][34][18], uint8 sv_lighting[34][34][18]) -{ - int a,b; - assert((chunk_x & 1) == 0); - assert((chunk_y & 1) == 0); - for (b=-1; b < 3; ++b) { - for (a=-1; a < 3; ++a) { - int xo = a*16+1; - int yo = b*16+1; - int x,y; - fast_chunk *fc = fc_table[b+1][a+1]; - for (y=0; y < 16; ++y) - for (x=0; x < 16; ++x) - if (xo+x >= 0 && xo+x < 34 && yo+y >= 0 && yo+y < 34) - make_converted_fastchunk(fc,x,y, segment, sv_blocktype[xo+x][yo+y], sv_lighting[xo+x][yo+y]); - } - } -} - -// build 1 mesh covering 2x2 chunks -void build_chunk(int chunk_x, int chunk_y, fast_chunk *fc_table[4][4], raw_mesh *rm) -{ - int a,b,z; - stbvox_input_description *map; - - #ifdef VHEIGHT_TEST - unsigned char vheight[34][34][18]; - #endif - - #ifndef STBVOX_CONFIG_DISABLE_TEX2 - unsigned char tex2_choice[34][34][18]; - #endif - - assert((chunk_x & 1) == 0); - assert((chunk_y & 1) == 0); - - rm->cx = chunk_x; - rm->cy = chunk_y; - - stbvox_set_input_stride(&rm->mm, 34*18, 18); - - assert(rm->mm.input.geometry == NULL); - - map = stbvox_get_input_description(&rm->mm); - map->block_tex1_face = minecraft_tex1_for_blocktype; - map->block_color_face = minecraft_color_for_blocktype; - map->block_geometry = minecraft_geom_for_blocktype; - - stbvox_reset_buffers(&rm->mm); - stbvox_set_buffer(&rm->mm, 0, 0, rm->build_buffer, BUILD_BUFFER_SIZE); - stbvox_set_buffer(&rm->mm, 0, 1, rm->face_buffer , FACE_BUFFER_SIZE); - - map->blocktype = &rm->sv_blocktype[1][1][1]; // this is (0,0,0), but we need to be able to query off the edges - map->lighting = &rm->sv_lighting[1][1][1]; - - // fill in the top two rows of the buffer - for (a=0; a < 34; ++a) { - for (b=0; b < 34; ++b) { - rm->sv_blocktype[a][b][16] = 0; - rm->sv_lighting [a][b][16] = 255; - rm->sv_blocktype[a][b][17] = 0; - rm->sv_lighting [a][b][17] = 255; - } - } - - #ifndef STBVOX_CONFIG_DISABLE_TEX2 - for (a=0; a < 34; ++a) { - for (b=0; b < 34; ++b) { - int px = chunk_x*16 + a - 1; - int py = chunk_y*16 + b - 1; - float dist = (float) sqrt(px*px + py*py); - float s1 = (float) sin(dist / 16), s2, s3; - dist = (float) sqrt((px-80)*(px-80) + (py-50)*(py-50)); - s2 = (float) sin(dist / 11); - for (z=0; z < 18; ++z) { - s3 = (float) sin(z * 3.141592 / 8); - - s3 = s1*s2*s3; - tex2_choice[a][b][z] = 63 & (int) stb_linear_remap(s3,-1,1, -20,83); - } - } - } - #endif - - for (z=256-16; z >= SKIP_TERRAIN; z -= 16) - { - int z0 = z; - int z1 = z+16; - if (z1 == 256) z1 = 255; - - make_map_segment_for_superchunk_preconvert(chunk_x, chunk_y, z >> 4, fc_table, rm->sv_blocktype, rm->sv_lighting); - - map->blocktype = &rm->sv_blocktype[1][1][1-z]; // specify location of 0,0,0 so that accessing z0..z1 gets right data - map->lighting = &rm->sv_lighting[1][1][1-z]; - #ifndef STBVOX_CONFIG_DISABLE_TEX2 - map->tex2 = &tex2_choice[1][1][1-z]; - #endif - - #ifdef VHEIGHT_TEST - // hacky test of vheight - for (a=0; a < 34; ++a) { - for (b=0; b < 34; ++b) { - int c; - for (c=0; c < 17; ++c) { - if (rm->sv_blocktype[a][b][c] != 0 && rm->sv_blocktype[a][b][c+1] == 0) { - // topmost block - vheight[a][b][c] = rand() & 255; - rm->sv_blocktype[a][b][c] = 168; - } else if (c > 0 && rm->sv_blocktype[a][b][c] != 0 && rm->sv_blocktype[a][b][c-1] == 0) { - // bottommost block - vheight[a][b][c] = ((rand() % 3) << 6) + ((rand() % 3) << 4) + ((rand() % 3) << 2) + (rand() % 3); - rm->sv_blocktype[a][b][c] = 169; - } - } - vheight[a][b][c] = STBVOX_MAKE_VHEIGHT(2,2,2,2); // flat top - } - } - map->vheight = &vheight[1][1][1-z]; - #endif - - { - stbvox_set_input_range(&rm->mm, 0,0,z0, 32,32,z1); - stbvox_set_default_mesh(&rm->mm, 0); - stbvox_make_mesh(&rm->mm); - } - - // copy the bottom two rows of data up to the top - for (a=0; a < 34; ++a) { - for (b=0; b < 34; ++b) { - rm->sv_blocktype[a][b][16] = rm->sv_blocktype[a][b][0]; - rm->sv_blocktype[a][b][17] = rm->sv_blocktype[a][b][1]; - rm->sv_lighting [a][b][16] = rm->sv_lighting [a][b][0]; - rm->sv_lighting [a][b][17] = rm->sv_lighting [a][b][1]; - } - } - } - - stbvox_set_mesh_coordinates(&rm->mm, chunk_x*16, chunk_y*16, 0); - stbvox_get_transform(&rm->mm, rm->transform); - - stbvox_set_input_range(&rm->mm, 0,0,0, 32,32,255); - stbvox_get_bounds(&rm->mm, rm->bounds); - - rm->num_quads = stbvox_get_quad_count(&rm->mm, 0); -} - -int next_blocktype = 255; - -unsigned char mc_rot[4] = { 1,3,2,0 }; - -// create blocktypes with rotation baked into type... -// @TODO we no longer need this now that we store rotations -// in lighting -void build_stair_rotations(int blocktype, unsigned char *map) -{ - int i; - - // use the existing block type for floor stairs; allocate a new type for ceil stairs - for (i=0; i < 6; ++i) { - minecraft_color_for_blocktype[next_blocktype][i] = minecraft_color_for_blocktype[blocktype][i]; - minecraft_tex1_for_blocktype [next_blocktype][i] = minecraft_tex1_for_blocktype [blocktype][i]; - } - minecraft_geom_for_blocktype[next_blocktype] = (unsigned char) STBVOX_MAKE_GEOMETRY(STBVOX_GEOM_ceil_slope_north_is_bottom, 0, 0); - minecraft_geom_for_blocktype[ blocktype] = (unsigned char) STBVOX_MAKE_GEOMETRY(STBVOX_GEOM_floor_slope_north_is_top, 0, 0); - - for (i=0; i < 4; ++i) { - map[0+i+8] = map[0+i] = blocktype; - map[4+i+8] = map[4+i] = next_blocktype; - } - --next_blocktype; -} - -void build_wool_variations(int bt, unsigned char *map) -{ - int i,k; - unsigned char tex[16] = { 64, 210, 194, 178, 162, 146, 130, 114, 225, 209, 193, 177, 161, 145, 129, 113 }; - for (i=0; i < 16; ++i) { - if (i == 0) - map[i] = bt; - else { - map[i] = next_blocktype; - for (k=0; k < 6; ++k) { - minecraft_tex1_for_blocktype[next_blocktype][k] = tex[i]; - } - minecraft_geom_for_blocktype[next_blocktype] = minecraft_geom_for_blocktype[bt]; - --next_blocktype; - } - } -} - -void build_wood_variations(int bt, unsigned char *map) -{ - int i,k; - unsigned char tex[4] = { 5, 198, 214, 199 }; - for (i=0; i < 4; ++i) { - if (i == 0) - map[i] = bt; - else { - map[i] = next_blocktype; - for (k=0; k < 6; ++k) { - minecraft_tex1_for_blocktype[next_blocktype][k] = tex[i]; - } - minecraft_geom_for_blocktype[next_blocktype] = minecraft_geom_for_blocktype[bt]; - --next_blocktype; - } - } - map[i] = map[i-1]; - ++i; - for (; i < 16; ++i) - map[i] = bt; -} - -void remap_in_place(int bt, int rm) -{ - int i; - remap[bt] = rm; - for (i=0; i < 16; ++i) - remap_data[rm][i] = bt; -} - - -void mesh_init(void) -{ - int i; - - chunk_cache_mutex = SDL_CreateMutex(); - chunk_get_mutex = SDL_CreateMutex(); - - for (i=0; i < 256; ++i) { - memcpy(minecraft_tex1_for_blocktype[i], minecraft_info[i]+1, 6); - effective_blocktype[i] = (minecraft_info[i][0] == C_empty ? 0 : i); - minecraft_geom_for_blocktype[i] = geom_map[minecraft_info[i][0]]; - } - //effective_blocktype[50] = 0; // delete torches - - for (i=0; i < 6*256; ++i) { - if (minecraft_tex1_for_blocktype[0][i] == 40) - minecraft_color_for_blocktype[0][i] = 38 | 64; // apply to tex1 - if (minecraft_tex1_for_blocktype[0][i] == 39) - minecraft_color_for_blocktype[0][i] = 39 | 64; // apply to tex1 - if (minecraft_tex1_for_blocktype[0][i] == 105) - minecraft_color_for_blocktype[0][i] = 63; // emissive - if (minecraft_tex1_for_blocktype[0][i] == 212) - minecraft_color_for_blocktype[0][i] = 63; // emissive - if (minecraft_tex1_for_blocktype[0][i] == 80) - minecraft_color_for_blocktype[0][i] = 63; // emissive - } - - for (i=0; i < 6; ++i) { - minecraft_color_for_blocktype[172][i] = 47 | 64; // apply to tex1 - minecraft_color_for_blocktype[178][i] = 47 | 64; // apply to tex1 - minecraft_color_for_blocktype[18][i] = 39 | 64; // green - minecraft_color_for_blocktype[161][i] = 37 | 64; // green - minecraft_color_for_blocktype[10][i] = 63; // emissive lava - minecraft_color_for_blocktype[11][i] = 63; // emissive - //minecraft_color_for_blocktype[56][i] = 63; // emissive diamond - minecraft_color_for_blocktype[48][i] = 63; // emissive dungeon - } - - #ifdef VHEIGHT_TEST - effective_blocktype[168] = 168; - minecraft_tex1_for_blocktype[168][0] = 1; - minecraft_tex1_for_blocktype[168][1] = 1; - minecraft_tex1_for_blocktype[168][2] = 1; - minecraft_tex1_for_blocktype[168][3] = 1; - minecraft_tex1_for_blocktype[168][4] = 1; - minecraft_tex1_for_blocktype[168][5] = 1; - minecraft_geom_for_blocktype[168] = STBVOX_GEOM_floor_vheight_12; - effective_blocktype[169] = 169; - minecraft_tex1_for_blocktype[169][0] = 1; - minecraft_tex1_for_blocktype[169][1] = 1; - minecraft_tex1_for_blocktype[169][2] = 1; - minecraft_tex1_for_blocktype[169][3] = 1; - minecraft_tex1_for_blocktype[169][4] = 1; - minecraft_tex1_for_blocktype[169][5] = 1; - minecraft_geom_for_blocktype[169] = STBVOX_GEOM_ceil_vheight_03; - #endif - - remap[53] = 1; - remap[67] = 2; - remap[108] = 3; - remap[109] = 4; - remap[114] = 5; - remap[136] = 6; - remap[156] = 7; - for (i=0; i < 256; ++i) - if (remap[i]) - build_stair_rotations(i, remap_data[remap[i]]); - remap[35] = 8; - build_wool_variations(35, remap_data[remap[35]]); - remap[5] = 11; - build_wood_variations(5, remap_data[remap[5]]); - - // set the remap flags for these so they write the rotation values - remap_in_place(54, 9); - remap_in_place(146, 10); -} - -// Timing stats while optimizing the single-threaded builder - -// 32..-32, 32..-32, SKIP_TERRAIN=0, !FANCY_LEAVES on 'mcrealm' data set - -// 6.27s - reblocked to do 16 z at a time instead of 256 (still using 66x66x258), 4 meshes in parallel -// 5.96s - reblocked to use FAST_CHUNK (no intermediate data structure) -// 5.45s - unknown change, or previous measurement was wrong - -// 6.12s - use preconverted data, not in-place -// 5.91s - use preconverted, in-place -// 5.34s - preconvert, in-place, avoid dependency chain (suggested by ryg) -// 5.34s - preconvert, in-place, avoid dependency chain, use bit-table instead of byte-table -// 5.50s - preconvert, in-place, branchless - -// 6.42s - non-preconvert, avoid dependency chain (not an error) -// 5.40s - non-preconvert, w/dependency chain (same as earlier) - -// 5.50s - non-FAST_CHUNK, reblocked outer loop for better cache reuse -// 4.73s - FAST_CHUNK non-preconvert, reblocked outer loop -// 4.25s - preconvert, in-place, reblocked outer loop -// 4.18s - preconvert, in-place, unrolled again -// 4.10s - 34x34 1 mesh instead of 66x66 and 4 meshes (will make it easier to do multiple threads) - -// 4.83s - building bitmasks but not using them (2 bits per block, one if empty, one if solid) - -// 5.16s - using empty bitmasks to early out -// 5.01s - using solid & empty bitmasks to early out - "foo" -// 4.64s - empty bitmask only, test 8 at a time, then test geom -// 4.72s - empty bitmask only, 8 at a time, then test bits -// 4.46s - split bitmask building into three loops (each byte is separate) -// 4.42s - further optimize computing bitmask - -// 4.58s - using solid & empty bitmasks to early out, same as "foo" but faster bitmask building -// 4.12s - using solid & empty bitmasks to efficiently test neighbors -// 4.04s - using 16-bit fetches (not endian-independent) -// - note this is first place that beats previous best '4.10s - 34x34 1 mesh' - -// 4.30s - current time with bitmasks disabled again (note was 4.10s earlier) -// 3.95s - bitmasks enabled again, no other changes -// 4.00s - current time with bitmasks disabled again, no other changes -- wide variation that is time dependent? -// (note that most of the numbers listed here are median of 3 values already) -// 3.98s - bitmasks enabled - -// Bitmasks removed from the code as not worth the complexity increase - - - -// Raw data for Q&A: -// -// 26% parsing & loading minecraft files (4/5ths of which is zlib decode) -// 39% building mesh from stb input format -// 18% converting from minecraft blocks to stb blocks -// 9% reordering from minecraft axis order to stb axis order -// 7% uploading vertex buffer to OpenGL diff --git a/third_party/stb/tests/caveview/cave_parse.c b/third_party/stb/tests/caveview/cave_parse.c deleted file mode 100644 index e8ae02b7db..0000000000 --- a/third_party/stb/tests/caveview/cave_parse.c +++ /dev/null @@ -1,632 +0,0 @@ -#include -#include -#include -#include - -#define FAST_CHUNK // disabling this enables the old, slower path that deblocks into a regular form - -#include "cave_parse.h" - -#include "stb_image.h" -#include "stb.h" - -#define NUM_CHUNKS_PER_REGION 32 // only on one axis -#define NUM_CHUNKS_PER_REGION_LOG2 5 - -#define NUM_COLUMNS_PER_CHUNK 16 -#define NUM_COLUMNS_PER_CHUNK_LOG2 4 - -uint32 read_uint32_be(FILE *f) -{ - unsigned char data[4]; - fread(data, 1, 4, f); - return (data[0]<<24) + (data[1]<<16) + (data[2]<<8) + data[3]; -} - -typedef struct -{ - uint8 *data; - size_t len; - int x,z; // chunk index - int refcount; // for multi-threading -} compressed_chunk; - -typedef struct -{ - int x,z; - uint32 sector_data[NUM_CHUNKS_PER_REGION][NUM_CHUNKS_PER_REGION]; -} region; - -size_t cached_compressed=0; - -FILE *last_region; -int last_region_x; -int last_region_z; -int opened=0; - -static void open_file(int reg_x, int reg_z) -{ - if (!opened || last_region_x != reg_x || last_region_z != reg_z) { - char filename[256]; - if (last_region != NULL) - fclose(last_region); - sprintf(filename, "r.%d.%d.mca", reg_x, reg_z); - last_region = fopen(filename, "rb"); - last_region_x = reg_x; - last_region_z = reg_z; - opened = 1; - } -} - -static region *load_region(int reg_x, int reg_z) -{ - region *r; - int x,z; - - open_file(reg_x, reg_z); - - r = malloc(sizeof(*r)); - - if (last_region == NULL) { - memset(r, 0, sizeof(*r)); - } else { - fseek(last_region, 0, SEEK_SET); - for (z=0; z < NUM_CHUNKS_PER_REGION; ++z) - for (x=0; x < NUM_CHUNKS_PER_REGION; ++x) - r->sector_data[z][x] = read_uint32_be(last_region); - } - r->x = reg_x; - r->z = reg_z; - - return r; -} - -void free_region(region *r) -{ - free(r); -} - -#define MAX_MAP_REGIONS 64 // in one axis: 64 regions * 32 chunk/region * 16 columns/chunk = 16384 columns -region *regions[MAX_MAP_REGIONS][MAX_MAP_REGIONS]; - -static region *get_region(int reg_x, int reg_z) -{ - int slot_x = reg_x & (MAX_MAP_REGIONS-1); - int slot_z = reg_z & (MAX_MAP_REGIONS-1); - region *r; - - r = regions[slot_z][slot_x]; - - if (r) { - if (r->x == reg_x && r->z == reg_z) - return r; - free_region(r); - } - - r = load_region(reg_x, reg_z); - regions[slot_z][slot_x] = r; - - return r; -} - -// about one region, so size should be ok -#define NUM_CACHED_X 64 -#define NUM_CACHED_Z 64 - -// @TODO: is it really worth caching these? we probably can just -// pull them from the disk cache nearly as efficiently. -// Can test that by setting to 1x1? -compressed_chunk *cached_chunk[NUM_CACHED_Z][NUM_CACHED_X]; - -static void deref_compressed_chunk(compressed_chunk *cc) -{ - assert(cc->refcount > 0); - --cc->refcount; - if (cc->refcount == 0) { - if (cc->data) - free(cc->data); - free(cc); - } -} - -static compressed_chunk *get_compressed_chunk(int chunk_x, int chunk_z) -{ - int slot_x = chunk_x & (NUM_CACHED_X-1); - int slot_z = chunk_z & (NUM_CACHED_Z-1); - compressed_chunk *cc = cached_chunk[slot_z][slot_x]; - - if (cc && cc->x == chunk_x && cc->z == chunk_z) - return cc; - else { - int reg_x = chunk_x >> NUM_CHUNKS_PER_REGION_LOG2; - int reg_z = chunk_z >> NUM_CHUNKS_PER_REGION_LOG2; - region *r = get_region(reg_x, reg_z); - if (cc) { - deref_compressed_chunk(cc); - cached_chunk[slot_z][slot_x] = NULL; - } - cc = malloc(sizeof(*cc)); - cc->x = chunk_x; - cc->z = chunk_z; - { - int subchunk_x = chunk_x & (NUM_CHUNKS_PER_REGION-1); - int subchunk_z = chunk_z & (NUM_CHUNKS_PER_REGION-1); - uint32 code = r->sector_data[subchunk_z][subchunk_x]; - - if (code & 255) { - open_file(reg_x, reg_z); - fseek(last_region, (code>>8)*4096, SEEK_SET); - cc->len = (code&255)*4096; - cc->data = malloc(cc->len); - fread(cc->data, 1, cc->len, last_region); - } else { - cc->len = 0; - cc->data = 0; - } - } - cc->refcount = 1; - cached_chunk[slot_z][slot_x] = cc; - return cc; - } -} - - -// NBT parser -- can automatically parse stuff we don't -// have definitions for, but want to explicitly parse -// stuff we do have definitions for. -// -// option 1: auto-parse everything into data structures, -// then read those -// -// option 2: have a "parse next object" which -// doesn't resolve whether it expands its children -// yet, and then the user either says "expand" or -// "skip" after looking at the name. Anything with -// "children" without names can't go through this -// interface. -// -// Let's try option 2. - - -typedef struct -{ - unsigned char *buffer_start; - unsigned char *buffer_end; - unsigned char *cur; - int nesting; - char temp_buffer[256]; -} nbt; - -enum { TAG_End=0, TAG_Byte=1, TAG_Short=2, TAG_Int=3, TAG_Long=4, - TAG_Float=5, TAG_Double=6, TAG_Byte_Array=7, TAG_String=8, - TAG_List=9, TAG_Compound=10, TAG_Int_Array=11 }; - -static void nbt_get_string_data(unsigned char *data, char *buffer, size_t bufsize) -{ - int len = data[0]*256 + data[1]; - int i; - for (i=0; i < len && i+1 < (int) bufsize; ++i) - buffer[i] = (char) data[i+2]; - buffer[i] = 0; -} - -static char *nbt_peek(nbt *n) -{ - unsigned char type = *n->cur; - if (type == TAG_End) - return NULL; - nbt_get_string_data(n->cur+1, n->temp_buffer, sizeof(n->temp_buffer)); - return n->temp_buffer; -} - -static uint32 nbt_parse_uint32(unsigned char *buffer) -{ - return (buffer[0] << 24) + (buffer[1]<<16) + (buffer[2]<<8) + buffer[3]; -} - -static void nbt_skip(nbt *n); - -// skip an item that doesn't have an id or name prefix (usable in lists) -static void nbt_skip_raw(nbt *n, unsigned char type) -{ - switch (type) { - case TAG_Byte : n->cur += 1; break; - case TAG_Short : n->cur += 2; break; - case TAG_Int : n->cur += 4; break; - case TAG_Long : n->cur += 8; break; - case TAG_Float : n->cur += 4; break; - case TAG_Double: n->cur += 8; break; - case TAG_Byte_Array: n->cur += 4 + 1*nbt_parse_uint32(n->cur); break; - case TAG_Int_Array : n->cur += 4 + 4*nbt_parse_uint32(n->cur); break; - case TAG_String : n->cur += 2 + (n->cur[0]*256 + n->cur[1]); break; - case TAG_List : { - unsigned char list_type = *n->cur++; - unsigned int list_len = nbt_parse_uint32(n->cur); - unsigned int i; - n->cur += 4; // list_len - for (i=0; i < list_len; ++i) - nbt_skip_raw(n, list_type); - break; - } - case TAG_Compound : { - while (*n->cur != TAG_End) - nbt_skip(n); - nbt_skip(n); // skip the TAG_end - break; - } - } - assert(n->cur <= n->buffer_end); -} - -static void nbt_skip(nbt *n) -{ - unsigned char type = *n->cur++; - if (type == TAG_End) - return; - // skip name - n->cur += (n->cur[0]*256 + n->cur[1]) + 2; - nbt_skip_raw(n, type); -} - -// byteswap -static void nbt_swap(unsigned char *ptr, int len) -{ - int i; - for (i=0; i < (len>>1); ++i) { - unsigned char t = ptr[i]; - ptr[i] = ptr[len-1-i]; - ptr[len-1-i] = t; - } -} - -// pass in the expected type, fail if doesn't match -// returns a pointer to the data, byteswapped if appropriate -static void *nbt_get_fromlist(nbt *n, unsigned char type, int *len) -{ - unsigned char *ptr; - assert(type != TAG_Compound); - assert(type != TAG_List); // we could support getting lists of primitives as if they were arrays, but eh - if (len) *len = 1; - ptr = n->cur; - switch (type) { - case TAG_Byte : break; - - case TAG_Short : nbt_swap(ptr, 2); break; - case TAG_Int : nbt_swap(ptr, 4); break; - case TAG_Long : nbt_swap(ptr, 8); break; - case TAG_Float : nbt_swap(ptr, 4); break; - case TAG_Double: nbt_swap(ptr, 8); break; - - case TAG_Byte_Array: - *len = nbt_parse_uint32(ptr); - ptr += 4; - break; - case TAG_Int_Array: { - int i; - *len = nbt_parse_uint32(ptr); - ptr += 4; - for (i=0; i < *len; ++i) - nbt_swap(ptr + 4*i, 4); - break; - } - - default: assert(0); // unhandled case - } - nbt_skip_raw(n, type); - return ptr; -} - -static void *nbt_get(nbt *n, unsigned char type, int *len) -{ - assert(n->cur[0] == type); - n->cur += 3 + (n->cur[1]*256+n->cur[2]); - return nbt_get_fromlist(n, type, len); -} - -static void nbt_begin_compound(nbt *n) // start a compound -{ - assert(*n->cur == TAG_Compound); - // skip header - n->cur += 3 + (n->cur[1]*256 + n->cur[2]); - ++n->nesting; -} - -static void nbt_begin_compound_in_list(nbt *n) // start a compound -{ - ++n->nesting; -} - -static void nbt_end_compound(nbt *n) // end a compound -{ - assert(*n->cur == TAG_End); - assert(n->nesting != 0); - ++n->cur; - --n->nesting; -} - -// @TODO no interface to get lists from lists -static int nbt_begin_list(nbt *n, unsigned char type) -{ - uint32 len; - unsigned char *ptr; - - ptr = n->cur + 3 + (n->cur[1]*256 + n->cur[2]); - if (ptr[0] != type) - return -1; - n->cur = ptr; - len = nbt_parse_uint32(n->cur+1); - assert(n->cur[0] == type); - // @TODO keep a stack with the count to make sure they do it right - ++n->nesting; - n->cur += 5; - return (int) len; -} - -static void nbt_end_list(nbt *n) -{ - --n->nesting; -} - -// raw_block chunk is 16x256x16x4 = 2^(4+8+4+2) = 256KB -// -// if we want to process 64x64x256 at a time, that will be: -// 4*4*256KB => 4MB per area in raw_block -// -// (plus we maybe need to decode adjacent regions) - - -#ifdef FAST_CHUNK -typedef fast_chunk parse_chunk; -#else -typedef chunk parse_chunk; -#endif - -static parse_chunk *minecraft_chunk_parse(unsigned char *data, size_t len) -{ - char *s; - parse_chunk *c = NULL; - - nbt n_store, *n = &n_store; - n->buffer_start = data; - n->buffer_end = data + len; - n->cur = n->buffer_start; - n->nesting = 0; - - nbt_begin_compound(n); - while ((s = nbt_peek(n)) != NULL) { - if (!strcmp(s, "Level")) { - int *height; - c = malloc(sizeof(*c)); - #ifdef FAST_CHUNK - memset(c, 0, sizeof(*c)); - c->pointer_to_free = data; - #else - c->rb[15][15][255].block = 0; - #endif - c->max_y = 0; - - nbt_begin_compound(n); - while ((s = nbt_peek(n)) != NULL) { - if (!strcmp(s, "xPos")) - c->xpos = *(int *) nbt_get(n, TAG_Int, 0); - else if (!strcmp(s, "zPos")) - c->zpos = *(int *) nbt_get(n, TAG_Int, 0); - else if (!strcmp(s, "Sections")) { - int count = nbt_begin_list(n, TAG_Compound), i; - if (count == -1) { - // this not-a-list case happens in The End and I'm not sure - // what it means... possibly one of those silly encodings - // where it's not encoded as a list if there's only one? - // not worth figuring out - nbt_skip(n); - count = -1; - } - for (i=0; i < count; ++i) { - int yi, len; - uint8 *light = NULL, *blocks = NULL, *data = NULL, *skylight = NULL; - nbt_begin_compound_in_list(n); - while ((s = nbt_peek(n)) != NULL) { - if (!strcmp(s, "Y")) - yi = * (uint8 *) nbt_get(n, TAG_Byte, 0); - else if (!strcmp(s, "BlockLight")) { - light = nbt_get(n, TAG_Byte_Array, &len); - assert(len == 2048); - } else if (!strcmp(s, "Blocks")) { - blocks = nbt_get(n, TAG_Byte_Array, &len); - assert(len == 4096); - } else if (!strcmp(s, "Data")) { - data = nbt_get(n, TAG_Byte_Array, &len); - assert(len == 2048); - } else if (!strcmp(s, "SkyLight")) { - skylight = nbt_get(n, TAG_Byte_Array, &len); - assert(len == 2048); - } - } - nbt_end_compound(n); - - assert(yi < 16); - - #ifndef FAST_CHUNK - - // clear data below current max_y - { - int x,z; - while (c->max_y < yi*16) { - for (x=0; x < 16; ++x) - for (z=0; z < 16; ++z) - c->rb[z][x][c->max_y].block = 0; - ++c->max_y; - } - } - - // now assemble the data - { - int x,y,z, o2=0,o4=0; - for (y=0; y < 16; ++y) { - for (z=0; z < 16; ++z) { - for (x=0; x < 16; x += 2) { - raw_block *rb = &c->rb[15-z][x][y + yi*16]; // 15-z because switching to z-up will require flipping an axis - rb[0].block = blocks[o4]; - rb[0].light = light[o2] & 15; - rb[0].data = data[o2] & 15; - rb[0].skylight = skylight[o2] & 15; - - rb[256].block = blocks[o4+1]; - rb[256].light = light[o2] >> 4; - rb[256].data = data[o2] >> 4; - rb[256].skylight = skylight[o2] >> 4; - - o2 += 1; - o4 += 2; - } - } - } - c->max_y += 16; - } - #else - c->blockdata[yi] = blocks; - c->data [yi] = data; - c->light [yi] = light; - c->skylight [yi] = skylight; - #endif - } - //nbt_end_list(n); - } else if (!strcmp(s, "HeightMap")) { - height = nbt_get(n, TAG_Int_Array, &len); - assert(len == 256); - } else - nbt_skip(n); - } - nbt_end_compound(n); - - } else - nbt_skip(n); - } - nbt_end_compound(n); - assert(n->cur == n->buffer_end); - return c; -} - -#define MAX_DECODED_CHUNK_X 64 -#define MAX_DECODED_CHUNK_Z 64 - -typedef struct -{ - int cx,cz; - fast_chunk *fc; - int valid; -} decoded_buffer; - -static decoded_buffer decoded_buffers[MAX_DECODED_CHUNK_Z][MAX_DECODED_CHUNK_X]; -void lock_chunk_get_mutex(void); -void unlock_chunk_get_mutex(void); - -#ifdef FAST_CHUNK -fast_chunk *get_decoded_fastchunk_uncached(int chunk_x, int chunk_z) -{ - unsigned char *decoded; - compressed_chunk *cc; - int inlen; - int len; - fast_chunk *fc; - - lock_chunk_get_mutex(); - cc = get_compressed_chunk(chunk_x, chunk_z); - if (cc->len != 0) - ++cc->refcount; - unlock_chunk_get_mutex(); - - if (cc->len == 0) - return NULL; - - assert(cc != NULL); - - assert(cc->data[4] == 2); - - inlen = nbt_parse_uint32(cc->data); - decoded = stbi_zlib_decode_malloc_guesssize(cc->data+5, inlen, inlen*3, &len); - assert(decoded != NULL); - assert(len != 0); - - lock_chunk_get_mutex(); - deref_compressed_chunk(cc); - unlock_chunk_get_mutex(); - - #ifdef FAST_CHUNK - fc = minecraft_chunk_parse(decoded, len); - #else - fc = NULL; - #endif - if (fc == NULL) - free(decoded); - return fc; -} - - -decoded_buffer *get_decoded_buffer(int chunk_x, int chunk_z) -{ - decoded_buffer *db = &decoded_buffers[chunk_z&(MAX_DECODED_CHUNK_Z-1)][chunk_x&(MAX_DECODED_CHUNK_X-1)]; - if (db->valid) { - if (db->cx == chunk_x && db->cz == chunk_z) - return db; - if (db->fc) { - free(db->fc->pointer_to_free); - free(db->fc); - } - } - - db->cx = chunk_x; - db->cz = chunk_z; - db->valid = 1; - db->fc = 0; - - { - db->fc = get_decoded_fastchunk_uncached(chunk_x, chunk_z); - return db; - } -} - -fast_chunk *get_decoded_fastchunk(int chunk_x, int chunk_z) -{ - decoded_buffer *db = get_decoded_buffer(chunk_x, chunk_z); - return db->fc; -} -#endif - -#ifndef FAST_CHUNK -chunk *get_decoded_chunk_raw(int chunk_x, int chunk_z) -{ - unsigned char *decoded; - compressed_chunk *cc = get_compressed_chunk(chunk_x, chunk_z); - assert(cc != NULL); - if (cc->len == 0) - return NULL; - else { - chunk *ch; - int inlen = nbt_parse_uint32(cc->data); - int len; - assert(cc->data[4] == 2); - decoded = stbi_zlib_decode_malloc_guesssize(cc->data+5, inlen, inlen*3, &len); - assert(decoded != NULL); - #ifdef FAST_CHUNK - ch = NULL; - #else - ch = minecraft_chunk_parse(decoded, len); - #endif - free(decoded); - return ch; - } -} - -static chunk *decoded_chunks[MAX_DECODED_CHUNK_Z][MAX_DECODED_CHUNK_X]; -chunk *get_decoded_chunk(int chunk_x, int chunk_z) -{ - chunk *c = decoded_chunks[chunk_z&(MAX_DECODED_CHUNK_Z-1)][chunk_x&(MAX_DECODED_CHUNK_X-1)]; - if (c && c->xpos == chunk_x && c->zpos == chunk_z) - return c; - if (c) free(c); - c = get_decoded_chunk_raw(chunk_x, chunk_z); - decoded_chunks[chunk_z&(MAX_DECODED_CHUNK_Z-1)][chunk_x&(MAX_DECODED_CHUNK_X-1)] = c; - return c; -} -#endif diff --git a/third_party/stb/tests/caveview/cave_parse.h b/third_party/stb/tests/caveview/cave_parse.h deleted file mode 100644 index 4cdfe2ad70..0000000000 --- a/third_party/stb/tests/caveview/cave_parse.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef INCLUDE_CAVE_PARSE_H -#define INCLUDE_CAVE_PARSE_H - -typedef struct -{ - unsigned char block; - unsigned char data; - unsigned char light:4; - unsigned char skylight:4; -} raw_block; - -// this is the old fully-decoded chunk -typedef struct -{ - int xpos, zpos, max_y; - int height[16][16]; - raw_block rb[16][16][256]; // [z][x][y] which becomes [y][x][z] in stb -} chunk; - -chunk *get_decoded_chunk(int chunk_x, int chunk_z); - -#define NUM_SEGMENTS 16 -typedef struct -{ - int max_y, xpos, zpos; - - unsigned char *blockdata[NUM_SEGMENTS]; - unsigned char *data[NUM_SEGMENTS]; - unsigned char *skylight[NUM_SEGMENTS]; - unsigned char *light[NUM_SEGMENTS]; - - void *pointer_to_free; - - int refcount; // this allows multi-threaded building without wrapping in ANOTHER struct -} fast_chunk; - -fast_chunk *get_decoded_fastchunk(int chunk_x, int chunk_z); // cache, never call free() - -fast_chunk *get_decoded_fastchunk_uncached(int chunk_x, int chunk_z); - -#endif diff --git a/third_party/stb/tests/caveview/cave_render.c b/third_party/stb/tests/caveview/cave_render.c deleted file mode 100644 index 3ed46288a4..0000000000 --- a/third_party/stb/tests/caveview/cave_render.c +++ /dev/null @@ -1,951 +0,0 @@ -// This file renders vertex buffers, converts raw meshes -// to GL meshes, and manages threads that do the raw-mesh -// building (found in cave_mesher.c) - - -#include "stb_voxel_render.h" - -#define STB_GLEXT_DECLARE "glext_list.h" -#include "stb_gl.h" -#include "stb_image.h" -#include "stb_glprog.h" - -#include "caveview.h" -#include "cave_parse.h" -#include "stb.h" -#include "sdl.h" -#include "sdl_thread.h" -#include -#include - -//#define STBVOX_CONFIG_TEX1_EDGE_CLAMP - - -// currently no dynamic way to set mesh cache size or view distance -//#define SHORTVIEW - - -stbvox_mesh_maker g_mesh_maker; - -GLuint main_prog; -GLint uniform_locations[64]; - -//#define MAX_QUADS_PER_DRAW (65536 / 4) // assuming 16-bit indices, 4 verts per quad -//#define FIXED_INDEX_BUFFER_SIZE (MAX_QUADS_PER_DRAW * 6 * 2) // 16*1024 * 12 == ~192KB - -// while uploading texture data, this holds our each texture -#define TEX_SIZE 64 -uint32 texture[TEX_SIZE][TEX_SIZE]; - -GLuint voxel_tex[2]; - -// chunk state -enum -{ - STATE_invalid, - STATE_needed, - STATE_requested, - STATE_abandoned, - STATE_valid, -}; - -// mesh is 32x32x255 ... this is hardcoded in that -// a mesh covers 2x2 minecraft chunks, no #defines for it -typedef struct -{ - int state; - int chunk_x, chunk_y; - int num_quads; - float priority; - int vbuf_size, fbuf_size; - - float transform[3][3]; - float bounds[2][3]; - - GLuint vbuf;// vbuf_tex; - GLuint fbuf, fbuf_tex; - -} chunk_mesh; - -void scale_texture(unsigned char *src, int x, int y, int w, int h) -{ - int i,j,k; - assert(w == 256 && h == 256); - for (j=0; j < TEX_SIZE; ++j) { - for (i=0; i < TEX_SIZE; ++i) { - uint32 val=0; - for (k=0; k < 4; ++k) { - val >>= 8; - val += src[ 4*(x+(i>>2)) + 4*w*(y+(j>>2)) + k]<<24; - } - texture[j][i] = val; - } - } -} - -void build_base_texture(int n) -{ - int x,y; - uint32 color = stb_rand() | 0x808080; - for (y=0; ystate == STATE_valid) { - glDeleteTextures(1, &cm->fbuf_tex); - glDeleteBuffersARB(1, &cm->vbuf); - glDeleteBuffersARB(1, &cm->fbuf); - cached_chunk_mesh[slot_y][slot_x].state = STATE_invalid; - } -} - -void upload_mesh(chunk_mesh *cm, uint8 *build_buffer, uint8 *face_buffer) -{ - glGenBuffersARB(1, &cm->vbuf); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, cm->vbuf); - glBufferDataARB(GL_ARRAY_BUFFER_ARB, cm->num_quads*4*sizeof(uint32), build_buffer, GL_STATIC_DRAW_ARB); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); - - glGenBuffersARB(1, &cm->fbuf); - glBindBufferARB(GL_TEXTURE_BUFFER_ARB, cm->fbuf); - glBufferDataARB(GL_TEXTURE_BUFFER_ARB, cm->num_quads*sizeof(uint32), face_buffer , GL_STATIC_DRAW_ARB); - glBindBufferARB(GL_TEXTURE_BUFFER_ARB, 0); - - glGenTextures(1, &cm->fbuf_tex); - glBindTexture(GL_TEXTURE_BUFFER_ARB, cm->fbuf_tex); - glTexBufferARB(GL_TEXTURE_BUFFER_ARB, GL_RGBA8UI, cm->fbuf); - glBindTexture(GL_TEXTURE_BUFFER_ARB, 0); -} - -static void upload_mesh_data(raw_mesh *rm) -{ - int cx = rm->cx; - int cy = rm->cy; - int slot_x = (cx >> 1) & (CACHED_MESH_NUM_X-1); - int slot_y = (cy >> 1) & (CACHED_MESH_NUM_Y-1); - chunk_mesh *cm; - - free_chunk(slot_x, slot_y); - - cm = &cached_chunk_mesh[slot_y][slot_x]; - cm->num_quads = rm->num_quads; - - upload_mesh(cm, rm->build_buffer, rm->face_buffer); - cm->vbuf_size = rm->num_quads*4*sizeof(uint32); - cm->fbuf_size = rm->num_quads*sizeof(uint32); - cm->priority = 100000; - cm->chunk_x = cx; - cm->chunk_y = cy; - - memcpy(cm->bounds, rm->bounds, sizeof(cm->bounds)); - memcpy(cm->transform, rm->transform, sizeof(cm->transform)); - - // write barrier here - cm->state = STATE_valid; -} - -GLint uniform_loc[16]; -float table3[128][3]; -float table4[64][4]; -GLint tablei[2]; - -float step=0; - -#ifdef SHORTVIEW -int view_dist_in_chunks = 50; -#else -int view_dist_in_chunks = 80; -#endif - -void setup_uniforms(float pos[3]) -{ - int i,j; - step += 1.0f/60.0f; - for (i=0; i < STBVOX_UNIFORM_count; ++i) { - stbvox_uniform_info raw, *ui=&raw; - stbvox_get_uniform_info(&raw, i); - uniform_loc[i] = -1; - - if (i == STBVOX_UNIFORM_texscale || i == STBVOX_UNIFORM_texgen || i == STBVOX_UNIFORM_color_table) - continue; - - if (ui) { - void *data = ui->default_value; - uniform_loc[i] = stbgl_find_uniform(main_prog, ui->name); - switch (i) { - case STBVOX_UNIFORM_face_data: - tablei[0] = 2; - data = tablei; - break; - - case STBVOX_UNIFORM_tex_array: - glActiveTextureARB(GL_TEXTURE0_ARB); - glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, voxel_tex[0]); - glActiveTextureARB(GL_TEXTURE1_ARB); - glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, voxel_tex[1]); - glActiveTextureARB(GL_TEXTURE0_ARB); - tablei[0] = 0; - tablei[1] = 1; - data = tablei; - break; - - case STBVOX_UNIFORM_color_table: - data = ui->default_value; - ((float *)data)[63*4+3] = 2.0f; // emissive - break; - - case STBVOX_UNIFORM_camera_pos: - data = table3[0]; - table3[0][0] = pos[0]; - table3[0][1] = pos[1]; - table3[0][2] = pos[2]; - table3[0][3] = stb_max(0,(float)sin(step*2)*0.125f); - break; - - case STBVOX_UNIFORM_ambient: { - float bright = 1.0; - //float bright = 0.75; - float amb[3][3]; - - // ambient direction is sky-colored upwards - // "ambient" lighting is from above - table4[0][0] = 0.3f; - table4[0][1] = -0.5f; - table4[0][2] = 0.9f; - - amb[1][0] = 0.3f; amb[1][1] = 0.3f; amb[1][2] = 0.3f; // dark-grey - amb[2][0] = 1.0; amb[2][1] = 1.0; amb[2][2] = 1.0; // white - - // convert so (table[1]*dot+table[2]) gives - // above interpolation - // lerp((dot+1)/2, amb[1], amb[2]) - // amb[1] + (amb[2] - amb[1]) * (dot+1)/2 - // amb[1] + (amb[2] - amb[1]) * dot/2 + (amb[2]-amb[1])/2 - - for (j=0; j < 3; ++j) { - table4[1][j] = (amb[2][j] - amb[1][j])/2 * bright; - table4[2][j] = (amb[1][j] + amb[2][j])/2 * bright; - } - - // fog color - table4[3][0] = 0.6f, table4[3][1] = 0.7f, table4[3][2] = 0.9f; - table4[3][3] = 1.0f / (view_dist_in_chunks * 16); - table4[3][3] *= table4[3][3]; - - data = table4; - break; - } - } - - switch (ui->type) { - case STBVOX_UNIFORM_TYPE_sampler: stbglUniform1iv(uniform_loc[i], ui->array_length, data); break; - case STBVOX_UNIFORM_TYPE_vec2: stbglUniform2fv(uniform_loc[i], ui->array_length, data); break; - case STBVOX_UNIFORM_TYPE_vec3: stbglUniform3fv(uniform_loc[i], ui->array_length, data); break; - case STBVOX_UNIFORM_TYPE_vec4: stbglUniform4fv(uniform_loc[i], ui->array_length, data); break; - } - } - } -} - -GLuint unitex[64], unibuf[64]; -void make_texture_buffer_for_uniform(int uniform, int slot) -{ - GLenum type; - stbvox_uniform_info raw, *ui=&raw; - GLint uloc; - - stbvox_get_uniform_info(ui, uniform); - uloc = stbgl_find_uniform(main_prog, ui->name); - - if (uniform == STBVOX_UNIFORM_color_table) - ((float *)ui->default_value)[63*4+3] = 2.0f; // emissive - - glGenBuffersARB(1, &unibuf[uniform]); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, unibuf[uniform]); - glBufferDataARB(GL_ARRAY_BUFFER_ARB, ui->array_length * ui->bytes_per_element, ui->default_value, GL_STATIC_DRAW_ARB); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); - - glGenTextures(1, &unitex[uniform]); - glBindTexture(GL_TEXTURE_BUFFER_ARB, unitex[uniform]); - switch (ui->type) { - case STBVOX_UNIFORM_TYPE_vec2: type = GL_RG32F; break; - case STBVOX_UNIFORM_TYPE_vec3: type = GL_RGB32F; break; - case STBVOX_UNIFORM_TYPE_vec4: type = GL_RGBA32F; break; - default: assert(0); - } - glTexBufferARB(GL_TEXTURE_BUFFER_ARB, type, unibuf[uniform]); - glBindTexture(GL_TEXTURE_BUFFER_ARB, 0); - - glActiveTextureARB(GL_TEXTURE0 + slot); - glBindTexture(GL_TEXTURE_BUFFER_ARB, unitex[uniform]); - glActiveTextureARB(GL_TEXTURE0); - - stbglUseProgram(main_prog); - stbglUniform1i(uloc, slot); -} - -#define MAX_MESH_WORKERS 8 -#define MAX_CHUNK_LOAD_WORKERS 2 - -int num_mesh_workers; -int num_chunk_load_workers; - -typedef struct -{ - int state; - int request_cx; - int request_cy; - int padding[13]; - - SDL_sem * request_received; - - SDL_sem * chunk_server_done_processing; - int chunk_action; - int chunk_request_x; - int chunk_request_y; - fast_chunk *chunks[4][4]; - - int padding2[16]; - raw_mesh rm; - int padding3[16]; - - uint8 *build_buffer; - uint8 *face_buffer ; -} mesh_worker; - -enum -{ - WSTATE_idle, - WSTATE_requested, - WSTATE_running, - WSTATE_mesh_ready, -}; - -mesh_worker mesh_data[MAX_MESH_WORKERS]; -int num_meshes_started; // stats - -int request_chunk(int chunk_x, int chunk_y); -void update_meshes_from_render_thread(void); - -unsigned char tex2_data[64][4]; - -void init_tex2_gradient(void) -{ - int i; - for (i=0; i < 16; ++i) { - tex2_data[i+ 0][0] = 64 + 12*i; - tex2_data[i+ 0][1] = 32; - tex2_data[i+ 0][2] = 64; - - tex2_data[i+16][0] = 255; - tex2_data[i+16][1] = 32 + 8*i; - tex2_data[i+16][2] = 64; - - tex2_data[i+32][0] = 255; - tex2_data[i+32][1] = 160; - tex2_data[i+32][2] = 64 + 12*i; - - tex2_data[i+48][0] = 255; - tex2_data[i+48][1] = 160 + 6*i; - tex2_data[i+48][2] = 255; - } -} - -void set_tex2_alpha(float fa) -{ - int i; - int a = (int) stb_lerp(fa, 0, 255); - if (a < 0) a = 0; else if (a > 255) a = 255; - glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, voxel_tex[1]); - for (i=0; i < 64; ++i) { - tex2_data[i][3] = a; - glTexSubImage3DEXT(GL_TEXTURE_2D_ARRAY_EXT, 0, 0,0,i, 1,1,1, GL_RGBA, GL_UNSIGNED_BYTE, tex2_data[i]); - } -} - -void render_init(void) -{ - int i; - char *binds[] = { "attr_vertex", "attr_face", NULL }; - char *vertex; - char *fragment; - int w=0,h=0; - - unsigned char *texdata = stbi_load("terrain.png", &w, &h, NULL, 4); - - stbvox_init_mesh_maker(&g_mesh_maker); - for (i=0; i < num_mesh_workers; ++i) { - stbvox_init_mesh_maker(&mesh_data[i].rm.mm); - } - - vertex = stbvox_get_vertex_shader(); - fragment = stbvox_get_fragment_shader(); - - { - char error_buffer[1024]; - char *main_vertex[] = { vertex, NULL }; - char *main_fragment[] = { fragment, NULL }; - main_prog = stbgl_create_program(main_vertex, main_fragment, binds, error_buffer, sizeof(error_buffer)); - if (main_prog == 0) { - ods("Compile error for main shader: %s\n", error_buffer); - assert(0); - exit(1); - } - } - //init_index_buffer(); - - make_texture_buffer_for_uniform(STBVOX_UNIFORM_texscale , 3); - make_texture_buffer_for_uniform(STBVOX_UNIFORM_texgen , 4); - make_texture_buffer_for_uniform(STBVOX_UNIFORM_color_table , 5); - - glGenTextures(2, voxel_tex); - - glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, voxel_tex[0]); - glTexImage3DEXT(GL_TEXTURE_2D_ARRAY_EXT, 0, GL_RGBA, - TEX_SIZE,TEX_SIZE,256, - 0,GL_RGBA,GL_UNSIGNED_BYTE,NULL); - for (i=0; i < 256; ++i) { - if (texdata) - scale_texture(texdata, (i&15)*w/16, (h/16)*(i>>4), w,h); - else - build_base_texture(i); - glTexSubImage3DEXT(GL_TEXTURE_2D_ARRAY_EXT, 0, 0,0,i, TEX_SIZE,TEX_SIZE,1, GL_RGBA, GL_UNSIGNED_BYTE, texture[0]); - } - glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16); - #ifdef STBVOX_CONFIG_TEX1_EDGE_CLAMP - glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - #endif - - glGenerateMipmapEXT(GL_TEXTURE_2D_ARRAY_EXT); - - glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, voxel_tex[1]); - glTexImage3DEXT(GL_TEXTURE_2D_ARRAY_EXT, 0, GL_RGBA, - 1,1,64, - 0,GL_RGBA,GL_UNSIGNED_BYTE,NULL); - init_tex2_gradient(); - set_tex2_alpha(0.0); - #if 0 - for (i=0; i < 128; ++i) { - //build_overlay_texture(i); - glTexSubImage3DEXT(GL_TEXTURE_2D_ARRAY_EXT, 0, 0,0,i, TEX_SIZE,TEX_SIZE,1, GL_RGBA, GL_UNSIGNED_BYTE, texture[0]); - } - #endif - glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glGenerateMipmapEXT(GL_TEXTURE_2D_ARRAY_EXT); -} - -void world_init(void) -{ - int a,b,x,y; - - Uint64 start_time, end_time; - #ifdef NDEBUG - int range = 32; - #else - int range = 12; - #endif - - start_time = SDL_GetPerformanceCounter(); - - // iterate in 8x8 clusters of qchunks at a time to get better converted-chunk-cache reuse - // than a purely row-by-row ordering is (single-threaded this is a bigger win than - // any of the above optimizations were, since it halves zlib/mc-conversion costs) - for (x=-range; x <= range; x += 16) - for (y=-range; y <= range; y += 16) - for (b=y; b < y+16 && b <= range; b += 2) - for (a=x; a < x+16 && a <= range; a += 2) - while (!request_chunk(a, b)) { // if request fails, all threads are busy - update_meshes_from_render_thread(); - SDL_Delay(1); - } - - // wait until all the workers are done, - // (this is only needed if we want to time - // when the build finishes, or when we want to reset the - // cache size; otherwise we could just go ahead and - // start rendering whatever we've got) - for(;;) { - int i; - update_meshes_from_render_thread(); - for (i=0; i < num_mesh_workers; ++i) - if (mesh_data[i].state != WSTATE_idle) - break; - if (i == num_mesh_workers) - break; - SDL_Delay(3); - } - - end_time = SDL_GetPerformanceCounter(); - ods("Build time: %7.2fs\n", (end_time - start_time) / (float) SDL_GetPerformanceFrequency()); - - // don't waste lots of storage on chunk caches once it's finished starting-up; - // this was only needed to be this large because we worked in large blocks - // to maximize sharing - reset_cache_size(32); -} - -extern SDL_mutex * chunk_cache_mutex; - -int mesh_worker_handler(void *data) -{ - mesh_worker *mw = data; - mw->face_buffer = malloc(FACE_BUFFER_SIZE); - mw->build_buffer = malloc(BUILD_BUFFER_SIZE); - - // this loop only works because the compiler can't - // tell that the SDL_calls don't access mw->state; - // really we should barrier that stuff - for(;;) { - int i,j; - int cx,cy; - - // wait for a chunk request - SDL_SemWait(mw->request_received); - - // analyze the chunk request - assert(mw->state == WSTATE_requested); - cx = mw->request_cx; - cy = mw->request_cy; - - // this is inaccurate as it can block while another thread has the cache locked - mw->state = WSTATE_running; - - // get the chunks we need (this takes a lock and caches them) - for (j=0; j < 4; ++j) - for (i=0; i < 4; ++i) - mw->chunks[j][i] = get_converted_fastchunk(cx-1 + i, cy-1 + j); - - // build the mesh based on the chunks - mw->rm.build_buffer = mw->build_buffer; - mw->rm.face_buffer = mw->face_buffer; - build_chunk(cx, cy, mw->chunks, &mw->rm); - mw->state = WSTATE_mesh_ready; - // don't need to notify of this, because it gets polled - - // when done, free the chunks - - // for efficiency we just take the mutex once around the whole thing, - // though this spreads the mutex logic over two files - SDL_LockMutex(chunk_cache_mutex); - for (j=0; j < 4; ++j) - for (i=0; i < 4; ++i) { - deref_fastchunk(mw->chunks[j][i]); - mw->chunks[j][i] = NULL; - } - SDL_UnlockMutex(chunk_cache_mutex); - } - return 0; -} - -int request_chunk(int chunk_x, int chunk_y) -{ - int i; - for (i=0; i < num_mesh_workers; ++i) { - mesh_worker *mw = &mesh_data[i]; - if (mw->state == WSTATE_idle) { - mw->request_cx = chunk_x; - mw->request_cy = chunk_y; - mw->state = WSTATE_requested; - SDL_SemPost(mw->request_received); - ++num_meshes_started; - return 1; - } - } - return 0; -} - -void prepare_threads(void) -{ - int i; - int num_proc = SDL_GetCPUCount(); - - if (num_proc > 6) - num_mesh_workers = num_proc/2; - else if (num_proc > 4) - num_mesh_workers = 4; - else - num_mesh_workers = num_proc-1; - -// @TODO -// Thread usage is probably pretty terrible; need to make a -// separate queue of needed chunks, instead of just generating -// one request per thread per frame, and a separate queue of -// results. (E.g. If it takes 1.5 frames to build mesh, thread -// is idle for 0.5 frames.) To fake this for now, I've just -// doubled the number of threads to let those serve as a 'queue', -// but that's dumb. - - num_mesh_workers *= 2; // try to get better thread usage - - if (num_mesh_workers > MAX_MESH_WORKERS) - num_mesh_workers = MAX_MESH_WORKERS; - - for (i=0; i < num_mesh_workers; ++i) { - mesh_worker *data = &mesh_data[i]; - data->request_received = SDL_CreateSemaphore(0); - data->chunk_server_done_processing = SDL_CreateSemaphore(0); - SDL_CreateThread(mesh_worker_handler, "mesh worker", data); - } -} - - -// "better" buffer uploading -#if 0 - if (glBufferStorage) { - glDeleteBuffersARB(1, &vb->vbuf); - glGenBuffersARB(1, &vb->vbuf); - - glBindBufferARB(GL_ARRAY_BUFFER_ARB, vb->vbuf); - glBufferStorage(GL_ARRAY_BUFFER_ARB, sizeof(build_buffer), build_buffer, 0); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); - } else { - glBindBufferARB(GL_ARRAY_BUFFER_ARB, vb->vbuf); - glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(build_buffer), build_buffer, GL_STATIC_DRAW_ARB); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); - } -#endif - - -typedef struct -{ - float x,y,z,w; -} plane; - -static plane frustum[6]; - -static void matd_mul(double out[4][4], double src1[4][4], double src2[4][4]) -{ - int i,j,k; - for (j=0; j < 4; ++j) { - for (i=0; i < 4; ++i) { - double t=0; - for (k=0; k < 4; ++k) - t += src1[k][i] * src2[j][k]; - out[i][j] = t; - } - } -} - -// https://fgiesen.wordpress.com/2012/08/31/frustum-planes-from-the-projection-matrix/ -static void compute_frustum(void) -{ - int i; - GLdouble mv[4][4],proj[4][4], mvproj[4][4]; - glGetDoublev(GL_MODELVIEW_MATRIX , mv[0]); - glGetDoublev(GL_PROJECTION_MATRIX, proj[0]); - matd_mul(mvproj, proj, mv); - for (i=0; i < 4; ++i) { - (&frustum[0].x)[i] = (float) (mvproj[3][i] + mvproj[0][i]); - (&frustum[1].x)[i] = (float) (mvproj[3][i] - mvproj[0][i]); - (&frustum[2].x)[i] = (float) (mvproj[3][i] + mvproj[1][i]); - (&frustum[3].x)[i] = (float) (mvproj[3][i] - mvproj[1][i]); - (&frustum[4].x)[i] = (float) (mvproj[3][i] + mvproj[2][i]); - (&frustum[5].x)[i] = (float) (mvproj[3][i] - mvproj[2][i]); - } -} - -static int test_plane(plane *p, float x0, float y0, float z0, float x1, float y1, float z1) -{ - // return false if the box is entirely behind the plane - float d=0; - assert(x0 <= x1 && y0 <= y1 && z0 <= z1); - if (p->x > 0) d += x1*p->x; else d += x0*p->x; - if (p->y > 0) d += y1*p->y; else d += y0*p->y; - if (p->z > 0) d += z1*p->z; else d += z0*p->z; - return d + p->w >= 0; -} - -static int is_box_in_frustum(float *bmin, float *bmax) -{ - int i; - for (i=0; i < 6; ++i) - if (!test_plane(&frustum[i], bmin[0], bmin[1], bmin[2], bmax[0], bmax[1], bmax[2])) - return 0; - return 1; -} - -float compute_priority(int cx, int cy, float x, float y) -{ - float distx, disty, dist2; - distx = (cx*16+8) - x; - disty = (cy*16+8) - y; - dist2 = distx*distx + disty*disty; - return view_dist_in_chunks*view_dist_in_chunks * 16 * 16 - dist2; -} - -int chunk_locations, chunks_considered, chunks_in_frustum; -int quads_considered, quads_rendered; -int chunk_storage_rendered, chunk_storage_considered, chunk_storage_total; -int update_frustum = 1; - -#ifdef SHORTVIEW -int max_chunk_storage = 450 << 20; -int min_chunk_storage = 350 << 20; -#else -int max_chunk_storage = 900 << 20; -int min_chunk_storage = 800 << 20; -#endif - -float min_priority = -500; // this really wants to be in unit space, not squared space - -int num_meshes_uploaded; - -void update_meshes_from_render_thread(void) -{ - int i; - for (i=0; i < num_mesh_workers; ++i) { - mesh_worker *mw = &mesh_data[i]; - if (mw->state == WSTATE_mesh_ready) { - upload_mesh_data(&mw->rm); - ++num_meshes_uploaded; - mw->state = WSTATE_idle; - } - } -} - -extern float tex2_alpha; -extern int global_hack; -int num_threads_active; -float chunk_server_activity; - -void render_caves(float campos[3]) -{ - float x = campos[0], y = campos[1]; - int qchunk_x, qchunk_y; - int cam_x, cam_y; - int i,j, rad; - - compute_frustum(); - - chunk_locations = chunks_considered = chunks_in_frustum = 0; - quads_considered = quads_rendered = 0; - chunk_storage_total = chunk_storage_considered = chunk_storage_rendered = 0; - - cam_x = (int) floor(x+0.5); - cam_y = (int) floor(y+0.5); - - qchunk_x = (((int) floor(x)+16) >> 5) << 1; - qchunk_y = (((int) floor(y)+16) >> 5) << 1; - - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, 0.5); - - stbglUseProgram(main_prog); - setup_uniforms(campos); // set uniforms to default values inefficiently - glActiveTextureARB(GL_TEXTURE2_ARB); - stbglEnableVertexAttribArray(0); - - { - float lighting[2][3] = { { campos[0],campos[1],campos[2] }, { 0.75,0.75,0.65f } }; - float bright = 8; - lighting[1][0] *= bright; - lighting[1][1] *= bright; - lighting[1][2] *= bright; - stbglUniform3fv(stbgl_find_uniform(main_prog, "light_source"), 2, lighting[0]); - } - - if (global_hack) - set_tex2_alpha(tex2_alpha); - - num_meshes_uploaded = 0; - update_meshes_from_render_thread(); - - // traverse all in-range chunks and analyze them - for (j=-view_dist_in_chunks; j <= view_dist_in_chunks; j += 2) { - for (i=-view_dist_in_chunks; i <= view_dist_in_chunks; i += 2) { - float priority; - int cx = qchunk_x + i; - int cy = qchunk_y + j; - - priority = compute_priority(cx, cy, x, y); - if (priority >= min_priority) { - int slot_x = (cx>>1) & (CACHED_MESH_NUM_X-1); - int slot_y = (cy>>1) & (CACHED_MESH_NUM_Y-1); - chunk_mesh *cm = &cached_chunk_mesh[slot_y][slot_x]; - ++chunk_locations; - if (cm->state == STATE_valid && priority >= 0) { - // check if chunk pos actually matches - if (cm->chunk_x != cx || cm->chunk_y != cy) { - // we have a stale chunk we need to recreate - free_chunk(slot_x, slot_y); // it probably will have already gotten freed, but just in case - } - } - if (cm->state == STATE_invalid) { - cm->chunk_x = cx; - cm->chunk_y = cy; - cm->state = STATE_needed; - } - cm->priority = priority; - } - } - } - - // draw front-to-back - for (rad = 0; rad <= view_dist_in_chunks; rad += 2) { - for (j=-rad; j <= rad; j += 2) { - // if j is +- rad, then iterate i through all values - // if j isn't +-rad, then i should be only -rad & rad - int step = 2; - if (abs(j) != rad) - step = 2*rad; - for (i=-rad; i <= rad; i += step) { - int cx = qchunk_x + i; - int cy = qchunk_y + j; - int slot_x = (cx>>1) & (CACHED_MESH_NUM_X-1); - int slot_y = (cy>>1) & (CACHED_MESH_NUM_Y-1); - chunk_mesh *cm = &cached_chunk_mesh[slot_y][slot_x]; - if (cm->state == STATE_valid && cm->priority >= 0) { - ++chunks_considered; - quads_considered += cm->num_quads; - if (is_box_in_frustum(cm->bounds[0], cm->bounds[1])) { - ++chunks_in_frustum; - - // @TODO if in range - stbglUniform3fv(uniform_loc[STBVOX_UNIFORM_transform], 3, cm->transform[0]); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, cm->vbuf); - glVertexAttribIPointer(0, 1, GL_UNSIGNED_INT, 4, (void*) 0); - glBindTexture(GL_TEXTURE_BUFFER_ARB, cm->fbuf_tex); - glDrawArrays(GL_QUADS, 0, cm->num_quads*4); - quads_rendered += cm->num_quads; - - chunk_storage_rendered += cm->vbuf_size + cm->fbuf_size; - } - chunk_storage_considered += cm->vbuf_size + cm->fbuf_size; - } - } - } - } - - stbglDisableVertexAttribArray(0); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); - glActiveTextureARB(GL_TEXTURE0_ARB); - - stbglUseProgram(0); - num_meshes_started = 0; - - { - #define MAX_QUEUE 8 - float highest_priority[MAX_QUEUE]; - int highest_i[MAX_QUEUE], highest_j[MAX_QUEUE]; - float lowest_priority = view_dist_in_chunks * view_dist_in_chunks * 16 * 16.0f; - int lowest_i = -1, lowest_j = -1; - - for (i=0; i < MAX_QUEUE; ++i) { - highest_priority[i] = min_priority; - highest_i[i] = -1; - highest_j[i] = -1; - } - - for (j=0; j < CACHED_MESH_NUM_Y; ++j) { - for (i=0; i < CACHED_MESH_NUM_X; ++i) { - chunk_mesh *cm = &cached_chunk_mesh[j][i]; - if (cm->state == STATE_valid) { - cm->priority = compute_priority(cm->chunk_x, cm->chunk_y, x, y); - chunk_storage_total += cm->vbuf_size + cm->fbuf_size; - if (cm->priority < lowest_priority) { - lowest_priority = cm->priority; - lowest_i = i; - lowest_j = j; - } - } - if (cm->state == STATE_needed) { - cm->priority = compute_priority(cm->chunk_x, cm->chunk_y, x, y); - if (cm->priority < min_priority) - cm->state = STATE_invalid; - else if (cm->priority > highest_priority[0]) { - int k; - highest_priority[0] = cm->priority; - highest_i[0] = i; - highest_j[0] = j; - // bubble this up to right place - for (k=0; k < MAX_QUEUE-1; ++k) { - if (highest_priority[k] > highest_priority[k+1]) { - highest_priority[k] = highest_priority[k+1]; - highest_priority[k+1] = cm->priority; - highest_i[k] = highest_i[k+1]; - highest_i[k+1] = i; - highest_j[k] = highest_j[k+1]; - highest_j[k+1] = j; - } else { - break; - } - } - } - } - } - } - - - // I couldn't find any straightforward logic that avoids - // the hysteresis problem of continually creating & freeing - // a block on the margin, so I just don't free a block until - // it's out of range, but this doesn't actually correctly - // handle when the cache is too small for the given range - if (chunk_storage_total >= min_chunk_storage && lowest_i >= 0) { - if (cached_chunk_mesh[lowest_j][lowest_i].priority < -1200) // -1000? 0? - free_chunk(lowest_i, lowest_j); - } - - if (chunk_storage_total < max_chunk_storage && highest_i[0] >= 0) { - for (j=MAX_QUEUE-1; j >= 0; --j) { - if (highest_j[0] >= 0) { - chunk_mesh *cm = &cached_chunk_mesh[highest_j[j]][highest_i[j]]; - if (request_chunk(cm->chunk_x, cm->chunk_y)) { - cm->state = STATE_requested; - } else { - // if we couldn't queue this one, skip the remainder - break; - } - } - } - } - } - - update_meshes_from_render_thread(); - - num_threads_active = 0; - for (i=0; i < num_mesh_workers; ++i) { - num_threads_active += (mesh_data[i].state == WSTATE_running); - } -} diff --git a/third_party/stb/tests/caveview/caveview.dsp b/third_party/stb/tests/caveview/caveview.dsp deleted file mode 100644 index 2a462d3f87..0000000000 --- a/third_party/stb/tests/caveview/caveview.dsp +++ /dev/null @@ -1,157 +0,0 @@ -# Microsoft Developer Studio Project File - Name="caveview" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Application" 0x0101 - -CFG=caveview - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "caveview.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "caveview.mak" CFG="caveview - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "caveview - Win32 Release" (based on "Win32 (x86) Application") -!MESSAGE "caveview - Win32 Debug" (based on "Win32 (x86) Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "caveview - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /WX /GX /Zd /O2 /I "../.." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sdl2.lib opengl32.lib glu32.lib winmm.lib sdl2_mixer.lib advapi32.lib /nologo /subsystem:windows /debug /machine:I386 -# SUBTRACT LINK32 /map - -!ELSEIF "$(CFG)" == "caveview - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /WX /Gm /GX /Zi /Od /I "../.." /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib winspool.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sdl2.lib opengl32.lib glu32.lib winmm.lib sdl2_mixer.lib /nologo /subsystem:windows /incremental:no /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "caveview - Win32 Release" -# Name "caveview - Win32 Debug" -# Begin Source File - -SOURCE=.\cave_main.c -# End Source File -# Begin Source File - -SOURCE=.\cave_mesher.c -# End Source File -# Begin Source File - -SOURCE=.\cave_parse.c -# End Source File -# Begin Source File - -SOURCE=.\cave_parse.h -# End Source File -# Begin Source File - -SOURCE=.\cave_render.c -# End Source File -# Begin Source File - -SOURCE=.\caveview.h -# End Source File -# Begin Source File - -SOURCE=.\glext.h -# End Source File -# Begin Source File - -SOURCE=.\glext_list.h -# End Source File -# Begin Source File - -SOURCE=.\README.md -# End Source File -# Begin Source File - -SOURCE=.\win32\SDL_windows_main.c -# End Source File -# Begin Source File - -SOURCE=..\..\stb.h -# End Source File -# Begin Source File - -SOURCE=..\..\stb_easy_font.h -# End Source File -# Begin Source File - -SOURCE=.\stb_gl.h -# End Source File -# Begin Source File - -SOURCE=.\stb_glprog.h -# End Source File -# Begin Source File - -SOURCE=..\..\stb_image.h -# End Source File -# Begin Source File - -SOURCE=..\..\stb_voxel_render.h -# End Source File -# End Target -# End Project diff --git a/third_party/stb/tests/caveview/caveview.dsw b/third_party/stb/tests/caveview/caveview.dsw deleted file mode 100644 index ddc9387e05..0000000000 --- a/third_party/stb/tests/caveview/caveview.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "caveview"=.\caveview.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/third_party/stb/tests/caveview/caveview.h b/third_party/stb/tests/caveview/caveview.h deleted file mode 100644 index 73a71da0d3..0000000000 --- a/third_party/stb/tests/caveview/caveview.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef INCLUDE_CAVEVIEW_H -#define INCLUDE_CAVEVIEW_H - -#include "stb.h" - -#include "stb_voxel_render.h" - -typedef struct -{ - int cx,cy; - - stbvox_mesh_maker mm; - - uint8 *build_buffer; - uint8 *face_buffer; - - int num_quads; - float transform[3][3]; - float bounds[2][3]; - - uint8 sv_blocktype[34][34][18]; - uint8 sv_lighting [34][34][18]; -} raw_mesh; - -// a 3D checkerboard of empty,solid would be: 32x32x255x6/2 ~= 800000 -// an all-leaf qchunk would be: 32 x 32 x 255 x 6 ~= 1,600,000 - -#define BUILD_QUAD_MAX 400000 -#define BUILD_BUFFER_SIZE (4*4*BUILD_QUAD_MAX) // 4 bytes per vertex, 4 vertices per quad -#define FACE_BUFFER_SIZE ( 4*BUILD_QUAD_MAX) // 4 bytes per quad - - -extern void mesh_init(void); -extern void render_init(void); -extern void world_init(void); -extern void ods(char *fmt, ...); // output debug string -extern void reset_cache_size(int size); - - -extern void render_caves(float pos[3]); - - -#include "cave_parse.h" // fast_chunk - -extern fast_chunk *get_converted_fastchunk(int chunk_x, int chunk_y); -extern void build_chunk(int chunk_x, int chunk_y, fast_chunk *fc_table[4][4], raw_mesh *rm); -extern void reset_cache_size(int size); -extern void deref_fastchunk(fast_chunk *fc); - -#endif \ No newline at end of file diff --git a/third_party/stb/tests/caveview/glext.h b/third_party/stb/tests/caveview/glext.h deleted file mode 100644 index c6a233ad17..0000000000 --- a/third_party/stb/tests/caveview/glext.h +++ /dev/null @@ -1,11124 +0,0 @@ -#ifndef __glext_h_ -#define __glext_h_ 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2013 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ -/* -** This header is generated from the Khronos OpenGL / OpenGL ES XML -** API Registry. The current version of the Registry, generator scripts -** used to make the header, and the header can be found at -** http://www.opengl.org/registry/ -** -** Khronos $Revision: 24756 $ on $Date: 2014-01-14 03:42:29 -0800 (Tue, 14 Jan 2014) $ -*/ - -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN 1 -#endif -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -#define GL_GLEXT_VERSION 20140114 - -/* Generated C header for: - * API: gl - * Profile: compatibility - * Versions considered: .* - * Versions emitted: 1\.[2-9]|[234]\.[0-9] - * Default extensions included: gl - * Additional extensions included: _nomatch_^ - * Extensions removed: _nomatch_^ - */ - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#define GL_RESCALE_NORMAL 0x803A -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); -GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif -#endif /* GL_VERSION_1_2 */ - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define GL_COMPRESSED_RGB 0x84ED -#define GL_COMPRESSED_RGBA 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 -#define GL_TEXTURE_COMPRESSED 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_CLAMP_TO_BORDER 0x812D -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 -#define GL_MULTISAMPLE_BIT 0x20000000 -#define GL_NORMAL_MAP 0x8511 -#define GL_REFLECTION_MAP 0x8512 -#define GL_COMPRESSED_ALPHA 0x84E9 -#define GL_COMPRESSED_LUMINANCE 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB -#define GL_COMPRESSED_INTENSITY 0x84EC -#define GL_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_SOURCE0_RGB 0x8580 -#define GL_SOURCE1_RGB 0x8581 -#define GL_SOURCE2_RGB 0x8582 -#define GL_SOURCE0_ALPHA 0x8588 -#define GL_SOURCE1_ALPHA 0x8589 -#define GL_SOURCE2_ALPHA 0x858A -#define GL_OPERAND0_RGB 0x8590 -#define GL_OPERAND1_RGB 0x8591 -#define GL_OPERAND2_RGB 0x8592 -#define GL_OPERAND0_ALPHA 0x8598 -#define GL_OPERAND1_ALPHA 0x8599 -#define GL_OPERAND2_ALPHA 0x859A -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_SUBTRACT 0x84E7 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -#define GL_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTexture (GLenum texture); -GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); -GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, void *img); -GLAPI void APIENTRY glClientActiveTexture (GLenum texture); -GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); -GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); -GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); -GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); -GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); -GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); -GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); -GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); -GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); -GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); -GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); -GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); -GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); -GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); -GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); -GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); -GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); -#endif -#endif /* GL_VERSION_1_3 */ - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_GENERATE_MIPMAP 0x8191 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_FOG_COORDINATE_SOURCE 0x8450 -#define GL_FOG_COORDINATE 0x8451 -#define GL_FRAGMENT_DEPTH 0x8452 -#define GL_CURRENT_FOG_COORDINATE 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 -#define GL_FOG_COORDINATE_ARRAY 0x8457 -#define GL_COLOR_SUM 0x8458 -#define GL_CURRENT_SECONDARY_COLOR 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D -#define GL_SECONDARY_COLOR_ARRAY 0x845E -#define GL_TEXTURE_FILTER_CONTROL 0x8500 -#define GL_DEPTH_TEXTURE_MODE 0x884B -#define GL_COMPARE_R_TO_TEXTURE 0x884E -#define GL_FUNC_ADD 0x8006 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); -GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); -GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); -GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); -GLAPI void APIENTRY glFogCoordf (GLfloat coord); -GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); -GLAPI void APIENTRY glFogCoordd (GLdouble coord); -GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); -GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); -GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); -GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); -GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); -GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); -GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); -GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); -GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); -GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); -GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); -GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); -GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); -GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); -GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); -GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); -GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); -GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2iv (const GLint *v); -GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); -GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3iv (const GLint *v); -GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); -GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -GLAPI void APIENTRY glBlendEquation (GLenum mode); -#endif -#endif /* GL_VERSION_1_4 */ - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 -#include -typedef ptrdiff_t GLsizeiptr; -typedef ptrdiff_t GLintptr; -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_QUERY_COUNTER_BITS 0x8864 -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#define GL_BUFFER_ACCESS 0x88BB -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_SAMPLES_PASSED 0x8914 -#define GL_SRC1_ALPHA 0x8589 -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E -#define GL_FOG_COORD_SRC 0x8450 -#define GL_FOG_COORD 0x8451 -#define GL_CURRENT_FOG_COORD 0x8453 -#define GL_FOG_COORD_ARRAY_TYPE 0x8454 -#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORD_ARRAY_POINTER 0x8456 -#define GL_FOG_COORD_ARRAY 0x8457 -#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D -#define GL_SRC0_RGB 0x8580 -#define GL_SRC1_RGB 0x8581 -#define GL_SRC2_RGB 0x8582 -#define GL_SRC0_ALPHA 0x8588 -#define GL_SRC2_ALPHA 0x858A -typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void *data); -typedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsQuery (GLuint id); -GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); -GLAPI void APIENTRY glEndQuery (GLenum target); -GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); -GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); -GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); -GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); -GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); -GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); -GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); -GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, void *data); -GLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access); -GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); -GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); -#endif -#endif /* GL_VERSION_1_5 */ - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -typedef char GLchar; -#define GL_BLEND_EQUATION_RGB 0x8009 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_MAX_VARYING_FLOATS 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_SHADER_TYPE 0x8B4F -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_1D 0x8B5D -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_CUBE 0x8B60 -#define GL_SAMPLER_1D_SHADOW 0x8B61 -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_DELETE_STATUS 0x8B80 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 -#define GL_LOWER_LEFT 0x8CA1 -#define GL_UPPER_LEFT 0x8CA2 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 -#define GL_POINT_SPRITE 0x8861 -#define GL_COORD_REPLACE 0x8862 -#define GL_MAX_TEXTURE_COORDS 0x8871 -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); -GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); -GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); -GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); -GLAPI void APIENTRY glCompileShader (GLuint shader); -GLAPI GLuint APIENTRY glCreateProgram (void); -GLAPI GLuint APIENTRY glCreateShader (GLenum type); -GLAPI void APIENTRY glDeleteProgram (GLuint program); -GLAPI void APIENTRY glDeleteShader (GLuint shader); -GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); -GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); -GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); -GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); -GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); -GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); -GLAPI GLboolean APIENTRY glIsProgram (GLuint program); -GLAPI GLboolean APIENTRY glIsShader (GLuint shader); -GLAPI void APIENTRY glLinkProgram (GLuint program); -GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); -GLAPI void APIENTRY glUseProgram (GLuint program); -GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); -GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); -GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glValidateProgram (GLuint program); -GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); -#endif -#endif /* GL_VERSION_2_0 */ - -#ifndef GL_VERSION_2_1 -#define GL_VERSION_2_1 1 -#define GL_PIXEL_PACK_BUFFER 0x88EB -#define GL_PIXEL_UNPACK_BUFFER 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF -#define GL_FLOAT_MAT2x3 0x8B65 -#define GL_FLOAT_MAT2x4 0x8B66 -#define GL_FLOAT_MAT3x2 0x8B67 -#define GL_FLOAT_MAT3x4 0x8B68 -#define GL_FLOAT_MAT4x2 0x8B69 -#define GL_FLOAT_MAT4x3 0x8B6A -#define GL_SRGB 0x8C40 -#define GL_SRGB8 0x8C41 -#define GL_SRGB_ALPHA 0x8C42 -#define GL_SRGB8_ALPHA8 0x8C43 -#define GL_COMPRESSED_SRGB 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 -#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F -#define GL_SLUMINANCE_ALPHA 0x8C44 -#define GL_SLUMINANCE8_ALPHA8 0x8C45 -#define GL_SLUMINANCE 0x8C46 -#define GL_SLUMINANCE8 0x8C47 -#define GL_COMPRESSED_SLUMINANCE 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif -#endif /* GL_VERSION_2_1 */ - -#ifndef GL_VERSION_3_0 -#define GL_VERSION_3_0 1 -typedef unsigned short GLhalf; -#define GL_COMPARE_REF_TO_TEXTURE 0x884E -#define GL_CLIP_DISTANCE0 0x3000 -#define GL_CLIP_DISTANCE1 0x3001 -#define GL_CLIP_DISTANCE2 0x3002 -#define GL_CLIP_DISTANCE3 0x3003 -#define GL_CLIP_DISTANCE4 0x3004 -#define GL_CLIP_DISTANCE5 0x3005 -#define GL_CLIP_DISTANCE6 0x3006 -#define GL_CLIP_DISTANCE7 0x3007 -#define GL_MAX_CLIP_DISTANCES 0x0D32 -#define GL_MAJOR_VERSION 0x821B -#define GL_MINOR_VERSION 0x821C -#define GL_NUM_EXTENSIONS 0x821D -#define GL_CONTEXT_FLAGS 0x821E -#define GL_COMPRESSED_RED 0x8225 -#define GL_COMPRESSED_RG 0x8226 -#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 -#define GL_RGBA32F 0x8814 -#define GL_RGB32F 0x8815 -#define GL_RGBA16F 0x881A -#define GL_RGB16F 0x881B -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD -#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF -#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 -#define GL_CLAMP_READ_COLOR 0x891C -#define GL_FIXED_ONLY 0x891D -#define GL_MAX_VARYING_COMPONENTS 0x8B4B -#define GL_TEXTURE_1D_ARRAY 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 -#define GL_TEXTURE_2D_ARRAY 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D -#define GL_R11F_G11F_B10F 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B -#define GL_RGB9_E5 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E -#define GL_TEXTURE_SHARED_SIZE 0x8C3F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 -#define GL_PRIMITIVES_GENERATED 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 -#define GL_RASTERIZER_DISCARD 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B -#define GL_INTERLEAVED_ATTRIBS 0x8C8C -#define GL_SEPARATE_ATTRIBS 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F -#define GL_RGBA32UI 0x8D70 -#define GL_RGB32UI 0x8D71 -#define GL_RGBA16UI 0x8D76 -#define GL_RGB16UI 0x8D77 -#define GL_RGBA8UI 0x8D7C -#define GL_RGB8UI 0x8D7D -#define GL_RGBA32I 0x8D82 -#define GL_RGB32I 0x8D83 -#define GL_RGBA16I 0x8D88 -#define GL_RGB16I 0x8D89 -#define GL_RGBA8I 0x8D8E -#define GL_RGB8I 0x8D8F -#define GL_RED_INTEGER 0x8D94 -#define GL_GREEN_INTEGER 0x8D95 -#define GL_BLUE_INTEGER 0x8D96 -#define GL_RGB_INTEGER 0x8D98 -#define GL_RGBA_INTEGER 0x8D99 -#define GL_BGR_INTEGER 0x8D9A -#define GL_BGRA_INTEGER 0x8D9B -#define GL_SAMPLER_1D_ARRAY 0x8DC0 -#define GL_SAMPLER_2D_ARRAY 0x8DC1 -#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 -#define GL_UNSIGNED_INT_VEC2 0x8DC6 -#define GL_UNSIGNED_INT_VEC3 0x8DC7 -#define GL_UNSIGNED_INT_VEC4 0x8DC8 -#define GL_INT_SAMPLER_1D 0x8DC9 -#define GL_INT_SAMPLER_2D 0x8DCA -#define GL_INT_SAMPLER_3D 0x8DCB -#define GL_INT_SAMPLER_CUBE 0x8DCC -#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF -#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 -#define GL_QUERY_WAIT 0x8E13 -#define GL_QUERY_NO_WAIT 0x8E14 -#define GL_QUERY_BY_REGION_WAIT 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 -#define GL_BUFFER_ACCESS_FLAGS 0x911F -#define GL_BUFFER_MAP_LENGTH 0x9120 -#define GL_BUFFER_MAP_OFFSET 0x9121 -#define GL_DEPTH_COMPONENT32F 0x8CAC -#define GL_DEPTH32F_STENCIL8 0x8CAD -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 -#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 -#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 -#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 -#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 -#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 -#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 -#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 -#define GL_FRAMEBUFFER_DEFAULT 0x8218 -#define GL_FRAMEBUFFER_UNDEFINED 0x8219 -#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define GL_DEPTH_STENCIL 0x84F9 -#define GL_UNSIGNED_INT_24_8 0x84FA -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE 0x88F1 -#define GL_TEXTURE_RED_TYPE 0x8C10 -#define GL_TEXTURE_GREEN_TYPE 0x8C11 -#define GL_TEXTURE_BLUE_TYPE 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE 0x8C13 -#define GL_TEXTURE_DEPTH_TYPE 0x8C16 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_READ_FRAMEBUFFER 0x8CA8 -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA -#define GL_RENDERBUFFER_SAMPLES 0x8CAB -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_COLOR_ATTACHMENT1 0x8CE1 -#define GL_COLOR_ATTACHMENT2 0x8CE2 -#define GL_COLOR_ATTACHMENT3 0x8CE3 -#define GL_COLOR_ATTACHMENT4 0x8CE4 -#define GL_COLOR_ATTACHMENT5 0x8CE5 -#define GL_COLOR_ATTACHMENT6 0x8CE6 -#define GL_COLOR_ATTACHMENT7 0x8CE7 -#define GL_COLOR_ATTACHMENT8 0x8CE8 -#define GL_COLOR_ATTACHMENT9 0x8CE9 -#define GL_COLOR_ATTACHMENT10 0x8CEA -#define GL_COLOR_ATTACHMENT11 0x8CEB -#define GL_COLOR_ATTACHMENT12 0x8CEC -#define GL_COLOR_ATTACHMENT13 0x8CED -#define GL_COLOR_ATTACHMENT14 0x8CEE -#define GL_COLOR_ATTACHMENT15 0x8CEF -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_STENCIL_INDEX1 0x8D46 -#define GL_STENCIL_INDEX4 0x8D47 -#define GL_STENCIL_INDEX8 0x8D48 -#define GL_STENCIL_INDEX16 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define GL_MAX_SAMPLES 0x8D57 -#define GL_INDEX 0x8222 -#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 -#define GL_FRAMEBUFFER_SRGB 0x8DB9 -#define GL_HALF_FLOAT 0x140B -#define GL_MAP_READ_BIT 0x0001 -#define GL_MAP_WRITE_BIT 0x0002 -#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 -#define GL_COMPRESSED_RED_RGTC1 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC -#define GL_COMPRESSED_RG_RGTC2 0x8DBD -#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE -#define GL_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_R16 0x822A -#define GL_RG8 0x822B -#define GL_RG16 0x822C -#define GL_R16F 0x822D -#define GL_R32F 0x822E -#define GL_RG16F 0x822F -#define GL_RG32F 0x8230 -#define GL_R8I 0x8231 -#define GL_R8UI 0x8232 -#define GL_R16I 0x8233 -#define GL_R16UI 0x8234 -#define GL_R32I 0x8235 -#define GL_R32UI 0x8236 -#define GL_RG8I 0x8237 -#define GL_RG8UI 0x8238 -#define GL_RG16I 0x8239 -#define GL_RG16UI 0x823A -#define GL_RG32I 0x823B -#define GL_RG32UI 0x823C -#define GL_VERTEX_ARRAY_BINDING 0x85B5 -#define GL_CLAMP_VERTEX_COLOR 0x891A -#define GL_CLAMP_FRAGMENT_COLOR 0x891B -#define GL_ALPHA_INTEGER 0x8D97 -typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); -GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); -GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); -GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); -GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); -GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedback (void); -GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); -GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); -GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); -GLAPI void APIENTRY glEndConditionalRender (void); -GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); -GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); -GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); -GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); -GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); -GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); -GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); -GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); -GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); -GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); -GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); -GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); -GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); -GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); -GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); -GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); -GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); -GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); -GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); -GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); -GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateMipmap (GLenum target); -GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); -GLAPI void APIENTRY glBindVertexArray (GLuint array); -GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); -GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); -GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); -#endif -#endif /* GL_VERSION_3_0 */ - -#ifndef GL_VERSION_3_1 -#define GL_VERSION_3_1 1 -#define GL_SAMPLER_2D_RECT 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 -#define GL_SAMPLER_BUFFER 0x8DC2 -#define GL_INT_SAMPLER_2D_RECT 0x8DCD -#define GL_INT_SAMPLER_BUFFER 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 -#define GL_TEXTURE_BUFFER 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D -#define GL_TEXTURE_RECTANGLE 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 -#define GL_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGB8_SNORM 0x8F96 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_R16_SNORM 0x8F98 -#define GL_RG16_SNORM 0x8F99 -#define GL_RGB16_SNORM 0x8F9A -#define GL_RGBA16_SNORM 0x8F9B -#define GL_SIGNED_NORMALIZED 0x8F9C -#define GL_PRIMITIVE_RESTART 0x8F9D -#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E -#define GL_COPY_READ_BUFFER 0x8F36 -#define GL_COPY_WRITE_BUFFER 0x8F37 -#define GL_UNIFORM_BUFFER 0x8A11 -#define GL_UNIFORM_BUFFER_BINDING 0x8A28 -#define GL_UNIFORM_BUFFER_START 0x8A29 -#define GL_UNIFORM_BUFFER_SIZE 0x8A2A -#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B -#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D -#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E -#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F -#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 -#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 -#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 -#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 -#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 -#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 -#define GL_UNIFORM_TYPE 0x8A37 -#define GL_UNIFORM_SIZE 0x8A38 -#define GL_UNIFORM_NAME_LENGTH 0x8A39 -#define GL_UNIFORM_BLOCK_INDEX 0x8A3A -#define GL_UNIFORM_OFFSET 0x8A3B -#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C -#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D -#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E -#define GL_UNIFORM_BLOCK_BINDING 0x8A3F -#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 -#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 -#define GL_INVALID_INDEX 0xFFFFFFFFu -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); -typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); -typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); -GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); -GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); -GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); -GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); -GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#endif -#endif /* GL_VERSION_3_1 */ - -#ifndef GL_VERSION_3_2 -#define GL_VERSION_3_2 1 -typedef struct __GLsync *GLsync; -#ifndef GLEXT_64_TYPES_DEFINED -/* This code block is duplicated in glxext.h, so must be protected */ -#define GLEXT_64_TYPES_DEFINED -/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ -/* (as used in the GL_EXT_timer_query extension). */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#include -#elif defined(__sun__) || defined(__digital__) -#include -#if defined(__STDC__) -#if defined(__arch64__) || defined(_LP64) -typedef long int int64_t; -typedef unsigned long int uint64_t; -#else -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#endif /* __arch64__ */ -#endif /* __STDC__ */ -#elif defined( __VMS ) || defined(__sgi) -#include -#elif defined(__SCO__) || defined(__USLC__) -#include -#elif defined(__UNIXOS2__) || defined(__SOL64__) -typedef long int int32_t; -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#elif defined(_WIN32) && defined(__GNUC__) -#include -#elif defined(_WIN32) -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#else -/* Fallback if nothing above works */ -#include -#endif -#endif -typedef uint64_t GLuint64; -typedef int64_t GLint64; -#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 -#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 -#define GL_LINES_ADJACENCY 0x000A -#define GL_LINE_STRIP_ADJACENCY 0x000B -#define GL_TRIANGLES_ADJACENCY 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D -#define GL_PROGRAM_POINT_SIZE 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 -#define GL_GEOMETRY_SHADER 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT 0x8916 -#define GL_GEOMETRY_INPUT_TYPE 0x8917 -#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 -#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 -#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 -#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 -#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 -#define GL_CONTEXT_PROFILE_MASK 0x9126 -#define GL_DEPTH_CLAMP 0x864F -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION 0x8E4D -#define GL_LAST_VERTEX_CONVENTION 0x8E4E -#define GL_PROVOKING_VERTEX 0x8E4F -#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F -#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 -#define GL_OBJECT_TYPE 0x9112 -#define GL_SYNC_CONDITION 0x9113 -#define GL_SYNC_STATUS 0x9114 -#define GL_SYNC_FLAGS 0x9115 -#define GL_SYNC_FENCE 0x9116 -#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 -#define GL_UNSIGNALED 0x9118 -#define GL_SIGNALED 0x9119 -#define GL_ALREADY_SIGNALED 0x911A -#define GL_TIMEOUT_EXPIRED 0x911B -#define GL_CONDITION_SATISFIED 0x911C -#define GL_WAIT_FAILED 0x911D -#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull -#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 -#define GL_SAMPLE_POSITION 0x8E50 -#define GL_SAMPLE_MASK 0x8E51 -#define GL_SAMPLE_MASK_VALUE 0x8E52 -#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 -#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 -#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 -#define GL_TEXTURE_SAMPLES 0x9106 -#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 -#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 -#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A -#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B -#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D -#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E -#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F -#define GL_MAX_INTEGER_SAMPLES 0x9110 -typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); -typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); -typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); -typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); -typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); -typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); -GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); -GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); -GLAPI void APIENTRY glProvokingVertex (GLenum mode); -GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); -GLAPI GLboolean APIENTRY glIsSync (GLsync sync); -GLAPI void APIENTRY glDeleteSync (GLsync sync); -GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); -GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); -GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); -GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); -GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); -GLAPI void APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask); -#endif -#endif /* GL_VERSION_3_2 */ - -#ifndef GL_VERSION_3_3 -#define GL_VERSION_3_3 1 -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE -#define GL_SRC1_COLOR 0x88F9 -#define GL_ONE_MINUS_SRC1_COLOR 0x88FA -#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB -#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC -#define GL_ANY_SAMPLES_PASSED 0x8C2F -#define GL_SAMPLER_BINDING 0x8919 -#define GL_RGB10_A2UI 0x906F -#define GL_TEXTURE_SWIZZLE_R 0x8E42 -#define GL_TEXTURE_SWIZZLE_G 0x8E43 -#define GL_TEXTURE_SWIZZLE_B 0x8E44 -#define GL_TEXTURE_SWIZZLE_A 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 -#define GL_TIME_ELAPSED 0x88BF -#define GL_TIMESTAMP 0x8E28 -#define GL_INT_2_10_10_10_REV 0x8D9F -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); -typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); -typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); -typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); -GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); -GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); -GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); -GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); -GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); -GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); -GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); -GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); -GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); -GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); -GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); -GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); -GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); -GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); -GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); -GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); -GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); -#endif -#endif /* GL_VERSION_3_3 */ - -#ifndef GL_VERSION_4_0 -#define GL_VERSION_4_0 1 -#define GL_SAMPLE_SHADING 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F -#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B -#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F -#define GL_DRAW_INDIRECT_BUFFER 0x8F3F -#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 -#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F -#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C -#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D -#define GL_MAX_VERTEX_STREAMS 0x8E71 -#define GL_DOUBLE_VEC2 0x8FFC -#define GL_DOUBLE_VEC3 0x8FFD -#define GL_DOUBLE_VEC4 0x8FFE -#define GL_DOUBLE_MAT2 0x8F46 -#define GL_DOUBLE_MAT3 0x8F47 -#define GL_DOUBLE_MAT4 0x8F48 -#define GL_DOUBLE_MAT2x3 0x8F49 -#define GL_DOUBLE_MAT2x4 0x8F4A -#define GL_DOUBLE_MAT3x2 0x8F4B -#define GL_DOUBLE_MAT3x4 0x8F4C -#define GL_DOUBLE_MAT4x2 0x8F4D -#define GL_DOUBLE_MAT4x3 0x8F4E -#define GL_ACTIVE_SUBROUTINES 0x8DE5 -#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 -#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 -#define GL_MAX_SUBROUTINES 0x8DE7 -#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 -#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A -#define GL_COMPATIBLE_SUBROUTINES 0x8E4B -#define GL_PATCHES 0x000E -#define GL_PATCH_VERTICES 0x8E72 -#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 -#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 -#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 -#define GL_TESS_GEN_MODE 0x8E76 -#define GL_TESS_GEN_SPACING 0x8E77 -#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 -#define GL_TESS_GEN_POINT_MODE 0x8E79 -#define GL_ISOLINES 0x8E7A -#define GL_FRACTIONAL_ODD 0x8E7B -#define GL_FRACTIONAL_EVEN 0x8E7C -#define GL_MAX_PATCH_VERTICES 0x8E7D -#define GL_MAX_TESS_GEN_LEVEL 0x8E7E -#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F -#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 -#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 -#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 -#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 -#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 -#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 -#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 -#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 -#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A -#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C -#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D -#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E -#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 -#define GL_TESS_EVALUATION_SHADER 0x8E87 -#define GL_TESS_CONTROL_SHADER 0x8E88 -#define GL_TRANSFORM_FEEDBACK 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 -#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 -typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); -typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); -typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); -typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); -typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); -typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); -typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); -typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMinSampleShading (GLfloat value); -GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect); -GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect); -GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); -GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); -GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); -GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); -GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); -GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); -GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); -GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); -GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); -GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); -GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); -GLAPI void APIENTRY glPauseTransformFeedback (void); -GLAPI void APIENTRY glResumeTransformFeedback (void); -GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); -GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); -GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); -GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); -GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); -#endif -#endif /* GL_VERSION_4_0 */ - -#ifndef GL_VERSION_4_1 -#define GL_VERSION_4_1 1 -#define GL_FIXED 0x140C -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B -#define GL_LOW_FLOAT 0x8DF0 -#define GL_MEDIUM_FLOAT 0x8DF1 -#define GL_HIGH_FLOAT 0x8DF2 -#define GL_LOW_INT 0x8DF3 -#define GL_MEDIUM_INT 0x8DF4 -#define GL_HIGH_INT 0x8DF5 -#define GL_SHADER_COMPILER 0x8DFA -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#define GL_RGB565 0x8D62 -#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 -#define GL_PROGRAM_BINARY_LENGTH 0x8741 -#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE -#define GL_PROGRAM_BINARY_FORMATS 0x87FF -#define GL_VERTEX_SHADER_BIT 0x00000001 -#define GL_FRAGMENT_SHADER_BIT 0x00000002 -#define GL_GEOMETRY_SHADER_BIT 0x00000004 -#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 -#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 -#define GL_ALL_SHADER_BITS 0xFFFFFFFF -#define GL_PROGRAM_SEPARABLE 0x8258 -#define GL_ACTIVE_PROGRAM 0x8259 -#define GL_PROGRAM_PIPELINE_BINDING 0x825A -#define GL_MAX_VIEWPORTS 0x825B -#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C -#define GL_VIEWPORT_BOUNDS_RANGE 0x825D -#define GL_LAYER_PROVOKING_VERTEX 0x825E -#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F -#define GL_UNDEFINED_VERTEX 0x8260 -typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); -typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); -typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); -typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); -typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); -typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); -typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); -typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); -typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); -typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); -typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); -typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReleaseShaderCompiler (void); -GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); -GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); -GLAPI void APIENTRY glClearDepthf (GLfloat d); -GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); -GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); -GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); -GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); -GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); -GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); -GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); -GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); -GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); -GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); -GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); -GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); -GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); -GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); -GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); -GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); -GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); -GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); -GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); -#endif -#endif /* GL_VERSION_4_1 */ - -#ifndef GL_VERSION_4_2 -#define GL_VERSION_4_2 1 -#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 -#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 -#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 -#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A -#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B -#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C -#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D -#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E -#define GL_NUM_SAMPLE_COUNTS 0x9380 -#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC -#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 -#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 -#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 -#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 -#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB -#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE -#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF -#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 -#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 -#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 -#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 -#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 -#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC -#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 -#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA -#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB -#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 -#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 -#define GL_UNIFORM_BARRIER_BIT 0x00000004 -#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 -#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 -#define GL_COMMAND_BARRIER_BIT 0x00000040 -#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 -#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 -#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 -#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 -#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 -#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 -#define GL_ALL_BARRIER_BITS 0xFFFFFFFF -#define GL_MAX_IMAGE_UNITS 0x8F38 -#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 -#define GL_IMAGE_BINDING_NAME 0x8F3A -#define GL_IMAGE_BINDING_LEVEL 0x8F3B -#define GL_IMAGE_BINDING_LAYERED 0x8F3C -#define GL_IMAGE_BINDING_LAYER 0x8F3D -#define GL_IMAGE_BINDING_ACCESS 0x8F3E -#define GL_IMAGE_1D 0x904C -#define GL_IMAGE_2D 0x904D -#define GL_IMAGE_3D 0x904E -#define GL_IMAGE_2D_RECT 0x904F -#define GL_IMAGE_CUBE 0x9050 -#define GL_IMAGE_BUFFER 0x9051 -#define GL_IMAGE_1D_ARRAY 0x9052 -#define GL_IMAGE_2D_ARRAY 0x9053 -#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 -#define GL_IMAGE_2D_MULTISAMPLE 0x9055 -#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 -#define GL_INT_IMAGE_1D 0x9057 -#define GL_INT_IMAGE_2D 0x9058 -#define GL_INT_IMAGE_3D 0x9059 -#define GL_INT_IMAGE_2D_RECT 0x905A -#define GL_INT_IMAGE_CUBE 0x905B -#define GL_INT_IMAGE_BUFFER 0x905C -#define GL_INT_IMAGE_1D_ARRAY 0x905D -#define GL_INT_IMAGE_2D_ARRAY 0x905E -#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F -#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 -#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 -#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 -#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 -#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 -#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 -#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 -#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C -#define GL_MAX_IMAGE_SAMPLES 0x906D -#define GL_IMAGE_BINDING_FORMAT 0x906E -#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 -#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA -#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB -#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC -#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD -#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE -#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF -#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C -#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D -#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E -#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F -#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); -typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); -typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); -GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); -GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); -GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); -#endif -#endif /* GL_VERSION_4_2 */ - -#ifndef GL_VERSION_4_3 -#define GL_VERSION_4_3 1 -typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 -#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E -#define GL_COMPRESSED_RGB8_ETC2 0x9274 -#define GL_COMPRESSED_SRGB8_ETC2 0x9275 -#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 -#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 -#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 -#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 -#define GL_COMPRESSED_R11_EAC 0x9270 -#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 -#define GL_COMPRESSED_RG11_EAC 0x9272 -#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 -#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 -#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A -#define GL_MAX_ELEMENT_INDEX 0x8D6B -#define GL_COMPUTE_SHADER 0x91B9 -#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB -#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC -#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD -#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 -#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 -#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 -#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 -#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 -#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB -#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE -#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF -#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED -#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE -#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF -#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 -#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 -#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 -#define GL_DEBUG_SOURCE_API 0x8246 -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 -#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 -#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 -#define GL_DEBUG_SOURCE_APPLICATION 0x824A -#define GL_DEBUG_SOURCE_OTHER 0x824B -#define GL_DEBUG_TYPE_ERROR 0x824C -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E -#define GL_DEBUG_TYPE_PORTABILITY 0x824F -#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 -#define GL_DEBUG_TYPE_OTHER 0x8251 -#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES 0x9145 -#define GL_DEBUG_SEVERITY_HIGH 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 -#define GL_DEBUG_SEVERITY_LOW 0x9148 -#define GL_DEBUG_TYPE_MARKER 0x8268 -#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 -#define GL_DEBUG_TYPE_POP_GROUP 0x826A -#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B -#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C -#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D -#define GL_BUFFER 0x82E0 -#define GL_SHADER 0x82E1 -#define GL_PROGRAM 0x82E2 -#define GL_QUERY 0x82E3 -#define GL_PROGRAM_PIPELINE 0x82E4 -#define GL_SAMPLER 0x82E6 -#define GL_MAX_LABEL_LENGTH 0x82E8 -#define GL_DEBUG_OUTPUT 0x92E0 -#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 -#define GL_MAX_UNIFORM_LOCATIONS 0x826E -#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 -#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 -#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 -#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 -#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 -#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 -#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 -#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 -#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 -#define GL_INTERNALFORMAT_SUPPORTED 0x826F -#define GL_INTERNALFORMAT_PREFERRED 0x8270 -#define GL_INTERNALFORMAT_RED_SIZE 0x8271 -#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 -#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 -#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 -#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 -#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 -#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 -#define GL_INTERNALFORMAT_RED_TYPE 0x8278 -#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 -#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A -#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B -#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C -#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D -#define GL_MAX_WIDTH 0x827E -#define GL_MAX_HEIGHT 0x827F -#define GL_MAX_DEPTH 0x8280 -#define GL_MAX_LAYERS 0x8281 -#define GL_MAX_COMBINED_DIMENSIONS 0x8282 -#define GL_COLOR_COMPONENTS 0x8283 -#define GL_DEPTH_COMPONENTS 0x8284 -#define GL_STENCIL_COMPONENTS 0x8285 -#define GL_COLOR_RENDERABLE 0x8286 -#define GL_DEPTH_RENDERABLE 0x8287 -#define GL_STENCIL_RENDERABLE 0x8288 -#define GL_FRAMEBUFFER_RENDERABLE 0x8289 -#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A -#define GL_FRAMEBUFFER_BLEND 0x828B -#define GL_READ_PIXELS 0x828C -#define GL_READ_PIXELS_FORMAT 0x828D -#define GL_READ_PIXELS_TYPE 0x828E -#define GL_TEXTURE_IMAGE_FORMAT 0x828F -#define GL_TEXTURE_IMAGE_TYPE 0x8290 -#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 -#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 -#define GL_MIPMAP 0x8293 -#define GL_MANUAL_GENERATE_MIPMAP 0x8294 -#define GL_AUTO_GENERATE_MIPMAP 0x8295 -#define GL_COLOR_ENCODING 0x8296 -#define GL_SRGB_READ 0x8297 -#define GL_SRGB_WRITE 0x8298 -#define GL_FILTER 0x829A -#define GL_VERTEX_TEXTURE 0x829B -#define GL_TESS_CONTROL_TEXTURE 0x829C -#define GL_TESS_EVALUATION_TEXTURE 0x829D -#define GL_GEOMETRY_TEXTURE 0x829E -#define GL_FRAGMENT_TEXTURE 0x829F -#define GL_COMPUTE_TEXTURE 0x82A0 -#define GL_TEXTURE_SHADOW 0x82A1 -#define GL_TEXTURE_GATHER 0x82A2 -#define GL_TEXTURE_GATHER_SHADOW 0x82A3 -#define GL_SHADER_IMAGE_LOAD 0x82A4 -#define GL_SHADER_IMAGE_STORE 0x82A5 -#define GL_SHADER_IMAGE_ATOMIC 0x82A6 -#define GL_IMAGE_TEXEL_SIZE 0x82A7 -#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 -#define GL_IMAGE_PIXEL_FORMAT 0x82A9 -#define GL_IMAGE_PIXEL_TYPE 0x82AA -#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC -#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD -#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE -#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF -#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 -#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 -#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 -#define GL_CLEAR_BUFFER 0x82B4 -#define GL_TEXTURE_VIEW 0x82B5 -#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 -#define GL_FULL_SUPPORT 0x82B7 -#define GL_CAVEAT_SUPPORT 0x82B8 -#define GL_IMAGE_CLASS_4_X_32 0x82B9 -#define GL_IMAGE_CLASS_2_X_32 0x82BA -#define GL_IMAGE_CLASS_1_X_32 0x82BB -#define GL_IMAGE_CLASS_4_X_16 0x82BC -#define GL_IMAGE_CLASS_2_X_16 0x82BD -#define GL_IMAGE_CLASS_1_X_16 0x82BE -#define GL_IMAGE_CLASS_4_X_8 0x82BF -#define GL_IMAGE_CLASS_2_X_8 0x82C0 -#define GL_IMAGE_CLASS_1_X_8 0x82C1 -#define GL_IMAGE_CLASS_11_11_10 0x82C2 -#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 -#define GL_VIEW_CLASS_128_BITS 0x82C4 -#define GL_VIEW_CLASS_96_BITS 0x82C5 -#define GL_VIEW_CLASS_64_BITS 0x82C6 -#define GL_VIEW_CLASS_48_BITS 0x82C7 -#define GL_VIEW_CLASS_32_BITS 0x82C8 -#define GL_VIEW_CLASS_24_BITS 0x82C9 -#define GL_VIEW_CLASS_16_BITS 0x82CA -#define GL_VIEW_CLASS_8_BITS 0x82CB -#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC -#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD -#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE -#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF -#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 -#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 -#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 -#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 -#define GL_UNIFORM 0x92E1 -#define GL_UNIFORM_BLOCK 0x92E2 -#define GL_PROGRAM_INPUT 0x92E3 -#define GL_PROGRAM_OUTPUT 0x92E4 -#define GL_BUFFER_VARIABLE 0x92E5 -#define GL_SHADER_STORAGE_BLOCK 0x92E6 -#define GL_VERTEX_SUBROUTINE 0x92E8 -#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 -#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA -#define GL_GEOMETRY_SUBROUTINE 0x92EB -#define GL_FRAGMENT_SUBROUTINE 0x92EC -#define GL_COMPUTE_SUBROUTINE 0x92ED -#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE -#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF -#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 -#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 -#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 -#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 -#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 -#define GL_ACTIVE_RESOURCES 0x92F5 -#define GL_MAX_NAME_LENGTH 0x92F6 -#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 -#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 -#define GL_NAME_LENGTH 0x92F9 -#define GL_TYPE 0x92FA -#define GL_ARRAY_SIZE 0x92FB -#define GL_OFFSET 0x92FC -#define GL_BLOCK_INDEX 0x92FD -#define GL_ARRAY_STRIDE 0x92FE -#define GL_MATRIX_STRIDE 0x92FF -#define GL_IS_ROW_MAJOR 0x9300 -#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 -#define GL_BUFFER_BINDING 0x9302 -#define GL_BUFFER_DATA_SIZE 0x9303 -#define GL_NUM_ACTIVE_VARIABLES 0x9304 -#define GL_ACTIVE_VARIABLES 0x9305 -#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 -#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 -#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 -#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 -#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A -#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B -#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C -#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D -#define GL_LOCATION 0x930E -#define GL_LOCATION_INDEX 0x930F -#define GL_IS_PER_PATCH 0x92E7 -#define GL_SHADER_STORAGE_BUFFER 0x90D2 -#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 -#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 -#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 -#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 -#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 -#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 -#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 -#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA -#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB -#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC -#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD -#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE -#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF -#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 -#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 -#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA -#define GL_TEXTURE_BUFFER_OFFSET 0x919D -#define GL_TEXTURE_BUFFER_SIZE 0x919E -#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F -#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB -#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC -#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD -#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE -#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF -#define GL_VERTEX_ATTRIB_BINDING 0x82D4 -#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 -#define GL_VERTEX_BINDING_DIVISOR 0x82D6 -#define GL_VERTEX_BINDING_OFFSET 0x82D7 -#define GL_VERTEX_BINDING_STRIDE 0x82D8 -#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 -#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA -#define GL_DISPLAY_LIST 0x82E7 -typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); -typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); -typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); -typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); -typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); -typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); -typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); -typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); -typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); -typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); -typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); -typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); -typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); -typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); -typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); -typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); -typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); -typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); -typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); -typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); -GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); -GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); -GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); -GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); -GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); -GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); -GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); -GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); -GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); -GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); -GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); -GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); -GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); -GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); -GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); -GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); -GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); -GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); -GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); -GLAPI void APIENTRY glPopDebugGroup (void); -GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); -GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); -GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); -GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); -#endif -#endif /* GL_VERSION_4_3 */ - -#ifndef GL_VERSION_4_4 -#define GL_VERSION_4_4 1 -#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 -#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 -#define GL_TEXTURE_BUFFER_BINDING 0x8C2A -#define GL_MAP_PERSISTENT_BIT 0x0040 -#define GL_MAP_COHERENT_BIT 0x0080 -#define GL_DYNAMIC_STORAGE_BIT 0x0100 -#define GL_CLIENT_STORAGE_BIT 0x0200 -#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 -#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F -#define GL_BUFFER_STORAGE_FLAGS 0x8220 -#define GL_CLEAR_TEXTURE 0x9365 -#define GL_LOCATION_COMPONENT 0x934A -#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B -#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C -#define GL_QUERY_BUFFER 0x9192 -#define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 -#define GL_QUERY_BUFFER_BINDING 0x9193 -#define GL_QUERY_RESULT_NO_WAIT 0x9194 -#define GL_MIRROR_CLAMP_TO_EDGE 0x8743 -typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); -typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); -typedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); -typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); -typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers); -typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); -typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferStorage (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); -GLAPI void APIENTRY glClearTexImage (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glClearTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glBindBuffersBase (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); -GLAPI void APIENTRY glBindBuffersRange (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); -GLAPI void APIENTRY glBindTextures (GLuint first, GLsizei count, const GLuint *textures); -GLAPI void APIENTRY glBindSamplers (GLuint first, GLsizei count, const GLuint *samplers); -GLAPI void APIENTRY glBindImageTextures (GLuint first, GLsizei count, const GLuint *textures); -GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); -#endif -#endif /* GL_VERSION_4_4 */ - -#ifndef GL_ARB_ES2_compatibility -#define GL_ARB_ES2_compatibility 1 -#endif /* GL_ARB_ES2_compatibility */ - -#ifndef GL_ARB_ES3_compatibility -#define GL_ARB_ES3_compatibility 1 -#endif /* GL_ARB_ES3_compatibility */ - -#ifndef GL_ARB_arrays_of_arrays -#define GL_ARB_arrays_of_arrays 1 -#endif /* GL_ARB_arrays_of_arrays */ - -#ifndef GL_ARB_base_instance -#define GL_ARB_base_instance 1 -#endif /* GL_ARB_base_instance */ - -#ifndef GL_ARB_bindless_texture -#define GL_ARB_bindless_texture 1 -typedef uint64_t GLuint64EXT; -#define GL_UNSIGNED_INT64_ARB 0x140F -typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture); -typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler); -typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle); -typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access); -typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value); -typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); -typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint64 APIENTRY glGetTextureHandleARB (GLuint texture); -GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleARB (GLuint texture, GLuint sampler); -GLAPI void APIENTRY glMakeTextureHandleResidentARB (GLuint64 handle); -GLAPI void APIENTRY glMakeTextureHandleNonResidentARB (GLuint64 handle); -GLAPI GLuint64 APIENTRY glGetImageHandleARB (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -GLAPI void APIENTRY glMakeImageHandleResidentARB (GLuint64 handle, GLenum access); -GLAPI void APIENTRY glMakeImageHandleNonResidentARB (GLuint64 handle); -GLAPI void APIENTRY glUniformHandleui64ARB (GLint location, GLuint64 value); -GLAPI void APIENTRY glUniformHandleui64vARB (GLint location, GLsizei count, const GLuint64 *value); -GLAPI void APIENTRY glProgramUniformHandleui64ARB (GLuint program, GLint location, GLuint64 value); -GLAPI void APIENTRY glProgramUniformHandleui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *values); -GLAPI GLboolean APIENTRY glIsTextureHandleResidentARB (GLuint64 handle); -GLAPI GLboolean APIENTRY glIsImageHandleResidentARB (GLuint64 handle); -GLAPI void APIENTRY glVertexAttribL1ui64ARB (GLuint index, GLuint64EXT x); -GLAPI void APIENTRY glVertexAttribL1ui64vARB (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glGetVertexAttribLui64vARB (GLuint index, GLenum pname, GLuint64EXT *params); -#endif -#endif /* GL_ARB_bindless_texture */ - -#ifndef GL_ARB_blend_func_extended -#define GL_ARB_blend_func_extended 1 -#endif /* GL_ARB_blend_func_extended */ - -#ifndef GL_ARB_buffer_storage -#define GL_ARB_buffer_storage 1 -#endif /* GL_ARB_buffer_storage */ - -#ifndef GL_ARB_cl_event -#define GL_ARB_cl_event 1 -struct _cl_context; -struct _cl_event; -#define GL_SYNC_CL_EVENT_ARB 0x8240 -#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 -typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); -#endif -#endif /* GL_ARB_cl_event */ - -#ifndef GL_ARB_clear_buffer_object -#define GL_ARB_clear_buffer_object 1 -#endif /* GL_ARB_clear_buffer_object */ - -#ifndef GL_ARB_clear_texture -#define GL_ARB_clear_texture 1 -#endif /* GL_ARB_clear_texture */ - -#ifndef GL_ARB_color_buffer_float -#define GL_ARB_color_buffer_float 1 -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D -typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); -#endif -#endif /* GL_ARB_color_buffer_float */ - -#ifndef GL_ARB_compatibility -#define GL_ARB_compatibility 1 -#endif /* GL_ARB_compatibility */ - -#ifndef GL_ARB_compressed_texture_pixel_storage -#define GL_ARB_compressed_texture_pixel_storage 1 -#endif /* GL_ARB_compressed_texture_pixel_storage */ - -#ifndef GL_ARB_compute_shader -#define GL_ARB_compute_shader 1 -#define GL_COMPUTE_SHADER_BIT 0x00000020 -#endif /* GL_ARB_compute_shader */ - -#ifndef GL_ARB_compute_variable_group_size -#define GL_ARB_compute_variable_group_size 1 -#define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344 -#define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB -#define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345 -#define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF -typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDispatchComputeGroupSizeARB (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); -#endif -#endif /* GL_ARB_compute_variable_group_size */ - -#ifndef GL_ARB_conservative_depth -#define GL_ARB_conservative_depth 1 -#endif /* GL_ARB_conservative_depth */ - -#ifndef GL_ARB_copy_buffer -#define GL_ARB_copy_buffer 1 -#define GL_COPY_READ_BUFFER_BINDING 0x8F36 -#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 -#endif /* GL_ARB_copy_buffer */ - -#ifndef GL_ARB_copy_image -#define GL_ARB_copy_image 1 -#endif /* GL_ARB_copy_image */ - -#ifndef GL_ARB_debug_output -#define GL_ARB_debug_output 1 -typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 -#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 -#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 -#define GL_DEBUG_SOURCE_API_ARB 0x8246 -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 -#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 -#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 -#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A -#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B -#define GL_DEBUG_TYPE_ERROR_ARB 0x824C -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E -#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F -#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 -#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 -#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 -#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 -typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const void *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#endif -#endif /* GL_ARB_debug_output */ - -#ifndef GL_ARB_depth_buffer_float -#define GL_ARB_depth_buffer_float 1 -#endif /* GL_ARB_depth_buffer_float */ - -#ifndef GL_ARB_depth_clamp -#define GL_ARB_depth_clamp 1 -#endif /* GL_ARB_depth_clamp */ - -#ifndef GL_ARB_depth_texture -#define GL_ARB_depth_texture 1 -#define GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B -#endif /* GL_ARB_depth_texture */ - -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers 1 -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 -typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); -#endif -#endif /* GL_ARB_draw_buffers */ - -#ifndef GL_ARB_draw_buffers_blend -#define GL_ARB_draw_buffers_blend 1 -typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif -#endif /* GL_ARB_draw_buffers_blend */ - -#ifndef GL_ARB_draw_elements_base_vertex -#define GL_ARB_draw_elements_base_vertex 1 -#endif /* GL_ARB_draw_elements_base_vertex */ - -#ifndef GL_ARB_draw_indirect -#define GL_ARB_draw_indirect 1 -#endif /* GL_ARB_draw_indirect */ - -#ifndef GL_ARB_draw_instanced -#define GL_ARB_draw_instanced 1 -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); -#endif -#endif /* GL_ARB_draw_instanced */ - -#ifndef GL_ARB_enhanced_layouts -#define GL_ARB_enhanced_layouts 1 -#endif /* GL_ARB_enhanced_layouts */ - -#ifndef GL_ARB_explicit_attrib_location -#define GL_ARB_explicit_attrib_location 1 -#endif /* GL_ARB_explicit_attrib_location */ - -#ifndef GL_ARB_explicit_uniform_location -#define GL_ARB_explicit_uniform_location 1 -#endif /* GL_ARB_explicit_uniform_location */ - -#ifndef GL_ARB_fragment_coord_conventions -#define GL_ARB_fragment_coord_conventions 1 -#endif /* GL_ARB_fragment_coord_conventions */ - -#ifndef GL_ARB_fragment_layer_viewport -#define GL_ARB_fragment_layer_viewport 1 -#endif /* GL_ARB_fragment_layer_viewport */ - -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_FORMAT_ARB 0x8876 -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define GL_MATRIX0_ARB 0x88C0 -#define GL_MATRIX1_ARB 0x88C1 -#define GL_MATRIX2_ARB 0x88C2 -#define GL_MATRIX3_ARB 0x88C3 -#define GL_MATRIX4_ARB 0x88C4 -#define GL_MATRIX5_ARB 0x88C5 -#define GL_MATRIX6_ARB 0x88C6 -#define GL_MATRIX7_ARB 0x88C7 -#define GL_MATRIX8_ARB 0x88C8 -#define GL_MATRIX9_ARB 0x88C9 -#define GL_MATRIX10_ARB 0x88CA -#define GL_MATRIX11_ARB 0x88CB -#define GL_MATRIX12_ARB 0x88CC -#define GL_MATRIX13_ARB 0x88CD -#define GL_MATRIX14_ARB 0x88CE -#define GL_MATRIX15_ARB 0x88CF -#define GL_MATRIX16_ARB 0x88D0 -#define GL_MATRIX17_ARB 0x88D1 -#define GL_MATRIX18_ARB 0x88D2 -#define GL_MATRIX19_ARB 0x88D3 -#define GL_MATRIX20_ARB 0x88D4 -#define GL_MATRIX21_ARB 0x88D5 -#define GL_MATRIX22_ARB 0x88D6 -#define GL_MATRIX23_ARB 0x88D7 -#define GL_MATRIX24_ARB 0x88D8 -#define GL_MATRIX25_ARB 0x88D9 -#define GL_MATRIX26_ARB 0x88DA -#define GL_MATRIX27_ARB 0x88DB -#define GL_MATRIX28_ARB 0x88DC -#define GL_MATRIX29_ARB 0x88DD -#define GL_MATRIX30_ARB 0x88DE -#define GL_MATRIX31_ARB 0x88DF -typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void *string); -typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void *string); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const void *string); -GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); -GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); -GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, void *string); -GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); -#endif -#endif /* GL_ARB_fragment_program */ - -#ifndef GL_ARB_fragment_program_shadow -#define GL_ARB_fragment_program_shadow 1 -#endif /* GL_ARB_fragment_program_shadow */ - -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif /* GL_ARB_fragment_shader */ - -#ifndef GL_ARB_framebuffer_no_attachments -#define GL_ARB_framebuffer_no_attachments 1 -#endif /* GL_ARB_framebuffer_no_attachments */ - -#ifndef GL_ARB_framebuffer_object -#define GL_ARB_framebuffer_object 1 -#endif /* GL_ARB_framebuffer_object */ - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_ARB_framebuffer_sRGB 1 -#endif /* GL_ARB_framebuffer_sRGB */ - -#ifndef GL_ARB_geometry_shader4 -#define GL_ARB_geometry_shader4 1 -#define GL_LINES_ADJACENCY_ARB 0x000A -#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B -#define GL_TRIANGLES_ADJACENCY_ARB 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D -#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 -#define GL_GEOMETRY_SHADER_ARB 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); -GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif -#endif /* GL_ARB_geometry_shader4 */ - -#ifndef GL_ARB_get_program_binary -#define GL_ARB_get_program_binary 1 -#endif /* GL_ARB_get_program_binary */ - -#ifndef GL_ARB_gpu_shader5 -#define GL_ARB_gpu_shader5 1 -#endif /* GL_ARB_gpu_shader5 */ - -#ifndef GL_ARB_gpu_shader_fp64 -#define GL_ARB_gpu_shader_fp64 1 -#endif /* GL_ARB_gpu_shader_fp64 */ - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel 1 -typedef unsigned short GLhalfARB; -#define GL_HALF_FLOAT_ARB 0x140B -#endif /* GL_ARB_half_float_pixel */ - -#ifndef GL_ARB_half_float_vertex -#define GL_ARB_half_float_vertex 1 -#endif /* GL_ARB_half_float_vertex */ - -#ifndef GL_ARB_imaging -#define GL_ARB_imaging 1 -#define GL_BLEND_COLOR 0x8005 -#define GL_BLEND_EQUATION 0x8009 -#define GL_CONVOLUTION_1D 0x8010 -#define GL_CONVOLUTION_2D 0x8011 -#define GL_SEPARABLE_2D 0x8012 -#define GL_CONVOLUTION_BORDER_MODE 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define GL_REDUCE 0x8016 -#define GL_CONVOLUTION_FORMAT 0x8017 -#define GL_CONVOLUTION_WIDTH 0x8018 -#define GL_CONVOLUTION_HEIGHT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define GL_HISTOGRAM 0x8024 -#define GL_PROXY_HISTOGRAM 0x8025 -#define GL_HISTOGRAM_WIDTH 0x8026 -#define GL_HISTOGRAM_FORMAT 0x8027 -#define GL_HISTOGRAM_RED_SIZE 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define GL_HISTOGRAM_SINK 0x802D -#define GL_MINMAX 0x802E -#define GL_MINMAX_FORMAT 0x802F -#define GL_MINMAX_SINK 0x8030 -#define GL_TABLE_TOO_LARGE 0x8031 -#define GL_COLOR_MATRIX 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define GL_COLOR_TABLE 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define GL_PROXY_COLOR_TABLE 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define GL_COLOR_TABLE_SCALE 0x80D6 -#define GL_COLOR_TABLE_BIAS 0x80D7 -#define GL_COLOR_TABLE_FORMAT 0x80D8 -#define GL_COLOR_TABLE_WIDTH 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_CONSTANT_BORDER 0x8151 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 -typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, void *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, void *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); -GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, void *table); -GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); -GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); -GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); -GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); -GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, void *image); -GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); -GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); -GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glResetHistogram (GLenum target); -GLAPI void APIENTRY glResetMinmax (GLenum target); -#endif -#endif /* GL_ARB_imaging */ - -#ifndef GL_ARB_indirect_parameters -#define GL_ARB_indirect_parameters 1 -#define GL_PARAMETER_BUFFER_ARB 0x80EE -#define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -#endif -#endif /* GL_ARB_indirect_parameters */ - -#ifndef GL_ARB_instanced_arrays -#define GL_ARB_instanced_arrays 1 -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); -#endif -#endif /* GL_ARB_instanced_arrays */ - -#ifndef GL_ARB_internalformat_query -#define GL_ARB_internalformat_query 1 -#endif /* GL_ARB_internalformat_query */ - -#ifndef GL_ARB_internalformat_query2 -#define GL_ARB_internalformat_query2 1 -#define GL_SRGB_DECODE_ARB 0x8299 -#endif /* GL_ARB_internalformat_query2 */ - -#ifndef GL_ARB_invalidate_subdata -#define GL_ARB_invalidate_subdata 1 -#endif /* GL_ARB_invalidate_subdata */ - -#ifndef GL_ARB_map_buffer_alignment -#define GL_ARB_map_buffer_alignment 1 -#endif /* GL_ARB_map_buffer_alignment */ - -#ifndef GL_ARB_map_buffer_range -#define GL_ARB_map_buffer_range 1 -#endif /* GL_ARB_map_buffer_range */ - -#ifndef GL_ARB_matrix_palette -#define GL_ARB_matrix_palette 1 -#define GL_MATRIX_PALETTE_ARB 0x8840 -#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 -#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 -#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 -#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 -#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 -#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 -#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 -#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 -#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 -typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); -GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); -GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); -GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); -GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); -#endif -#endif /* GL_ARB_matrix_palette */ - -#ifndef GL_ARB_multi_bind -#define GL_ARB_multi_bind 1 -#endif /* GL_ARB_multi_bind */ - -#ifndef GL_ARB_multi_draw_indirect -#define GL_ARB_multi_draw_indirect 1 -#endif /* GL_ARB_multi_draw_indirect */ - -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); -#endif -#endif /* GL_ARB_multisample */ - -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 -typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTextureARB (GLenum texture); -GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); -GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); -GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); -GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); -GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); -GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); -GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); -GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); -GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); -GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); -GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); -GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); -GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); -GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); -GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); -#endif -#endif /* GL_ARB_multitexture */ - -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#define GL_SAMPLES_PASSED_ARB 0x8914 -typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); -GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); -GLAPI void APIENTRY glEndQueryARB (GLenum target); -GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); -#endif -#endif /* GL_ARB_occlusion_query */ - -#ifndef GL_ARB_occlusion_query2 -#define GL_ARB_occlusion_query2 1 -#endif /* GL_ARB_occlusion_query2 */ - -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -#endif /* GL_ARB_pixel_buffer_object */ - -#ifndef GL_ARB_point_parameters -#define GL_ARB_point_parameters 1 -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 -typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); -#endif -#endif /* GL_ARB_point_parameters */ - -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 -#endif /* GL_ARB_point_sprite */ - -#ifndef GL_ARB_program_interface_query -#define GL_ARB_program_interface_query 1 -#endif /* GL_ARB_program_interface_query */ - -#ifndef GL_ARB_provoking_vertex -#define GL_ARB_provoking_vertex 1 -#endif /* GL_ARB_provoking_vertex */ - -#ifndef GL_ARB_query_buffer_object -#define GL_ARB_query_buffer_object 1 -#endif /* GL_ARB_query_buffer_object */ - -#ifndef GL_ARB_robust_buffer_access_behavior -#define GL_ARB_robust_buffer_access_behavior 1 -#endif /* GL_ARB_robust_buffer_access_behavior */ - -#ifndef GL_ARB_robustness -#define GL_ARB_robustness 1 -#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 -#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 -#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 -#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 -typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); -typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); -typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); -typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void *img); -typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); -typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); -typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); -typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); -typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); -typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); -typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); -GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); -GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); -GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, void *img); -GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); -GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); -GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); -GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); -GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); -GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); -GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); -GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); -GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); -GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); -#endif -#endif /* GL_ARB_robustness */ - -#ifndef GL_ARB_robustness_isolation -#define GL_ARB_robustness_isolation 1 -#endif /* GL_ARB_robustness_isolation */ - -#ifndef GL_ARB_sample_shading -#define GL_ARB_sample_shading 1 -#define GL_SAMPLE_SHADING_ARB 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 -typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); -#endif -#endif /* GL_ARB_sample_shading */ - -#ifndef GL_ARB_sampler_objects -#define GL_ARB_sampler_objects 1 -#endif /* GL_ARB_sampler_objects */ - -#ifndef GL_ARB_seamless_cube_map -#define GL_ARB_seamless_cube_map 1 -#endif /* GL_ARB_seamless_cube_map */ - -#ifndef GL_ARB_seamless_cubemap_per_texture -#define GL_ARB_seamless_cubemap_per_texture 1 -#endif /* GL_ARB_seamless_cubemap_per_texture */ - -#ifndef GL_ARB_separate_shader_objects -#define GL_ARB_separate_shader_objects 1 -#endif /* GL_ARB_separate_shader_objects */ - -#ifndef GL_ARB_shader_atomic_counters -#define GL_ARB_shader_atomic_counters 1 -#endif /* GL_ARB_shader_atomic_counters */ - -#ifndef GL_ARB_shader_bit_encoding -#define GL_ARB_shader_bit_encoding 1 -#endif /* GL_ARB_shader_bit_encoding */ - -#ifndef GL_ARB_shader_draw_parameters -#define GL_ARB_shader_draw_parameters 1 -#endif /* GL_ARB_shader_draw_parameters */ - -#ifndef GL_ARB_shader_group_vote -#define GL_ARB_shader_group_vote 1 -#endif /* GL_ARB_shader_group_vote */ - -#ifndef GL_ARB_shader_image_load_store -#define GL_ARB_shader_image_load_store 1 -#endif /* GL_ARB_shader_image_load_store */ - -#ifndef GL_ARB_shader_image_size -#define GL_ARB_shader_image_size 1 -#endif /* GL_ARB_shader_image_size */ - -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 -#ifdef __APPLE__ -typedef void *GLhandleARB; -#else -typedef unsigned int GLhandleARB; -#endif -typedef char GLcharARB; -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); -typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); -GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); -GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); -GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); -GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); -GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); -GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); -GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); -GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); -GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); -GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); -GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); -GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); -GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); -GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); -GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); -GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#endif -#endif /* GL_ARB_shader_objects */ - -#ifndef GL_ARB_shader_precision -#define GL_ARB_shader_precision 1 -#endif /* GL_ARB_shader_precision */ - -#ifndef GL_ARB_shader_stencil_export -#define GL_ARB_shader_stencil_export 1 -#endif /* GL_ARB_shader_stencil_export */ - -#ifndef GL_ARB_shader_storage_buffer_object -#define GL_ARB_shader_storage_buffer_object 1 -#endif /* GL_ARB_shader_storage_buffer_object */ - -#ifndef GL_ARB_shader_subroutine -#define GL_ARB_shader_subroutine 1 -#endif /* GL_ARB_shader_subroutine */ - -#ifndef GL_ARB_shader_texture_lod -#define GL_ARB_shader_texture_lod 1 -#endif /* GL_ARB_shader_texture_lod */ - -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif /* GL_ARB_shading_language_100 */ - -#ifndef GL_ARB_shading_language_420pack -#define GL_ARB_shading_language_420pack 1 -#endif /* GL_ARB_shading_language_420pack */ - -#ifndef GL_ARB_shading_language_include -#define GL_ARB_shading_language_include 1 -#define GL_SHADER_INCLUDE_ARB 0x8DAE -#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 -#define GL_NAMED_STRING_TYPE_ARB 0x8DEA -typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); -typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); -typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); -typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); -GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); -GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); -GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#endif -#endif /* GL_ARB_shading_language_include */ - -#ifndef GL_ARB_shading_language_packing -#define GL_ARB_shading_language_packing 1 -#endif /* GL_ARB_shading_language_packing */ - -#ifndef GL_ARB_shadow -#define GL_ARB_shadow 1 -#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E -#endif /* GL_ARB_shadow */ - -#ifndef GL_ARB_shadow_ambient -#define GL_ARB_shadow_ambient 1 -#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF -#endif /* GL_ARB_shadow_ambient */ - -#ifndef GL_ARB_sparse_texture -#define GL_ARB_sparse_texture 1 -#define GL_TEXTURE_SPARSE_ARB 0x91A6 -#define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 -#define GL_MIN_SPARSE_LEVEL_ARB 0x919B -#define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 -#define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 -#define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 -#define GL_VIRTUAL_PAGE_SIZE_Z_ARB 0x9197 -#define GL_MAX_SPARSE_TEXTURE_SIZE_ARB 0x9198 -#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 -#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A -#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 -typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); -#endif -#endif /* GL_ARB_sparse_texture */ - -#ifndef GL_ARB_stencil_texturing -#define GL_ARB_stencil_texturing 1 -#endif /* GL_ARB_stencil_texturing */ - -#ifndef GL_ARB_sync -#define GL_ARB_sync 1 -#endif /* GL_ARB_sync */ - -#ifndef GL_ARB_tessellation_shader -#define GL_ARB_tessellation_shader 1 -#endif /* GL_ARB_tessellation_shader */ - -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 -#define GL_CLAMP_TO_BORDER_ARB 0x812D -#endif /* GL_ARB_texture_border_clamp */ - -#ifndef GL_ARB_texture_buffer_object -#define GL_ARB_texture_buffer_object 1 -#define GL_TEXTURE_BUFFER_ARB 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E -typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); -#endif -#endif /* GL_ARB_texture_buffer_object */ - -#ifndef GL_ARB_texture_buffer_object_rgb32 -#define GL_ARB_texture_buffer_object_rgb32 1 -#endif /* GL_ARB_texture_buffer_object_rgb32 */ - -#ifndef GL_ARB_texture_buffer_range -#define GL_ARB_texture_buffer_range 1 -#endif /* GL_ARB_texture_buffer_range */ - -#ifndef GL_ARB_texture_compression -#define GL_ARB_texture_compression 1 -#define GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define GL_COMPRESSED_RGB_ARB 0x84ED -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, void *img); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void *img); -#endif -#endif /* GL_ARB_texture_compression */ - -#ifndef GL_ARB_texture_compression_bptc -#define GL_ARB_texture_compression_bptc 1 -#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C -#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D -#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E -#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F -#endif /* GL_ARB_texture_compression_bptc */ - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_ARB_texture_compression_rgtc 1 -#endif /* GL_ARB_texture_compression_rgtc */ - -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C -#endif /* GL_ARB_texture_cube_map */ - -#ifndef GL_ARB_texture_cube_map_array -#define GL_ARB_texture_cube_map_array 1 -#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B -#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F -#endif /* GL_ARB_texture_cube_map_array */ - -#ifndef GL_ARB_texture_env_add -#define GL_ARB_texture_env_add 1 -#endif /* GL_ARB_texture_env_add */ - -#ifndef GL_ARB_texture_env_combine -#define GL_ARB_texture_env_combine 1 -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_SOURCE0_RGB_ARB 0x8580 -#define GL_SOURCE1_RGB_ARB 0x8581 -#define GL_SOURCE2_RGB_ARB 0x8582 -#define GL_SOURCE0_ALPHA_ARB 0x8588 -#define GL_SOURCE1_ALPHA_ARB 0x8589 -#define GL_SOURCE2_ALPHA_ARB 0x858A -#define GL_OPERAND0_RGB_ARB 0x8590 -#define GL_OPERAND1_RGB_ARB 0x8591 -#define GL_OPERAND2_RGB_ARB 0x8592 -#define GL_OPERAND0_ALPHA_ARB 0x8598 -#define GL_OPERAND1_ALPHA_ARB 0x8599 -#define GL_OPERAND2_ALPHA_ARB 0x859A -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#endif /* GL_ARB_texture_env_combine */ - -#ifndef GL_ARB_texture_env_crossbar -#define GL_ARB_texture_env_crossbar 1 -#endif /* GL_ARB_texture_env_crossbar */ - -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF -#endif /* GL_ARB_texture_env_dot3 */ - -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#endif /* GL_ARB_texture_float */ - -#ifndef GL_ARB_texture_gather -#define GL_ARB_texture_gather 1 -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F -#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F -#endif /* GL_ARB_texture_gather */ - -#ifndef GL_ARB_texture_mirror_clamp_to_edge -#define GL_ARB_texture_mirror_clamp_to_edge 1 -#endif /* GL_ARB_texture_mirror_clamp_to_edge */ - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 -#define GL_MIRRORED_REPEAT_ARB 0x8370 -#endif /* GL_ARB_texture_mirrored_repeat */ - -#ifndef GL_ARB_texture_multisample -#define GL_ARB_texture_multisample 1 -#endif /* GL_ARB_texture_multisample */ - -#ifndef GL_ARB_texture_non_power_of_two -#define GL_ARB_texture_non_power_of_two 1 -#endif /* GL_ARB_texture_non_power_of_two */ - -#ifndef GL_ARB_texture_query_levels -#define GL_ARB_texture_query_levels 1 -#endif /* GL_ARB_texture_query_levels */ - -#ifndef GL_ARB_texture_query_lod -#define GL_ARB_texture_query_lod 1 -#endif /* GL_ARB_texture_query_lod */ - -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#endif /* GL_ARB_texture_rectangle */ - -#ifndef GL_ARB_texture_rg -#define GL_ARB_texture_rg 1 -#endif /* GL_ARB_texture_rg */ - -#ifndef GL_ARB_texture_rgb10_a2ui -#define GL_ARB_texture_rgb10_a2ui 1 -#endif /* GL_ARB_texture_rgb10_a2ui */ - -#ifndef GL_ARB_texture_stencil8 -#define GL_ARB_texture_stencil8 1 -#endif /* GL_ARB_texture_stencil8 */ - -#ifndef GL_ARB_texture_storage -#define GL_ARB_texture_storage 1 -#endif /* GL_ARB_texture_storage */ - -#ifndef GL_ARB_texture_storage_multisample -#define GL_ARB_texture_storage_multisample 1 -#endif /* GL_ARB_texture_storage_multisample */ - -#ifndef GL_ARB_texture_swizzle -#define GL_ARB_texture_swizzle 1 -#endif /* GL_ARB_texture_swizzle */ - -#ifndef GL_ARB_texture_view -#define GL_ARB_texture_view 1 -#endif /* GL_ARB_texture_view */ - -#ifndef GL_ARB_timer_query -#define GL_ARB_timer_query 1 -#endif /* GL_ARB_timer_query */ - -#ifndef GL_ARB_transform_feedback2 -#define GL_ARB_transform_feedback2 1 -#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 -#endif /* GL_ARB_transform_feedback2 */ - -#ifndef GL_ARB_transform_feedback3 -#define GL_ARB_transform_feedback3 1 -#endif /* GL_ARB_transform_feedback3 */ - -#ifndef GL_ARB_transform_feedback_instanced -#define GL_ARB_transform_feedback_instanced 1 -#endif /* GL_ARB_transform_feedback_instanced */ - -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 -#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); -GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); -GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); -GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); -#endif -#endif /* GL_ARB_transpose_matrix */ - -#ifndef GL_ARB_uniform_buffer_object -#define GL_ARB_uniform_buffer_object 1 -#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C -#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 -#endif /* GL_ARB_uniform_buffer_object */ - -#ifndef GL_ARB_vertex_array_bgra -#define GL_ARB_vertex_array_bgra 1 -#endif /* GL_ARB_vertex_array_bgra */ - -#ifndef GL_ARB_vertex_array_object -#define GL_ARB_vertex_array_object 1 -#endif /* GL_ARB_vertex_array_object */ - -#ifndef GL_ARB_vertex_attrib_64bit -#define GL_ARB_vertex_attrib_64bit 1 -#endif /* GL_ARB_vertex_attrib_64bit */ - -#ifndef GL_ARB_vertex_attrib_binding -#define GL_ARB_vertex_attrib_binding 1 -#endif /* GL_ARB_vertex_attrib_binding */ - -#ifndef GL_ARB_vertex_blend -#define GL_ARB_vertex_blend 1 -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F -typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); -typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); -typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); -typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); -typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); -typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); -typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); -GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); -GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); -GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); -GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); -GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); -GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); -GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); -GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glVertexBlendARB (GLint count); -#endif -#endif /* GL_ARB_vertex_blend */ - -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 -typedef ptrdiff_t GLsizeiptrARB; -typedef ptrdiff_t GLintptrARB; -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA -typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); -typedef void *(APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, void **params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); -GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); -GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); -GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); -GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); -GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); -GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); -GLAPI void *APIENTRY glMapBufferARB (GLenum target, GLenum access); -GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); -GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, void **params); -#endif -#endif /* GL_ARB_vertex_buffer_object */ - -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void **pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); -GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); -GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, void **pointer); -#endif -#endif /* GL_ARB_vertex_program */ - -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); -GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); -#endif -#endif /* GL_ARB_vertex_shader */ - -#ifndef GL_ARB_vertex_type_10f_11f_11f_rev -#define GL_ARB_vertex_type_10f_11f_11f_rev 1 -#endif /* GL_ARB_vertex_type_10f_11f_11f_rev */ - -#ifndef GL_ARB_vertex_type_2_10_10_10_rev -#define GL_ARB_vertex_type_2_10_10_10_rev 1 -#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ - -#ifndef GL_ARB_viewport_array -#define GL_ARB_viewport_array 1 -#endif /* GL_ARB_viewport_array */ - -#ifndef GL_ARB_window_pos -#define GL_ARB_window_pos 1 -typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); -GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); -GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); -GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); -#endif -#endif /* GL_ARB_window_pos */ - -#ifndef GL_KHR_debug -#define GL_KHR_debug 1 -#endif /* GL_KHR_debug */ - -#ifndef GL_KHR_texture_compression_astc_hdr -#define GL_KHR_texture_compression_astc_hdr 1 -#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 -#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 -#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 -#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 -#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 -#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 -#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 -#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 -#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 -#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 -#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA -#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB -#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC -#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD -#endif /* GL_KHR_texture_compression_astc_hdr */ - -#ifndef GL_KHR_texture_compression_astc_ldr -#define GL_KHR_texture_compression_astc_ldr 1 -#endif /* GL_KHR_texture_compression_astc_ldr */ - -#ifndef GL_OES_byte_coordinates -#define GL_OES_byte_coordinates 1 -typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords); -typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s); -typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t); -typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); -typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); -typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x); -typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y); -typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z); -typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s); -GLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords); -GLAPI void APIENTRY glMultiTexCoord2bOES (GLenum texture, GLbyte s, GLbyte t); -GLAPI void APIENTRY glMultiTexCoord2bvOES (GLenum texture, const GLbyte *coords); -GLAPI void APIENTRY glMultiTexCoord3bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r); -GLAPI void APIENTRY glMultiTexCoord3bvOES (GLenum texture, const GLbyte *coords); -GLAPI void APIENTRY glMultiTexCoord4bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); -GLAPI void APIENTRY glMultiTexCoord4bvOES (GLenum texture, const GLbyte *coords); -GLAPI void APIENTRY glTexCoord1bOES (GLbyte s); -GLAPI void APIENTRY glTexCoord1bvOES (const GLbyte *coords); -GLAPI void APIENTRY glTexCoord2bOES (GLbyte s, GLbyte t); -GLAPI void APIENTRY glTexCoord2bvOES (const GLbyte *coords); -GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r); -GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords); -GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q); -GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords); -GLAPI void APIENTRY glVertex2bOES (GLbyte x); -GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); -GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y); -GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); -GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z); -GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); -#endif -#endif /* GL_OES_byte_coordinates */ - -#ifndef GL_OES_compressed_paletted_texture -#define GL_OES_compressed_paletted_texture 1 -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 -#endif /* GL_OES_compressed_paletted_texture */ - -#ifndef GL_OES_fixed_point -#define GL_OES_fixed_point 1 -typedef GLint GLfixed; -#define GL_FIXED_OES 0x140C -typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); -typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth); -typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); -typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f); -typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param); -typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); -typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation); -typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param); -typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); -typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); -typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param); -typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); -typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); -typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); -typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); -typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); -typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEOESPROC) (GLfixed value, GLboolean invert); -typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value); -typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); -typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue); -typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components); -typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u); -typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v); -typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v); -typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values); -typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component); -typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); -typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); -typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); -typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2); -typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords); -typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token); -typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values); -typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities); -typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y); -typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w); -typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); -typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2); -typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s); -typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t); -typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r); -typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q); -typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x); -typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y); -typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref); -GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -GLAPI void APIENTRY glClearDepthxOES (GLfixed depth); -GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); -GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f); -GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param); -GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param); -GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); -GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation); -GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param); -GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param); -GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); -GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glLineWidthxOES (GLfixed width); -GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m); -GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); -GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param); -GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m); -GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); -GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); -GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); -GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glPointSizexOES (GLfixed size); -GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); -GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); -GLAPI void APIENTRY glSampleCoverageOES (GLfixed value, GLboolean invert); -GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); -GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); -GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); -GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); -GLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value); -GLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); -GLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -GLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -GLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue); -GLAPI void APIENTRY glColor3xvOES (const GLfixed *components); -GLAPI void APIENTRY glColor4xvOES (const GLfixed *components); -GLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param); -GLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glEvalCoord1xOES (GLfixed u); -GLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords); -GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v); -GLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords); -GLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer); -GLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v); -GLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param); -GLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values); -GLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glIndexxOES (GLfixed component); -GLAPI void APIENTRY glIndexxvOES (const GLfixed *component); -GLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m); -GLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); -GLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); -GLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2); -GLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); -GLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m); -GLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s); -GLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords); -GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t); -GLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords); -GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r); -GLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords); -GLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords); -GLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords); -GLAPI void APIENTRY glPassThroughxOES (GLfixed token); -GLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values); -GLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param); -GLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param); -GLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor); -GLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities); -GLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y); -GLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords); -GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z); -GLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords); -GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w); -GLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords); -GLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); -GLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2); -GLAPI void APIENTRY glTexCoord1xOES (GLfixed s); -GLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords); -GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t); -GLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords); -GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r); -GLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords); -GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q); -GLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords); -GLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); -GLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glVertex2xOES (GLfixed x); -GLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords); -GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y); -GLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords); -GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z); -GLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords); -#endif -#endif /* GL_OES_fixed_point */ - -#ifndef GL_OES_query_matrix -#define GL_OES_query_matrix 1 -typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent); -#endif -#endif /* GL_OES_query_matrix */ - -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#endif /* GL_OES_read_format */ - -#ifndef GL_OES_single_precision -#define GL_OES_single_precision 1 -typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); -typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); -typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); -typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation); -typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClearDepthfOES (GLclampf depth); -GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); -GLAPI void APIENTRY glDepthRangefOES (GLclampf n, GLclampf f); -GLAPI void APIENTRY glFrustumfOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); -GLAPI void APIENTRY glOrthofOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -#endif -#endif /* GL_OES_single_precision */ - -#ifndef GL_3DFX_multisample -#define GL_3DFX_multisample 1 -#define GL_MULTISAMPLE_3DFX 0x86B2 -#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define GL_SAMPLES_3DFX 0x86B4 -#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 -#endif /* GL_3DFX_multisample */ - -#ifndef GL_3DFX_tbuffer -#define GL_3DFX_tbuffer 1 -typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); -#endif -#endif /* GL_3DFX_tbuffer */ - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_3DFX_texture_compression_FXT1 1 -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 -#endif /* GL_3DFX_texture_compression_FXT1 */ - -#ifndef GL_AMD_blend_minmax_factor -#define GL_AMD_blend_minmax_factor 1 -#define GL_FACTOR_MIN_AMD 0x901C -#define GL_FACTOR_MAX_AMD 0x901D -#endif /* GL_AMD_blend_minmax_factor */ - -#ifndef GL_AMD_conservative_depth -#define GL_AMD_conservative_depth 1 -#endif /* GL_AMD_conservative_depth */ - -#ifndef GL_AMD_debug_output -#define GL_AMD_debug_output 1 -typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); -#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 -#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 -#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 -#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A -#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B -#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C -#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D -#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E -#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F -#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 -typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, void *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); -#endif -#endif /* GL_AMD_debug_output */ - -#ifndef GL_AMD_depth_clamp_separate -#define GL_AMD_depth_clamp_separate 1 -#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E -#define GL_DEPTH_CLAMP_FAR_AMD 0x901F -#endif /* GL_AMD_depth_clamp_separate */ - -#ifndef GL_AMD_draw_buffers_blend -#define GL_AMD_draw_buffers_blend 1 -typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -#endif -#endif /* GL_AMD_draw_buffers_blend */ - -#ifndef GL_AMD_interleaved_elements -#define GL_AMD_interleaved_elements 1 -#define GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4 -#define GL_VERTEX_ID_SWIZZLE_AMD 0x91A5 -typedef void (APIENTRYP PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribParameteriAMD (GLuint index, GLenum pname, GLint param); -#endif -#endif /* GL_AMD_interleaved_elements */ - -#ifndef GL_AMD_multi_draw_indirect -#define GL_AMD_multi_draw_indirect 1 -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); -#endif -#endif /* GL_AMD_multi_draw_indirect */ - -#ifndef GL_AMD_name_gen_delete -#define GL_AMD_name_gen_delete 1 -#define GL_DATA_BUFFER_AMD 0x9151 -#define GL_PERFORMANCE_MONITOR_AMD 0x9152 -#define GL_QUERY_OBJECT_AMD 0x9153 -#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 -#define GL_SAMPLER_OBJECT_AMD 0x9155 -typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); -typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); -typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); -GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); -GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); -#endif -#endif /* GL_AMD_name_gen_delete */ - -#ifndef GL_AMD_occlusion_query_event -#define GL_AMD_occlusion_query_event 1 -#define GL_OCCLUSION_QUERY_EVENT_MASK_AMD 0x874F -#define GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD 0x00000001 -#define GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD 0x00000002 -#define GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD 0x00000004 -#define GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD 0x00000008 -#define GL_QUERY_ALL_EVENT_BITS_AMD 0xFFFFFFFF -typedef void (APIENTRYP PFNGLQUERYOBJECTPARAMETERUIAMDPROC) (GLenum target, GLuint id, GLenum pname, GLuint param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glQueryObjectParameteruiAMD (GLenum target, GLuint id, GLenum pname, GLuint param); -#endif -#endif /* GL_AMD_occlusion_query_event */ - -#ifndef GL_AMD_performance_monitor -#define GL_AMD_performance_monitor 1 -#define GL_COUNTER_TYPE_AMD 0x8BC0 -#define GL_COUNTER_RANGE_AMD 0x8BC1 -#define GL_UNSIGNED_INT64_AMD 0x8BC2 -#define GL_PERCENTAGE_AMD 0x8BC3 -#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 -#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 -#define GL_PERFMON_RESULT_AMD 0x8BC6 -typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); -typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); -typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); -typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); -GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); -GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); -GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); -GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); -GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); -GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif -#endif /* GL_AMD_performance_monitor */ - -#ifndef GL_AMD_pinned_memory -#define GL_AMD_pinned_memory 1 -#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 -#endif /* GL_AMD_pinned_memory */ - -#ifndef GL_AMD_query_buffer_object -#define GL_AMD_query_buffer_object 1 -#define GL_QUERY_BUFFER_AMD 0x9192 -#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 -#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 -#endif /* GL_AMD_query_buffer_object */ - -#ifndef GL_AMD_sample_positions -#define GL_AMD_sample_positions 1 -#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F -typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); -#endif -#endif /* GL_AMD_sample_positions */ - -#ifndef GL_AMD_seamless_cubemap_per_texture -#define GL_AMD_seamless_cubemap_per_texture 1 -#endif /* GL_AMD_seamless_cubemap_per_texture */ - -#ifndef GL_AMD_shader_atomic_counter_ops -#define GL_AMD_shader_atomic_counter_ops 1 -#endif /* GL_AMD_shader_atomic_counter_ops */ - -#ifndef GL_AMD_shader_stencil_export -#define GL_AMD_shader_stencil_export 1 -#endif /* GL_AMD_shader_stencil_export */ - -#ifndef GL_AMD_shader_trinary_minmax -#define GL_AMD_shader_trinary_minmax 1 -#endif /* GL_AMD_shader_trinary_minmax */ - -#ifndef GL_AMD_sparse_texture -#define GL_AMD_sparse_texture 1 -#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 -#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 -#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 -#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 -#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 -#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A -#define GL_MIN_SPARSE_LEVEL_AMD 0x919B -#define GL_MIN_LOD_WARNING_AMD 0x919C -#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 -typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); -typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); -GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); -#endif -#endif /* GL_AMD_sparse_texture */ - -#ifndef GL_AMD_stencil_operation_extended -#define GL_AMD_stencil_operation_extended 1 -#define GL_SET_AMD 0x874A -#define GL_REPLACE_VALUE_AMD 0x874B -#define GL_STENCIL_OP_VALUE_AMD 0x874C -#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D -typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); -#endif -#endif /* GL_AMD_stencil_operation_extended */ - -#ifndef GL_AMD_texture_texture4 -#define GL_AMD_texture_texture4 1 -#endif /* GL_AMD_texture_texture4 */ - -#ifndef GL_AMD_transform_feedback3_lines_triangles -#define GL_AMD_transform_feedback3_lines_triangles 1 -#endif /* GL_AMD_transform_feedback3_lines_triangles */ - -#ifndef GL_AMD_vertex_shader_layer -#define GL_AMD_vertex_shader_layer 1 -#endif /* GL_AMD_vertex_shader_layer */ - -#ifndef GL_AMD_vertex_shader_tessellator -#define GL_AMD_vertex_shader_tessellator 1 -#define GL_SAMPLER_BUFFER_AMD 0x9001 -#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 -#define GL_TESSELLATION_MODE_AMD 0x9004 -#define GL_TESSELLATION_FACTOR_AMD 0x9005 -#define GL_DISCRETE_AMD 0x9006 -#define GL_CONTINUOUS_AMD 0x9007 -typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); -GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); -#endif -#endif /* GL_AMD_vertex_shader_tessellator */ - -#ifndef GL_AMD_vertex_shader_viewport_index -#define GL_AMD_vertex_shader_viewport_index 1 -#endif /* GL_AMD_vertex_shader_viewport_index */ - -#ifndef GL_APPLE_aux_depth_stencil -#define GL_APPLE_aux_depth_stencil 1 -#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 -#endif /* GL_APPLE_aux_depth_stencil */ - -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#endif /* GL_APPLE_client_storage */ - -#ifndef GL_APPLE_element_array -#define GL_APPLE_element_array 1 -#define GL_ELEMENT_ARRAY_APPLE 0x8A0C -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E -typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const void *pointer); -GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); -GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#endif -#endif /* GL_APPLE_element_array */ - -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B -typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); -typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); -typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); -GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); -GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); -GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); -GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); -#endif -#endif /* GL_APPLE_fence */ - -#ifndef GL_APPLE_float_pixels -#define GL_APPLE_float_pixels 1 -#define GL_HALF_APPLE 0x140B -#define GL_RGBA_FLOAT32_APPLE 0x8814 -#define GL_RGB_FLOAT32_APPLE 0x8815 -#define GL_ALPHA_FLOAT32_APPLE 0x8816 -#define GL_INTENSITY_FLOAT32_APPLE 0x8817 -#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 -#define GL_RGBA_FLOAT16_APPLE 0x881A -#define GL_RGB_FLOAT16_APPLE 0x881B -#define GL_ALPHA_FLOAT16_APPLE 0x881C -#define GL_INTENSITY_FLOAT16_APPLE 0x881D -#define GL_LUMINANCE_FLOAT16_APPLE 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F -#define GL_COLOR_FLOAT_APPLE 0x8A0F -#endif /* GL_APPLE_float_pixels */ - -#ifndef GL_APPLE_flush_buffer_range -#define GL_APPLE_flush_buffer_range 1 -#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 -#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 -typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); -#endif -#endif /* GL_APPLE_flush_buffer_range */ - -#ifndef GL_APPLE_object_purgeable -#define GL_APPLE_object_purgeable 1 -#define GL_BUFFER_OBJECT_APPLE 0x85B3 -#define GL_RELEASED_APPLE 0x8A19 -#define GL_VOLATILE_APPLE 0x8A1A -#define GL_RETAINED_APPLE 0x8A1B -#define GL_UNDEFINED_APPLE 0x8A1C -#define GL_PURGEABLE_APPLE 0x8A1D -typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); -typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); -GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); -GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); -#endif -#endif /* GL_APPLE_object_purgeable */ - -#ifndef GL_APPLE_rgb_422 -#define GL_APPLE_rgb_422 1 -#define GL_RGB_422_APPLE 0x8A1F -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#define GL_RGB_RAW_422_APPLE 0x8A51 -#endif /* GL_APPLE_rgb_422 */ - -#ifndef GL_APPLE_row_bytes -#define GL_APPLE_row_bytes 1 -#define GL_PACK_ROW_BYTES_APPLE 0x8A15 -#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 -#endif /* GL_APPLE_row_bytes */ - -#ifndef GL_APPLE_specular_vector -#define GL_APPLE_specular_vector 1 -#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 -#endif /* GL_APPLE_specular_vector */ - -#ifndef GL_APPLE_texture_range -#define GL_APPLE_texture_range 1 -#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 -#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 -#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC -#define GL_STORAGE_PRIVATE_APPLE 0x85BD -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF -typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const void *pointer); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, void **params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const void *pointer); -GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, void **params); -#endif -#endif /* GL_APPLE_texture_range */ - -#ifndef GL_APPLE_transform_hint -#define GL_APPLE_transform_hint 1 -#define GL_TRANSFORM_HINT_APPLE 0x85B1 -#endif /* GL_APPLE_transform_hint */ - -#ifndef GL_APPLE_vertex_array_object -#define GL_APPLE_vertex_array_object 1 -#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); -GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); -GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); -GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); -#endif -#endif /* GL_APPLE_vertex_array_object */ - -#ifndef GL_APPLE_vertex_array_range -#define GL_APPLE_vertex_array_range 1 -#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E -#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F -#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define GL_STORAGE_CLIENT_APPLE 0x85B4 -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); -typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, void *pointer); -GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, void *pointer); -GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); -#endif -#endif /* GL_APPLE_vertex_array_range */ - -#ifndef GL_APPLE_vertex_program_evaluators -#define GL_APPLE_vertex_program_evaluators 1 -#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 -#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 -#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 -#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 -#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 -#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 -#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 -#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 -#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 -#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); -GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); -GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); -GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); -#endif -#endif /* GL_APPLE_vertex_program_evaluators */ - -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 -#define GL_YCBCR_422_APPLE 0x85B9 -#endif /* GL_APPLE_ycbcr_422 */ - -#ifndef GL_ATI_draw_buffers -#define GL_ATI_draw_buffers 1 -#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 -#define GL_DRAW_BUFFER0_ATI 0x8825 -#define GL_DRAW_BUFFER1_ATI 0x8826 -#define GL_DRAW_BUFFER2_ATI 0x8827 -#define GL_DRAW_BUFFER3_ATI 0x8828 -#define GL_DRAW_BUFFER4_ATI 0x8829 -#define GL_DRAW_BUFFER5_ATI 0x882A -#define GL_DRAW_BUFFER6_ATI 0x882B -#define GL_DRAW_BUFFER7_ATI 0x882C -#define GL_DRAW_BUFFER8_ATI 0x882D -#define GL_DRAW_BUFFER9_ATI 0x882E -#define GL_DRAW_BUFFER10_ATI 0x882F -#define GL_DRAW_BUFFER11_ATI 0x8830 -#define GL_DRAW_BUFFER12_ATI 0x8831 -#define GL_DRAW_BUFFER13_ATI 0x8832 -#define GL_DRAW_BUFFER14_ATI 0x8833 -#define GL_DRAW_BUFFER15_ATI 0x8834 -typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); -#endif -#endif /* GL_ATI_draw_buffers */ - -#ifndef GL_ATI_element_array -#define GL_ATI_element_array 1 -#define GL_ELEMENT_ARRAY_ATI 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A -typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerATI (GLenum type, const void *pointer); -GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); -GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); -#endif -#endif /* GL_ATI_element_array */ - -#ifndef GL_ATI_envmap_bumpmap -#define GL_ATI_envmap_bumpmap 1 -#define GL_BUMP_ROT_MATRIX_ATI 0x8775 -#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 -#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 -#define GL_BUMP_TEX_UNITS_ATI 0x8778 -#define GL_DUDV_ATI 0x8779 -#define GL_DU8DV8_ATI 0x877A -#define GL_BUMP_ENVMAP_ATI 0x877B -#define GL_BUMP_TARGET_ATI 0x877C -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); -GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); -GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); -GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); -#endif -#endif /* GL_ATI_envmap_bumpmap */ - -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader 1 -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_REG_6_ATI 0x8927 -#define GL_REG_7_ATI 0x8928 -#define GL_REG_8_ATI 0x8929 -#define GL_REG_9_ATI 0x892A -#define GL_REG_10_ATI 0x892B -#define GL_REG_11_ATI 0x892C -#define GL_REG_12_ATI 0x892D -#define GL_REG_13_ATI 0x892E -#define GL_REG_14_ATI 0x892F -#define GL_REG_15_ATI 0x8930 -#define GL_REG_16_ATI 0x8931 -#define GL_REG_17_ATI 0x8932 -#define GL_REG_18_ATI 0x8933 -#define GL_REG_19_ATI 0x8934 -#define GL_REG_20_ATI 0x8935 -#define GL_REG_21_ATI 0x8936 -#define GL_REG_22_ATI 0x8937 -#define GL_REG_23_ATI 0x8938 -#define GL_REG_24_ATI 0x8939 -#define GL_REG_25_ATI 0x893A -#define GL_REG_26_ATI 0x893B -#define GL_REG_27_ATI 0x893C -#define GL_REG_28_ATI 0x893D -#define GL_REG_29_ATI 0x893E -#define GL_REG_30_ATI 0x893F -#define GL_REG_31_ATI 0x8940 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_CON_8_ATI 0x8949 -#define GL_CON_9_ATI 0x894A -#define GL_CON_10_ATI 0x894B -#define GL_CON_11_ATI 0x894C -#define GL_CON_12_ATI 0x894D -#define GL_CON_13_ATI 0x894E -#define GL_CON_14_ATI 0x894F -#define GL_CON_15_ATI 0x8950 -#define GL_CON_16_ATI 0x8951 -#define GL_CON_17_ATI 0x8952 -#define GL_CON_18_ATI 0x8953 -#define GL_CON_19_ATI 0x8954 -#define GL_CON_20_ATI 0x8955 -#define GL_CON_21_ATI 0x8956 -#define GL_CON_22_ATI 0x8957 -#define GL_CON_23_ATI 0x8958 -#define GL_CON_24_ATI 0x8959 -#define GL_CON_25_ATI 0x895A -#define GL_CON_26_ATI 0x895B -#define GL_CON_27_ATI 0x895C -#define GL_CON_28_ATI 0x895D -#define GL_CON_29_ATI 0x895E -#define GL_CON_30_ATI 0x895F -#define GL_CON_31_ATI 0x8960 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E -#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F -#define GL_NUM_PASSES_ATI 0x8970 -#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 -#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 -#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 -#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 -#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_SWIZZLE_STRQ_ATI 0x897A -#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B -#define GL_RED_BIT_ATI 0x00000001 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); -typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); -GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); -GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); -GLAPI void APIENTRY glBeginFragmentShaderATI (void); -GLAPI void APIENTRY glEndFragmentShaderATI (void); -GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); -GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); -GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); -#endif -#endif /* GL_ATI_fragment_shader */ - -#ifndef GL_ATI_map_object_buffer -#define GL_ATI_map_object_buffer 1 -typedef void *(APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void *APIENTRY glMapObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); -#endif -#endif /* GL_ATI_map_object_buffer */ - -#ifndef GL_ATI_meminfo -#define GL_ATI_meminfo 1 -#define GL_VBO_FREE_MEMORY_ATI 0x87FB -#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC -#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD -#endif /* GL_ATI_meminfo */ - -#ifndef GL_ATI_pixel_format_float -#define GL_ATI_pixel_format_float 1 -#define GL_RGBA_FLOAT_MODE_ATI 0x8820 -#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 -#endif /* GL_ATI_pixel_format_float */ - -#ifndef GL_ATI_pn_triangles -#define GL_ATI_pn_triangles 1 -#define GL_PN_TRIANGLES_ATI 0x87F0 -#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 -#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 -#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 -#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 -#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 -#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 -#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 -#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 -typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); -GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); -#endif -#endif /* GL_ATI_pn_triangles */ - -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif -#endif /* GL_ATI_separate_stencil */ - -#ifndef GL_ATI_text_fragment_shader -#define GL_ATI_text_fragment_shader 1 -#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 -#endif /* GL_ATI_text_fragment_shader */ - -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 -#endif /* GL_ATI_texture_env_combine3 */ - -#ifndef GL_ATI_texture_float -#define GL_ATI_texture_float 1 -#define GL_RGBA_FLOAT32_ATI 0x8814 -#define GL_RGB_FLOAT32_ATI 0x8815 -#define GL_ALPHA_FLOAT32_ATI 0x8816 -#define GL_INTENSITY_FLOAT32_ATI 0x8817 -#define GL_LUMINANCE_FLOAT32_ATI 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 -#define GL_RGBA_FLOAT16_ATI 0x881A -#define GL_RGB_FLOAT16_ATI 0x881B -#define GL_ALPHA_FLOAT16_ATI 0x881C -#define GL_INTENSITY_FLOAT16_ATI 0x881D -#define GL_LUMINANCE_FLOAT16_ATI 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F -#endif /* GL_ATI_texture_float */ - -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 -#endif /* GL_ATI_texture_mirror_once */ - -#ifndef GL_ATI_vertex_array_object -#define GL_ATI_vertex_array_object 1 -#define GL_STATIC_ATI 0x8760 -#define GL_DYNAMIC_ATI 0x8761 -#define GL_PRESERVE_ATI 0x8762 -#define GL_DISCARD_ATI 0x8763 -#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 -#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 -#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 -#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 -typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void *pointer, GLenum usage); -typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const void *pointer, GLenum usage); -GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); -GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); -GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); -#endif -#endif /* GL_ATI_vertex_array_object */ - -#ifndef GL_ATI_vertex_attrib_array_object -#define GL_ATI_vertex_attrib_array_object 1 -typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); -#endif -#endif /* GL_ATI_vertex_attrib_array_object */ - -#ifndef GL_ATI_vertex_streams -#define GL_ATI_vertex_streams 1 -#define GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define GL_VERTEX_STREAM0_ATI 0x876C -#define GL_VERTEX_STREAM1_ATI 0x876D -#define GL_VERTEX_STREAM2_ATI 0x876E -#define GL_VERTEX_STREAM3_ATI 0x876F -#define GL_VERTEX_STREAM4_ATI 0x8770 -#define GL_VERTEX_STREAM5_ATI 0x8771 -#define GL_VERTEX_STREAM6_ATI 0x8772 -#define GL_VERTEX_STREAM7_ATI 0x8773 -#define GL_VERTEX_SOURCE_ATI 0x8774 -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); -GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); -GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); -GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); -GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); -GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); -GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); -GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); -GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); -GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); -#endif -#endif /* GL_ATI_vertex_streams */ - -#ifndef GL_EXT_422_pixels -#define GL_EXT_422_pixels 1 -#define GL_422_EXT 0x80CC -#define GL_422_REV_EXT 0x80CD -#define GL_422_AVERAGE_EXT 0x80CE -#define GL_422_REV_AVERAGE_EXT 0x80CF -#endif /* GL_EXT_422_pixels */ - -#ifndef GL_EXT_abgr -#define GL_EXT_abgr 1 -#define GL_ABGR_EXT 0x8000 -#endif /* GL_EXT_abgr */ - -#ifndef GL_EXT_bgra -#define GL_EXT_bgra 1 -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 -#endif /* GL_EXT_bgra */ - -#ifndef GL_EXT_bindable_uniform -#define GL_EXT_bindable_uniform 1 -#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 -#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 -#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 -#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED -#define GL_UNIFORM_BUFFER_EXT 0x8DEE -#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF -typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); -typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); -typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); -GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); -GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); -#endif -#endif /* GL_EXT_bindable_uniform */ - -#ifndef GL_EXT_blend_color -#define GL_EXT_blend_color 1 -#define GL_CONSTANT_COLOR_EXT 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define GL_CONSTANT_ALPHA_EXT 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define GL_BLEND_COLOR_EXT 0x8005 -typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -#endif -#endif /* GL_EXT_blend_color */ - -#ifndef GL_EXT_blend_equation_separate -#define GL_EXT_blend_equation_separate 1 -#define GL_BLEND_EQUATION_RGB_EXT 0x8009 -#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); -#endif -#endif /* GL_EXT_blend_equation_separate */ - -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif -#endif /* GL_EXT_blend_func_separate */ - -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 -#endif /* GL_EXT_blend_logic_op */ - -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_BLEND_EQUATION_EXT 0x8009 -typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); -#endif -#endif /* GL_EXT_blend_minmax */ - -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B -#endif /* GL_EXT_blend_subtract */ - -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 -#endif /* GL_EXT_clip_volume_hint */ - -#ifndef GL_EXT_cmyka -#define GL_EXT_cmyka 1 -#define GL_CMYK_EXT 0x800C -#define GL_CMYKA_EXT 0x800D -#define GL_PACK_CMYK_HINT_EXT 0x800E -#define GL_UNPACK_CMYK_HINT_EXT 0x800F -#endif /* GL_EXT_cmyka */ - -#ifndef GL_EXT_color_subtable -#define GL_EXT_color_subtable 1 -typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif -#endif /* GL_EXT_color_subtable */ - -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 -typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); -GLAPI void APIENTRY glUnlockArraysEXT (void); -#endif -#endif /* GL_EXT_compiled_vertex_array */ - -#ifndef GL_EXT_convolution -#define GL_EXT_convolution 1 -#define GL_CONVOLUTION_1D_EXT 0x8010 -#define GL_CONVOLUTION_2D_EXT 0x8011 -#define GL_SEPARABLE_2D_EXT 0x8012 -#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 -#define GL_REDUCE_EXT 0x8016 -#define GL_CONVOLUTION_FORMAT_EXT 0x8017 -#define GL_CONVOLUTION_WIDTH_EXT 0x8018 -#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); -GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); -GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); -GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); -GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, void *image); -GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); -GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); -#endif -#endif /* GL_EXT_convolution */ - -#ifndef GL_EXT_coordinate_frame -#define GL_EXT_coordinate_frame 1 -#define GL_TANGENT_ARRAY_EXT 0x8439 -#define GL_BINORMAL_ARRAY_EXT 0x843A -#define GL_CURRENT_TANGENT_EXT 0x843B -#define GL_CURRENT_BINORMAL_EXT 0x843C -#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E -#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F -#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 -#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 -#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 -#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 -#define GL_MAP1_TANGENT_EXT 0x8444 -#define GL_MAP2_TANGENT_EXT 0x8445 -#define GL_MAP1_BINORMAL_EXT 0x8446 -#define GL_MAP2_BINORMAL_EXT 0x8447 -typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); -typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); -typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); -typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); -typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); -typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); -typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); -typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); -typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); -typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); -typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); -GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); -GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); -GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); -GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); -GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); -GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); -GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); -GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); -GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); -GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); -GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); -GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); -GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); -GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const void *pointer); -#endif -#endif /* GL_EXT_coordinate_frame */ - -#ifndef GL_EXT_copy_texture -#define GL_EXT_copy_texture 1 -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif -#endif /* GL_EXT_copy_texture */ - -#ifndef GL_EXT_cull_vertex -#define GL_EXT_cull_vertex 1 -#define GL_CULL_VERTEX_EXT 0x81AA -#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB -#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC -typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); -GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); -#endif -#endif /* GL_EXT_cull_vertex */ - -#ifndef GL_EXT_debug_label -#define GL_EXT_debug_label 1 -#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F -#define GL_PROGRAM_OBJECT_EXT 0x8B40 -#define GL_SHADER_OBJECT_EXT 0x8B48 -#define GL_BUFFER_OBJECT_EXT 0x9151 -#define GL_QUERY_OBJECT_EXT 0x9153 -#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 -typedef void (APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); -typedef void (APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); -GLAPI void APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); -#endif -#endif /* GL_EXT_debug_label */ - -#ifndef GL_EXT_debug_marker -#define GL_EXT_debug_marker 1 -typedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); -typedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); -typedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); -GLAPI void APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); -GLAPI void APIENTRY glPopGroupMarkerEXT (void); -#endif -#endif /* GL_EXT_debug_marker */ - -#ifndef GL_EXT_depth_bounds_test -#define GL_EXT_depth_bounds_test 1 -#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define GL_DEPTH_BOUNDS_EXT 0x8891 -typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); -#endif -#endif /* GL_EXT_depth_bounds_test */ - -#ifndef GL_EXT_direct_state_access -#define GL_EXT_direct_state_access 1 -#define GL_PROGRAM_MATRIX_EXT 0x8E2D -#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E -#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F -typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); -typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); -typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); -typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); -typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void **data); -typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, void *img); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, void *img); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); -typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); -typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void **params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); -typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); -typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); -typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); -typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); -typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); -typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void **param); -typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param); -typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); -typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); -typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); -GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); -GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); -GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); -GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); -GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); -GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); -GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); -GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); -GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); -GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); -GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); -GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); -GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); -GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, void **data); -GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); -GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); -GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); -GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); -GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); -GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, void *img); -GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, void *img); -GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); -GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); -GLAPI void *APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); -GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); -GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, void **params); -GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); -GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); -GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); -GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); -GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); -GLAPI void APIENTRY glEnableClientStateiEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glDisableClientStateiEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glGetFloati_vEXT (GLenum pname, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetDoublei_vEXT (GLenum pname, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetPointeri_vEXT (GLenum pname, GLuint index, void **params); -GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); -GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, void *string); -GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); -GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); -GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); -GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); -GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); -GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); -GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); -GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glVertexArrayVertexOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayEdgeFlagOffsetEXT (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayIndexOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayNormalOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayMultiTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayFogCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArraySecondaryColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayVertexAttribOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayVertexAttribIOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glEnableVertexArrayEXT (GLuint vaobj, GLenum array); -GLAPI void APIENTRY glDisableVertexArrayEXT (GLuint vaobj, GLenum array); -GLAPI void APIENTRY glEnableVertexArrayAttribEXT (GLuint vaobj, GLuint index); -GLAPI void APIENTRY glDisableVertexArrayAttribEXT (GLuint vaobj, GLuint index); -GLAPI void APIENTRY glGetVertexArrayIntegervEXT (GLuint vaobj, GLenum pname, GLint *param); -GLAPI void APIENTRY glGetVertexArrayPointervEXT (GLuint vaobj, GLenum pname, void **param); -GLAPI void APIENTRY glGetVertexArrayIntegeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLint *param); -GLAPI void APIENTRY glGetVertexArrayPointeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, void **param); -GLAPI void *APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); -GLAPI void APIENTRY glNamedBufferStorageEXT (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); -GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); -GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); -GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); -GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); -GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); -GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glTexturePageCommitmentEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); -GLAPI void APIENTRY glVertexArrayVertexAttribDivisorEXT (GLuint vaobj, GLuint index, GLuint divisor); -#endif -#endif /* GL_EXT_direct_state_access */ - -#ifndef GL_EXT_draw_buffers2 -#define GL_EXT_draw_buffers2 1 -typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -#endif -#endif /* GL_EXT_draw_buffers2 */ - -#ifndef GL_EXT_draw_instanced -#define GL_EXT_draw_instanced 1 -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); -#endif -#endif /* GL_EXT_draw_instanced */ - -#ifndef GL_EXT_draw_range_elements -#define GL_EXT_draw_range_elements 1 -#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 -#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); -#endif -#endif /* GL_EXT_draw_range_elements */ - -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 -typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); -GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); -GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); -GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); -GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const void *pointer); -#endif -#endif /* GL_EXT_fog_coord */ - -#ifndef GL_EXT_framebuffer_blit -#define GL_EXT_framebuffer_blit 1 -#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif -#endif /* GL_EXT_framebuffer_blit */ - -#ifndef GL_EXT_framebuffer_multisample -#define GL_EXT_framebuffer_multisample 1 -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define GL_MAX_SAMPLES_EXT 0x8D57 -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif -#endif /* GL_EXT_framebuffer_multisample */ - -#ifndef GL_EXT_framebuffer_multisample_blit_scaled -#define GL_EXT_framebuffer_multisample_blit_scaled 1 -#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA -#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB -#endif /* GL_EXT_framebuffer_multisample_blit_scaled */ - -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); -GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); -GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); -GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); -GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); -GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); -GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); -GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); -GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); -#endif -#endif /* GL_EXT_framebuffer_object */ - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_EXT_framebuffer_sRGB 1 -#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 -#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA -#endif /* GL_EXT_framebuffer_sRGB */ - -#ifndef GL_EXT_geometry_shader4 -#define GL_EXT_geometry_shader4 1 -#define GL_GEOMETRY_SHADER_EXT 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE -#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 -#define GL_LINES_ADJACENCY_EXT 0x000A -#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B -#define GL_TRIANGLES_ADJACENCY_EXT 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 -#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); -#endif -#endif /* GL_EXT_geometry_shader4 */ - -#ifndef GL_EXT_gpu_program_parameters -#define GL_EXT_gpu_program_parameters 1 -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -#endif -#endif /* GL_EXT_gpu_program_parameters */ - -#ifndef GL_EXT_gpu_shader4 -#define GL_EXT_gpu_shader4 1 -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD -#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 -#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 -#define GL_SAMPLER_BUFFER_EXT 0x8DC2 -#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 -#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 -#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 -#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 -#define GL_INT_SAMPLER_1D_EXT 0x8DC9 -#define GL_INT_SAMPLER_2D_EXT 0x8DCA -#define GL_INT_SAMPLER_3D_EXT 0x8DCB -#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC -#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD -#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF -#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 -#define GL_MIN_PROGRAM_TEXEL_OFFSET_EXT 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET_EXT 0x8905 -typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); -GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); -GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); -GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); -#endif -#endif /* GL_EXT_gpu_shader4 */ - -#ifndef GL_EXT_histogram -#define GL_EXT_histogram 1 -#define GL_HISTOGRAM_EXT 0x8024 -#define GL_PROXY_HISTOGRAM_EXT 0x8025 -#define GL_HISTOGRAM_WIDTH_EXT 0x8026 -#define GL_HISTOGRAM_FORMAT_EXT 0x8027 -#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C -#define GL_HISTOGRAM_SINK_EXT 0x802D -#define GL_MINMAX_EXT 0x802E -#define GL_MINMAX_FORMAT_EXT 0x802F -#define GL_MINMAX_SINK_EXT 0x8030 -#define GL_TABLE_TOO_LARGE_EXT 0x8031 -typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glResetHistogramEXT (GLenum target); -GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); -#endif -#endif /* GL_EXT_histogram */ - -#ifndef GL_EXT_index_array_formats -#define GL_EXT_index_array_formats 1 -#define GL_IUI_V2F_EXT 0x81AD -#define GL_IUI_V3F_EXT 0x81AE -#define GL_IUI_N3F_V2F_EXT 0x81AF -#define GL_IUI_N3F_V3F_EXT 0x81B0 -#define GL_T2F_IUI_V2F_EXT 0x81B1 -#define GL_T2F_IUI_V3F_EXT 0x81B2 -#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 -#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 -#endif /* GL_EXT_index_array_formats */ - -#ifndef GL_EXT_index_func -#define GL_EXT_index_func 1 -#define GL_INDEX_TEST_EXT 0x81B5 -#define GL_INDEX_TEST_FUNC_EXT 0x81B6 -#define GL_INDEX_TEST_REF_EXT 0x81B7 -typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); -#endif -#endif /* GL_EXT_index_func */ - -#ifndef GL_EXT_index_material -#define GL_EXT_index_material 1 -#define GL_INDEX_MATERIAL_EXT 0x81B8 -#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 -#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA -typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); -#endif -#endif /* GL_EXT_index_material */ - -#ifndef GL_EXT_index_texture -#define GL_EXT_index_texture 1 -#endif /* GL_EXT_index_texture */ - -#ifndef GL_EXT_light_texture -#define GL_EXT_light_texture 1 -#define GL_FRAGMENT_MATERIAL_EXT 0x8349 -#define GL_FRAGMENT_NORMAL_EXT 0x834A -#define GL_FRAGMENT_COLOR_EXT 0x834C -#define GL_ATTENUATION_EXT 0x834D -#define GL_SHADOW_ATTENUATION_EXT 0x834E -#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F -#define GL_TEXTURE_LIGHT_EXT 0x8350 -#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 -#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 -typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); -GLAPI void APIENTRY glTextureLightEXT (GLenum pname); -GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); -#endif -#endif /* GL_EXT_light_texture */ - -#ifndef GL_EXT_misc_attribute -#define GL_EXT_misc_attribute 1 -#endif /* GL_EXT_misc_attribute */ - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); -#endif -#endif /* GL_EXT_multi_draw_arrays */ - -#ifndef GL_EXT_multisample -#define GL_EXT_multisample 1 -#define GL_MULTISAMPLE_EXT 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#define GL_SAMPLE_MASK_EXT 0x80A0 -#define GL_1PASS_EXT 0x80A1 -#define GL_2PASS_0_EXT 0x80A2 -#define GL_2PASS_1_EXT 0x80A3 -#define GL_4PASS_0_EXT 0x80A4 -#define GL_4PASS_1_EXT 0x80A5 -#define GL_4PASS_2_EXT 0x80A6 -#define GL_4PASS_3_EXT 0x80A7 -#define GL_SAMPLE_BUFFERS_EXT 0x80A8 -#define GL_SAMPLES_EXT 0x80A9 -#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA -#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB -#define GL_SAMPLE_PATTERN_EXT 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 -typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); -GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); -#endif -#endif /* GL_EXT_multisample */ - -#ifndef GL_EXT_packed_depth_stencil -#define GL_EXT_packed_depth_stencil 1 -#define GL_DEPTH_STENCIL_EXT 0x84F9 -#define GL_UNSIGNED_INT_24_8_EXT 0x84FA -#define GL_DEPTH24_STENCIL8_EXT 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 -#endif /* GL_EXT_packed_depth_stencil */ - -#ifndef GL_EXT_packed_float -#define GL_EXT_packed_float 1 -#define GL_R11F_G11F_B10F_EXT 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B -#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C -#endif /* GL_EXT_packed_float */ - -#ifndef GL_EXT_packed_pixels -#define GL_EXT_packed_pixels 1 -#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 -#endif /* GL_EXT_packed_pixels */ - -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void *data); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); -GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, void *data); -GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -#endif -#endif /* GL_EXT_paletted_texture */ - -#ifndef GL_EXT_pixel_buffer_object -#define GL_EXT_pixel_buffer_object 1 -#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF -#endif /* GL_EXT_pixel_buffer_object */ - -#ifndef GL_EXT_pixel_transform -#define GL_EXT_pixel_transform 1 -#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 -#define GL_PIXEL_MAG_FILTER_EXT 0x8331 -#define GL_PIXEL_MIN_FILTER_EXT 0x8332 -#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 -#define GL_CUBIC_EXT 0x8334 -#define GL_AVERAGE_EXT 0x8335 -#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 -#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 -#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -#endif -#endif /* GL_EXT_pixel_transform */ - -#ifndef GL_EXT_pixel_transform_color_table -#define GL_EXT_pixel_transform_color_table 1 -#endif /* GL_EXT_pixel_transform_color_table */ - -#ifndef GL_EXT_point_parameters -#define GL_EXT_point_parameters 1 -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 -typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); -#endif -#endif /* GL_EXT_point_parameters */ - -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 -typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); -#endif -#endif /* GL_EXT_polygon_offset */ - -#ifndef GL_EXT_provoking_vertex -#define GL_EXT_provoking_vertex 1 -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D -#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E -#define GL_PROVOKING_VERTEX_EXT 0x8E4F -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); -#endif -#endif /* GL_EXT_provoking_vertex */ - -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 -#define GL_RESCALE_NORMAL_EXT 0x803A -#endif /* GL_EXT_rescale_normal */ - -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); -GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); -GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); -GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); -GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); -GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); -GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); -GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); -GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); -GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); -GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); -GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); -GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); -GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); -#endif -#endif /* GL_EXT_secondary_color */ - -#ifndef GL_EXT_separate_shader_objects -#define GL_EXT_separate_shader_objects 1 -#define GL_ACTIVE_PROGRAM_EXT 0x8B8D -typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); -typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); -GLAPI void APIENTRY glActiveProgramEXT (GLuint program); -GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); -#endif -#endif /* GL_EXT_separate_shader_objects */ - -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#endif /* GL_EXT_separate_specular_color */ - -#ifndef GL_EXT_shader_image_load_store -#define GL_EXT_shader_image_load_store 1 -#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 -#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 -#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A -#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B -#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C -#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D -#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E -#define GL_IMAGE_1D_EXT 0x904C -#define GL_IMAGE_2D_EXT 0x904D -#define GL_IMAGE_3D_EXT 0x904E -#define GL_IMAGE_2D_RECT_EXT 0x904F -#define GL_IMAGE_CUBE_EXT 0x9050 -#define GL_IMAGE_BUFFER_EXT 0x9051 -#define GL_IMAGE_1D_ARRAY_EXT 0x9052 -#define GL_IMAGE_2D_ARRAY_EXT 0x9053 -#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 -#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 -#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 -#define GL_INT_IMAGE_1D_EXT 0x9057 -#define GL_INT_IMAGE_2D_EXT 0x9058 -#define GL_INT_IMAGE_3D_EXT 0x9059 -#define GL_INT_IMAGE_2D_RECT_EXT 0x905A -#define GL_INT_IMAGE_CUBE_EXT 0x905B -#define GL_INT_IMAGE_BUFFER_EXT 0x905C -#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D -#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E -#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F -#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 -#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 -#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 -#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 -#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 -#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 -#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 -#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C -#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D -#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E -#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 -#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 -#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 -#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 -#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 -#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 -#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 -#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 -#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 -#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 -#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 -#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 -#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF -typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); -typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); -GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); -#endif -#endif /* GL_EXT_shader_image_load_store */ - -#ifndef GL_EXT_shader_integer_mix -#define GL_EXT_shader_integer_mix 1 -#endif /* GL_EXT_shader_integer_mix */ - -#ifndef GL_EXT_shadow_funcs -#define GL_EXT_shadow_funcs 1 -#endif /* GL_EXT_shadow_funcs */ - -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB -#endif /* GL_EXT_shared_texture_palette */ - -#ifndef GL_EXT_stencil_clear_tag -#define GL_EXT_stencil_clear_tag 1 -#define GL_STENCIL_TAG_BITS_EXT 0x88F2 -#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 -typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); -#endif -#endif /* GL_EXT_stencil_clear_tag */ - -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 -typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); -#endif -#endif /* GL_EXT_stencil_two_side */ - -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 -#endif /* GL_EXT_stencil_wrap */ - -#ifndef GL_EXT_subtexture -#define GL_EXT_subtexture 1 -typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -#endif -#endif /* GL_EXT_subtexture */ - -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 -#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 -#endif /* GL_EXT_texture */ - -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 -typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -#endif -#endif /* GL_EXT_texture3D */ - -#ifndef GL_EXT_texture_array -#define GL_EXT_texture_array 1 -#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 -#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D -#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF -#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E -#endif /* GL_EXT_texture_array */ - -#ifndef GL_EXT_texture_buffer_object -#define GL_EXT_texture_buffer_object 1 -#define GL_TEXTURE_BUFFER_EXT 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E -typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); -#endif -#endif /* GL_EXT_texture_buffer_object */ - -#ifndef GL_EXT_texture_compression_latc -#define GL_EXT_texture_compression_latc 1 -#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 -#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 -#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 -#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 -#endif /* GL_EXT_texture_compression_latc */ - -#ifndef GL_EXT_texture_compression_rgtc -#define GL_EXT_texture_compression_rgtc 1 -#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC -#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD -#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE -#endif /* GL_EXT_texture_compression_rgtc */ - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_EXT_texture_compression_s3tc 1 -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#endif /* GL_EXT_texture_compression_s3tc */ - -#ifndef GL_EXT_texture_cube_map -#define GL_EXT_texture_cube_map 1 -#define GL_NORMAL_MAP_EXT 0x8511 -#define GL_REFLECTION_MAP_EXT 0x8512 -#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C -#endif /* GL_EXT_texture_cube_map */ - -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 -#endif /* GL_EXT_texture_env_add */ - -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A -#endif /* GL_EXT_texture_env_combine */ - -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif /* GL_EXT_texture_env_dot3 */ - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif /* GL_EXT_texture_filter_anisotropic */ - -#ifndef GL_EXT_texture_integer -#define GL_EXT_texture_integer 1 -#define GL_RGBA32UI_EXT 0x8D70 -#define GL_RGB32UI_EXT 0x8D71 -#define GL_ALPHA32UI_EXT 0x8D72 -#define GL_INTENSITY32UI_EXT 0x8D73 -#define GL_LUMINANCE32UI_EXT 0x8D74 -#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 -#define GL_RGBA16UI_EXT 0x8D76 -#define GL_RGB16UI_EXT 0x8D77 -#define GL_ALPHA16UI_EXT 0x8D78 -#define GL_INTENSITY16UI_EXT 0x8D79 -#define GL_LUMINANCE16UI_EXT 0x8D7A -#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B -#define GL_RGBA8UI_EXT 0x8D7C -#define GL_RGB8UI_EXT 0x8D7D -#define GL_ALPHA8UI_EXT 0x8D7E -#define GL_INTENSITY8UI_EXT 0x8D7F -#define GL_LUMINANCE8UI_EXT 0x8D80 -#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 -#define GL_RGBA32I_EXT 0x8D82 -#define GL_RGB32I_EXT 0x8D83 -#define GL_ALPHA32I_EXT 0x8D84 -#define GL_INTENSITY32I_EXT 0x8D85 -#define GL_LUMINANCE32I_EXT 0x8D86 -#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 -#define GL_RGBA16I_EXT 0x8D88 -#define GL_RGB16I_EXT 0x8D89 -#define GL_ALPHA16I_EXT 0x8D8A -#define GL_INTENSITY16I_EXT 0x8D8B -#define GL_LUMINANCE16I_EXT 0x8D8C -#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D -#define GL_RGBA8I_EXT 0x8D8E -#define GL_RGB8I_EXT 0x8D8F -#define GL_ALPHA8I_EXT 0x8D90 -#define GL_INTENSITY8I_EXT 0x8D91 -#define GL_LUMINANCE8I_EXT 0x8D92 -#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 -#define GL_RED_INTEGER_EXT 0x8D94 -#define GL_GREEN_INTEGER_EXT 0x8D95 -#define GL_BLUE_INTEGER_EXT 0x8D96 -#define GL_ALPHA_INTEGER_EXT 0x8D97 -#define GL_RGB_INTEGER_EXT 0x8D98 -#define GL_RGBA_INTEGER_EXT 0x8D99 -#define GL_BGR_INTEGER_EXT 0x8D9A -#define GL_BGRA_INTEGER_EXT 0x8D9B -#define GL_LUMINANCE_INTEGER_EXT 0x8D9C -#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D -#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); -typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); -GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); -#endif -#endif /* GL_EXT_texture_integer */ - -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#endif /* GL_EXT_texture_lod_bias */ - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_EXT_texture_mirror_clamp 1 -#define GL_MIRROR_CLAMP_EXT 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 -#endif /* GL_EXT_texture_mirror_clamp */ - -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 -#define GL_TEXTURE_PRIORITY_EXT 0x8066 -#define GL_TEXTURE_RESIDENT_EXT 0x8067 -#define GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define GL_TEXTURE_2D_BINDING_EXT 0x8069 -#define GL_TEXTURE_3D_BINDING_EXT 0x806A -typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); -GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); -GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); -GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); -GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); -GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif -#endif /* GL_EXT_texture_object */ - -#ifndef GL_EXT_texture_perturb_normal -#define GL_EXT_texture_perturb_normal 1 -#define GL_PERTURB_EXT 0x85AE -#define GL_TEXTURE_NORMAL_EXT 0x85AF -typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); -#endif -#endif /* GL_EXT_texture_perturb_normal */ - -#ifndef GL_EXT_texture_sRGB -#define GL_EXT_texture_sRGB 1 -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB8_EXT 0x8C41 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define GL_SLUMINANCE_EXT 0x8C46 -#define GL_SLUMINANCE8_EXT 0x8C47 -#define GL_COMPRESSED_SRGB_EXT 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F -#endif /* GL_EXT_texture_sRGB */ - -#ifndef GL_EXT_texture_sRGB_decode -#define GL_EXT_texture_sRGB_decode 1 -#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 -#define GL_DECODE_EXT 0x8A49 -#define GL_SKIP_DECODE_EXT 0x8A4A -#endif /* GL_EXT_texture_sRGB_decode */ - -#ifndef GL_EXT_texture_shared_exponent -#define GL_EXT_texture_shared_exponent 1 -#define GL_RGB9_E5_EXT 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E -#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F -#endif /* GL_EXT_texture_shared_exponent */ - -#ifndef GL_EXT_texture_snorm -#define GL_EXT_texture_snorm 1 -#define GL_ALPHA_SNORM 0x9010 -#define GL_LUMINANCE_SNORM 0x9011 -#define GL_LUMINANCE_ALPHA_SNORM 0x9012 -#define GL_INTENSITY_SNORM 0x9013 -#define GL_ALPHA8_SNORM 0x9014 -#define GL_LUMINANCE8_SNORM 0x9015 -#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 -#define GL_INTENSITY8_SNORM 0x9017 -#define GL_ALPHA16_SNORM 0x9018 -#define GL_LUMINANCE16_SNORM 0x9019 -#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A -#define GL_INTENSITY16_SNORM 0x901B -#define GL_RED_SNORM 0x8F90 -#define GL_RG_SNORM 0x8F91 -#define GL_RGB_SNORM 0x8F92 -#define GL_RGBA_SNORM 0x8F93 -#endif /* GL_EXT_texture_snorm */ - -#ifndef GL_EXT_texture_swizzle -#define GL_EXT_texture_swizzle 1 -#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 -#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 -#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 -#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 -#endif /* GL_EXT_texture_swizzle */ - -#ifndef GL_EXT_timer_query -#define GL_EXT_timer_query 1 -#define GL_TIME_ELAPSED_EXT 0x88BF -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); -#endif -#endif /* GL_EXT_timer_query */ - -#ifndef GL_EXT_transform_feedback -#define GL_EXT_transform_feedback 1 -#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F -#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C -#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D -#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 -#define GL_RASTERIZER_DISCARD_EXT 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedbackEXT (void); -GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); -GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -#endif -#endif /* GL_EXT_transform_feedback */ - -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 -typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); -typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, void **params); -typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glArrayElementEXT (GLint i); -GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); -GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); -GLAPI void APIENTRY glGetPointervEXT (GLenum pname, void **params); -GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); -GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); -GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -#endif -#endif /* GL_EXT_vertex_array */ - -#ifndef GL_EXT_vertex_array_bgra -#define GL_EXT_vertex_array_bgra 1 -#endif /* GL_EXT_vertex_array_bgra */ - -#ifndef GL_EXT_vertex_attrib_64bit -#define GL_EXT_vertex_attrib_64bit 1 -#define GL_DOUBLE_VEC2_EXT 0x8FFC -#define GL_DOUBLE_VEC3_EXT 0x8FFD -#define GL_DOUBLE_VEC4_EXT 0x8FFE -#define GL_DOUBLE_MAT2_EXT 0x8F46 -#define GL_DOUBLE_MAT3_EXT 0x8F47 -#define GL_DOUBLE_MAT4_EXT 0x8F48 -#define GL_DOUBLE_MAT2x3_EXT 0x8F49 -#define GL_DOUBLE_MAT2x4_EXT 0x8F4A -#define GL_DOUBLE_MAT3x2_EXT 0x8F4B -#define GL_DOUBLE_MAT3x4_EXT 0x8F4C -#define GL_DOUBLE_MAT4x2_EXT 0x8F4D -#define GL_DOUBLE_MAT4x3_EXT 0x8F4E -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); -#endif -#endif /* GL_EXT_vertex_attrib_64bit */ - -#ifndef GL_EXT_vertex_shader -#define GL_EXT_vertex_shader 1 -#define GL_VERTEX_SHADER_EXT 0x8780 -#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 -#define GL_OP_INDEX_EXT 0x8782 -#define GL_OP_NEGATE_EXT 0x8783 -#define GL_OP_DOT3_EXT 0x8784 -#define GL_OP_DOT4_EXT 0x8785 -#define GL_OP_MUL_EXT 0x8786 -#define GL_OP_ADD_EXT 0x8787 -#define GL_OP_MADD_EXT 0x8788 -#define GL_OP_FRAC_EXT 0x8789 -#define GL_OP_MAX_EXT 0x878A -#define GL_OP_MIN_EXT 0x878B -#define GL_OP_SET_GE_EXT 0x878C -#define GL_OP_SET_LT_EXT 0x878D -#define GL_OP_CLAMP_EXT 0x878E -#define GL_OP_FLOOR_EXT 0x878F -#define GL_OP_ROUND_EXT 0x8790 -#define GL_OP_EXP_BASE_2_EXT 0x8791 -#define GL_OP_LOG_BASE_2_EXT 0x8792 -#define GL_OP_POWER_EXT 0x8793 -#define GL_OP_RECIP_EXT 0x8794 -#define GL_OP_RECIP_SQRT_EXT 0x8795 -#define GL_OP_SUB_EXT 0x8796 -#define GL_OP_CROSS_PRODUCT_EXT 0x8797 -#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 -#define GL_OP_MOV_EXT 0x8799 -#define GL_OUTPUT_VERTEX_EXT 0x879A -#define GL_OUTPUT_COLOR0_EXT 0x879B -#define GL_OUTPUT_COLOR1_EXT 0x879C -#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D -#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E -#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F -#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 -#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 -#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 -#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 -#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 -#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 -#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 -#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 -#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 -#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 -#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA -#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB -#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC -#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD -#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE -#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF -#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 -#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 -#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 -#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 -#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 -#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 -#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 -#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 -#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 -#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 -#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA -#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB -#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC -#define GL_OUTPUT_FOG_EXT 0x87BD -#define GL_SCALAR_EXT 0x87BE -#define GL_VECTOR_EXT 0x87BF -#define GL_MATRIX_EXT 0x87C0 -#define GL_VARIANT_EXT 0x87C1 -#define GL_INVARIANT_EXT 0x87C2 -#define GL_LOCAL_CONSTANT_EXT 0x87C3 -#define GL_LOCAL_EXT 0x87C4 -#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 -#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 -#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 -#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 -#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE -#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF -#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 -#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 -#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 -#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 -#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 -#define GL_X_EXT 0x87D5 -#define GL_Y_EXT 0x87D6 -#define GL_Z_EXT 0x87D7 -#define GL_W_EXT 0x87D8 -#define GL_NEGATIVE_X_EXT 0x87D9 -#define GL_NEGATIVE_Y_EXT 0x87DA -#define GL_NEGATIVE_Z_EXT 0x87DB -#define GL_NEGATIVE_W_EXT 0x87DC -#define GL_ZERO_EXT 0x87DD -#define GL_ONE_EXT 0x87DE -#define GL_NEGATIVE_ONE_EXT 0x87DF -#define GL_NORMALIZED_RANGE_EXT 0x87E0 -#define GL_FULL_RANGE_EXT 0x87E1 -#define GL_CURRENT_VERTEX_EXT 0x87E2 -#define GL_MVP_MATRIX_EXT 0x87E3 -#define GL_VARIANT_VALUE_EXT 0x87E4 -#define GL_VARIANT_DATATYPE_EXT 0x87E5 -#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 -#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 -#define GL_VARIANT_ARRAY_EXT 0x87E8 -#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 -#define GL_INVARIANT_VALUE_EXT 0x87EA -#define GL_INVARIANT_DATATYPE_EXT 0x87EB -#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC -#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED -typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); -typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); -typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const void *addr); -typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const void *addr); -typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); -typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); -typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); -typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); -typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); -typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); -typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); -typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); -typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const void *addr); -typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); -typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); -typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, void **data); -typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVertexShaderEXT (void); -GLAPI void APIENTRY glEndVertexShaderEXT (void); -GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); -GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); -GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); -GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); -GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); -GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); -GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const void *addr); -GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const void *addr); -GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); -GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); -GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); -GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); -GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); -GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); -GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); -GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); -GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const void *addr); -GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); -GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); -GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); -GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); -GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); -GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); -GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); -GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); -GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, void **data); -GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -#endif -#endif /* GL_EXT_vertex_shader */ - -#ifndef GL_EXT_vertex_weighting -#define GL_EXT_vertex_weighting 1 -#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 -#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 -#define GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define GL_VERTEX_WEIGHTING_EXT 0x8509 -#define GL_MODELVIEW0_EXT 0x1700 -#define GL_MODELVIEW1_EXT 0x850A -#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B -#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C -#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D -#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E -#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F -#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); -GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); -GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); -#endif -#endif /* GL_EXT_vertex_weighting */ - -#ifndef GL_EXT_x11_sync_object -#define GL_EXT_x11_sync_object 1 -#define GL_SYNC_X11_FENCE_EXT 0x90E1 -typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); -#endif -#endif /* GL_EXT_x11_sync_object */ - -#ifndef GL_GREMEDY_frame_terminator -#define GL_GREMEDY_frame_terminator 1 -typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); -#endif -#endif /* GL_GREMEDY_frame_terminator */ - -#ifndef GL_GREMEDY_string_marker -#define GL_GREMEDY_string_marker 1 -typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const void *string); -#endif -#endif /* GL_GREMEDY_string_marker */ - -#ifndef GL_HP_convolution_border_modes -#define GL_HP_convolution_border_modes 1 -#define GL_IGNORE_BORDER_HP 0x8150 -#define GL_CONSTANT_BORDER_HP 0x8151 -#define GL_REPLICATE_BORDER_HP 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 -#endif /* GL_HP_convolution_border_modes */ - -#ifndef GL_HP_image_transform -#define GL_HP_image_transform 1 -#define GL_IMAGE_SCALE_X_HP 0x8155 -#define GL_IMAGE_SCALE_Y_HP 0x8156 -#define GL_IMAGE_TRANSLATE_X_HP 0x8157 -#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 -#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 -#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A -#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B -#define GL_IMAGE_MAG_FILTER_HP 0x815C -#define GL_IMAGE_MIN_FILTER_HP 0x815D -#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E -#define GL_CUBIC_HP 0x815F -#define GL_AVERAGE_HP 0x8160 -#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 -#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 -#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); -#endif -#endif /* GL_HP_image_transform */ - -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 -#endif /* GL_HP_occlusion_test */ - -#ifndef GL_HP_texture_lighting -#define GL_HP_texture_lighting 1 -#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 -#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 -#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 -#endif /* GL_HP_texture_lighting */ - -#ifndef GL_IBM_cull_vertex -#define GL_IBM_cull_vertex 1 -#define GL_CULL_VERTEX_IBM 103050 -#endif /* GL_IBM_cull_vertex */ - -#ifndef GL_IBM_multimode_draw_arrays -#define GL_IBM_multimode_draw_arrays 1 -typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); -#endif -#endif /* GL_IBM_multimode_draw_arrays */ - -#ifndef GL_IBM_rasterpos_clip -#define GL_IBM_rasterpos_clip 1 -#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 -#endif /* GL_IBM_rasterpos_clip */ - -#ifndef GL_IBM_static_data -#define GL_IBM_static_data 1 -#define GL_ALL_STATIC_DATA_IBM 103060 -#define GL_STATIC_VERTEX_ARRAY_IBM 103061 -typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target); -#endif -#endif /* GL_IBM_static_data */ - -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_IBM_texture_mirrored_repeat 1 -#define GL_MIRRORED_REPEAT_IBM 0x8370 -#endif /* GL_IBM_texture_mirrored_repeat */ - -#ifndef GL_IBM_vertex_array_lists -#define GL_IBM_vertex_array_lists 1 -#define GL_VERTEX_ARRAY_LIST_IBM 103070 -#define GL_NORMAL_ARRAY_LIST_IBM 103071 -#define GL_COLOR_ARRAY_LIST_IBM 103072 -#define GL_INDEX_ARRAY_LIST_IBM 103073 -#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 -#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 -#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 -#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 -#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 -#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 -#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 -#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 -#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 -#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 -#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 -#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 -typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean **pointer, GLint ptrstride); -GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); -GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); -GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); -GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -#endif -#endif /* GL_IBM_vertex_array_lists */ - -#ifndef GL_INGR_blend_func_separate -#define GL_INGR_blend_func_separate 1 -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif -#endif /* GL_INGR_blend_func_separate */ - -#ifndef GL_INGR_color_clamp -#define GL_INGR_color_clamp 1 -#define GL_RED_MIN_CLAMP_INGR 0x8560 -#define GL_GREEN_MIN_CLAMP_INGR 0x8561 -#define GL_BLUE_MIN_CLAMP_INGR 0x8562 -#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 -#define GL_RED_MAX_CLAMP_INGR 0x8564 -#define GL_GREEN_MAX_CLAMP_INGR 0x8565 -#define GL_BLUE_MAX_CLAMP_INGR 0x8566 -#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 -#endif /* GL_INGR_color_clamp */ - -#ifndef GL_INGR_interlace_read -#define GL_INGR_interlace_read 1 -#define GL_INTERLACE_READ_INGR 0x8568 -#endif /* GL_INGR_interlace_read */ - -#ifndef GL_INTEL_fragment_shader_ordering -#define GL_INTEL_fragment_shader_ordering 1 -#endif /* GL_INTEL_fragment_shader_ordering */ - -#ifndef GL_INTEL_map_texture -#define GL_INTEL_map_texture 1 -#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF -#define GL_LAYOUT_DEFAULT_INTEL 0 -#define GL_LAYOUT_LINEAR_INTEL 1 -#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 -typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); -typedef void *(APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture); -GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level); -GLAPI void *APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); -#endif -#endif /* GL_INTEL_map_texture */ - -#ifndef GL_INTEL_parallel_arrays -#define GL_INTEL_parallel_arrays 1 -#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 -#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 -#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 -#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 -#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 -typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void **pointer); -typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const void **pointer); -GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const void **pointer); -GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const void **pointer); -GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const void **pointer); -#endif -#endif /* GL_INTEL_parallel_arrays */ - -#ifndef GL_INTEL_performance_query -#define GL_INTEL_performance_query 1 -#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 -#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 -#define GL_PERFQUERY_WAIT_INTEL 0x83FB -#define GL_PERFQUERY_FLUSH_INTEL 0x83FA -#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 -#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 -#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 -#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 -#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 -#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 -#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 -#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 -#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 -#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA -#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB -#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC -#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD -#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE -#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF -#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 -typedef void (APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); -typedef void (APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); -typedef void (APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); -typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); -typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); -typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); -typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); -typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); -typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); -typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); -GLAPI void APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); -GLAPI void APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); -GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); -GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); -GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); -GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); -GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); -GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); -GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); -#endif -#endif /* GL_INTEL_performance_query */ - -#ifndef GL_MESAX_texture_stack -#define GL_MESAX_texture_stack 1 -#define GL_TEXTURE_1D_STACK_MESAX 0x8759 -#define GL_TEXTURE_2D_STACK_MESAX 0x875A -#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B -#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C -#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D -#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E -#endif /* GL_MESAX_texture_stack */ - -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 -#define GL_PACK_INVERT_MESA 0x8758 -#endif /* GL_MESA_pack_invert */ - -#ifndef GL_MESA_resize_buffers -#define GL_MESA_resize_buffers 1 -typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glResizeBuffersMESA (void); -#endif -#endif /* GL_MESA_resize_buffers */ - -#ifndef GL_MESA_window_pos -#define GL_MESA_window_pos 1 -typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); -GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); -GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); -#endif -#endif /* GL_MESA_window_pos */ - -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define GL_YCBCR_MESA 0x8757 -#endif /* GL_MESA_ycbcr_texture */ - -#ifndef GL_NVX_conditional_render -#define GL_NVX_conditional_render 1 -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id); -GLAPI void APIENTRY glEndConditionalRenderNVX (void); -#endif -#endif /* GL_NVX_conditional_render */ - -#ifndef GL_NV_bindless_multi_draw_indirect -#define GL_NV_bindless_multi_draw_indirect 1 -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); -GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); -#endif -#endif /* GL_NV_bindless_multi_draw_indirect */ - -#ifndef GL_NV_bindless_texture -#define GL_NV_bindless_texture 1 -typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); -typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); -typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); -typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); -typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); -typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); -typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); -GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); -GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); -GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); -GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); -GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); -GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); -GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); -GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); -GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); -GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); -GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); -#endif -#endif /* GL_NV_bindless_texture */ - -#ifndef GL_NV_blend_equation_advanced -#define GL_NV_blend_equation_advanced 1 -#define GL_BLEND_OVERLAP_NV 0x9281 -#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 -#define GL_BLUE_NV 0x1905 -#define GL_COLORBURN_NV 0x929A -#define GL_COLORDODGE_NV 0x9299 -#define GL_CONJOINT_NV 0x9284 -#define GL_CONTRAST_NV 0x92A1 -#define GL_DARKEN_NV 0x9297 -#define GL_DIFFERENCE_NV 0x929E -#define GL_DISJOINT_NV 0x9283 -#define GL_DST_ATOP_NV 0x928F -#define GL_DST_IN_NV 0x928B -#define GL_DST_NV 0x9287 -#define GL_DST_OUT_NV 0x928D -#define GL_DST_OVER_NV 0x9289 -#define GL_EXCLUSION_NV 0x92A0 -#define GL_GREEN_NV 0x1904 -#define GL_HARDLIGHT_NV 0x929B -#define GL_HARDMIX_NV 0x92A9 -#define GL_HSL_COLOR_NV 0x92AF -#define GL_HSL_HUE_NV 0x92AD -#define GL_HSL_LUMINOSITY_NV 0x92B0 -#define GL_HSL_SATURATION_NV 0x92AE -#define GL_INVERT_OVG_NV 0x92B4 -#define GL_INVERT_RGB_NV 0x92A3 -#define GL_LIGHTEN_NV 0x9298 -#define GL_LINEARBURN_NV 0x92A5 -#define GL_LINEARDODGE_NV 0x92A4 -#define GL_LINEARLIGHT_NV 0x92A7 -#define GL_MINUS_CLAMPED_NV 0x92B3 -#define GL_MINUS_NV 0x929F -#define GL_MULTIPLY_NV 0x9294 -#define GL_OVERLAY_NV 0x9296 -#define GL_PINLIGHT_NV 0x92A8 -#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 -#define GL_PLUS_CLAMPED_NV 0x92B1 -#define GL_PLUS_DARKER_NV 0x9292 -#define GL_PLUS_NV 0x9291 -#define GL_RED_NV 0x1903 -#define GL_SCREEN_NV 0x9295 -#define GL_SOFTLIGHT_NV 0x929C -#define GL_SRC_ATOP_NV 0x928E -#define GL_SRC_IN_NV 0x928A -#define GL_SRC_NV 0x9286 -#define GL_SRC_OUT_NV 0x928C -#define GL_SRC_OVER_NV 0x9288 -#define GL_UNCORRELATED_NV 0x9282 -#define GL_VIVIDLIGHT_NV 0x92A6 -#define GL_XOR_NV 0x1506 -typedef void (APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendParameteriNV (GLenum pname, GLint value); -GLAPI void APIENTRY glBlendBarrierNV (void); -#endif -#endif /* GL_NV_blend_equation_advanced */ - -#ifndef GL_NV_blend_equation_advanced_coherent -#define GL_NV_blend_equation_advanced_coherent 1 -#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 -#endif /* GL_NV_blend_equation_advanced_coherent */ - -#ifndef GL_NV_blend_square -#define GL_NV_blend_square 1 -#endif /* GL_NV_blend_square */ - -#ifndef GL_NV_compute_program5 -#define GL_NV_compute_program5 1 -#define GL_COMPUTE_PROGRAM_NV 0x90FB -#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC -#endif /* GL_NV_compute_program5 */ - -#ifndef GL_NV_conditional_render -#define GL_NV_conditional_render 1 -#define GL_QUERY_WAIT_NV 0x8E13 -#define GL_QUERY_NO_WAIT_NV 0x8E14 -#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); -GLAPI void APIENTRY glEndConditionalRenderNV (void); -#endif -#endif /* GL_NV_conditional_render */ - -#ifndef GL_NV_copy_depth_to_color -#define GL_NV_copy_depth_to_color 1 -#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F -#endif /* GL_NV_copy_depth_to_color */ - -#ifndef GL_NV_copy_image -#define GL_NV_copy_image 1 -typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -#endif -#endif /* GL_NV_copy_image */ - -#ifndef GL_NV_deep_texture3D -#define GL_NV_deep_texture3D 1 -#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 -#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 -#endif /* GL_NV_deep_texture3D */ - -#ifndef GL_NV_depth_buffer_float -#define GL_NV_depth_buffer_float 1 -#define GL_DEPTH_COMPONENT32F_NV 0x8DAB -#define GL_DEPTH32F_STENCIL8_NV 0x8DAC -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD -#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF -typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); -typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); -GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); -#endif -#endif /* GL_NV_depth_buffer_float */ - -#ifndef GL_NV_depth_clamp -#define GL_NV_depth_clamp 1 -#define GL_DEPTH_CLAMP_NV 0x864F -#endif /* GL_NV_depth_clamp */ - -#ifndef GL_NV_draw_texture -#define GL_NV_draw_texture 1 -typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); -#endif -#endif /* GL_NV_draw_texture */ - -#ifndef GL_NV_evaluators -#define GL_NV_evaluators 1 -#define GL_EVAL_2D_NV 0x86C0 -#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 -#define GL_MAP_TESSELLATION_NV 0x86C2 -#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 -#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 -#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 -#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 -#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 -#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 -#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 -#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA -#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB -#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC -#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD -#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE -#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF -#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 -#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 -#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 -#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 -#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 -#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 -#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 -#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 -typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); -typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); -GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); -GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); -#endif -#endif /* GL_NV_evaluators */ - -#ifndef GL_NV_explicit_multisample -#define GL_NV_explicit_multisample 1 -#define GL_SAMPLE_POSITION_NV 0x8E50 -#define GL_SAMPLE_MASK_NV 0x8E51 -#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 -#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 -#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 -#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 -#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 -#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 -#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 -#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); -typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); -GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); -GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); -#endif -#endif /* GL_NV_explicit_multisample */ - -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); -GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); -GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); -GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); -GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); -GLAPI void APIENTRY glFinishFenceNV (GLuint fence); -GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); -#endif -#endif /* GL_NV_fence */ - -#ifndef GL_NV_float_buffer -#define GL_NV_float_buffer 1 -#define GL_FLOAT_R_NV 0x8880 -#define GL_FLOAT_RG_NV 0x8881 -#define GL_FLOAT_RGB_NV 0x8882 -#define GL_FLOAT_RGBA_NV 0x8883 -#define GL_FLOAT_R16_NV 0x8884 -#define GL_FLOAT_R32_NV 0x8885 -#define GL_FLOAT_RG16_NV 0x8886 -#define GL_FLOAT_RG32_NV 0x8887 -#define GL_FLOAT_RGB16_NV 0x8888 -#define GL_FLOAT_RGB32_NV 0x8889 -#define GL_FLOAT_RGBA16_NV 0x888A -#define GL_FLOAT_RGBA32_NV 0x888B -#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C -#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D -#define GL_FLOAT_RGBA_MODE_NV 0x888E -#endif /* GL_NV_float_buffer */ - -#ifndef GL_NV_fog_distance -#define GL_NV_fog_distance 1 -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C -#endif /* GL_NV_fog_distance */ - -#ifndef GL_NV_fragment_program -#define GL_NV_fragment_program 1 -#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 -#define GL_FRAGMENT_PROGRAM_NV 0x8870 -#define GL_MAX_TEXTURE_COORDS_NV 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 -#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 -#define GL_PROGRAM_ERROR_STRING_NV 0x8874 -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#endif -#endif /* GL_NV_fragment_program */ - -#ifndef GL_NV_fragment_program2 -#define GL_NV_fragment_program2 1 -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 -#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 -#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 -#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 -#endif /* GL_NV_fragment_program2 */ - -#ifndef GL_NV_fragment_program4 -#define GL_NV_fragment_program4 1 -#endif /* GL_NV_fragment_program4 */ - -#ifndef GL_NV_fragment_program_option -#define GL_NV_fragment_program_option 1 -#endif /* GL_NV_fragment_program_option */ - -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_NV_framebuffer_multisample_coverage 1 -#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB -#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 -#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 -#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -#endif -#endif /* GL_NV_framebuffer_multisample_coverage */ - -#ifndef GL_NV_geometry_program4 -#define GL_NV_geometry_program4 1 -#define GL_GEOMETRY_PROGRAM_NV 0x8C26 -#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 -#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 -typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); -GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif -#endif /* GL_NV_geometry_program4 */ - -#ifndef GL_NV_geometry_shader4 -#define GL_NV_geometry_shader4 1 -#endif /* GL_NV_geometry_shader4 */ - -#ifndef GL_NV_gpu_program4 -#define GL_NV_gpu_program4 1 -#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 -#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 -#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 -#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 -#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 -#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 -#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); -GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); -#endif -#endif /* GL_NV_gpu_program4 */ - -#ifndef GL_NV_gpu_program5 -#define GL_NV_gpu_program5 1 -#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C -#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F -#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 -#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 -typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); -#endif -#endif /* GL_NV_gpu_program5 */ - -#ifndef GL_NV_gpu_program5_mem_extended -#define GL_NV_gpu_program5_mem_extended 1 -#endif /* GL_NV_gpu_program5_mem_extended */ - -#ifndef GL_NV_gpu_shader5 -#define GL_NV_gpu_shader5 1 -typedef int64_t GLint64EXT; -#define GL_INT64_NV 0x140E -#define GL_UNSIGNED_INT64_NV 0x140F -#define GL_INT8_NV 0x8FE0 -#define GL_INT8_VEC2_NV 0x8FE1 -#define GL_INT8_VEC3_NV 0x8FE2 -#define GL_INT8_VEC4_NV 0x8FE3 -#define GL_INT16_NV 0x8FE4 -#define GL_INT16_VEC2_NV 0x8FE5 -#define GL_INT16_VEC3_NV 0x8FE6 -#define GL_INT16_VEC4_NV 0x8FE7 -#define GL_INT64_VEC2_NV 0x8FE9 -#define GL_INT64_VEC3_NV 0x8FEA -#define GL_INT64_VEC4_NV 0x8FEB -#define GL_UNSIGNED_INT8_NV 0x8FEC -#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED -#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE -#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF -#define GL_UNSIGNED_INT16_NV 0x8FF0 -#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 -#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 -#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 -#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 -#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 -#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 -#define GL_FLOAT16_NV 0x8FF8 -#define GL_FLOAT16_VEC2_NV 0x8FF9 -#define GL_FLOAT16_VEC3_NV 0x8FFA -#define GL_FLOAT16_VEC4_NV 0x8FFB -typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); -typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); -typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); -GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); -GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); -GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); -GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); -GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif -#endif /* GL_NV_gpu_shader5 */ - -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 -typedef unsigned short GLhalfNV; -#define GL_HALF_FLOAT_NV 0x140B -typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); -typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); -typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); -GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); -GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); -GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); -GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); -GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); -GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); -GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); -GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); -GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); -GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); -GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); -GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); -GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -#endif -#endif /* GL_NV_half_float */ - -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent 1 -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 -#endif /* GL_NV_light_max_exponent */ - -#ifndef GL_NV_multisample_coverage -#define GL_NV_multisample_coverage 1 -#define GL_COLOR_SAMPLES_NV 0x8E20 -#endif /* GL_NV_multisample_coverage */ - -#ifndef GL_NV_multisample_filter_hint -#define GL_NV_multisample_filter_hint 1 -#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 -#endif /* GL_NV_multisample_filter_hint */ - -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 -typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); -GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); -GLAPI void APIENTRY glEndOcclusionQueryNV (void); -GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); -#endif -#endif /* GL_NV_occlusion_query */ - -#ifndef GL_NV_packed_depth_stencil -#define GL_NV_packed_depth_stencil 1 -#define GL_DEPTH_STENCIL_NV 0x84F9 -#define GL_UNSIGNED_INT_24_8_NV 0x84FA -#endif /* GL_NV_packed_depth_stencil */ - -#ifndef GL_NV_parameter_buffer_object -#define GL_NV_parameter_buffer_object 1 -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 -#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 -#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 -#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); -#endif -#endif /* GL_NV_parameter_buffer_object */ - -#ifndef GL_NV_parameter_buffer_object2 -#define GL_NV_parameter_buffer_object2 1 -#endif /* GL_NV_parameter_buffer_object2 */ - -#ifndef GL_NV_path_rendering -#define GL_NV_path_rendering 1 -#define GL_PATH_FORMAT_SVG_NV 0x9070 -#define GL_PATH_FORMAT_PS_NV 0x9071 -#define GL_STANDARD_FONT_NAME_NV 0x9072 -#define GL_SYSTEM_FONT_NAME_NV 0x9073 -#define GL_FILE_NAME_NV 0x9074 -#define GL_PATH_STROKE_WIDTH_NV 0x9075 -#define GL_PATH_END_CAPS_NV 0x9076 -#define GL_PATH_INITIAL_END_CAP_NV 0x9077 -#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 -#define GL_PATH_JOIN_STYLE_NV 0x9079 -#define GL_PATH_MITER_LIMIT_NV 0x907A -#define GL_PATH_DASH_CAPS_NV 0x907B -#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C -#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D -#define GL_PATH_DASH_OFFSET_NV 0x907E -#define GL_PATH_CLIENT_LENGTH_NV 0x907F -#define GL_PATH_FILL_MODE_NV 0x9080 -#define GL_PATH_FILL_MASK_NV 0x9081 -#define GL_PATH_FILL_COVER_MODE_NV 0x9082 -#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 -#define GL_PATH_STROKE_MASK_NV 0x9084 -#define GL_COUNT_UP_NV 0x9088 -#define GL_COUNT_DOWN_NV 0x9089 -#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A -#define GL_CONVEX_HULL_NV 0x908B -#define GL_BOUNDING_BOX_NV 0x908D -#define GL_TRANSLATE_X_NV 0x908E -#define GL_TRANSLATE_Y_NV 0x908F -#define GL_TRANSLATE_2D_NV 0x9090 -#define GL_TRANSLATE_3D_NV 0x9091 -#define GL_AFFINE_2D_NV 0x9092 -#define GL_AFFINE_3D_NV 0x9094 -#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 -#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 -#define GL_UTF8_NV 0x909A -#define GL_UTF16_NV 0x909B -#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C -#define GL_PATH_COMMAND_COUNT_NV 0x909D -#define GL_PATH_COORD_COUNT_NV 0x909E -#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F -#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 -#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 -#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 -#define GL_SQUARE_NV 0x90A3 -#define GL_ROUND_NV 0x90A4 -#define GL_TRIANGULAR_NV 0x90A5 -#define GL_BEVEL_NV 0x90A6 -#define GL_MITER_REVERT_NV 0x90A7 -#define GL_MITER_TRUNCATE_NV 0x90A8 -#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 -#define GL_USE_MISSING_GLYPH_NV 0x90AA -#define GL_PATH_ERROR_POSITION_NV 0x90AB -#define GL_PATH_FOG_GEN_MODE_NV 0x90AC -#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD -#define GL_ADJACENT_PAIRS_NV 0x90AE -#define GL_FIRST_TO_REST_NV 0x90AF -#define GL_PATH_GEN_MODE_NV 0x90B0 -#define GL_PATH_GEN_COEFF_NV 0x90B1 -#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 -#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 -#define GL_PATH_STENCIL_FUNC_NV 0x90B7 -#define GL_PATH_STENCIL_REF_NV 0x90B8 -#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 -#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD -#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE -#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF -#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 -#define GL_MOVE_TO_RESETS_NV 0x90B5 -#define GL_MOVE_TO_CONTINUES_NV 0x90B6 -#define GL_CLOSE_PATH_NV 0x00 -#define GL_MOVE_TO_NV 0x02 -#define GL_RELATIVE_MOVE_TO_NV 0x03 -#define GL_LINE_TO_NV 0x04 -#define GL_RELATIVE_LINE_TO_NV 0x05 -#define GL_HORIZONTAL_LINE_TO_NV 0x06 -#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 -#define GL_VERTICAL_LINE_TO_NV 0x08 -#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 -#define GL_QUADRATIC_CURVE_TO_NV 0x0A -#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B -#define GL_CUBIC_CURVE_TO_NV 0x0C -#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D -#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E -#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F -#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 -#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 -#define GL_SMALL_CCW_ARC_TO_NV 0x12 -#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 -#define GL_SMALL_CW_ARC_TO_NV 0x14 -#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 -#define GL_LARGE_CCW_ARC_TO_NV 0x16 -#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 -#define GL_LARGE_CW_ARC_TO_NV 0x18 -#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 -#define GL_RESTART_PATH_NV 0xF0 -#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 -#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 -#define GL_RECT_NV 0xF6 -#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 -#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA -#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC -#define GL_ARC_TO_NV 0xFE -#define GL_RELATIVE_ARC_TO_NV 0xFF -#define GL_BOLD_BIT_NV 0x01 -#define GL_ITALIC_BIT_NV 0x02 -#define GL_GLYPH_WIDTH_BIT_NV 0x01 -#define GL_GLYPH_HEIGHT_BIT_NV 0x02 -#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 -#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 -#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 -#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 -#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 -#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 -#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 -#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 -#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 -#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 -#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 -#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 -#define GL_FONT_ASCENDER_BIT_NV 0x00200000 -#define GL_FONT_DESCENDER_BIT_NV 0x00400000 -#define GL_FONT_HEIGHT_BIT_NV 0x00800000 -#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 -#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 -#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 -#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 -#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); -typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); -typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); -typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); -typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); -typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); -typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); -typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); -typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); -typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); -typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); -typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); -typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); -typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); -typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); -typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); -typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); -typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); -typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); -typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); -typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); -typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); -typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); -typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); -typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); -typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); -typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); -typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); -typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); -typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); -typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); -typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); -typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); -typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); -typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); -typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); -GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); -GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); -GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); -GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); -GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); -GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); -GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); -GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); -GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); -GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); -GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); -GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); -GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); -GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); -GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); -GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); -GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); -GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); -GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); -GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); -GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); -GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); -GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); -GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); -GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); -GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); -GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); -GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); -GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); -GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); -GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); -GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); -GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); -GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); -GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); -GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); -GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); -GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); -GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); -GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); -GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); -#endif -#endif /* GL_NV_path_rendering */ - -#ifndef GL_NV_pixel_data_range -#define GL_NV_pixel_data_range 1 -#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 -#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 -#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A -#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B -#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C -#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D -typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const void *pointer); -typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const void *pointer); -GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); -#endif -#endif /* GL_NV_pixel_data_range */ - -#ifndef GL_NV_point_sprite -#define GL_NV_point_sprite 1 -#define GL_POINT_SPRITE_NV 0x8861 -#define GL_COORD_REPLACE_NV 0x8862 -#define GL_POINT_SPRITE_R_MODE_NV 0x8863 -typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); -GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); -#endif -#endif /* GL_NV_point_sprite */ - -#ifndef GL_NV_present_video -#define GL_NV_present_video 1 -#define GL_FRAME_NV 0x8E26 -#define GL_FIELDS_NV 0x8E27 -#define GL_CURRENT_TIME_NV 0x8E28 -#define GL_NUM_FILL_STREAMS_NV 0x8E29 -#define GL_PRESENT_TIME_NV 0x8E2A -#define GL_PRESENT_DURATION_NV 0x8E2B -typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); -typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); -typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); -GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); -GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); -GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); -#endif -#endif /* GL_NV_present_video */ - -#ifndef GL_NV_primitive_restart -#define GL_NV_primitive_restart 1 -#define GL_PRIMITIVE_RESTART_NV 0x8558 -#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPrimitiveRestartNV (void); -GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); -#endif -#endif /* GL_NV_primitive_restart */ - -#ifndef GL_NV_register_combiners -#define GL_NV_register_combiners 1 -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); -GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); -GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); -GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); -#endif -#endif /* GL_NV_register_combiners */ - -#ifndef GL_NV_register_combiners2 -#define GL_NV_register_combiners2 1 -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 -typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); -#endif -#endif /* GL_NV_register_combiners2 */ - -#ifndef GL_NV_shader_atomic_counters -#define GL_NV_shader_atomic_counters 1 -#endif /* GL_NV_shader_atomic_counters */ - -#ifndef GL_NV_shader_atomic_float -#define GL_NV_shader_atomic_float 1 -#endif /* GL_NV_shader_atomic_float */ - -#ifndef GL_NV_shader_buffer_load -#define GL_NV_shader_buffer_load 1 -#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D -#define GL_GPU_ADDRESS_NV 0x8F34 -#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 -typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); -typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); -typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); -typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); -typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); -typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); -typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); -typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); -GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); -GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); -GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); -GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); -GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); -GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); -GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); -GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); -GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); -GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif -#endif /* GL_NV_shader_buffer_load */ - -#ifndef GL_NV_shader_buffer_store -#define GL_NV_shader_buffer_store 1 -#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 -#endif /* GL_NV_shader_buffer_store */ - -#ifndef GL_NV_shader_storage_buffer_object -#define GL_NV_shader_storage_buffer_object 1 -#endif /* GL_NV_shader_storage_buffer_object */ - -#ifndef GL_NV_tessellation_program5 -#define GL_NV_tessellation_program5 1 -#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 -#define GL_TESS_CONTROL_PROGRAM_NV 0x891E -#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F -#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 -#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 -#endif /* GL_NV_tessellation_program5 */ - -#ifndef GL_NV_texgen_emboss -#define GL_NV_texgen_emboss 1 -#define GL_EMBOSS_LIGHT_NV 0x855D -#define GL_EMBOSS_CONSTANT_NV 0x855E -#define GL_EMBOSS_MAP_NV 0x855F -#endif /* GL_NV_texgen_emboss */ - -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 -#endif /* GL_NV_texgen_reflection */ - -#ifndef GL_NV_texture_barrier -#define GL_NV_texture_barrier 1 -typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureBarrierNV (void); -#endif -#endif /* GL_NV_texture_barrier */ - -#ifndef GL_NV_texture_compression_vtc -#define GL_NV_texture_compression_vtc 1 -#endif /* GL_NV_texture_compression_vtc */ - -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B -#endif /* GL_NV_texture_env_combine4 */ - -#ifndef GL_NV_texture_expand_normal -#define GL_NV_texture_expand_normal 1 -#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F -#endif /* GL_NV_texture_expand_normal */ - -#ifndef GL_NV_texture_multisample -#define GL_NV_texture_multisample 1 -#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 -#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 -typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -#endif -#endif /* GL_NV_texture_multisample */ - -#ifndef GL_NV_texture_rectangle -#define GL_NV_texture_rectangle 1 -#define GL_TEXTURE_RECTANGLE_NV 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 -#endif /* GL_NV_texture_rectangle */ - -#ifndef GL_NV_texture_shader -#define GL_NV_texture_shader 1 -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F -#endif /* GL_NV_texture_shader */ - -#ifndef GL_NV_texture_shader2 -#define GL_NV_texture_shader2 1 -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#endif /* GL_NV_texture_shader2 */ - -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 -#endif /* GL_NV_texture_shader3 */ - -#ifndef GL_NV_transform_feedback -#define GL_NV_transform_feedback 1 -#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 -#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 -#define GL_TEXTURE_COORD_NV 0x8C79 -#define GL_CLIP_DISTANCE_NV 0x8C7A -#define GL_VERTEX_ID_NV 0x8C7B -#define GL_PRIMITIVE_ID_NV 0x8C7C -#define GL_GENERIC_ATTRIB_NV 0x8C7D -#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 -#define GL_ACTIVE_VARYINGS_NV 0x8C81 -#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 -#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 -#define GL_PRIMITIVES_GENERATED_NV 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 -#define GL_RASTERIZER_DISCARD_NV 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B -#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C -#define GL_SEPARATE_ATTRIBS_NV 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F -#define GL_LAYER_NV 0x8DAA -#define GL_NEXT_BUFFER_NV -2 -#define GL_SKIP_COMPONENTS4_NV -3 -#define GL_SKIP_COMPONENTS3_NV -4 -#define GL_SKIP_COMPONENTS2_NV -5 -#define GL_SKIP_COMPONENTS1_NV -6 -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedbackNV (void); -GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); -GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); -GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); -GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); -#endif -#endif /* GL_NV_transform_feedback */ - -#ifndef GL_NV_transform_feedback2 -#define GL_NV_transform_feedback2 1 -#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); -GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); -GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); -GLAPI void APIENTRY glPauseTransformFeedbackNV (void); -GLAPI void APIENTRY glResumeTransformFeedbackNV (void); -GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); -#endif -#endif /* GL_NV_transform_feedback2 */ - -#ifndef GL_NV_vdpau_interop -#define GL_NV_vdpau_interop 1 -typedef GLintptr GLvdpauSurfaceNV; -#define GL_SURFACE_STATE_NV 0x86EB -#define GL_SURFACE_REGISTERED_NV 0x86FD -#define GL_SURFACE_MAPPED_NV 0x8700 -#define GL_WRITE_DISCARD_NV 0x88BE -typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const void *vdpDevice, const void *getProcAddress); -typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); -typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -typedef GLboolean (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); -typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); -typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); -typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); -typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVDPAUInitNV (const void *vdpDevice, const void *getProcAddress); -GLAPI void APIENTRY glVDPAUFiniNV (void); -GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -GLAPI GLboolean APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); -GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); -GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); -GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); -GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); -#endif -#endif /* GL_NV_vdpau_interop */ - -#ifndef GL_NV_vertex_array_range -#define GL_NV_vertex_array_range 1 -#define GL_VERTEX_ARRAY_RANGE_NV 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E -#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); -GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const void *pointer); -#endif -#endif /* GL_NV_vertex_array_range */ - -#ifndef GL_NV_vertex_array_range2 -#define GL_NV_vertex_array_range2 1 -#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 -#endif /* GL_NV_vertex_array_range2 */ - -#ifndef GL_NV_vertex_attrib_integer_64bit -#define GL_NV_vertex_attrib_integer_64bit 1 -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); -GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); -GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); -#endif -#endif /* GL_NV_vertex_attrib_integer_64bit */ - -#ifndef GL_NV_vertex_buffer_unified_memory -#define GL_NV_vertex_buffer_unified_memory 1 -#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E -#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F -#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 -#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 -#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 -#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 -#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 -#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 -#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 -#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 -#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 -#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 -#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A -#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B -#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C -#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D -#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E -#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F -#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 -#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 -#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 -#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 -#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 -#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 -#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 -typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); -typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); -GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); -GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); -GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); -#endif -#endif /* GL_NV_vertex_buffer_unified_memory */ - -#ifndef GL_NV_vertex_program -#define GL_NV_vertex_program 1 -#define GL_VERTEX_PROGRAM_NV 0x8620 -#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 -#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 -#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 -#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 -#define GL_CURRENT_ATTRIB_NV 0x8626 -#define GL_PROGRAM_LENGTH_NV 0x8627 -#define GL_PROGRAM_STRING_NV 0x8628 -#define GL_MODELVIEW_PROJECTION_NV 0x8629 -#define GL_IDENTITY_NV 0x862A -#define GL_INVERSE_NV 0x862B -#define GL_TRANSPOSE_NV 0x862C -#define GL_INVERSE_TRANSPOSE_NV 0x862D -#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E -#define GL_MAX_TRACK_MATRICES_NV 0x862F -#define GL_MATRIX0_NV 0x8630 -#define GL_MATRIX1_NV 0x8631 -#define GL_MATRIX2_NV 0x8632 -#define GL_MATRIX3_NV 0x8633 -#define GL_MATRIX4_NV 0x8634 -#define GL_MATRIX5_NV 0x8635 -#define GL_MATRIX6_NV 0x8636 -#define GL_MATRIX7_NV 0x8637 -#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 -#define GL_CURRENT_MATRIX_NV 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 -#define GL_PROGRAM_PARAMETER_NV 0x8644 -#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 -#define GL_PROGRAM_TARGET_NV 0x8646 -#define GL_PROGRAM_RESIDENT_NV 0x8647 -#define GL_TRACK_MATRIX_NV 0x8648 -#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 -#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A -#define GL_PROGRAM_ERROR_POSITION_NV 0x864B -#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 -#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 -#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 -#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 -#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 -#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 -#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 -#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 -#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 -#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 -#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A -#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B -#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C -#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D -#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E -#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F -#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 -#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 -#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 -#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 -#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 -#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 -#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 -#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 -#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 -#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 -#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A -#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B -#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C -#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D -#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E -#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F -#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 -#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 -#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 -#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 -#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 -#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 -#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 -#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 -#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 -#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 -#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A -#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B -#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C -#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D -#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E -#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F -typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); -typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); -typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, void **pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); -GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); -GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); -GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); -GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, void **pointer); -GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); -GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); -GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); -GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); -GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); -#endif -#endif /* GL_NV_vertex_program */ - -#ifndef GL_NV_vertex_program1_1 -#define GL_NV_vertex_program1_1 1 -#endif /* GL_NV_vertex_program1_1 */ - -#ifndef GL_NV_vertex_program2 -#define GL_NV_vertex_program2 1 -#endif /* GL_NV_vertex_program2 */ - -#ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option 1 -#endif /* GL_NV_vertex_program2_option */ - -#ifndef GL_NV_vertex_program3 -#define GL_NV_vertex_program3 1 -#endif /* GL_NV_vertex_program3 */ - -#ifndef GL_NV_vertex_program4 -#define GL_NV_vertex_program4 1 -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); -GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); -GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); -GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); -GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); -GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); -#endif -#endif /* GL_NV_vertex_program4 */ - -#ifndef GL_NV_video_capture -#define GL_NV_video_capture 1 -#define GL_VIDEO_BUFFER_NV 0x9020 -#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 -#define GL_FIELD_UPPER_NV 0x9022 -#define GL_FIELD_LOWER_NV 0x9023 -#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 -#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 -#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 -#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 -#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 -#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 -#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A -#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B -#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C -#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D -#define GL_PARTIAL_SUCCESS_NV 0x902E -#define GL_SUCCESS_NV 0x902F -#define GL_FAILURE_NV 0x9030 -#define GL_YCBYCR8_422_NV 0x9031 -#define GL_YCBAYCR8A_4224_NV 0x9032 -#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 -#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 -#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 -#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 -#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 -#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 -#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 -#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A -#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B -#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C -typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); -typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); -typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); -typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); -GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); -GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); -GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); -GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); -GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); -GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); -GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); -#endif -#endif /* GL_NV_video_capture */ - -#ifndef GL_OML_interlace -#define GL_OML_interlace 1 -#define GL_INTERLACE_OML 0x8980 -#define GL_INTERLACE_READ_OML 0x8981 -#endif /* GL_OML_interlace */ - -#ifndef GL_OML_resample -#define GL_OML_resample 1 -#define GL_PACK_RESAMPLE_OML 0x8984 -#define GL_UNPACK_RESAMPLE_OML 0x8985 -#define GL_RESAMPLE_REPLICATE_OML 0x8986 -#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 -#define GL_RESAMPLE_AVERAGE_OML 0x8988 -#define GL_RESAMPLE_DECIMATE_OML 0x8989 -#endif /* GL_OML_resample */ - -#ifndef GL_OML_subsample -#define GL_OML_subsample 1 -#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 -#endif /* GL_OML_subsample */ - -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 -#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD -#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 -#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C -#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E -#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F -#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 -#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 -#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 -#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 -#define GL_CLIP_NEAR_HINT_PGI 0x1A220 -#define GL_CLIP_FAR_HINT_PGI 0x1A221 -#define GL_WIDE_LINE_HINT_PGI 0x1A222 -#define GL_BACK_NORMALS_HINT_PGI 0x1A223 -typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); -#endif -#endif /* GL_PGI_misc_hints */ - -#ifndef GL_PGI_vertex_hints -#define GL_PGI_vertex_hints 1 -#define GL_VERTEX_DATA_HINT_PGI 0x1A22A -#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B -#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C -#define GL_MAX_VERTEX_HINT_PGI 0x1A22D -#define GL_COLOR3_BIT_PGI 0x00010000 -#define GL_COLOR4_BIT_PGI 0x00020000 -#define GL_EDGEFLAG_BIT_PGI 0x00040000 -#define GL_INDEX_BIT_PGI 0x00080000 -#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 -#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 -#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 -#define GL_MAT_EMISSION_BIT_PGI 0x00800000 -#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 -#define GL_MAT_SHININESS_BIT_PGI 0x02000000 -#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 -#define GL_NORMAL_BIT_PGI 0x08000000 -#define GL_TEXCOORD1_BIT_PGI 0x10000000 -#define GL_TEXCOORD2_BIT_PGI 0x20000000 -#define GL_TEXCOORD3_BIT_PGI 0x40000000 -#define GL_TEXCOORD4_BIT_PGI 0x80000000 -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 -#endif /* GL_PGI_vertex_hints */ - -#ifndef GL_REND_screen_coordinates -#define GL_REND_screen_coordinates 1 -#define GL_SCREEN_COORDINATES_REND 0x8490 -#define GL_INVERTED_SCREEN_W_REND 0x8491 -#endif /* GL_REND_screen_coordinates */ - -#ifndef GL_S3_s3tc -#define GL_S3_s3tc 1 -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 -#define GL_RGBA_S3TC 0x83A2 -#define GL_RGBA4_S3TC 0x83A3 -#define GL_RGBA_DXT5_S3TC 0x83A4 -#define GL_RGBA4_DXT5_S3TC 0x83A5 -#endif /* GL_S3_s3tc */ - -#ifndef GL_SGIS_detail_texture -#define GL_SGIS_detail_texture 1 -#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 -#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 -#define GL_LINEAR_DETAIL_SGIS 0x8097 -#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 -#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 -#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A -#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B -#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C -typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); -#endif -#endif /* GL_SGIS_detail_texture */ - -#ifndef GL_SGIS_fog_function -#define GL_SGIS_fog_function 1 -#define GL_FOG_FUNC_SGIS 0x812A -#define GL_FOG_FUNC_POINTS_SGIS 0x812B -#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C -typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); -#endif -#endif /* GL_SGIS_fog_function */ - -#ifndef GL_SGIS_generate_mipmap -#define GL_SGIS_generate_mipmap 1 -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#endif /* GL_SGIS_generate_mipmap */ - -#ifndef GL_SGIS_multisample -#define GL_SGIS_multisample 1 -#define GL_MULTISAMPLE_SGIS 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F -#define GL_SAMPLE_MASK_SGIS 0x80A0 -#define GL_1PASS_SGIS 0x80A1 -#define GL_2PASS_0_SGIS 0x80A2 -#define GL_2PASS_1_SGIS 0x80A3 -#define GL_4PASS_0_SGIS 0x80A4 -#define GL_4PASS_1_SGIS 0x80A5 -#define GL_4PASS_2_SGIS 0x80A6 -#define GL_4PASS_3_SGIS 0x80A7 -#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 -#define GL_SAMPLES_SGIS 0x80A9 -#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA -#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB -#define GL_SAMPLE_PATTERN_SGIS 0x80AC -typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); -GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); -#endif -#endif /* GL_SGIS_multisample */ - -#ifndef GL_SGIS_pixel_texture -#define GL_SGIS_pixel_texture 1 -#define GL_PIXEL_TEXTURE_SGIS 0x8353 -#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 -#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 -#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); -GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); -GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); -GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); -#endif -#endif /* GL_SGIS_pixel_texture */ - -#ifndef GL_SGIS_point_line_texgen -#define GL_SGIS_point_line_texgen 1 -#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 -#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 -#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 -#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 -#define GL_EYE_POINT_SGIS 0x81F4 -#define GL_OBJECT_POINT_SGIS 0x81F5 -#define GL_EYE_LINE_SGIS 0x81F6 -#define GL_OBJECT_LINE_SGIS 0x81F7 -#endif /* GL_SGIS_point_line_texgen */ - -#ifndef GL_SGIS_point_parameters -#define GL_SGIS_point_parameters 1 -#define GL_POINT_SIZE_MIN_SGIS 0x8126 -#define GL_POINT_SIZE_MAX_SGIS 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 -#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 -typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); -#endif -#endif /* GL_SGIS_point_parameters */ - -#ifndef GL_SGIS_sharpen_texture -#define GL_SGIS_sharpen_texture 1 -#define GL_LINEAR_SHARPEN_SGIS 0x80AD -#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE -#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF -#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 -typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); -#endif -#endif /* GL_SGIS_sharpen_texture */ - -#ifndef GL_SGIS_texture4D -#define GL_SGIS_texture4D 1 -#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 -#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 -#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 -#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 -#define GL_TEXTURE_4D_SGIS 0x8134 -#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 -#define GL_TEXTURE_4DSIZE_SGIS 0x8136 -#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 -#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 -#define GL_TEXTURE_4D_BINDING_SGIS 0x814F -typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); -#endif -#endif /* GL_SGIS_texture4D */ - -#ifndef GL_SGIS_texture_border_clamp -#define GL_SGIS_texture_border_clamp 1 -#define GL_CLAMP_TO_BORDER_SGIS 0x812D -#endif /* GL_SGIS_texture_border_clamp */ - -#ifndef GL_SGIS_texture_color_mask -#define GL_SGIS_texture_color_mask 1 -#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF -typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif -#endif /* GL_SGIS_texture_color_mask */ - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 -#define GL_CLAMP_TO_EDGE_SGIS 0x812F -#endif /* GL_SGIS_texture_edge_clamp */ - -#ifndef GL_SGIS_texture_filter4 -#define GL_SGIS_texture_filter4 1 -#define GL_FILTER4_SGIS 0x8146 -#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 -typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); -typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); -GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#endif -#endif /* GL_SGIS_texture_filter4 */ - -#ifndef GL_SGIS_texture_lod -#define GL_SGIS_texture_lod 1 -#define GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D -#endif /* GL_SGIS_texture_lod */ - -#ifndef GL_SGIS_texture_select -#define GL_SGIS_texture_select 1 -#define GL_DUAL_ALPHA4_SGIS 0x8110 -#define GL_DUAL_ALPHA8_SGIS 0x8111 -#define GL_DUAL_ALPHA12_SGIS 0x8112 -#define GL_DUAL_ALPHA16_SGIS 0x8113 -#define GL_DUAL_LUMINANCE4_SGIS 0x8114 -#define GL_DUAL_LUMINANCE8_SGIS 0x8115 -#define GL_DUAL_LUMINANCE12_SGIS 0x8116 -#define GL_DUAL_LUMINANCE16_SGIS 0x8117 -#define GL_DUAL_INTENSITY4_SGIS 0x8118 -#define GL_DUAL_INTENSITY8_SGIS 0x8119 -#define GL_DUAL_INTENSITY12_SGIS 0x811A -#define GL_DUAL_INTENSITY16_SGIS 0x811B -#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C -#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D -#define GL_QUAD_ALPHA4_SGIS 0x811E -#define GL_QUAD_ALPHA8_SGIS 0x811F -#define GL_QUAD_LUMINANCE4_SGIS 0x8120 -#define GL_QUAD_LUMINANCE8_SGIS 0x8121 -#define GL_QUAD_INTENSITY4_SGIS 0x8122 -#define GL_QUAD_INTENSITY8_SGIS 0x8123 -#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 -#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 -#endif /* GL_SGIS_texture_select */ - -#ifndef GL_SGIX_async -#define GL_SGIX_async 1 -#define GL_ASYNC_MARKER_SGIX 0x8329 -typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); -typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); -typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); -GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); -GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); -GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); -GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); -GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); -#endif -#endif /* GL_SGIX_async */ - -#ifndef GL_SGIX_async_histogram -#define GL_SGIX_async_histogram 1 -#define GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D -#endif /* GL_SGIX_async_histogram */ - -#ifndef GL_SGIX_async_pixel -#define GL_SGIX_async_pixel 1 -#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C -#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D -#define GL_ASYNC_READ_PIXELS_SGIX 0x835E -#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F -#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 -#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 -#endif /* GL_SGIX_async_pixel */ - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_SGIX_blend_alpha_minmax 1 -#define GL_ALPHA_MIN_SGIX 0x8320 -#define GL_ALPHA_MAX_SGIX 0x8321 -#endif /* GL_SGIX_blend_alpha_minmax */ - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_SGIX_calligraphic_fragment 1 -#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 -#endif /* GL_SGIX_calligraphic_fragment */ - -#ifndef GL_SGIX_clipmap -#define GL_SGIX_clipmap 1 -#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 -#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 -#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 -#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 -#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 -#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 -#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 -#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 -#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 -#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D -#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E -#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F -#endif /* GL_SGIX_clipmap */ - -#ifndef GL_SGIX_convolution_accuracy -#define GL_SGIX_convolution_accuracy 1 -#define GL_CONVOLUTION_HINT_SGIX 0x8316 -#endif /* GL_SGIX_convolution_accuracy */ - -#ifndef GL_SGIX_depth_pass_instrument -#define GL_SGIX_depth_pass_instrument 1 -#endif /* GL_SGIX_depth_pass_instrument */ - -#ifndef GL_SGIX_depth_texture -#define GL_SGIX_depth_texture 1 -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 -#endif /* GL_SGIX_depth_texture */ - -#ifndef GL_SGIX_flush_raster -#define GL_SGIX_flush_raster 1 -typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushRasterSGIX (void); -#endif -#endif /* GL_SGIX_flush_raster */ - -#ifndef GL_SGIX_fog_offset -#define GL_SGIX_fog_offset 1 -#define GL_FOG_OFFSET_SGIX 0x8198 -#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 -#endif /* GL_SGIX_fog_offset */ - -#ifndef GL_SGIX_fragment_lighting -#define GL_SGIX_fragment_lighting 1 -#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 -#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 -#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 -#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 -#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 -#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 -#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 -#define GL_LIGHT_ENV_MODE_SGIX 0x8407 -#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 -#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 -#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A -#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B -#define GL_FRAGMENT_LIGHT0_SGIX 0x840C -#define GL_FRAGMENT_LIGHT1_SGIX 0x840D -#define GL_FRAGMENT_LIGHT2_SGIX 0x840E -#define GL_FRAGMENT_LIGHT3_SGIX 0x840F -#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 -#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 -#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 -#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 -typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); -GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); -GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); -GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); -GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); -GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); -#endif -#endif /* GL_SGIX_fragment_lighting */ - -#ifndef GL_SGIX_framezoom -#define GL_SGIX_framezoom 1 -#define GL_FRAMEZOOM_SGIX 0x818B -#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C -#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D -typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); -#endif -#endif /* GL_SGIX_framezoom */ - -#ifndef GL_SGIX_igloo_interface -#define GL_SGIX_igloo_interface 1 -typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const void *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const void *params); -#endif -#endif /* GL_SGIX_igloo_interface */ - -#ifndef GL_SGIX_instruments -#define GL_SGIX_instruments 1 -#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 -#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 -typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); -typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); -typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); -typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); -GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); -GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); -GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); -GLAPI void APIENTRY glStartInstrumentsSGIX (void); -GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); -#endif -#endif /* GL_SGIX_instruments */ - -#ifndef GL_SGIX_interlace -#define GL_SGIX_interlace 1 -#define GL_INTERLACE_SGIX 0x8094 -#endif /* GL_SGIX_interlace */ - -#ifndef GL_SGIX_ir_instrument1 -#define GL_SGIX_ir_instrument1 1 -#define GL_IR_INSTRUMENT1_SGIX 0x817F -#endif /* GL_SGIX_ir_instrument1 */ - -#ifndef GL_SGIX_list_priority -#define GL_SGIX_list_priority 1 -#define GL_LIST_PRIORITY_SGIX 0x8182 -typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); -GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); -GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); -GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); -#endif -#endif /* GL_SGIX_list_priority */ - -#ifndef GL_SGIX_pixel_texture -#define GL_SGIX_pixel_texture 1 -#define GL_PIXEL_TEX_GEN_SGIX 0x8139 -#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B -typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); -#endif -#endif /* GL_SGIX_pixel_texture */ - -#ifndef GL_SGIX_pixel_tiles -#define GL_SGIX_pixel_tiles 1 -#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E -#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F -#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 -#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 -#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 -#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 -#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 -#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 -#endif /* GL_SGIX_pixel_tiles */ - -#ifndef GL_SGIX_polynomial_ffd -#define GL_SGIX_polynomial_ffd 1 -#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 -#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 -#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 -#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 -#define GL_DEFORMATIONS_MASK_SGIX 0x8196 -#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); -GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); -#endif -#endif /* GL_SGIX_polynomial_ffd */ - -#ifndef GL_SGIX_reference_plane -#define GL_SGIX_reference_plane 1 -#define GL_REFERENCE_PLANE_SGIX 0x817D -#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E -typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); -#endif -#endif /* GL_SGIX_reference_plane */ - -#ifndef GL_SGIX_resample -#define GL_SGIX_resample 1 -#define GL_PACK_RESAMPLE_SGIX 0x842C -#define GL_UNPACK_RESAMPLE_SGIX 0x842D -#define GL_RESAMPLE_REPLICATE_SGIX 0x842E -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F -#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#endif /* GL_SGIX_resample */ - -#ifndef GL_SGIX_scalebias_hint -#define GL_SGIX_scalebias_hint 1 -#define GL_SCALEBIAS_HINT_SGIX 0x8322 -#endif /* GL_SGIX_scalebias_hint */ - -#ifndef GL_SGIX_shadow -#define GL_SGIX_shadow 1 -#define GL_TEXTURE_COMPARE_SGIX 0x819A -#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D -#endif /* GL_SGIX_shadow */ - -#ifndef GL_SGIX_shadow_ambient -#define GL_SGIX_shadow_ambient 1 -#define GL_SHADOW_AMBIENT_SGIX 0x80BF -#endif /* GL_SGIX_shadow_ambient */ - -#ifndef GL_SGIX_sprite -#define GL_SGIX_sprite 1 -#define GL_SPRITE_SGIX 0x8148 -#define GL_SPRITE_MODE_SGIX 0x8149 -#define GL_SPRITE_AXIS_SGIX 0x814A -#define GL_SPRITE_TRANSLATION_SGIX 0x814B -#define GL_SPRITE_AXIAL_SGIX 0x814C -#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D -#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); -GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); -GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); -#endif -#endif /* GL_SGIX_sprite */ - -#ifndef GL_SGIX_subsample -#define GL_SGIX_subsample 1 -#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 -#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 -#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 -#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 -#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 -#endif /* GL_SGIX_subsample */ - -#ifndef GL_SGIX_tag_sample_buffer -#define GL_SGIX_tag_sample_buffer 1 -typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTagSampleBufferSGIX (void); -#endif -#endif /* GL_SGIX_tag_sample_buffer */ - -#ifndef GL_SGIX_texture_add_env -#define GL_SGIX_texture_add_env 1 -#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE -#endif /* GL_SGIX_texture_add_env */ - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_SGIX_texture_coordinate_clamp 1 -#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B -#endif /* GL_SGIX_texture_coordinate_clamp */ - -#ifndef GL_SGIX_texture_lod_bias -#define GL_SGIX_texture_lod_bias 1 -#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E -#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F -#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 -#endif /* GL_SGIX_texture_lod_bias */ - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_SGIX_texture_multi_buffer 1 -#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E -#endif /* GL_SGIX_texture_multi_buffer */ - -#ifndef GL_SGIX_texture_scale_bias -#define GL_SGIX_texture_scale_bias 1 -#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 -#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A -#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B -#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C -#endif /* GL_SGIX_texture_scale_bias */ - -#ifndef GL_SGIX_vertex_preclip -#define GL_SGIX_vertex_preclip 1 -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF -#endif /* GL_SGIX_vertex_preclip */ - -#ifndef GL_SGIX_ycrcb -#define GL_SGIX_ycrcb 1 -#define GL_YCRCB_422_SGIX 0x81BB -#define GL_YCRCB_444_SGIX 0x81BC -#endif /* GL_SGIX_ycrcb */ - -#ifndef GL_SGIX_ycrcb_subsample -#define GL_SGIX_ycrcb_subsample 1 -#endif /* GL_SGIX_ycrcb_subsample */ - -#ifndef GL_SGIX_ycrcba -#define GL_SGIX_ycrcba 1 -#define GL_YCRCB_SGIX 0x8318 -#define GL_YCRCBA_SGIX 0x8319 -#endif /* GL_SGIX_ycrcba */ - -#ifndef GL_SGI_color_matrix -#define GL_SGI_color_matrix 1 -#define GL_COLOR_MATRIX_SGI 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB -#endif /* GL_SGI_color_matrix */ - -#ifndef GL_SGI_color_table -#define GL_SGI_color_table 1 -#define GL_COLOR_TABLE_SGI 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 -#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 -#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 -#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF -typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); -GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, void *table); -GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); -#endif -#endif /* GL_SGI_color_table */ - -#ifndef GL_SGI_texture_color_table -#define GL_SGI_texture_color_table 1 -#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD -#endif /* GL_SGI_texture_color_table */ - -#ifndef GL_SUNX_constant_data -#define GL_SUNX_constant_data 1 -#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 -typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFinishTextureSUNX (void); -#endif -#endif /* GL_SUNX_constant_data */ - -#ifndef GL_SUN_convolution_border_modes -#define GL_SUN_convolution_border_modes 1 -#define GL_WRAP_BORDER_SUN 0x81D4 -#endif /* GL_SUN_convolution_border_modes */ - -#ifndef GL_SUN_global_alpha -#define GL_SUN_global_alpha 1 -#define GL_GLOBAL_ALPHA_SUN 0x81D9 -#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); -GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); -GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); -GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); -GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); -GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); -GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); -GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); -#endif -#endif /* GL_SUN_global_alpha */ - -#ifndef GL_SUN_mesh_array -#define GL_SUN_mesh_array 1 -#define GL_QUAD_MESH_SUN 0x8614 -#define GL_TRIANGLE_MESH_SUN 0x8615 -typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); -#endif -#endif /* GL_SUN_mesh_array */ - -#ifndef GL_SUN_slice_accum -#define GL_SUN_slice_accum 1 -#define GL_SLICE_ACCUM_SUN 0x85CC -#endif /* GL_SUN_slice_accum */ - -#ifndef GL_SUN_triangle_list -#define GL_SUN_triangle_list 1 -#define GL_RESTART_SUN 0x0001 -#define GL_REPLACE_MIDDLE_SUN 0x0002 -#define GL_REPLACE_OLDEST_SUN 0x0003 -#define GL_TRIANGLE_LIST_SUN 0x81D7 -#define GL_REPLACEMENT_CODE_SUN 0x81D8 -#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 -#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 -#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 -#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 -#define GL_R1UI_V3F_SUN 0x85C4 -#define GL_R1UI_C4UB_V3F_SUN 0x85C5 -#define GL_R1UI_C3F_V3F_SUN 0x85C6 -#define GL_R1UI_N3F_V3F_SUN 0x85C7 -#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 -#define GL_R1UI_T2F_V3F_SUN 0x85C9 -#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA -#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void **pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); -GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); -GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); -GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); -GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); -GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); -GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const void **pointer); -#endif -#endif /* GL_SUN_triangle_list */ - -#ifndef GL_SUN_vertex -#define GL_SUN_vertex 1 -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#endif -#endif /* GL_SUN_vertex */ - -#ifndef GL_WIN_phong_shading -#define GL_WIN_phong_shading 1 -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB -#endif /* GL_WIN_phong_shading */ - -#ifndef GL_WIN_specular_fog -#define GL_WIN_specular_fog 1 -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC -#endif /* GL_WIN_specular_fog */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/third_party/stb/tests/caveview/glext_list.h b/third_party/stb/tests/caveview/glext_list.h deleted file mode 100644 index 5cdbca51f2..0000000000 --- a/third_party/stb/tests/caveview/glext_list.h +++ /dev/null @@ -1,34 +0,0 @@ -GLARB(ActiveTexture,ACTIVETEXTURE) -GLARB(ClientActiveTexture,CLIENTACTIVETEXTURE) -GLARB(MultiTexCoord2f,MULTITEXCOORD2F) -GLEXT(TexImage3D,TEXIMAGE3D) -GLEXT(TexSubImage3D,TEXSUBIMAGE3D) -GLEXT(GenerateMipmap,GENERATEMIPMAP) -GLARB(DebugMessageCallback,DEBUGMESSAGECALLBACK) - -GLCORE(VertexAttribIPointer,VERTEXATTRIBIPOINTER) - -GLEXT(BindFramebuffer,BINDFRAMEBUFFER) -GLEXT(DeleteFramebuffers,DELETEFRAMEBUFFERS) -GLEXT(GenFramebuffers,GENFRAMEBUFFERS) -GLEXT(CheckFramebufferStatus,CHECKFRAMEBUFFERSTATUS) -GLEXT(FramebufferTexture2D,FRAMEBUFFERTEXTURE2D) -GLEXT(BindRenderBuffer,BINDRENDERBUFFER) -GLEXT(RenderbufferStorage,RENDERBUFFERSTORAGE) -GLEXT(GenRenderbuffers,GENRENDERBUFFERS) -GLEXT(BindRenderbuffer,BINDRENDERBUFFER) -GLEXT(FramebufferRenderbuffer,FRAMEBUFFERRENDERBUFFER) -GLEXT(GenerateMipmap,GENERATEMIPMAP) - -GLARB(BindBuffer ,BINDBUFFER,) -GLARB(GenBuffers ,GENBUFFERS ) -GLARB(DeleteBuffers,DELETEBUFFERS) -GLARB(BufferData ,BUFFERDATA ) -GLARB(BufferSubData,BUFFERSUBDATA) -GLARB(MapBuffer ,MAPBUFFER ) -GLARB(UnmapBuffer ,UNMAPBUFFER ) -GLARB(TexBuffer ,TEXBUFFER ) - -GLEXT(NamedBufferStorage,NAMEDBUFFERSTORAGE) -GLE(BufferStorage,BUFFERSTORAGE) -GLE(GetStringi,GETSTRINGI) \ No newline at end of file diff --git a/third_party/stb/tests/caveview/main.c b/third_party/stb/tests/caveview/main.c deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/third_party/stb/tests/caveview/stb_gl.h b/third_party/stb/tests/caveview/stb_gl.h deleted file mode 100644 index 6498e28d8d..0000000000 --- a/third_party/stb/tests/caveview/stb_gl.h +++ /dev/null @@ -1,1103 +0,0 @@ -// stbgl - v0.04 - Sean Barrett 2008 - public domain -// -// Note that the gl extensions support requires glext.h. In fact, it works -// if you just concatenate glext.h onto the end of this file. In that case, -// this file is covered by the SGI FreeB license, and is not public domain. -// -// Extension usage: -// -// 1. Make a file called something like "extlist.txt" which contains stuff like: -// GLE(ShaderSourceARB,SHADERSOURCEARB) -// GLE(Uniform1iARB,UNIFORM1IARB) -// GLARB(ActiveTexture,ACTIVETEXTURE) // same as GLE(ActiveTextureARB,ACTIVETEXTUREARB) -// GLARB(ClientActiveTexture,CLIENTACTIVETEXTURE) -// GLE(MultiTexCoord2f,MULTITEXCOORD2F) -// -// 2. To declare functions (to make a header file), do this: -// #define STB_GLEXT_DECLARE "extlist.txt" -// #include "stb_gl.h" -// -// A good way to do this is to define STB_GLEXT_DECLARE project-wide. -// -// 3. To define functions (implement), do this in some C file: -// #define STB_GLEXT_DEFINE "extlist.txt" -// #include "stb_gl.h" -// -// If you've already defined STB_GLEXT_DECLARE, you can just do: -// #define STB_GLEXT_DEFINE_DECLARE -// #include "stb_gl.h" -// -// 4. Now you need to initialize: -// -// stbgl_initExtensions(); - - -#ifndef INCLUDE_STB_GL_H -#define INCLUDE_STB_GL_H - -#define STB_GL - -#ifdef _WIN32 -#ifndef WINGDIAPI -#define CALLBACK __stdcall -#define WINGDIAPI __declspec(dllimport) -#define APIENTRY __stdcall -#endif -#endif //_WIN32 - -#include - -#include -#include - -#ifndef M_PI -#define M_PI 3.14159265358979323846f -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -// like gluPerspective, but: -// fov is chosen to satisfy both hfov <= max_hfov & vfov <= max_vfov; -// set one to 179 or 0 to ignore it -// zoom is applied separately, so you can do linear zoom without -// mucking with trig with fov; 1 -> use exact fov -// 'aspect' is inferred from the current viewport, and ignores the -// possibility of non-square pixels -extern void stbgl_Perspective(float zoom, float max_hfov, float max_vfov, float znear, float zfar); -extern void stbgl_PerspectiveViewport(int x, int y, int w, int h, float zoom, float max_hfov, float max_vfov, float znear, float zfar); -extern void stbgl_initCamera_zup_facing_x(void); -extern void stbgl_initCamera_zup_facing_y(void); -extern void stbgl_positionCameraWithEulerAngles(float *loc, float *ang); -extern void stbgl_drawRect(float x0, float y0, float x1, float y1); -extern void stbgl_drawRectTC(float x0, float y0, float x1, float y1, float s0, float t0, float s1, float t1); -extern void stbgl_drawBox(float x, float y, float z, float sx, float sy, float sz, int cw); - -extern int stbgl_hasExtension(char *ext); -extern void stbgl_SimpleLight(int index, float bright, float x, float y, float z); -extern void stbgl_GlobalAmbient(float r, float g, float b); - -extern int stbgl_LoadTexture(char *filename, char *props); // only if stb_image is available - -extern int stbgl_TestTexture(int w); -extern int stbgl_TestTextureEx(int w, char *scale_table, int checks_log2, int r1,int g1,int b1, int r2, int b2, int g2); -extern unsigned int stbgl_rand(void); // internal, but exposed just in case; LCG, so use middle bits - -extern int stbgl_TexImage2D(int texid, int w, int h, void *data, char *props); -extern int stbgl_TexImage2D_Extra(int texid, int w, int h, void *data, int chan, char *props, int preserve_data); -// "props" is a series of characters (and blocks of characters), a la fopen()'s mode, -// e.g.: -// GLuint texid = stbgl_LoadTexture("myfile.jpg", "mbc") -// means: load the image "myfile.jpg", and do the following: -// generate mipmaps -// use bilinear filtering (not trilinear) -// use clamp-to-edge on both channels -// -// input descriptor: AT MOST ONE -// TEXT MEANING -// 1 1 channel of input (intensity/alpha) -// 2 2 channels of input (luminance, alpha) -// 3 3 channels of input (RGB) -// 4 4 channels of input (RGBA) -// l 1 channel of input (luminance) -// a 1 channel of input (alpha) -// la 2 channels of input (lum/alpha) -// rgb 3 channels of input (RGB) -// ycocg 3 channels of input (YCoCg - forces YCoCg output) -// ycocgj 4 channels of input (YCoCgJunk - forces YCoCg output) -// rgba 4 channels of input (RGBA) -// -// output descriptor: AT MOST ONE -// TEXT MEANING -// A 1 channel of output (alpha) -// I 1 channel of output (intensity) -// LA 2 channels of output (lum/alpha) -// RGB 3 channels of output (RGB) -// RGBA 4 channels of output (RGBA) -// DXT1 encode as a DXT1 texture (RGB unless input has RGBA) -// DXT3 encode as a DXT3 texture -// DXT5 encode as a DXT5 texture -// YCoCg encode as a DXT5 texture with Y in alpha, CoCg in RG -// D GL_DEPTH_COMPONENT -// NONE no input/output, don't call TexImage2D at all -// -// when reading from a file or using another interface with an explicit -// channel count, the input descriptor is ignored and instead the channel -// count is used as the input descriptor. if the file read is a DXT DDS, -// then it is passed directly to OpenGL in the file format. -// -// if an input descriptor is supplied but no output descriptor, the output -// is assumed to be the same as the input. if an output descriptor is supplied -// but no input descriptor, the input is assumed to be the same as the -// output. if neither is supplied, the input is assumed to be 4-channel. -// If DXT1 or YCoCG output is requested with no input, the input is assumed -// to be 4-channel but the alpha channel is ignored. -// -// filtering descriptor (default is no mipmaps) -// TEXT MEANING -// m generate mipmaps -// M mipmaps are provided, concatenated at end of data (from largest to smallest) -// t use trilinear filtering (default if mipmapped) -// b use bilinear filtering (default if not-mipmapped) -// n use nearest-neighbor sampling -// -// wrapping descriptor -// TEXT MEANING -// w wrap (default) -// c clamp-to-edge -// C GL_CLAMP (uses border color) -// -// If only one wrapping descriptor is supplied, it is applied to both channels. -// -// special: -// TEXT MEANING -// f input data is floats (default unsigned bytes) -// F input&output data is floats (default unsigned bytes) -// p explicitly pre-multiply the alpha -// P pad to power-of-two (default stretches) -// NP2 non-power-of-two -// + can overwrite the texture data with temp data -// ! free the texture data with "free" -// -// the properties string can also include spaces - -#ifdef __cplusplus -} -#endif - - -#ifdef STB_GL_IMPLEMENTATION -#include -#include -#include -#include - -int stbgl_hasExtension(char *ext) -{ - const char *s = glGetString(GL_EXTENSIONS); - for(;;) { - char *e = ext; - for (;;) { - if (*e == 0) { - if (*s == 0 || *s == ' ') return 1; - break; - } - if (*s != *e) - break; - ++s, ++e; - } - while (*s && *s != ' ') ++s; - if (!*s) return 0; - ++s; // skip space - } -} - -void stbgl_drawRect(float x0, float y0, float x1, float y1) -{ - glBegin(GL_POLYGON); - glTexCoord2f(0,0); glVertex2f(x0,y0); - glTexCoord2f(1,0); glVertex2f(x1,y0); - glTexCoord2f(1,1); glVertex2f(x1,y1); - glTexCoord2f(0,1); glVertex2f(x0,y1); - glEnd(); -} - -void stbgl_drawRectTC(float x0, float y0, float x1, float y1, float s0, float t0, float s1, float t1) -{ - glBegin(GL_POLYGON); - glTexCoord2f(s0,t0); glVertex2f(x0,y0); - glTexCoord2f(s1,t0); glVertex2f(x1,y0); - glTexCoord2f(s1,t1); glVertex2f(x1,y1); - glTexCoord2f(s0,t1); glVertex2f(x0,y1); - glEnd(); -} - -void stbgl_drawBox(float x, float y, float z, float sx, float sy, float sz, int cw) -{ - float x0,y0,z0,x1,y1,z1; - sx /=2, sy/=2, sz/=2; - x0 = x-sx; y0 = y-sy; z0 = z-sz; - x1 = x+sx; y1 = y+sy; z1 = z+sz; - - glBegin(GL_QUADS); - if (cw) { - glNormal3f(0,0,-1); - glTexCoord2f(0,0); glVertex3f(x0,y0,z0); - glTexCoord2f(1,0); glVertex3f(x1,y0,z0); - glTexCoord2f(1,1); glVertex3f(x1,y1,z0); - glTexCoord2f(0,1); glVertex3f(x0,y1,z0); - - glNormal3f(0,0,1); - glTexCoord2f(0,0); glVertex3f(x1,y0,z1); - glTexCoord2f(1,0); glVertex3f(x0,y0,z1); - glTexCoord2f(1,1); glVertex3f(x0,y1,z1); - glTexCoord2f(0,1); glVertex3f(x1,y1,z1); - - glNormal3f(-1,0,0); - glTexCoord2f(0,0); glVertex3f(x0,y1,z1); - glTexCoord2f(1,0); glVertex3f(x0,y0,z1); - glTexCoord2f(1,1); glVertex3f(x0,y0,z0); - glTexCoord2f(0,1); glVertex3f(x0,y1,z0); - - glNormal3f(1,0,0); - glTexCoord2f(0,0); glVertex3f(x1,y0,z1); - glTexCoord2f(1,0); glVertex3f(x1,y1,z1); - glTexCoord2f(1,1); glVertex3f(x1,y1,z0); - glTexCoord2f(0,1); glVertex3f(x1,y0,z0); - - glNormal3f(0,-1,0); - glTexCoord2f(0,0); glVertex3f(x0,y0,z1); - glTexCoord2f(1,0); glVertex3f(x1,y0,z1); - glTexCoord2f(1,1); glVertex3f(x1,y0,z0); - glTexCoord2f(0,1); glVertex3f(x0,y0,z0); - - glNormal3f(0,1,0); - glTexCoord2f(0,0); glVertex3f(x1,y1,z1); - glTexCoord2f(1,0); glVertex3f(x0,y1,z1); - glTexCoord2f(1,1); glVertex3f(x0,y1,z0); - glTexCoord2f(0,1); glVertex3f(x1,y1,z0); - } else { - glNormal3f(0,0,-1); - glTexCoord2f(0,0); glVertex3f(x0,y0,z0); - glTexCoord2f(0,1); glVertex3f(x0,y1,z0); - glTexCoord2f(1,1); glVertex3f(x1,y1,z0); - glTexCoord2f(1,0); glVertex3f(x1,y0,z0); - - glNormal3f(0,0,1); - glTexCoord2f(0,0); glVertex3f(x1,y0,z1); - glTexCoord2f(0,1); glVertex3f(x1,y1,z1); - glTexCoord2f(1,1); glVertex3f(x0,y1,z1); - glTexCoord2f(1,0); glVertex3f(x0,y0,z1); - - glNormal3f(-1,0,0); - glTexCoord2f(0,0); glVertex3f(x0,y1,z1); - glTexCoord2f(0,1); glVertex3f(x0,y1,z0); - glTexCoord2f(1,1); glVertex3f(x0,y0,z0); - glTexCoord2f(1,0); glVertex3f(x0,y0,z1); - - glNormal3f(1,0,0); - glTexCoord2f(0,0); glVertex3f(x1,y0,z1); - glTexCoord2f(0,1); glVertex3f(x1,y0,z0); - glTexCoord2f(1,1); glVertex3f(x1,y1,z0); - glTexCoord2f(1,0); glVertex3f(x1,y1,z1); - - glNormal3f(0,-1,0); - glTexCoord2f(0,0); glVertex3f(x0,y0,z1); - glTexCoord2f(0,1); glVertex3f(x0,y0,z0); - glTexCoord2f(1,1); glVertex3f(x1,y0,z0); - glTexCoord2f(1,0); glVertex3f(x1,y0,z1); - - glNormal3f(0,1,0); - glTexCoord2f(0,0); glVertex3f(x1,y1,z1); - glTexCoord2f(0,1); glVertex3f(x1,y1,z0); - glTexCoord2f(1,1); glVertex3f(x0,y1,z0); - glTexCoord2f(1,0); glVertex3f(x0,y1,z1); - } - glEnd(); -} - -void stbgl_SimpleLight(int index, float bright, float x, float y, float z) -{ - float d = (float) (1.0f/sqrt(x*x+y*y+z*z)); - float dir[4] = { x*d,y*d,z*d,0 }, zero[4] = { 0,0,0,0 }; - float c[4] = { bright,bright,bright,0 }; - GLuint light = GL_LIGHT0 + index; - glLightfv(light, GL_POSITION, dir); - glLightfv(light, GL_DIFFUSE, c); - glLightfv(light, GL_AMBIENT, zero); - glLightfv(light, GL_SPECULAR, zero); - glEnable(light); - glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); - glEnable(GL_COLOR_MATERIAL); -} - -void stbgl_GlobalAmbient(float r, float g, float b) -{ - float v[4] = { r,g,b,0 }; - glLightModelfv(GL_LIGHT_MODEL_AMBIENT, v); -} - - -#define stbgl_rad2deg(r) ((r)*180.0f / M_PI) -#define stbgl_deg2rad(r) ((r)/180.0f * M_PI) - -void stbgl_Perspective(float zoom, float max_hfov, float max_vfov, float znear, float zfar) -{ - float unit_width, unit_height, aspect, vfov; - int data[4],w,h; - glGetIntegerv(GL_VIEWPORT, data); - w = data[2]; - h = data[3]; - aspect = (float) w / h; - - if (max_hfov <= 0) max_hfov = 179; - if (max_vfov <= 0) max_vfov = 179; - - // convert max_hfov, max_vfov to worldspace width at depth=1 - unit_width = (float) tan(stbgl_deg2rad(max_hfov/2)) * 2; - unit_height = (float) tan(stbgl_deg2rad(max_vfov/2)) * 2; - // check if hfov = max_hfov is enough to satisfy it - if (unit_width <= aspect * unit_height) { - float height = unit_width / aspect; - vfov = (float) atan(( height/2) / zoom); - } else { - vfov = (float) atan((unit_height/2) / zoom); - } - vfov = (float) stbgl_rad2deg(vfov * 2); - gluPerspective(vfov, aspect, znear, zfar); -} - -void stbgl_PerspectiveViewport(int x, int y, int w, int h, float zoom, float min_hfov, float min_vfov, float znear, float zfar) -{ - if (znear <= 0.0001f) znear = 0.0001f; - glViewport(x,y,w,h); - glScissor(x,y,w,h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - stbgl_Perspective(zoom, min_hfov, min_vfov, znear, zfar); - glMatrixMode(GL_MODELVIEW); -} - -// point the camera along the positive X axis, Z-up -void stbgl_initCamera_zup_facing_x(void) -{ - glRotatef(-90, 1,0,0); - glRotatef( 90, 0,0,1); -} - -// point the camera along the positive Y axis, Z-up -void stbgl_initCamera_zup_facing_y(void) -{ - glRotatef(-90, 1,0,0); -} - -// setup a camera using Euler angles -void stbgl_positionCameraWithEulerAngles(float *loc, float *ang) -{ - glRotatef(-ang[1], 0,1,0); - glRotatef(-ang[0], 1,0,0); - glRotatef(-ang[2], 0,0,1); - glTranslatef(-loc[0], -loc[1], -loc[2]); -} - -static int stbgl_m(char *a, char *b) -{ - // skip first character - do { ++a,++b; } while (*b && *a == *b); - return *b == 0; -} - -#ifdef STBI_VERSION -#ifndef STBI_NO_STDIO -int stbgl_LoadTexture(char *filename, char *props) -{ - // @TODO: handle DDS files directly - int res; - void *data; - int w,h,c; - #ifndef STBI_NO_HDR - if (stbi_is_hdr(filename)) { - data = stbi_loadf(filename, &w, &h, &c, 0); - if (!data) return 0; - res = stbgl_TexImage2D_Extra(0, w,h,data, -c, props, 0); - free(data); - return res; - } - #endif - - data = stbi_load(filename, &w, &h, &c, 0); - if (!data) return 0; - res = stbgl_TexImage2D_Extra(0, w,h,data, c, props, 0); - free(data); - return res; -} -#endif -#endif // STBI_VERSION - -int stbgl_TexImage2D(int texid, int w, int h, void *data, char *props) -{ - return stbgl_TexImage2D_Extra(texid, w, h, data, 0, props,1); -} - -int stbgl_TestTexture(int w) -{ - char scale_table[] = { 10,20,30,30,35,40,5,18,25,13,7,5,3,3,2,2,2,2,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0 }; - return stbgl_TestTextureEx(w, scale_table, 2, 140,130,200, 180,200,170); -} - -unsigned int stbgl_rand(void) -{ - static unsigned int stbgl__rand_seed = 3248980923; // random typing - return stbgl__rand_seed = stbgl__rand_seed * 2147001325 + 715136305; // BCPL generator -} - -// wish this could be smaller, since it's so frivolous -int stbgl_TestTextureEx(int w, char *scale_table, int checks_log2, int r1,int g1,int b1, int r2, int b2, int g2) -{ - int rt[2] = {r1,r2}, gt[2] = {g1,g2}, bt[2] = {b1,b2}; - signed char modded[256]; - int i,j, m = w-1, s,k,scale; - unsigned char *data = (unsigned char *) malloc(w*w*3); - assert((m & w) == 0); - data[0] = 128; - for (s=0; s < 16; ++s) if ((1 << s) == w) break; - assert(w == (1 << s)); - // plasma fractal noise - for (k=s-1; k >= 0; --k) { - int step = 1 << k; - // interpolate from "parents" - for (j=0; j < w; j += step*2) { - for (i=0; i < w; i += step*2) { - int i1 = i+step, j1=j+step; - int i2 = (i+step*2)&m, j2 = (j+step*2)&m; - int p00 = data[(j*w+i )*3], p01 = data[(j2*w+i )*3]; - int p10 = data[(j*w+i2)*3], p11 = data[(j2*w+i2)*3]; - data[(j*w+i1)*3] = (p00+p10)>>1; - data[(j1*w+i)*3] = (p00+p01)>>1; - data[(j1*w+i1)*3]= (p00+p01+p10+p11)>>2; - } - } - scale = scale_table[s-k+1]; - if (!scale) continue; // just interpolate down the remaining data - for (j=0,i=0; i < 256; i += 2, j == scale ? j=0 : ++j) - modded[i] = j, modded[i+1] = -j; // precompute i%scale (plus sign) - for (j=0; j < w; j += step) - for (i=0; i < w; i += step) { - int x = data[(j*w+i)*3] + modded[(stbgl_rand() >> 12) & 255]; - data[(j*w+i)*3] = x < 0 ? 0 : x > 255 ? 255 : x; - } - } - for (j=0; j < w; ++j) - for (i=0; i < w; ++i) { - int check = ((i^j) & (1 << (s-checks_log2))) == 0; - int v = data[(j*w+i)*3] >> 2; - data[(j*w+i)*3+0] = rt[check]-v; - data[(j*w+i)*3+1] = gt[check]-v; - data[(j*w+i)*3+2] = bt[check]-v; - } - return stbgl_TexImage2D(0, w, w, data, "3m!"); // 3 channels, mipmap, free -} - -#ifdef _WIN32 -#ifndef WINGDIAPI -typedef int (__stdcall *stbgl__voidfunc)(void); -__declspec(dllimport) stbgl__voidfunc wglGetProcAddress(char *); -#endif -#define STB__HAS_WGLPROC -static void (__stdcall *stbgl__CompressedTexImage2DARB)(int target, int level, - int internalformat, int width, - int height, int border, - int imageSize, void *data); -static void stbgl__initCompTex(void) -{ - *((void **) &stbgl__CompressedTexImage2DARB) = (void *) wglGetProcAddress("glCompressedTexImage2DARB"); -} -#else -static void (*stbgl__CompressedTexImage2DARB)(int target, int level, - int internalformat, int width, - int height, int border, - int imageSize, void *data); -static void stbgl__initCompTex(void) -{ -} -#endif // _WIN32 - -#define STBGL_COMPRESSED_RGB_S3TC_DXT1 0x83F0 -#define STBGL_COMPRESSED_RGBA_S3TC_DXT1 0x83F1 -#define STBGL_COMPRESSED_RGBA_S3TC_DXT3 0x83F2 -#define STBGL_COMPRESSED_RGBA_S3TC_DXT5 0x83F3 - -#ifdef STB_COMPRESS_DXT_BLOCK -static void stbgl__convert(uint8 *p, uint8 *q, int n, int input_desc, uint8 *end) -{ - int i; - switch (input_desc) { - case GL_RED: - case GL_LUMINANCE: for (i=0; i < n; ++i,p+=4) p[0] = p[1] = p[2] = q[0], p[3]=255, q+=1; break; - case GL_ALPHA: for (i=0; i < n; ++i,p+=4) p[0] = p[1] = p[2] = 0, p[3] = q[0], q+=1; break; - case GL_LUMINANCE_ALPHA: for (i=0; i < n; ++i,p+=4) p[0] = p[1] = p[2] = q[0], p[3]=q[1], q+=2; break; - case GL_RGB: for (i=0; i < n; ++i,p+=4) p[0]=q[0],p[1]=q[1],p[2]=q[2],p[3]=255,q+=3; break; - case GL_RGBA: memcpy(p, q, n*4); break; - case GL_INTENSITY: for (i=0; i < n; ++i,p+=4) p[0] = p[1] = p[2] = p[3] = q[0], q+=1; break; - } - assert(p <= end); -} - -static void stbgl__compress(uint8 *p, uint8 *rgba, int w, int h, int output_desc, uint8 *end) -{ - int i,j,y,y2; - int alpha = (output_desc == STBGL_COMPRESSED_RGBA_S3TC_DXT5); - for (j=0; j < w; j += 4) { - int x=4; - for (i=0; i < h; i += 4) { - uint8 block[16*4]; - if (i+3 >= w) x = w-i; - for (y=0; y < 4; ++y) { - if (j+y >= h) break; - memcpy(block+y*16, rgba + w*4*(j+y) + i*4, x*4); - } - if (x < 4) { - switch (x) { - case 0: assert(0); - case 1: - for (y2=0; y2 < y; ++y2) { - memcpy(block+y2*16+1*4, block+y2*16+0*4, 4); - memcpy(block+y2*16+2*4, block+y2*16+0*4, 8); - } - break; - case 2: - for (y2=0; y2 < y; ++y2) - memcpy(block+y2*16+2*4, block+y2*16+0*4, 8); - break; - case 3: - for (y2=0; y2 < y; ++y2) - memcpy(block+y2*16+3*4, block+y2*16+1*4, 4); - break; - } - } - y2 = 0; - for(; y<4; ++y,++y2) - memcpy(block+y*16, block+y2*16, 4*4); - stb_compress_dxt_block(p, block, alpha, 10); - p += alpha ? 16 : 8; - } - } - assert(p <= end); -} -#endif // STB_COMPRESS_DXT_BLOCK - -// use the reserved temporary-use enumerant range, since no -// OpenGL enumerants should fall in that range -enum -{ - STBGL_UNDEFINED = 0x6000, - STBGL_YCOCG, - STBGL_YCOCGJ, - STBGL_GEN_MIPMAPS, - STBGL_MIPMAPS, - STBGL_NO_DOWNLOAD, -}; - -#define STBGL_CLAMP_TO_EDGE 0x812F -#define STBGL_CLAMP_TO_BORDER 0x812D - -#define STBGL_DEPTH_COMPONENT16 0x81A5 -#define STBGL_DEPTH_COMPONENT24 0x81A6 -#define STBGL_DEPTH_COMPONENT32 0x81A7 - -int stbgl_TexImage2D_Extra(int texid, int w, int h, void *data, int chan, char *props, int preserve_data) -{ - static int has_s3tc = -1; // haven't checked yet - int free_data = 0, is_compressed = 0; - int pad_to_power_of_two = 0, non_power_of_two = 0; - int premultiply_alpha = 0; // @TODO - int float_tex = 0; // @TODO - int input_type = GL_UNSIGNED_BYTE; - int input_desc = STBGL_UNDEFINED; - int output_desc = STBGL_UNDEFINED; - int mipmaps = STBGL_UNDEFINED; - int filter = STBGL_UNDEFINED, mag_filter; - int wrap_s = STBGL_UNDEFINED, wrap_t = STBGL_UNDEFINED; - - // parse out the properties - if (props == NULL) props = ""; - while (*props) { - switch (*props) { - case '1' : input_desc = GL_LUMINANCE; break; - case '2' : input_desc = GL_LUMINANCE_ALPHA; break; - case '3' : input_desc = GL_RGB; break; - case '4' : input_desc = GL_RGBA; break; - case 'l' : if (props[1] == 'a') { input_desc = GL_LUMINANCE_ALPHA; ++props; } - else input_desc = GL_LUMINANCE; - break; - case 'a' : input_desc = GL_ALPHA; break; - case 'r' : if (stbgl_m(props, "rgba")) { input_desc = GL_RGBA; props += 3; break; } - if (stbgl_m(props, "rgb")) { input_desc = GL_RGB; props += 2; break; } - input_desc = GL_RED; - break; - case 'y' : if (stbgl_m(props, "ycocg")) { - if (props[5] == 'j') { props += 5; input_desc = STBGL_YCOCGJ; } - else { props += 4; input_desc = STBGL_YCOCG; } - break; - } - return 0; - case 'L' : if (props[1] == 'A') { output_desc = GL_LUMINANCE_ALPHA; ++props; } - else output_desc = GL_LUMINANCE; - break; - case 'I' : output_desc = GL_INTENSITY; break; - case 'A' : output_desc = GL_ALPHA; break; - case 'R' : if (stbgl_m(props, "RGBA")) { output_desc = GL_RGBA; props += 3; break; } - if (stbgl_m(props, "RGB")) { output_desc = GL_RGB; props += 2; break; } - output_desc = GL_RED; - break; - case 'Y' : if (stbgl_m(props, "YCoCg") || stbgl_m(props, "YCOCG")) { - props += 4; - output_desc = STBGL_YCOCG; - break; - } - return 0; - case 'D' : if (stbgl_m(props, "DXT")) { - switch (props[3]) { - case '1': output_desc = STBGL_COMPRESSED_RGB_S3TC_DXT1; break; - case '3': output_desc = STBGL_COMPRESSED_RGBA_S3TC_DXT3; break; - case '5': output_desc = STBGL_COMPRESSED_RGBA_S3TC_DXT5; break; - default: return 0; - } - props += 3; - } else if (stbgl_m(props, "D16")) { - output_desc = STBGL_DEPTH_COMPONENT16; - input_desc = GL_DEPTH_COMPONENT; - props += 2; - } else if (stbgl_m(props, "D24")) { - output_desc = STBGL_DEPTH_COMPONENT24; - input_desc = GL_DEPTH_COMPONENT; - props += 2; - } else if (stbgl_m(props, "D32")) { - output_desc = STBGL_DEPTH_COMPONENT32; - input_desc = GL_DEPTH_COMPONENT; - props += 2; - } else { - output_desc = GL_DEPTH_COMPONENT; - input_desc = GL_DEPTH_COMPONENT; - } - break; - case 'N' : if (stbgl_m(props, "NONE")) { - props += 3; - input_desc = STBGL_NO_DOWNLOAD; - output_desc = STBGL_NO_DOWNLOAD; - break; - } - if (stbgl_m(props, "NP2")) { - non_power_of_two = 1; - props += 2; - break; - } - return 0; - case 'm' : mipmaps = STBGL_GEN_MIPMAPS; break; - case 'M' : mipmaps = STBGL_MIPMAPS; break; - case 't' : filter = GL_LINEAR_MIPMAP_LINEAR; break; - case 'b' : filter = GL_LINEAR; break; - case 'n' : filter = GL_NEAREST; break; - case 'w' : if (wrap_s == STBGL_UNDEFINED) wrap_s = GL_REPEAT; else wrap_t = GL_REPEAT; break; - case 'C' : if (wrap_s == STBGL_UNDEFINED) wrap_s = STBGL_CLAMP_TO_BORDER; else wrap_t = STBGL_CLAMP_TO_BORDER; break; - case 'c' : if (wrap_s == STBGL_UNDEFINED) wrap_s = STBGL_CLAMP_TO_EDGE; else wrap_t = STBGL_CLAMP_TO_EDGE; break; - case 'f' : input_type = GL_FLOAT; break; - case 'F' : input_type = GL_FLOAT; float_tex = 1; break; - case 'p' : premultiply_alpha = 1; break; - case 'P' : pad_to_power_of_two = 1; break; - case '+' : preserve_data = 0; break; - case '!' : preserve_data = 0; free_data = 1; break; - case ' ' : break; - case '-' : break; - default : if (free_data) free(data); - return 0; - } - ++props; - } - - // override input_desc based on channel count - if (output_desc != STBGL_NO_DOWNLOAD) { - switch (abs(chan)) { - case 1: input_desc = GL_LUMINANCE; break; - case 2: input_desc = GL_LUMINANCE_ALPHA; break; - case 3: input_desc = GL_RGB; break; - case 4: input_desc = GL_RGBA; break; - case 0: break; - default: return 0; - } - } - - // override input_desc based on channel info - if (chan > 0) { input_type = GL_UNSIGNED_BYTE; } - if (chan < 0) { input_type = GL_FLOAT; } - - if (output_desc == GL_ALPHA) { - if (input_desc == GL_LUMINANCE) - input_desc = GL_ALPHA; - if (input_desc == GL_RGB) { - // force a presumably-mono image to alpha - // @TODO handle 'preserve_data' case? - if (data && !preserve_data && input_type == GL_UNSIGNED_BYTE) { - int i; - unsigned char *p = (unsigned char *) data, *q = p; - for (i=0; i < w*h; ++i) { - *q = (p[0] + 2*p[1] + p[2]) >> 2; - p += 3; - q += 1; - } - input_desc = GL_ALPHA; - } - } - } - - // set undefined input/output based on the other - if (input_desc == STBGL_UNDEFINED && output_desc == STBGL_UNDEFINED) { - input_desc = output_desc = GL_RGBA; - } else if (output_desc == STBGL_UNDEFINED) { - switch (input_desc) { - case GL_LUMINANCE: - case GL_ALPHA: - case GL_LUMINANCE_ALPHA: - case GL_RGB: - case GL_RGBA: - output_desc = input_desc; - break; - case GL_RED: - output_desc = GL_INTENSITY; - break; - case STBGL_YCOCG: - case STBGL_YCOCGJ: - output_desc = STBGL_YCOCG; - break; - default: assert(0); return 0; - } - } else if (input_desc == STBGL_UNDEFINED) { - switch (output_desc) { - case GL_LUMINANCE: - case GL_ALPHA: - case GL_LUMINANCE_ALPHA: - case GL_RGB: - case GL_RGBA: - input_desc = output_desc; - break; - case GL_INTENSITY: - input_desc = GL_RED; - break; - case STBGL_YCOCG: - case STBGL_COMPRESSED_RGB_S3TC_DXT1: - case STBGL_COMPRESSED_RGBA_S3TC_DXT3: - case STBGL_COMPRESSED_RGBA_S3TC_DXT5: - input_desc = GL_RGBA; - break; - } - } else { - if (output_desc == STBGL_COMPRESSED_RGB_S3TC_DXT1) { - // if input has alpha, force output alpha - switch (input_desc) { - case GL_ALPHA: - case GL_LUMINANCE_ALPHA: - case GL_RGBA: - output_desc = STBGL_COMPRESSED_RGBA_S3TC_DXT5; - break; - } - } - } - - switch(input_desc) { - case GL_LUMINANCE: - case GL_RED: - case GL_ALPHA: - chan = 1; - break; - case GL_LUMINANCE_ALPHA: - chan = 2; - break; - case GL_RGB: - chan = 3; - break; - case GL_RGBA: - chan = 4; - break; - } - - if (pad_to_power_of_two && ((w & (w-1)) || (h & (h-1)))) { - if (output_desc != STBGL_NO_DOWNLOAD && input_type == GL_UNSIGNED_BYTE && chan > 0) { - unsigned char *new_data; - int w2 = w, h2 = h, j; - while (w & (w-1)) - w = (w | (w>>1))+1; - while (h & (h-1)) - h = (h | (h>>1))+1; - new_data = malloc(w * h * chan); - for (j=0; j < h2; ++j) { - memcpy(new_data + j * w * chan, (char *) data+j*w2*chan, w2*chan); - memset(new_data + (j * w+w2) * chan, 0, (w-w2)*chan); - } - for (; j < h; ++j) - memset(new_data + j*w*chan, 0, w*chan); - if (free_data) - free(data); - data = new_data; - free_data = 1; - } - } - - switch (output_desc) { - case STBGL_COMPRESSED_RGB_S3TC_DXT1: - case STBGL_COMPRESSED_RGBA_S3TC_DXT1: - case STBGL_COMPRESSED_RGBA_S3TC_DXT3: - case STBGL_COMPRESSED_RGBA_S3TC_DXT5: - is_compressed = 1; - if (has_s3tc == -1) { - has_s3tc = stbgl_hasExtension("GL_EXT_texture_compression_s3tc"); - if (has_s3tc) stbgl__initCompTex(); - } - if (!has_s3tc) { - is_compressed = 0; - if (output_desc == STBGL_COMPRESSED_RGB_S3TC_DXT1) - output_desc = GL_RGB; - else - output_desc = GL_RGBA; - } - } - - if (output_desc == STBGL_YCOCG) { - assert(0); - output_desc = GL_RGB; // @TODO! - if (free_data) free(data); - return 0; - } - - mag_filter = 0; - if (mipmaps != STBGL_UNDEFINED) { - switch (filter) { - case STBGL_UNDEFINED: filter = GL_LINEAR_MIPMAP_LINEAR; break; - case GL_NEAREST : mag_filter = GL_NEAREST; filter = GL_LINEAR_MIPMAP_LINEAR; break; - case GL_LINEAR : filter = GL_LINEAR_MIPMAP_NEAREST; break; - } - } else { - if (filter == STBGL_UNDEFINED) - filter = GL_LINEAR; - } - - // update filtering - if (!mag_filter) { - if (filter == GL_NEAREST) - mag_filter = GL_NEAREST; - else - mag_filter = GL_LINEAR; - } - - // update wrap/clamp - if (wrap_s == STBGL_UNDEFINED) wrap_s = GL_REPEAT; - if (wrap_t == STBGL_UNDEFINED) wrap_t = wrap_s; - - // if no texture id, generate one - if (texid == 0) { - GLuint tex; - glGenTextures(1, &tex); - if (tex == 0) { if (free_data) free(data); return 0; } - texid = tex; - } - - if (data == NULL && mipmaps == STBGL_GEN_MIPMAPS) - mipmaps = STBGL_MIPMAPS; - - if (output_desc == STBGL_NO_DOWNLOAD) - mipmaps = STBGL_NO_DOWNLOAD; - - glBindTexture(GL_TEXTURE_2D, texid); - -#ifdef STB_COMPRESS_DXT_BLOCK - if (!is_compressed || !stbgl__CompressedTexImage2DARB || output_desc == STBGL_COMPRESSED_RGBA_S3TC_DXT3 || data == NULL) -#endif - { - switch (mipmaps) { - case STBGL_NO_DOWNLOAD: - break; - - case STBGL_UNDEFINED: - // check if actually power-of-two - if (non_power_of_two || ((w & (w-1)) == 0 && (h & (h-1)) == 0)) - glTexImage2D(GL_TEXTURE_2D, 0, output_desc, w, h, 0, input_desc, input_type, data); - else - gluBuild2DMipmaps(GL_TEXTURE_2D, output_desc, w, h, input_desc, input_type, data); - // not power of two, so use glu to resize (generates mipmaps needlessly) - break; - - case STBGL_MIPMAPS: { - int level = 0; - int size = input_type == GL_FLOAT ? sizeof(float) : 1; - if (data == NULL) size = 0; // reuse same block of memory for all mipmaps - assert((w & (w-1)) == 0 && (h & (h-1)) == 0); // verify power-of-two - while (w > 1 && h > 1) { - glTexImage2D(GL_TEXTURE_2D, level, output_desc, w, h, 0, input_desc, input_type, data); - data = (void *) ((char *) data + w * h * size * chan); - if (w > 1) w >>= 1; - if (h > 1) h >>= 1; - ++level; - } - break; - } - case STBGL_GEN_MIPMAPS: - gluBuild2DMipmaps(GL_TEXTURE_2D, output_desc, w, h, input_desc, input_type, data); - break; - - default: - assert(0); - if (free_data) free(data); - return 0; - } -#ifdef STB_COMPRESS_DXT_BLOCK - } else { - uint8 *out, *rgba=0, *end_out, *end_rgba; - int level = 0, alpha = (output_desc != STBGL_COMPRESSED_RGB_S3TC_DXT1); - int size = input_type == GL_FLOAT ? sizeof(float) : 1; - int osize = alpha ? 16 : 8; - if (!free_data && mipmaps == STBGL_GEN_MIPMAPS) { - uint8 *temp = malloc(w*h*chan); - if (!temp) { if (free_data) free(data); return 0; } - memcpy(temp, data, w*h*chan); - if (free_data) free(data); - free_data = 1; - data = temp; - } - if (chan != 4 || size != 1) { - rgba = malloc(w*h*4); - if (!rgba) return 0; - end_rgba = rgba+w*h*4; - } - out = malloc((w+3)*(h+3)/16*osize); // enough storage for the s3tc data - if (!out) return 0; - end_out = out + ((w+3)*(h+3))/16*osize; - - for(;;) { - if (chan != 4) - stbgl__convert(rgba, data, w*h, input_desc, end_rgba); - stbgl__compress(out, rgba ? rgba : data, w, h, output_desc, end_out); - stbgl__CompressedTexImage2DARB(GL_TEXTURE_2D, level, output_desc, w, h, 0, ((w+3)&~3)*((h+3)&~3)/16*osize, out); - //glTexImage2D(GL_TEXTURE_2D, level, alpha?GL_RGBA:GL_RGB, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgba ? rgba : data); - - if (mipmaps == STBGL_UNDEFINED) break; - if (w <= 1 && h <= 1) break; - if (mipmaps == STBGL_MIPMAPS) data = (void *) ((char *) data + w * h * size * chan); - if (mipmaps == STBGL_GEN_MIPMAPS) { - int w2 = w>>1, h2=h>>1, i,j,k, s=w*chan; - uint8 *p = data, *q=data; - if (w == 1) { - for (j=0; j < h2; ++j) { - for (k=0; k < chan; ++k) - *p++ = (q[k] + q[s+k] + 1) >> 1; - q += s*2; - } - } else if (h == 1) { - for (i=0; i < w2; ++i) { - for (k=0; k < chan; ++k) - *p++ = (q[k] + q[k+chan] + 1) >> 1; - q += chan*2; - } - } else { - for (j=0; j < h2; ++j) { - for (i=0; i < w2; ++i) { - for (k=0; k < chan; ++k) - *p++ = (q[k] + q[k+chan] + q[s+k] + q[s+k+chan] + 2) >> 2; - q += chan*2; - } - q += s; - } - } - } - if (w > 1) w >>= 1; - if (h > 1) h >>= 1; - ++level; - } - if (out) free(out); - if (rgba) free(rgba); -#endif // STB_COMPRESS_DXT_BLOCK - } - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_t); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); - - if (free_data) free(data); - return texid; -} - -#endif // STB_DEFINE -#undef STB_EXTERN - -#endif //INCLUDE_STB_GL_H - -// Extension handling... must be outside the INCLUDE_ brackets - -#if defined(STB_GLEXT_DEFINE) || defined(STB_GLEXT_DECLARE) - -#ifndef STB_GLEXT_SKIP_DURING_RECURSION - -#ifndef GL_GLEXT_VERSION - - // First check if glext.h is concatenated on the end of this file - // (if it's concatenated on the beginning, we'll have GL_GLEXT_VERSION) - - #define STB_GLEXT_SKIP_DURING_RECURSION - #include __FILE__ - #undef STB_GLEXT_SKIP_DURING_RECURSION - - // now check if it's still undefined; if so, try going for it by name; - // if this errors, that's fine, since we can't compile without it - - #ifndef GL_GLEXT_VERSION - #include "glext.h" - #endif -#endif - -#define GLARB(a,b) GLE(a##ARB,b##ARB) -#define GLEXT(a,b) GLE(a##EXT,b##EXT) -#define GLNV(a,b) GLE(a##NV ,b##NV) -#define GLATI(a,b) GLE(a##ATI,b##ATI) -#define GLCORE(a,b) GLE(a,b) - -#ifdef STB_GLEXT_DEFINE_DECLARE -#define STB_GLEXT_DEFINE STB_GLEXT_DECLARE -#endif - -#if defined(STB_GLEXT_DECLARE) && defined(STB_GLEXT_DEFINE) -#undef STB_GLEXT_DECLARE -#endif - -#if defined(STB_GLEXT_DECLARE) && !defined(STB_GLEXT_DEFINE) - #define GLE(a,b) extern PFNGL##b##PROC gl##a; - - #ifdef __cplusplus - extern "C" { - #endif - - extern void stbgl_initExtensions(void); - - #include STB_GLEXT_DECLARE - - #ifdef __cplusplus - }; - #endif - -#else - - #ifndef STB_GLEXT_DEFINE - #error "Header file is screwed up somehow" - #endif - - #ifdef _WIN32 - #ifndef WINGDIAPI - #ifndef STB__HAS_WGLPROC - typedef int (__stdcall *stbgl__voidfunc)(void); - __declspec(dllimport) stbgl__voidfunc wglGetProcAddress(char *); - #endif - #endif - #define STBGL__GET_FUNC(x) wglGetProcAddress(x) - #endif - - #ifdef GLE - #undef GLE - #endif - - #define GLE(a,b) PFNGL##b##PROC gl##a; - #include STB_GLEXT_DEFINE - - #undef GLE - #define GLE(a,b) gl##a = (PFNGL##b##PROC) STBGL__GET_FUNC("gl" #a ); - - void stbgl_initExtensions(void) - { - #include STB_GLEXT_DEFINE - } - - #undef GLE - -#endif // STB_GLEXT_DECLARE - -#endif // STB_GLEXT_SKIP - -#endif // STB_GLEXT_DEFINE || STB_GLEXT_DECLARE diff --git a/third_party/stb/tests/caveview/stb_glprog.h b/third_party/stb/tests/caveview/stb_glprog.h deleted file mode 100644 index 8883a3ebe9..0000000000 --- a/third_party/stb/tests/caveview/stb_glprog.h +++ /dev/null @@ -1,504 +0,0 @@ -// stb_glprog v0.02 public domain functions to reduce GLSL boilerplate -// http://nothings.org/stb/stb_glprog.h especially with GL1 + ARB extensions -// -// Following defines *before* including have following effects: -// -// STB_GLPROG_IMPLEMENTATION -// creates the implementation -// -// STB_GLPROG_STATIC -// forces the implementation to be static (private to file that creates it) -// -// STB_GLPROG_ARB -// uses ARB extension names for GLSL functions and enumerants instead of core names -// -// STB_GLPROG_ARB_DEFINE_EXTENSIONS -// instantiates function pointers needed, static to implementing file -// to avoid collisions (but will collide if implementing file also -// defines any; best to isolate this to its own file in this case). -// This will try to automatically #include glext.h, but if it's not -// in the default include directories you'll need to include it -// yourself and define the next macro. -// -// STB_GLPROG_SUPPRESS_GLEXT_INCLUDE -// disables the automatic #include of glext.h which is normally -// forced by STB_GLPROG_ARB_DEFINE_EXTENSIONS -// -// So, e.g., sample usage on an old Windows compiler: -// -// #define STB_GLPROG_IMPLEMENTATION -// #define STB_GLPROG_ARB_DEFINE_EXTENSIONS -// #include -// #include "gl/gl.h" -// #include "stb_glprog.h" -// -// Note though that the header-file version of this (when you don't define -// STB_GLPROG_IMPLEMENTATION) still uses GLint and such, so you basically -// can only include it in places where you're already including GL, especially -// on Windows where including "gl.h" requires (some of) "windows.h". -// -// See following comment blocks for function documentation. -// -// Version history: -// 2013-12-08 v0.02 slightly simplified API and reduced GL resource usage (@rygorous) -// 2013-12-08 v0.01 initial release - - -// header file section starts here -#if !defined(INCLUDE_STB_GLPROG_H) -#define INCLUDE_STB_GLPROG_H - -#ifndef STB_GLPROG_STATIC -#ifdef __cplusplus -extern "C" { -#endif - -////////////////////////////////////////////////////////////////////////////// - -///////////// SHADER CREATION - - -/// EASY API - -extern GLuint stbgl_create_program(char const **vertex_source, char const **frag_source, char const **binds, char *error, int error_buflen); -// This function returns a compiled program or 0 if there's an error. -// To free the created program, call stbgl_delete_program. -// -// stbgl_create_program( -// char **vertex_source, // NULL or one or more strings with the vertex shader source, with a final NULL -// char **frag_source, // NULL or one or more strings with the fragment shader source, with a final NULL -// char **binds, // NULL or zero or more strings with attribute bind names, with a final NULL -// char *error, // output location where compile error message is placed -// int error_buflen) // length of error output buffer -// -// Returns a GLuint with the GL program object handle. -// -// If an individual bind string is "", no name is bound to that slot (this -// allows you to create binds that aren't continuous integers starting at 0). -// -// If the vertex shader is NULL, then fixed-function vertex pipeline -// is used, if that's legal in your version of GL. -// -// If the fragment shader is NULL, then fixed-function fragment pipeline -// is used, if that's legal in your version of GL. - -extern void stgbl_delete_program(GLuint program); -// deletes a program created by stbgl_create_program or stbgl_link_program - - -/// FLEXIBLE API - -extern GLuint stbgl_compile_shader(GLenum type, char const **sources, int num_sources, char *error, int error_buflen); -// compiles a shader. returns the shader on success or 0 on failure. -// -// type either: GL_VERTEX_SHADER or GL_FRAGMENT_SHADER -// or GL_VERTEX_SHADER_ARB or GL_FRAGMENT_SHADER_ARB -// or STBGL_VERTEX_SHADER or STBGL_FRAGMENT_SHADER -// sources array of strings containing the shader source -// num_sources number of string in sources, or -1 meaning sources is NULL-terminated -// error string to output compiler error to -// error_buflen length of error buffer in chars - -extern GLuint stbgl_link_program(GLuint vertex_shader, GLuint fragment_shader, char const **binds, int num_binds, char *error, int error_buflen); -// links a shader. returns the linked program on success or 0 on failure. -// -// vertex_shader a compiled vertex shader from stbgl_compile_shader, or 0 for fixed-function (if legal) -// fragment_shader a compiled fragment shader from stbgl_compile_shader, or 0 for fixed-function (if legal) -// - -extern void stbgl_delete_shader(GLuint shader); -// deletes a shader created by stbgl_compile_shader - - -///////////// RENDERING WITH SHADERS - -extern GLint stbgl_find_uniform(GLuint prog, char *uniform); - -extern void stbgl_find_uniforms(GLuint prog, GLint *locations, char const **uniforms, int num_uniforms); -// Given the locations array that is num_uniforms long, fills out -// the locations of each of those uniforms for the specified program. -// If num_uniforms is -1, then uniforms[] must be NULL-terminated - -// the following functions just wrap the difference in naming between GL2+ and ARB, -// so you don't need them unless you're using both ARB and GL2+ in the same codebase, -// or you're relying on this lib to provide the extensions -extern void stbglUseProgram(GLuint program); -extern void stbglVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * pointer); -extern void stbglEnableVertexAttribArray(GLuint index); -extern void stbglDisableVertexAttribArray(GLuint index); -extern void stbglUniform1fv(GLint loc, GLsizei count, const GLfloat *v); -extern void stbglUniform2fv(GLint loc, GLsizei count, const GLfloat *v); -extern void stbglUniform3fv(GLint loc, GLsizei count, const GLfloat *v); -extern void stbglUniform4fv(GLint loc, GLsizei count, const GLfloat *v); -extern void stbglUniform1iv(GLint loc, GLsizei count, const GLint *v); -extern void stbglUniform2iv(GLint loc, GLsizei count, const GLint *v); -extern void stbglUniform3iv(GLint loc, GLsizei count, const GLint *v); -extern void stbglUniform4iv(GLint loc, GLsizei count, const GLint *v); -extern void stbglUniform1f(GLint loc, float v0); -extern void stbglUniform2f(GLint loc, float v0, float v1); -extern void stbglUniform3f(GLint loc, float v0, float v1, float v2); -extern void stbglUniform4f(GLint loc, float v0, float v1, float v2, float v3); -extern void stbglUniform1i(GLint loc, GLint v0); -extern void stbglUniform2i(GLint loc, GLint v0, GLint v1); -extern void stbglUniform3i(GLint loc, GLint v0, GLint v1, GLint v2); -extern void stbglUniform4i(GLint loc, GLint v0, GLint v1, GLint v2, GLint v3); - - -////////////// END OF FUNCTIONS - -////////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -} -#endif -#endif // STB_GLPROG_STATIC - -#ifdef STB_GLPROG_ARB -#define STBGL_VERTEX_SHADER GL_VERTEX_SHADER_ARB -#define STBGL_FRAGMENT_SHADER GL_FRAGMENT_SHADER_ARB -#else -#define STBGL_VERTEX_SHADER GL_VERTEX_SHADER -#define STBGL_FRAGMENT_SHADER GL_FRAGMENT_SHADER -#endif - -#endif // INCLUDE_STB_GLPROG_H - - -///////// header file section ends here - - -#ifdef STB_GLPROG_IMPLEMENTATION -#include // strncpy - -#ifdef STB_GLPROG_STATIC -#define STB_GLPROG_DECLARE static -#else -#define STB_GLPROG_DECLARE extern -#endif - -// check if user wants this file to define the GL extensions itself -#ifdef STB_GLPROG_ARB_DEFINE_EXTENSIONS -#define STB_GLPROG_ARB // make sure later code uses the extensions - -#ifndef STB_GLPROG_SUPPRESS_GLEXT_INCLUDE -#include "glext.h" -#endif - -#define STB_GLPROG_EXTENSIONS \ - STB_GLPROG_FUNC(ATTACHOBJECT , AttachObject ) \ - STB_GLPROG_FUNC(BINDATTRIBLOCATION , BindAttribLocation ) \ - STB_GLPROG_FUNC(COMPILESHADER , CompileShader ) \ - STB_GLPROG_FUNC(CREATEPROGRAMOBJECT , CreateProgramObject ) \ - STB_GLPROG_FUNC(CREATESHADEROBJECT , CreateShaderObject ) \ - STB_GLPROG_FUNC(DELETEOBJECT , DeleteObject ) \ - STB_GLPROG_FUNC(DETACHOBJECT , DetachObject ) \ - STB_GLPROG_FUNC(DISABLEVERTEXATTRIBARRAY, DisableVertexAttribArray) \ - STB_GLPROG_FUNC(ENABLEVERTEXATTRIBARRAY, EnableVertexAttribArray ) \ - STB_GLPROG_FUNC(GETATTACHEDOBJECTS , GetAttachedObjects ) \ - STB_GLPROG_FUNC(GETOBJECTPARAMETERIV, GetObjectParameteriv) \ - STB_GLPROG_FUNC(GETINFOLOG , GetInfoLog ) \ - STB_GLPROG_FUNC(GETUNIFORMLOCATION , GetUniformLocation ) \ - STB_GLPROG_FUNC(LINKPROGRAM , LinkProgram ) \ - STB_GLPROG_FUNC(SHADERSOURCE , ShaderSource ) \ - STB_GLPROG_FUNC(UNIFORM1F , Uniform1f ) \ - STB_GLPROG_FUNC(UNIFORM2F , Uniform2f ) \ - STB_GLPROG_FUNC(UNIFORM3F , Uniform3f ) \ - STB_GLPROG_FUNC(UNIFORM4F , Uniform4f ) \ - STB_GLPROG_FUNC(UNIFORM1I , Uniform1i ) \ - STB_GLPROG_FUNC(UNIFORM2I , Uniform2i ) \ - STB_GLPROG_FUNC(UNIFORM3I , Uniform3i ) \ - STB_GLPROG_FUNC(UNIFORM4I , Uniform4i ) \ - STB_GLPROG_FUNC(UNIFORM1FV , Uniform1fv ) \ - STB_GLPROG_FUNC(UNIFORM2FV , Uniform2fv ) \ - STB_GLPROG_FUNC(UNIFORM3FV , Uniform3fv ) \ - STB_GLPROG_FUNC(UNIFORM4FV , Uniform4fv ) \ - STB_GLPROG_FUNC(UNIFORM1IV , Uniform1iv ) \ - STB_GLPROG_FUNC(UNIFORM2IV , Uniform2iv ) \ - STB_GLPROG_FUNC(UNIFORM3IV , Uniform3iv ) \ - STB_GLPROG_FUNC(UNIFORM4IV , Uniform4iv ) \ - STB_GLPROG_FUNC(USEPROGRAMOBJECT , UseProgramObject ) \ - STB_GLPROG_FUNC(VERTEXATTRIBPOINTER , VertexAttribPointer ) - -// define the static function pointers - -#define STB_GLPROG_FUNC(x,y) static PFNGL##x##ARBPROC gl##y##ARB; -STB_GLPROG_EXTENSIONS -#undef STB_GLPROG_FUNC - -// define the GetProcAddress - -#ifdef _WIN32 -#ifndef WINGDIAPI -#ifndef STB__HAS_WGLPROC -typedef int (__stdcall *stbgl__voidfunc)(void); -static __declspec(dllimport) stbgl__voidfunc wglGetProcAddress(char *); -#endif -#endif -#define STBGL__GET_FUNC(x) wglGetProcAddress(x) -#else -#error "need to define how this platform gets extensions" -#endif - -// create a function that fills out the function pointers - -static void stb_glprog_init(void) -{ - static int initialized = 0; // not thread safe! - if (initialized) return; - #define STB_GLPROG_FUNC(x,y) gl##y##ARB = (PFNGL##x##ARBPROC) STBGL__GET_FUNC("gl" #y "ARB"); - STB_GLPROG_EXTENSIONS - #undef STB_GLPROG_FUNC -} -#undef STB_GLPROG_EXTENSIONS - -#else -static void stb_glprog_init(void) -{ -} -#endif - - -// define generic names for many of the gl functions or extensions for later use; -// note that in some cases there are two functions in core and one function in ARB -#ifdef STB_GLPROG_ARB -#define stbglCreateShader glCreateShaderObjectARB -#define stbglDeleteShader glDeleteObjectARB -#define stbglAttachShader glAttachObjectARB -#define stbglDetachShader glDetachObjectARB -#define stbglShaderSource glShaderSourceARB -#define stbglCompileShader glCompileShaderARB -#define stbglGetShaderStatus(a,b) glGetObjectParameterivARB(a, GL_OBJECT_COMPILE_STATUS_ARB, b) -#define stbglGetShaderInfoLog glGetInfoLogARB -#define stbglCreateProgram glCreateProgramObjectARB -#define stbglDeleteProgram glDeleteObjectARB -#define stbglLinkProgram glLinkProgramARB -#define stbglGetProgramStatus(a,b) glGetObjectParameterivARB(a, GL_OBJECT_LINK_STATUS_ARB, b) -#define stbglGetProgramInfoLog glGetInfoLogARB -#define stbglGetAttachedShaders glGetAttachedObjectsARB -#define stbglBindAttribLocation glBindAttribLocationARB -#define stbglGetUniformLocation glGetUniformLocationARB -#define stbgl_UseProgram glUseProgramObjectARB -#else -#define stbglCreateShader glCreateShader -#define stbglDeleteShader glDeleteShader -#define stbglAttachShader glAttachShader -#define stbglDetachShader glDetachShader -#define stbglShaderSource glShaderSource -#define stbglCompileShader glCompileShader -#define stbglGetShaderStatus(a,b) glGetShaderiv(a, GL_COMPILE_STATUS, b) -#define stbglGetShaderInfoLog glGetShaderInfoLog -#define stbglCreateProgram glCreateProgram -#define stbglDeleteProgram glDeleteProgram -#define stbglLinkProgram glLinkProgram -#define stbglGetProgramStatus(a,b) glGetProgramiv(a, GL_LINK_STATUS, b) -#define stbglGetProgramInfoLog glGetProgramInfoLog -#define stbglGetAttachedShaders glGetAttachedShaders -#define stbglBindAttribLocation glBindAttribLocation -#define stbglGetUniformLocation glGetUniformLocation -#define stbgl_UseProgram glUseProgram -#endif - - -// perform a safe strcat of 3 strings, given that we can't rely on portable snprintf -// if you need to break on error, this is the best place to place a breakpoint -static void stb_glprog_error(char *error, int error_buflen, char *str1, char *str2, char *str3) -{ - int n = strlen(str1); - strncpy(error, str1, error_buflen); - if (n < error_buflen && str2) { - strncpy(error+n, str2, error_buflen - n); - n += strlen(str2); - if (n < error_buflen && str3) { - strncpy(error+n, str3, error_buflen - n); - } - } - error[error_buflen-1] = 0; -} - -STB_GLPROG_DECLARE GLuint stbgl_compile_shader(GLenum type, char const **sources, int num_sources, char *error, int error_buflen) -{ - char *typename = (type == STBGL_VERTEX_SHADER ? "vertex" : "fragment"); - int len; - GLint result; - GLuint shader; - - // initialize the extensions if we haven't already - stb_glprog_init(); - - // allocate - - shader = stbglCreateShader(type); - if (!shader) { - stb_glprog_error(error, error_buflen, "Couldn't allocate shader object in stbgl_compile_shader for ", typename, NULL); - return 0; - } - - // compile - - // if num_sources is negative, assume source is NULL-terminated and count the non-NULL ones - if (num_sources < 0) - for (num_sources = 0; sources[num_sources] != NULL; ++num_sources) - ; - stbglShaderSource(shader, num_sources, sources, NULL); - stbglCompileShader(shader); - stbglGetShaderStatus(shader, &result); - if (result) - return shader; - - // errors - - stb_glprog_error(error, error_buflen, "Compile error for ", typename, " shader: "); - len = strlen(error); - if (len < error_buflen) - stbglGetShaderInfoLog(shader, error_buflen-len, NULL, error+len); - - stbglDeleteShader(shader); - return 0; -} - -STB_GLPROG_DECLARE GLuint stbgl_link_program(GLuint vertex_shader, GLuint fragment_shader, char const **binds, int num_binds, char *error, int error_buflen) -{ - int len; - GLint result; - - // allocate - - GLuint prog = stbglCreateProgram(); - if (!prog) { - stb_glprog_error(error, error_buflen, "Couldn't allocate program object in stbgl_link_program", NULL, NULL); - return 0; - } - - // attach - - if (vertex_shader) - stbglAttachShader(prog, vertex_shader); - if (fragment_shader) - stbglAttachShader(prog, fragment_shader); - - // attribute binds - - if (binds) { - int i; - // if num_binds is negative, then it is NULL terminated - if (num_binds < 0) - for (num_binds=0; binds[num_binds]; ++num_binds) - ; - for (i=0; i < num_binds; ++i) - if (binds[i] && binds[i][0]) // empty binds can be NULL or "" - stbglBindAttribLocation(prog, i, binds[i]); - } - - // link - - stbglLinkProgram(prog); - - // detach - - if (vertex_shader) - stbglDetachShader(prog, vertex_shader); - if (fragment_shader) - stbglDetachShader(prog, fragment_shader); - - // errors - - stbglGetProgramStatus(prog, &result); - if (result) - return prog; - - stb_glprog_error(error, error_buflen, "Link error: ", NULL, NULL); - len = strlen(error); - if (len < error_buflen) - stbglGetProgramInfoLog(prog, error_buflen-len, NULL, error+len); - - stbglDeleteProgram(prog); - return 0; -} - -STB_GLPROG_DECLARE GLuint stbgl_create_program(char const **vertex_source, char const **frag_source, char const **binds, char *error, int error_buflen) -{ - GLuint vertex, fragment, prog=0; - vertex = stbgl_compile_shader(STBGL_VERTEX_SHADER, vertex_source, -1, error, error_buflen); - if (vertex) { - fragment = stbgl_compile_shader(STBGL_FRAGMENT_SHADER, frag_source, -1, error, error_buflen); - if (fragment) - prog = stbgl_link_program(vertex, fragment, binds, -1, error, error_buflen); - if (fragment) - stbglDeleteShader(fragment); - stbglDeleteShader(vertex); - } - return prog; -} - -STB_GLPROG_DECLARE void stbgl_delete_shader(GLuint shader) -{ - stbglDeleteShader(shader); -} - -STB_GLPROG_DECLARE void stgbl_delete_program(GLuint program) -{ - stbglDeleteProgram(program); -} - -GLint stbgl_find_uniform(GLuint prog, char *uniform) -{ - return stbglGetUniformLocation(prog, uniform); -} - -STB_GLPROG_DECLARE void stbgl_find_uniforms(GLuint prog, GLint *locations, char const **uniforms, int num_uniforms) -{ - int i; - if (num_uniforms < 0) - num_uniforms = 999999; - for (i=0; i < num_uniforms && uniforms[i]; ++i) - locations[i] = stbglGetUniformLocation(prog, uniforms[i]); -} - -STB_GLPROG_DECLARE void stbglUseProgram(GLuint program) -{ - stbgl_UseProgram(program); -} - -#ifdef STB_GLPROG_ARB -#define STBGL_ARBIFY(name) name##ARB -#else -#define STBGL_ARBIFY(name) name -#endif - -STB_GLPROG_DECLARE void stbglVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * pointer) -{ - STBGL_ARBIFY(glVertexAttribPointer)(index, size, type, normalized, stride, pointer); -} - -STB_GLPROG_DECLARE void stbglEnableVertexAttribArray (GLuint index) { STBGL_ARBIFY(glEnableVertexAttribArray )(index); } -STB_GLPROG_DECLARE void stbglDisableVertexAttribArray(GLuint index) { STBGL_ARBIFY(glDisableVertexAttribArray)(index); } - -STB_GLPROG_DECLARE void stbglUniform1fv(GLint loc, GLsizei count, const GLfloat *v) { STBGL_ARBIFY(glUniform1fv)(loc,count,v); } -STB_GLPROG_DECLARE void stbglUniform2fv(GLint loc, GLsizei count, const GLfloat *v) { STBGL_ARBIFY(glUniform2fv)(loc,count,v); } -STB_GLPROG_DECLARE void stbglUniform3fv(GLint loc, GLsizei count, const GLfloat *v) { STBGL_ARBIFY(glUniform3fv)(loc,count,v); } -STB_GLPROG_DECLARE void stbglUniform4fv(GLint loc, GLsizei count, const GLfloat *v) { STBGL_ARBIFY(glUniform4fv)(loc,count,v); } - -STB_GLPROG_DECLARE void stbglUniform1iv(GLint loc, GLsizei count, const GLint *v) { STBGL_ARBIFY(glUniform1iv)(loc,count,v); } -STB_GLPROG_DECLARE void stbglUniform2iv(GLint loc, GLsizei count, const GLint *v) { STBGL_ARBIFY(glUniform2iv)(loc,count,v); } -STB_GLPROG_DECLARE void stbglUniform3iv(GLint loc, GLsizei count, const GLint *v) { STBGL_ARBIFY(glUniform3iv)(loc,count,v); } -STB_GLPROG_DECLARE void stbglUniform4iv(GLint loc, GLsizei count, const GLint *v) { STBGL_ARBIFY(glUniform4iv)(loc,count,v); } - -STB_GLPROG_DECLARE void stbglUniform1f(GLint loc, float v0) - { STBGL_ARBIFY(glUniform1f)(loc,v0); } -STB_GLPROG_DECLARE void stbglUniform2f(GLint loc, float v0, float v1) - { STBGL_ARBIFY(glUniform2f)(loc,v0,v1); } -STB_GLPROG_DECLARE void stbglUniform3f(GLint loc, float v0, float v1, float v2) - { STBGL_ARBIFY(glUniform3f)(loc,v0,v1,v2); } -STB_GLPROG_DECLARE void stbglUniform4f(GLint loc, float v0, float v1, float v2, float v3) - { STBGL_ARBIFY(glUniform4f)(loc,v0,v1,v2,v3); } - -STB_GLPROG_DECLARE void stbglUniform1i(GLint loc, GLint v0) - { STBGL_ARBIFY(glUniform1i)(loc,v0); } -STB_GLPROG_DECLARE void stbglUniform2i(GLint loc, GLint v0, GLint v1) - { STBGL_ARBIFY(glUniform2i)(loc,v0,v1); } -STB_GLPROG_DECLARE void stbglUniform3i(GLint loc, GLint v0, GLint v1, GLint v2) - { STBGL_ARBIFY(glUniform3i)(loc,v0,v1,v2); } -STB_GLPROG_DECLARE void stbglUniform4i(GLint loc, GLint v0, GLint v1, GLint v2, GLint v3) - { STBGL_ARBIFY(glUniform4i)(loc,v0,v1,v2,v3); } - -#endif diff --git a/third_party/stb/tests/caveview/win32/SDL_windows_main.c b/third_party/stb/tests/caveview/win32/SDL_windows_main.c deleted file mode 100644 index 32e316b557..0000000000 --- a/third_party/stb/tests/caveview/win32/SDL_windows_main.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - SDL_windows_main.c, placed in the public domain by Sam Lantinga 4/13/98 - - The WinMain function -- calls your program's main() function -*/ -#include "SDL_config.h" - -#ifdef __WIN32__ - -//#include "../../core/windows/SDL_windows.h" - -/* Include this so we define UNICODE properly */ -#if defined(__WIN32__) -#define WIN32_LEAN_AND_MEAN -#define STRICT -#ifndef UNICODE -#define UNICODE 1 -#endif -#undef _WIN32_WINNT -#define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */ -#endif - -#include - -/* Routines to convert from UTF8 to native Windows text */ -#if UNICODE -#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR)) -#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (char *)(S), SDL_strlen(S)+1) -#else -/* !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. */ -#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)(S), (SDL_strlen(S)+1)) -#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1) -#endif - -/* Sets an error message based on a given HRESULT */ -extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr); - -/* Sets an error message based on GetLastError(). Always return -1. */ -extern int WIN_SetError(const char *prefix); - -/* Wrap up the oddities of CoInitialize() into a common function. */ -extern HRESULT WIN_CoInitialize(void); -extern void WIN_CoUninitialize(void); - -/* Returns SDL_TRUE if we're running on Windows Vista and newer */ -extern BOOL WIN_IsWindowsVistaOrGreater(); - -#include -#include - -/* Include the SDL main definition header */ -#include "SDL.h" -#include "SDL_main.h" - -#ifdef main -# undef main -#endif /* main */ - -static void -UnEscapeQuotes(char *arg) -{ - char *last = NULL; - - while (*arg) { - if (*arg == '"' && (last != NULL && *last == '\\')) { - char *c_curr = arg; - char *c_last = last; - - while (*c_curr) { - *c_last = *c_curr; - c_last = c_curr; - c_curr++; - } - *c_last = '\0'; - } - last = arg; - arg++; - } -} - -/* Parse a command line buffer into arguments */ -static int -ParseCommandLine(char *cmdline, char **argv) -{ - char *bufp; - char *lastp = NULL; - int argc, last_argc; - - argc = last_argc = 0; - for (bufp = cmdline; *bufp;) { - /* Skip leading whitespace */ - while (SDL_isspace(*bufp)) { - ++bufp; - } - /* Skip over argument */ - if (*bufp == '"') { - ++bufp; - if (*bufp) { - if (argv) { - argv[argc] = bufp; - } - ++argc; - } - /* Skip over word */ - lastp = bufp; - while (*bufp && (*bufp != '"' || *lastp == '\\')) { - lastp = bufp; - ++bufp; - } - } else { - if (*bufp) { - if (argv) { - argv[argc] = bufp; - } - ++argc; - } - /* Skip over word */ - while (*bufp && !SDL_isspace(*bufp)) { - ++bufp; - } - } - if (*bufp) { - if (argv) { - *bufp = '\0'; - } - ++bufp; - } - - /* Strip out \ from \" sequences */ - if (argv && last_argc != argc) { - UnEscapeQuotes(argv[last_argc]); - } - last_argc = argc; - } - if (argv) { - argv[argc] = NULL; - } - return (argc); -} - -/* Show an error message */ -static void -ShowError(const char *title, const char *message) -{ -/* If USE_MESSAGEBOX is defined, you need to link with user32.lib */ -#ifdef USE_MESSAGEBOX - MessageBox(NULL, message, title, MB_ICONEXCLAMATION | MB_OK); -#else - fprintf(stderr, "%s: %s\n", title, message); -#endif -} - -/* Pop up an out of memory message, returns to Windows */ -static BOOL -OutOfMemory(void) -{ - ShowError("Fatal Error", "Out of memory - aborting"); - return FALSE; -} - -#if defined(_MSC_VER) -/* The VC++ compiler needs main defined */ -#define console_main main -#endif - -/* This is where execution begins [console apps] */ -int -console_main(int argc, char *argv[]) -{ - int status; - - SDL_SetMainReady(); - - /* Run the application main() code */ - status = SDL_main(argc, argv); - - /* Exit cleanly, calling atexit() functions */ - exit(status); - - /* Hush little compiler, don't you cry... */ - return 0; -} - -/* This is where execution begins [windowed apps] */ -int WINAPI -WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) -{ - char **argv; - int argc; - char *cmdline; - - /* Grab the command line */ - TCHAR *text = GetCommandLine(); -#if UNICODE - cmdline = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)(text), (SDL_wcslen(text)+1)*sizeof(WCHAR)); -#else - cmdline = SDL_strdup(text); -#endif - if (cmdline == NULL) { - return OutOfMemory(); - } - - /* Parse it into argv and argc */ - argc = ParseCommandLine(cmdline, NULL); - argv = SDL_stack_alloc(char *, argc + 1); - if (argv == NULL) { - return OutOfMemory(); - } - ParseCommandLine(cmdline, argv); - - /* Run the main program */ - console_main(argc, argv); - - SDL_stack_free(argv); - - SDL_free(cmdline); - - /* Hush little compiler, don't you cry... */ - return 0; -} - -#endif /* __WIN32__ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/third_party/stb/tests/grid_reachability.c b/third_party/stb/tests/grid_reachability.c deleted file mode 100644 index 905f2c2f97..0000000000 --- a/third_party/stb/tests/grid_reachability.c +++ /dev/null @@ -1,363 +0,0 @@ -#define STB_CONNECTED_COMPONENTS_IMPLEMENTATION -#define STBCC_GRID_COUNT_X_LOG2 10 -#define STBCC_GRID_COUNT_Y_LOG2 10 -#include "stb_connected_components.h" - -#ifdef GRID_TEST - -#include -#include -#include - -//#define STB_DEFINE -#include "stb.h" - -//#define STB_IMAGE_IMPLEMENTATION -#include "stb_image.h" - -//#define STB_IMAGE_WRITE_IMPLEMENTATION -#include "stb_image_write.h" - -typedef struct -{ - uint16 x,y; -} point; - -point leader[1024][1024]; -uint32 color[1024][1024]; - -point find(int x, int y) -{ - point p,q; - p = leader[y][x]; - if (p.x == x && p.y == y) - return p; - q = find(p.x, p.y); - leader[y][x] = q; - return q; -} - -void onion(int x1, int y1, int x2, int y2) -{ - point p = find(x1,y1); - point q = find(x2,y2); - - if (p.x == q.x && p.y == q.y) - return; - - leader[p.y][p.x] = q; -} - -void reference(uint8 *map, int w, int h) -{ - int i,j; - - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { - leader[j][i].x = i; - leader[j][i].y = j; - } - } - - for (j=1; j < h-1; ++j) { - for (i=1; i < w-1; ++i) { - if (map[j*w+i] == 255) { - if (map[(j+1)*w+i] == 255) onion(i,j, i,j+1); - if (map[(j)*w+i+1] == 255) onion(i,j, i+1,j); - } - } - } - - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { - uint32 c = 0xff000000; - if (leader[j][i].x == i && leader[j][i].y == j) { - if (map[j*w+i] == 255) - c = stb_randLCG() | 0xff404040; - } - color[j][i] = c; - } - } - - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { - if (leader[j][i].x != i || leader[j][i].y != j) { - point p = find(i,j); - color[j][i] = color[p.y][p.x]; - } - } - } -} - -void write_map(stbcc_grid *g, int w, int h, char *filename) -{ - int i,j; - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { - unsigned int c; - c = stbcc_get_unique_id(g,i,j); - c = stb_rehash_improved(c)&0xffffff; - if (c == STBCC_NULL_UNIQUE_ID) - c = 0xff000000; - else - c = (~c)^0x555555; - if (i % 32 == 0 || j %32 == 0) { - int r = (c >> 16) & 255; - int g = (c >> 8) & 255; - int b = c & 255; - r = (r+130)/2; - g = (g+130)/2; - b = (b+130)/2; - c = 0xff000000 + (r<<16) + (g<<8) + b; - } - color[j][i] = c; - } - } - stbi_write_png(filename, w, h, 4, color, 4*w); -} - -void test_connected(stbcc_grid *g) -{ - int n = stbcc_query_grid_node_connection(g, 512, 90, 512, 871); - //printf("%d ", n); -} - -static char *message; -LARGE_INTEGER start; - -void start_timer(char *s) -{ - message = s; - QueryPerformanceCounter(&start); -} - -void end_timer(void) -{ - LARGE_INTEGER end, freq; - double tm; - - QueryPerformanceCounter(&end); - QueryPerformanceFrequency(&freq); - - tm = (end.QuadPart - start.QuadPart) / (double) freq.QuadPart; - printf("%6.4lf ms: %s\n", tm * 1000, message); -} - -extern void quicktest(void); - -int loc[5000][2]; -int main(int argc, char **argv) -{ - stbcc_grid *g; - - int w,h, i,j,k=0, count=0, r; - uint8 *map = stbi_load("data/map_03.png", &w, &h, 0, 1); - - assert(map); - quicktest(); - - for (j=0; j < h; ++j) - for (i=0; i < w; ++i) - map[j*w+i] = ~map[j*w+i]; - - for (i=0; i < w; ++i) - for (j=0; j < h; ++j) - //map[j*w+i] = (((i+1) ^ (j+1)) >> 1) & 1 ? 255 : 0; - map[j*w+i] = stb_max(abs(i-w/2),abs(j-h/2)) & 1 ? 255 : 0; - //map[j*w+i] = (((i ^ j) >> 5) ^ (i ^ j)) & 1 ? 255 : 0; - //map[j*w+i] = stb_rand() & 1 ? 255 : 0; - - #if 1 - for (i=0; i < 100000; ++i) - map[(stb_rand()%h)*w + stb_rand()%w] ^= 255; - #endif - - _mkdir("tests/output/stbcc"); - - stbi_write_png("tests/output/stbcc/reference.png", w, h, 1, map, 0); - - //reference(map, w, h); - - g = malloc(stbcc_grid_sizeof()); - printf("Size: %d\n", stbcc_grid_sizeof()); - -#if 0 - memset(map, 0, w*h); - stbcc_init_grid(g, map, w, h); - { - int n; - char **s = stb_stringfile("c:/x/clockwork_update.txt", &n); - write_map(g, w, h, "tests/output/stbcc/base.png"); - for (i=1; i < n; i += 1) { - int x,y,t; - sscanf(s[i], "%d %d %d", &x, &y, &t); - if (i == 571678) - write_map(g, w, h, stb_sprintf("tests/output/stbcc/clockwork_good.png", i)); - stbcc_update_grid(g, x, y, t); - if (i == 571678) - write_map(g, w, h, stb_sprintf("tests/output/stbcc/clockwork_bad.png", i)); - //if (i > 571648 && i <= 571712) - //write_map(g, w, h, stb_sprintf("tests/output/stbcc/clockwork_%06d.png", i)); - } - write_map(g, w, h, stb_sprintf("tests/output/stbcc/clockwork_%06d.png", i-1)); - } - return 0; -#endif - - - start_timer("init"); - stbcc_init_grid(g, map, w, h); - end_timer(); - //g = stb_file("c:/x/clockwork_path.bin", 0); - write_map(g, w, h, "tests/output/stbcc/base.png"); - - for (i=0; i < 5000;) { - loc[i][0] = stb_rand() % w; - loc[i][1] = stb_rand() % h; - if (stbcc_query_grid_open(g, loc[i][0], loc[i][1])) - ++i; - } - - r = 0; - start_timer("reachable"); - for (i=0; i < 2000; ++i) { - for (j=0; j < 2000; ++j) { - int x1 = loc[i][0], y1 = loc[i][1]; - int x2 = loc[2000+j][0], y2 = loc[2000+j][1]; - r += stbcc_query_grid_node_connection(g, x1,y1, x2,y2); - } - } - end_timer(); - printf("%d reachable\n", r); - - printf("Cluster size: %d,%d\n", STBCC__CLUSTER_SIZE_X, STBCC__CLUSTER_SIZE_Y); - - #if 1 - for (j=0; j < 10; ++j) { - for (i=0; i < 5000; ++i) { - loc[i][0] = stb_rand() % w; - loc[i][1] = stb_rand() % h; - } - start_timer("updating 2500"); - for (i=0; i < 2500; ++i) { - if (stbcc_query_grid_open(g, loc[i][0], loc[i][1])) - stbcc_update_grid(g, loc[i][0], loc[i][1], 1); - else - stbcc_update_grid(g, loc[i][0], loc[i][1], 0); - } - end_timer(); - write_map(g, w, h, stb_sprintf("tests/output/stbcc/update_random_%d.png", j*i)); - } - #endif - - #if 0 - start_timer("removing"); - count = 0; - for (i=0; i < 1800; ++i) { - int x,y,a,b; - x = stb_rand() % (w-32); - y = stb_rand() % (h-32); - - if (i & 1) { - for (a=0; a < 32; ++a) - for (b=0; b < 1; ++b) - if (stbcc_query_grid_open(g, x+a, y+b)) { - stbcc_update_grid(g, x+a, y+b, 1); - ++count; - } - } else { - for (a=0; a < 1; ++a) - for (b=0; b < 32; ++b) - if (stbcc_query_grid_open(g, x+a, y+b)) { - stbcc_update_grid(g, x+a, y+b, 1); - ++count; - } - } - - //if (i % 100 == 0) write_map(g, w, h, stb_sprintf("tests/output/stbcc/open_random_%d.png", i+1)); - } - end_timer(); - printf("Removed %d grid spaces\n", count); - write_map(g, w, h, stb_sprintf("tests/output/stbcc/open_random_%d.png", i)); - - - r = 0; - start_timer("reachable"); - for (i=0; i < 1000; ++i) { - for (j=0; j < 1000; ++j) { - int x1 = loc[i][0], y1 = loc[i][1]; - int x2 = loc[j][0], y2 = loc[j][1]; - r += stbcc_query_grid_node_connection(g, x1,y1, x2,y2); - } - } - end_timer(); - printf("%d reachable\n", r); - - start_timer("adding"); - count = 0; - for (i=0; i < 1800; ++i) { - int x,y,a,b; - x = stb_rand() % (w-32); - y = stb_rand() % (h-32); - - if (i & 1) { - for (a=0; a < 32; ++a) - for (b=0; b < 1; ++b) - if (!stbcc_query_grid_open(g, x+a, y+b)) { - stbcc_update_grid(g, x+a, y+b, 0); - ++count; - } - } else { - for (a=0; a < 1; ++a) - for (b=0; b < 32; ++b) - if (!stbcc_query_grid_open(g, x+a, y+b)) { - stbcc_update_grid(g, x+a, y+b, 0); - ++count; - } - } - - //if (i % 100 == 0) write_map(g, w, h, stb_sprintf("tests/output/stbcc/close_random_%d.png", i+1)); - } - end_timer(); - write_map(g, w, h, stb_sprintf("tests/output/stbcc/close_random_%d.png", i)); - printf("Added %d grid spaces\n", count); - #endif - - - #if 0 // for map_02.png - start_timer("process"); - for (k=0; k < 20; ++k) { - for (j=0; j < h; ++j) { - int any=0; - for (i=0; i < w; ++i) { - if (map[j*w+i] > 10 && map[j*w+i] < 250) { - //start_timer(stb_sprintf("open %d,%d", i,j)); - stbcc_update_grid(g, i, j, 0); - test_connected(g); - //end_timer(); - any = 1; - } - } - if (any) write_map(g, w, h, stb_sprintf("tests/output/stbcc/open_row_%04d.png", j)); - } - - for (j=0; j < h; ++j) { - int any=0; - for (i=0; i < w; ++i) { - if (map[j*w+i] > 10 && map[j*w+i] < 250) { - //start_timer(stb_sprintf("close %d,%d", i,j)); - stbcc_update_grid(g, i, j, 1); - test_connected(g); - //end_timer(); - any = 1; - } - } - if (any) write_map(g, w, h, stb_sprintf("tests/output/stbcc/close_row_%04d.png", j)); - } - } - end_timer(); - #endif - - return 0; -} -#endif diff --git a/third_party/stb/tests/herringbone.dsp b/third_party/stb/tests/herringbone.dsp deleted file mode 100644 index b82fee45aa..0000000000 --- a/third_party/stb/tests/herringbone.dsp +++ /dev/null @@ -1,95 +0,0 @@ -# Microsoft Developer Studio Project File - Name="herringbone" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=herringbone - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "herringbone.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "herringbone.mak" CFG="herringbone - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "herringbone - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "herringbone - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "herringbone - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "herringbone - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "herringbone___Win32_Debug" -# PROP BASE Intermediate_Dir "herringbone___Win32_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "herringbone - Win32 Release" -# Name "herringbone - Win32 Debug" -# Begin Source File - -SOURCE=.\herringbone_generator.c -# End Source File -# Begin Source File - -SOURCE=..\stb_herringbone_wang_tile.h -# End Source File -# End Target -# End Project diff --git a/third_party/stb/tests/herringbone_generator.c b/third_party/stb/tests/herringbone_generator.c deleted file mode 100644 index cf2a99eb98..0000000000 --- a/third_party/stb/tests/herringbone_generator.c +++ /dev/null @@ -1,87 +0,0 @@ -#define STB_HERRINGBONE_WANG_TILE_IMPLEMENTATION -#include "stb_herringbone_wang_tile.h" - -#define STB_IMAGE_WRITE_IMPLEMENTATION -#include "stb_image_write.h" - -// e 12 1 1 1 1 1 1 4 4 - -int main(int argc, char **argv) -{ - stbhw_config c = { 0 }; - int w,h, num_colors,i; - unsigned char *data; - - if (argc == 1) goto usage; - if (argc < 3) goto error; - - switch (argv[2][0]) { - case 'c': - if (argc < 8 || argc > 10) - goto error; - num_colors = 4; - c.is_corner = 1; - break; - - case 'e': - if (argc < 10 || argc > 12) - goto error; - num_colors = 6; - c.is_corner = 0; - break; - - default: - goto error; - } - - c.short_side_len = atoi(argv[3]); - for (i=0; i < num_colors; ++i) - c.num_color[i] = atoi(argv[4+i]); - - c.num_vary_x = 1; - c.num_vary_y = 1; - - if (argc > 4+i) - c.num_vary_x = atoi(argv[4+i]); - if (argc > 5+i) - c.num_vary_y = atoi(argv[5+i]); - - stbhw_get_template_size(&c, &w, &h); - - data = (unsigned char *) malloc(w*h*3); - - if (stbhw_make_template(&c, data, w, h, w*3)) - stbi_write_png(argv[1], w, h, 3, data, w*3); - else - fprintf(stderr, "Error: %s\n", stbhw_get_last_error()); - return 0; - - error: - fputs("Invalid command-line arguments\n\n", stderr); - usage: - fputs("Usage (see source for corner & edge type definitions):\n\n", stderr); - fputs("herringbone_generator {outfile} c {sidelen} {c0} {c1} {c2} {c3} [{vx} {vy}]\n" - " {outfile} -- filename that template will be written to as PNG\n" - " {sidelen} -- length of short side of rectangle in pixels\n" - " {c0} -- number of colors for corner type 0\n" - " {c1} -- number of colors for corner type 1\n" - " {c2} -- number of colors for corner type 2\n" - " {c3} -- number of colors for corner type 3\n" - " {vx} -- number of color-duplicating variations horizontally in template\n" - " {vy} -- number of color-duplicating variations vertically in template\n" - "\n" - , stderr); - fputs("herringbone_generator {outfile} e {sidelen} {e0} {e1} {e2} {e3} {e4} {e5} [{vx} {vy}]\n" - " {outfile} -- filename that template will be written to as PNG\n" - " {sidelen} -- length of short side of rectangle in pixels\n" - " {e0} -- number of colors for edge type 0\n" - " {e1} -- number of colors for edge type 1\n" - " {e2} -- number of colors for edge type 2\n" - " {e3} -- number of colors for edge type 3\n" - " {e4} -- number of colors for edge type 4\n" - " {e5} -- number of colors for edge type 5\n" - " {vx} -- number of color-duplicating variations horizontally in template\n" - " {vy} -- number of color-duplicating variations vertically in template\n" - , stderr); - return 1; -} diff --git a/third_party/stb/tests/herringbone_map.c b/third_party/stb/tests/herringbone_map.c deleted file mode 100644 index 22cc013100..0000000000 --- a/third_party/stb/tests/herringbone_map.c +++ /dev/null @@ -1,83 +0,0 @@ -#include - -#define STB_HBWANG_MAX_X 500 -#define STB_HBWANG_MAX_Y 500 - -#define STB_HERRINGBONE_WANG_TILE_IMPLEMENTATION -#include "stb_herringbone_wang_tile.h" - -#define STB_IMAGE_IMPLEMENTATION -#include "stb_image.h" - -#define STB_IMAGE_WRITE_IMPLEMENTATION -#include "stb_image_write.h" - -int main(int argc, char **argv) -{ - if (argc < 5) { - fprintf(stderr, "Usage: herringbone_map {inputfile} {output-width} {output-height} {outputfile}\n"); - return 1; - } else { - char *filename = argv[1]; - int out_w = atoi(argv[2]); - int out_h = atoi(argv[3]); - char *outfile = argv[4]; - - unsigned char *pixels, *out_pixels; - stbhw_tileset ts; - int w,h; - - pixels = stbi_load(filename, &w, &h, 0, 3); - if (pixels == 0) { - fprintf(stderr, "Couldn't open input file '%s'\n", filename); - exit(1); - } - - if (!stbhw_build_tileset_from_image(&ts, pixels, w*3, w, h)) { - fprintf(stderr, "Error: %s\n", stbhw_get_last_error()); - return 1; - } - - free(pixels); - - #ifdef DEBUG_OUTPUT - { - int i,j,k; - // add blue borders to top-left edges of the tiles - int hstride = (ts.short_side_len*2)*3; - int vstride = (ts.short_side_len )*3; - for (i=0; i < ts.num_h_tiles; ++i) { - unsigned char *pix = ts.h_tiles[i]->pixels; - for (j=0; j < ts.short_side_len*2; ++j) - for (k=0; k < 3; ++k) - pix[j*3+k] = (pix[j*3+k]*0.5+100+k*75)/1.5; - for (j=1; j < ts.short_side_len; ++j) - for (k=0; k < 3; ++k) - pix[j*hstride+k] = (pix[j*hstride+k]*0.5+100+k*75)/1.5; - } - for (i=0; i < ts.num_v_tiles; ++i) { - unsigned char *pix = ts.v_tiles[i]->pixels; - for (j=0; j < ts.short_side_len; ++j) - for (k=0; k < 3; ++k) - pix[j*3+k] = (pix[j*3+k]*0.5+100+k*75)/1.5; - for (j=1; j < ts.short_side_len*2; ++j) - for (k=0; k < 3; ++k) - pix[j*vstride+k] = (pix[j*vstride+k]*0.5+100+k*75)/1.5; - } - } - #endif - - out_pixels = malloc(out_w * out_h * 3); - - if (!stbhw_generate_image(&ts, NULL, out_pixels, out_w*3, out_w, out_h)) { - fprintf(stderr, "Error: %s\n", stbhw_get_last_error()); - return 1; - } - - stbi_write_png(argv[4], out_w, out_h, 3, out_pixels, out_w*3); - free(out_pixels); - - stbhw_free_tileset(&ts); - return 0; - } -} \ No newline at end of file diff --git a/third_party/stb/tests/herringbone_map.dsp b/third_party/stb/tests/herringbone_map.dsp deleted file mode 100644 index 3e26d6d78c..0000000000 --- a/third_party/stb/tests/herringbone_map.dsp +++ /dev/null @@ -1,94 +0,0 @@ -# Microsoft Developer Studio Project File - Name="herringbone_map" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=herringbone_map - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "herringbone_map.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "herringbone_map.mak" CFG="herringbone_map - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "herringbone_map - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "herringbone_map - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "herringbone_map - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "herringbone_map - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "herringbone_map___Win32_Debug" -# PROP BASE Intermediate_Dir "herringbone_map___Win32_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "herringbone_map - Win32 Release" -# Name "herringbone_map - Win32 Debug" -# Begin Source File - -SOURCE=.\herringbone_map.c -# End Source File -# Begin Source File - -SOURCE=..\stb_herringbone_wang_tile.h -# End Source File -# End Target -# End Project diff --git a/third_party/stb/tests/image_test.c b/third_party/stb/tests/image_test.c deleted file mode 100644 index 1fc236db8b..0000000000 --- a/third_party/stb/tests/image_test.c +++ /dev/null @@ -1,168 +0,0 @@ -#define STBI_WINDOWS_UTF8 - -#define STB_IMAGE_WRITE_IMPLEMENTATION -#include "stb_image_write.h" - -#define STB_IMAGE_IMPLEMENTATION -#include "stb_image.h" - -#define STB_DEFINE -#include "stb.h" - -//#define PNGSUITE_PRIMARY - -#if 0 -void test_ycbcr(void) -{ - STBI_SIMD_ALIGN(unsigned char, y[256]); - STBI_SIMD_ALIGN(unsigned char, cb[256]); - STBI_SIMD_ALIGN(unsigned char, cr[256]); - STBI_SIMD_ALIGN(unsigned char, out1[256][4]); - STBI_SIMD_ALIGN(unsigned char, out2[256][4]); - - int i,j,k; - int count = 0, bigcount=0, total=0; - - for (i=0; i < 256; ++i) { - for (j=0; j < 256; ++j) { - for (k=0; k < 256; ++k) { - y [k] = k; - cb[k] = j; - cr[k] = i; - } - stbi__YCbCr_to_RGB_row(out1[0], y, cb, cr, 256, 4); - stbi__YCbCr_to_RGB_sse2(out2[0], y, cb, cr, 256, 4); - for (k=0; k < 256; ++k) { - // inaccurate proxy for values outside of RGB cube - if (out1[k][0] == 0 || out1[k][1] == 0 || out1[k][2] == 0 || out1[k][0] == 255 || out1[k][1] == 255 || out1[k][2] == 255) - continue; - ++total; - if (out1[k][0] != out2[k][0] || out1[k][1] != out2[k][1] || out1[k][2] != out2[k][2]) { - int dist1 = abs(out1[k][0] - out2[k][0]); - int dist2 = abs(out1[k][1] - out2[k][1]); - int dist3 = abs(out1[k][2] - out2[k][2]); - ++count; - if (out1[k][1] > out2[k][1]) - ++bigcount; - } - } - } - printf("So far: %d (%d big) of %d\n", count, bigcount, total); - } - printf("Final: %d (%d big) of %d\n", count, bigcount, total); -} -#endif - -float hdr_data[200][200][3]; - -void dummy_write(void *context, void *data, int len) -{ - static char dummy[1024]; - if (len > 1024) len = 1024; - memcpy(dummy, data, len); -} - -int main(int argc, char **argv) -{ - int w,h; - //test_ycbcr(); - - #if 0 - // test hdr asserts - for (h=0; h < 100; h += 2) - for (w=0; w < 200; ++w) - hdr_data[h][w][0] = (float) rand(), - hdr_data[h][w][1] = (float) rand(), - hdr_data[h][w][2] = (float) rand(); - - stbi_write_hdr("output/test.hdr", 200,200,3,hdr_data[0][0]); - #endif - - if (argc > 1) { - int i, n; - - for (i=1; i < argc; ++i) { - int res; - int w2,h2,n2; - unsigned char *data; - printf("%s\n", argv[i]); - res = stbi_info(argv[i], &w2, &h2, &n2); - data = stbi_load(argv[i], &w, &h, &n, 4); if (data) free(data); else printf("Failed &n\n"); - data = stbi_load(argv[i], &w, &h, 0, 1); if (data) free(data); else printf("Failed 1\n"); - data = stbi_load(argv[i], &w, &h, 0, 2); if (data) free(data); else printf("Failed 2\n"); - data = stbi_load(argv[i], &w, &h, 0, 3); if (data) free(data); else printf("Failed 3\n"); - data = stbi_load(argv[i], &w, &h, &n, 4); - assert(data); - assert(w == w2 && h == h2 && n == n2); - assert(res); - if (data) { - char fname[512]; - stb_splitpath(fname, argv[i], STB_FILE); - stbi_write_png(stb_sprintf("output/%s.png", fname), w, h, 4, data, w*4); - stbi_write_bmp(stb_sprintf("output/%s.bmp", fname), w, h, 4, data); - stbi_write_tga(stb_sprintf("output/%s.tga", fname), w, h, 4, data); - stbi_write_png_to_func(dummy_write,0, w, h, 4, data, w*4); - stbi_write_bmp_to_func(dummy_write,0, w, h, 4, data); - stbi_write_tga_to_func(dummy_write,0, w, h, 4, data); - free(data); - } else - printf("FAILED 4\n"); - } - } else { - int i, nope=0; - #ifdef PNGSUITE_PRIMARY - char **files = stb_readdir_files("pngsuite/primary"); - #else - char **files = stb_readdir_files("images"); - #endif - for (i=0; i < stb_arr_len(files); ++i) { - int n; - char **failed = NULL; - unsigned char *data; - printf("."); - //printf("%s\n", files[i]); - data = stbi_load(files[i], &w, &h, &n, 0); if (data) free(data); else stb_arr_push(failed, "&n"); - data = stbi_load(files[i], &w, &h, 0, 1); if (data) free(data); else stb_arr_push(failed, "1"); - data = stbi_load(files[i], &w, &h, 0, 2); if (data) free(data); else stb_arr_push(failed, "2"); - data = stbi_load(files[i], &w, &h, 0, 3); if (data) free(data); else stb_arr_push(failed, "3"); - data = stbi_load(files[i], &w, &h, 0, 4); if (data) ; else stb_arr_push(failed, "4"); - if (data) { - char fname[512]; - - #ifdef PNGSUITE_PRIMARY - int w2,h2; - unsigned char *data2; - stb_splitpath(fname, files[i], STB_FILE_EXT); - data2 = stbi_load(stb_sprintf("pngsuite/primary_check/%s", fname), &w2, &h2, 0, 4); - if (!data2) - printf("FAILED: couldn't load 'pngsuite/primary_check/%s\n", fname); - else { - if (w != w2 || h != w2 || 0 != memcmp(data, data2, w*h*4)) { - int x,y,c; - if (w == w2 && h == h2) - for (y=0; y < h; ++y) - for (x=0; x < w; ++x) - for (c=0; c < 4; ++c) - assert(data[y*w*4+x*4+c] == data2[y*w*4+x*4+c]); - printf("FAILED: %s loaded but didn't match PRIMARY_check 32-bit version\n", files[i]); - } - free(data2); - } - #else - stb_splitpath(fname, files[i], STB_FILE); - stbi_write_png(stb_sprintf("output/%s.png", fname), w, h, 4, data, w*4); - #endif - free(data); - } - if (failed) { - int j; - printf("FAILED: "); - for (j=0; j < stb_arr_len(failed); ++j) - printf("%s ", failed[j]); - printf(" -- %s\n", files[i]); - } - } - printf("Tested %d files.\n", i); - } - return 0; -} diff --git a/third_party/stb/tests/image_test.dsp b/third_party/stb/tests/image_test.dsp deleted file mode 100644 index 4efd6474a5..0000000000 --- a/third_party/stb/tests/image_test.dsp +++ /dev/null @@ -1,98 +0,0 @@ -# Microsoft Developer Studio Project File - Name="image_test" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=image_test - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "image_test.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "image_test.mak" CFG="image_test - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "image_test - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "image_test - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "image_test - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "image_test - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug\image_test" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "image_test - Win32 Release" -# Name "image_test - Win32 Debug" -# Begin Source File - -SOURCE=.\image_test.c -# End Source File -# Begin Source File - -SOURCE=..\stb_image.h -# End Source File -# Begin Source File - -SOURCE=..\stb_image_write.h -# End Source File -# End Target -# End Project diff --git a/third_party/stb/tests/oversample/README.md b/third_party/stb/tests/oversample/README.md deleted file mode 100644 index cdfdfff532..0000000000 --- a/third_party/stb/tests/oversample/README.md +++ /dev/null @@ -1,94 +0,0 @@ -# Font character oversampling for rendering from atlas textures - -TL,DR: Run oversample.exe on a windows machine to see the -benefits of oversampling. It will try to use arial.ttf from the -Windows font directory unless you type the name of a .ttf file as -a command-line argument. - -## Benefits of oversampling - -Oversampling is a mechanism for improving subpixel rendering of characters. - -Improving subpixel has a few benefits: - -* With horizontal-oversampling, text can remain sharper while still being sub-pixel positioned for better kerning -* Horizontally-oversampled text significantly reduces aliasing when text animates horizontally -* Vertically-oversampled text significantly reduces aliasing when text animates vertically -* Text oversampled in both directions significantly reduces aliasing when text rotates - -## What text oversampling is - -A common strategy for rendering text is to cache character bitmaps -and reuse them. For hinted characters, every instance of a given -character is always identical, so this works fine. However, stb_truetype -doesn't do hinting. - -For anti-aliased characters, you can actually position the characters -with subpixel precision, and get different bitmaps based on that positioning -if you re-render the vector data. - -However, if you simply cache a single version of the bitmap and -draw it at different subpixel positions with a GPU, you will get -either the exact same result (if you use point-sampling on the -texture) or linear filtering. Linear filtering will cause a sub-pixel -positioned bitmap to blur further, causing a visible de-sharpening -of the character. (And, since the character wasn't hinted, it was -already blurrier than a hinted one would be, and now it gets even -more blurry.) - -You can avoid this by caching multiple variants of a character which -were rendered independently from the vector data. For example, you -might cache 3 versions of a char, at 0, 1/3, and 2/3rds of a pixel -horizontal offset, and always require characters to fall on integer -positions vertically. - -When creating a texture atlas for use on GPUs, which support bilinear -filtering, there is a better approach than caching several independent -positions, which is to allow lerping between the versions to allow -finer subpixel positioning. You can achieve these by interleaving -each of the cached bitmaps, but this turns out to be mathematically -equivalent to a simpler operation: oversampling and prefiltering the -characters. - -So, setting oversampling of 2x2 in stb_truetype is equivalent to caching -each character in 4 different variations, 1 for each subpixel position -in a 2x2 set. - -An advantage of this formulation is that no changes are required to -the rendering code; the exact same quad-rendering code works, it just -uses different texture coordinates. (Note this does potentially increase -texture bandwidth for text rendering since we end up minifying the texture -without using mipmapping, but you probably are not going to be fill-bound -by your text rendering.) - -## What about gamma? - -Gamma-correction for fonts just doesn't work. This doesn't seem to make -much sense -- it's physically correct, it simulates what we'd see if you -shrunk a font down really far, right? - -But you can play with it in the oversample.exe app. If you turn it on, -white-on-black fonts become too thick (i.e. they become too bright), and -black-on-white fonts become too thin (i.e. they are insufficiently dark). There is -no way to adjust the font's inherent thickness (i.e. by switching to -bold) to fix this for both; making the font thicker will make white -text worse, and making the font thinner will make black text worse. -Obviously you could use different fonts for light and dark cases, but -this doesn't seem like a very good way for fonts to work. - -Multiple people who have experimented with this independently (me, -Fabian Giesen,and Maxim Shemanarev of Anti-Grain Geometry) have all -concluded that correct gamma-correction does not produce the best -results for fonts. Font rendering just generally looks better without -gamma correction (or possibly with some arbitrary power stuck in -there, but it's not really correcting for gamma at that point). Maybe -this is in part a product of how we're used to fonts being on screens -which has changed how we expect them to look (e.g. perhaps hinting -oversharpens them and prevents the real-world thinning you'd see in -a black-on-white text). - -(AGG link on text rendering, including mention of gamma: - http://www.antigrain.com/research/font_rasterization/ ) - -Nevertheless, even if you turn on gamma-correction, you will find that -oversampling still helps in many cases for small fonts. diff --git a/third_party/stb/tests/oversample/main.c b/third_party/stb/tests/oversample/main.c deleted file mode 100644 index bc6bd0f34e..0000000000 --- a/third_party/stb/tests/oversample/main.c +++ /dev/null @@ -1,332 +0,0 @@ -#pragma warning(disable:4244; disable:4305; disable:4018) -#include -#include - -#define STB_WINMAIN -#include "stb_wingraph.h" - -#define STB_TRUETYPE_IMPLEMENTATION -#define STB_RECT_PACK_IMPLEMENTATION -#include "stb_rect_pack.h" -#include "stb_truetype.h" - -#ifndef WINGDIAPI -#define CALLBACK __stdcall -#define WINGDIAPI __declspec(dllimport) -#define APIENTRY __stdcall -#endif - -#include -#include - -#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 - -#define SIZE_X 1024 -#define SIZE_Y 768 - -stbtt_packedchar chardata[6][128]; - -int sx=SIZE_X, sy=SIZE_Y; - -#define BITMAP_W 512 -#define BITMAP_H 512 -unsigned char temp_bitmap[BITMAP_W][BITMAP_H]; -unsigned char ttf_buffer[1 << 25]; -GLuint font_tex; - -float scale[2] = { 24.0f, 14.0f }; - -int sf[6] = { 0,1,2, 0,1,2 }; - -void load_fonts(void) -{ - stbtt_pack_context pc; - int i; - FILE *f; - char filename[256]; - char *win = getenv("windir"); - if (win == NULL) win = getenv("SystemRoot"); - - f = fopen(stb_wingraph_commandline, "rb"); - if (!f) { - if (win == NULL) - sprintf(filename, "arial.ttf", win); - else - sprintf(filename, "%s/fonts/arial.ttf", win); - f = fopen(filename, "rb"); - if (!f) exit(0); - } - - fread(ttf_buffer, 1, 1<<25, f); - - stbtt_PackBegin(&pc, temp_bitmap[0], BITMAP_W, BITMAP_H, 0, 1, NULL); - for (i=0; i < 2; ++i) { - stbtt_PackSetOversampling(&pc, 1, 1); - stbtt_PackFontRange(&pc, ttf_buffer, 0, scale[i], 32, 95, chardata[i*3+0]+32); - stbtt_PackSetOversampling(&pc, 2, 2); - stbtt_PackFontRange(&pc, ttf_buffer, 0, scale[i], 32, 95, chardata[i*3+1]+32); - stbtt_PackSetOversampling(&pc, 3, 1); - stbtt_PackFontRange(&pc, ttf_buffer, 0, scale[i], 32, 95, chardata[i*3+2]+32); - } - stbtt_PackEnd(&pc); - - glGenTextures(1, &font_tex); - glBindTexture(GL_TEXTURE_2D, font_tex); - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, BITMAP_W, BITMAP_H, 0, GL_ALPHA, GL_UNSIGNED_BYTE, temp_bitmap); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); -} - -int black_on_white; - -void draw_init(void) -{ - glDisable(GL_CULL_FACE); - glDisable(GL_TEXTURE_2D); - glDisable(GL_LIGHTING); - glDisable(GL_DEPTH_TEST); - - glViewport(0,0,sx,sy); - if (black_on_white) - glClearColor(255,255,255,0); - else - glClearColor(0,0,0,0); - glClear(GL_COLOR_BUFFER_BIT); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluOrtho2D(0,sx,sy,0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - - -void drawBoxTC(float x0, float y0, float x1, float y1, float s0, float t0, float s1, float t1) -{ - glTexCoord2f(s0,t0); glVertex2f(x0,y0); - glTexCoord2f(s1,t0); glVertex2f(x1,y0); - glTexCoord2f(s1,t1); glVertex2f(x1,y1); - glTexCoord2f(s0,t1); glVertex2f(x0,y1); -} - -int integer_align; - -void print(float x, float y, int font, char *text) -{ - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, font_tex); - glBegin(GL_QUADS); - while (*text) { - stbtt_aligned_quad q; - stbtt_GetPackedQuad(chardata[font], BITMAP_W, BITMAP_H, *text++, &x, &y, &q, font ? 0 : integer_align); - drawBoxTC(q.x0,q.y0,q.x1,q.y1, q.s0,q.t0,q.s1,q.t1); - } - glEnd(); -} - -int font=3; -int translating; -int rotating=0; -int srgb=0; -float rotate_t, translate_t; -int show_tex; - -void draw_world(void) -{ - int sfont = sf[font]; - float x = 20; - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - if (black_on_white) - glColor3f(0,0,0); - else - glColor3f(1,1,1); - - - print(80, 30, sfont, "Controls:"); - print(100, 60, sfont, "S: toggle font size"); - print(100, 85, sfont, "O: toggle oversampling"); - print(100,110, sfont, "T: toggle translation"); - print(100,135, sfont, "R: toggle rotation"); - print(100,160, sfont, "P: toggle pixel-snap (only non-oversampled)"); - print(100,185, sfont, "G: toggle srgb gamma-correction"); - if (black_on_white) - print(100,210, sfont, "B: toggle to white-on-black"); - else - print(100,210, sfont, "B: toggle to black-on-white"); - print(100,235, sfont, "V: view font texture"); - - print(80, 300, sfont, "Current font:"); - - if (!show_tex) { - if (font < 3) - print(100, 350, sfont, "Font height: 24 pixels"); - else - print(100, 350, sfont, "Font height: 14 pixels"); - } - - if (font%3==1) - print(100, 325, sfont, "2x2 oversampled text at 1:1"); - else if (font%3 == 2) - print(100, 325, sfont, "3x1 oversampled text at 1:1"); - else if (integer_align) - print(100, 325, sfont, "1:1 text, one texel = one pixel, snapped to integer coordinates"); - else - print(100, 325, sfont, "1:1 text, one texel = one pixel"); - - if (show_tex) { - glBegin(GL_QUADS); - drawBoxTC(200,400, 200+BITMAP_W,300+BITMAP_H, 0,0,1,1); - glEnd(); - } else { - glMatrixMode(GL_MODELVIEW); - glTranslatef(200,350,0); - - if (translating) - x += fmod(translate_t*8,30); - - if (rotating) { - glTranslatef(100,150,0); - glRotatef(rotate_t*2,0,0,1); - glTranslatef(-100,-150,0); - } - print(x,100, font, "This is a test"); - print(x,130, font, "Now is the time for all good men to come to the aid of their country."); - print(x,160, font, "The quick brown fox jumps over the lazy dog."); - print(x,190, font, "0123456789"); - } -} - -void draw(void) -{ - draw_init(); - draw_world(); - stbwingraph_SwapBuffers(NULL); -} - -static int initialized=0; -static float last_dt; - -int move[4]; -int raw_mouse_x, raw_mouse_y; - -int loopmode(float dt, int real, int in_client) -{ - float actual_dt = dt; - - if (!initialized) return 0; - - rotate_t += dt; - translate_t += dt; - -// music_sim(); - if (!real) - return 0; - - if (dt > 0.25) dt = 0.25; - if (dt < 0.01) dt = 0.01; - - draw(); - - return 0; -} - -int winproc(void *data, stbwingraph_event *e) -{ - switch (e->type) { - case STBWGE_create: - break; - - case STBWGE_char: - switch(e->key) { - case 27: - stbwingraph_ShowCursor(NULL,1); - return STBWINGRAPH_winproc_exit; - break; - case 'o': case 'O': - font = (font+1) % 3 + (font/3)*3; - break; - case 's': case 'S': - font = (font+3) % 6; - break; - case 't': case 'T': - translating = !translating; - translate_t = 0; - break; - case 'r': case 'R': - rotating = !rotating; - rotate_t = 0; - break; - case 'p': case 'P': - integer_align = !integer_align; - break; - case 'g': case 'G': - srgb = !srgb; - if (srgb) - glEnable(GL_FRAMEBUFFER_SRGB_EXT); - else - glDisable(GL_FRAMEBUFFER_SRGB_EXT); - break; - case 'v': case 'V': - show_tex = !show_tex; - break; - case 'b': case 'B': - black_on_white = !black_on_white; - break; - } - break; - - case STBWGE_mousemove: - raw_mouse_x = e->mx; - raw_mouse_y = e->my; - break; - -#if 0 - case STBWGE_mousewheel: do_mouse(e,0,0); break; - case STBWGE_leftdown: do_mouse(e, 1,0); break; - case STBWGE_leftup: do_mouse(e,-1,0); break; - case STBWGE_rightdown: do_mouse(e,0, 1); break; - case STBWGE_rightup: do_mouse(e,0,-1); break; -#endif - - case STBWGE_keydown: - if (e->key == VK_RIGHT) move[0] = 1; - if (e->key == VK_LEFT) move[1] = 1; - if (e->key == VK_UP) move[2] = 1; - if (e->key == VK_DOWN) move[3] = 1; - break; - case STBWGE_keyup: - if (e->key == VK_RIGHT) move[0] = 0; - if (e->key == VK_LEFT) move[1] = 0; - if (e->key == VK_UP) move[2] = 0; - if (e->key == VK_DOWN) move[3] = 0; - break; - - case STBWGE_size: - sx = e->width; - sy = e->height; - loopmode(0,1,0); - break; - - case STBWGE_draw: - if (initialized) - loopmode(0,1,0); - break; - - default: - return STBWINGRAPH_unprocessed; - } - return 0; -} - -void stbwingraph_main(void) -{ - stbwingraph_Priority(2); - stbwingraph_CreateWindow(1, winproc, NULL, "tt", SIZE_X,SIZE_Y, 0, 1, 0, 0); - stbwingraph_ShowCursor(NULL, 0); - load_fonts(); - initialized = 1; - stbwingraph_MainLoop(loopmode, 0.016f); // 30 fps = 0.33 -} - diff --git a/third_party/stb/tests/oversample/oversample.dsp b/third_party/stb/tests/oversample/oversample.dsp deleted file mode 100644 index cc1edc3f5f..0000000000 --- a/third_party/stb/tests/oversample/oversample.dsp +++ /dev/null @@ -1,97 +0,0 @@ -# Microsoft Developer Studio Project File - Name="oversample" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Application" 0x0101 - -CFG=oversample - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "oversample.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "oversample.mak" CFG="oversample - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "oversample - Win32 Release" (based on "Win32 (x86) Application") -!MESSAGE "oversample - Win32 Debug" (based on "Win32 (x86) Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "oversample - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /WX /GX /O2 /I "c:\sean\prj\stb" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# SUBTRACT LINK32 /map /debug - -!ELSEIF "$(CFG)" == "oversample - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /WX /Gm /GX /Zi /Od /I "c:\sean\prj\stb" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib winspool.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:no /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "oversample - Win32 Release" -# Name "oversample - Win32 Debug" -# Begin Source File - -SOURCE=.\main.c -# End Source File -# End Target -# End Project diff --git a/third_party/stb/tests/oversample/oversample.dsw b/third_party/stb/tests/oversample/oversample.dsw deleted file mode 100644 index 0f5aa7fae6..0000000000 --- a/third_party/stb/tests/oversample/oversample.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "oversample"=.\oversample.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/third_party/stb/tests/oversample/oversample.exe b/third_party/stb/tests/oversample/oversample.exe deleted file mode 100644 index 0040693186..0000000000 Binary files a/third_party/stb/tests/oversample/oversample.exe and /dev/null differ diff --git a/third_party/stb/tests/oversample/stb_wingraph.h b/third_party/stb/tests/oversample/stb_wingraph.h deleted file mode 100644 index 94798ebdfd..0000000000 --- a/third_party/stb/tests/oversample/stb_wingraph.h +++ /dev/null @@ -1,829 +0,0 @@ -// stb_wingraph.h v0.01 - public domain windows graphics programming -// wraps WinMain, ChoosePixelFormat, ChangeDisplayResolution, etc. for -// doing OpenGL graphics -// -// in ONE source file, put '#define STB_DEFINE' before including this -// OR put '#define STB_WINMAIN' to define a WinMain that calls stbwingraph_main(void) -// -// @TODO: -// 2d rendering interface (that can be done easily in software) -// STB_WINGRAPH_SOFTWARE -- 2d software rendering only -// STB_WINGRAPH_OPENGL -- OpenGL only - - -#ifndef INCLUDE_STB_WINGRAPH_H -#define INCLUDE_STB_WINGRAPH_H - -#ifdef STB_WINMAIN - #ifndef STB_DEFINE - #define STB_DEFINE - #define STB_WINGRAPH_DISABLE_DEFINE_AT_END - #endif -#endif - -#ifdef STB_DEFINE - #pragma comment(lib, "opengl32.lib") - #pragma comment(lib, "glu32.lib") - #pragma comment(lib, "winmm.lib") - #pragma comment(lib, "gdi32.lib") - #pragma comment(lib, "user32.lib") -#endif - -#ifdef __cplusplus -#define STB_EXTERN extern "C" -#else -#define STB_EXTERN -#endif - -#ifdef STB_DEFINE -#ifndef _WINDOWS_ - #ifdef APIENTRY - #undef APIENTRY - #endif - #ifdef WINGDIAPI - #undef WINGDIAPI - #endif - #define _WIN32_WINNT 0x0400 // WM_MOUSEWHEEL - #include -#endif -#include -#include -#include -#include -#include -#endif - -typedef void * stbwingraph_hwnd; -typedef void * stbwingraph_hinstance; - -enum -{ - STBWINGRAPH_unprocessed = -(1 << 24), - STBWINGRAPH_do_not_show, - STBWINGRAPH_winproc_exit, - STBWINGRAPH_winproc_update, - STBWINGRAPH_update_exit, - STBWINGRAPH_update_pause, -}; - -typedef enum -{ - STBWGE__none=0, - - STBWGE_create, - STBWGE_create_postshow, - STBWGE_draw, - STBWGE_destroy, - STBWGE_char, - STBWGE_keydown, - STBWGE_syskeydown, - STBWGE_keyup, - STBWGE_syskeyup, - STBWGE_deactivate, - STBWGE_activate, - STBWGE_size, - - STBWGE_mousemove , - STBWGE_leftdown , STBWGE_leftup , - STBWGE_middledown, STBWGE_middleup, - STBWGE_rightdown , STBWGE_rightup , - STBWGE_mousewheel, -} stbwingraph_event_type; - -typedef struct -{ - stbwingraph_event_type type; - - // for input events (mouse, keyboard) - int mx,my; // mouse x & y - int dx,dy; - int shift, ctrl, alt; - - // for keyboard events - int key; - - // for STBWGE_size: - int width, height; - - // for STBWGE_crate - int did_share_lists; // if true, wglShareLists succeeded - - void *handle; - -} stbwingraph_event; - -typedef int (*stbwingraph_window_proc)(void *data, stbwingraph_event *event); - -extern stbwingraph_hinstance stbwingraph_app; -extern stbwingraph_hwnd stbwingraph_primary_window; -extern int stbwingraph_request_fullscreen; -extern int stbwingraph_request_windowed; - -STB_EXTERN void stbwingraph_ods(char *str, ...); -STB_EXTERN int stbwingraph_MessageBox(stbwingraph_hwnd win, unsigned int type, - char *caption, char *text, ...); -STB_EXTERN int stbwingraph_ChangeResolution(unsigned int w, unsigned int h, - unsigned int bits, int use_message_box); -STB_EXTERN int stbwingraph_SetPixelFormat(stbwingraph_hwnd win, int color_bits, - int alpha_bits, int depth_bits, int stencil_bits, int accum_bits); -STB_EXTERN int stbwingraph_DefineClass(void *hinstance, char *iconname); -STB_EXTERN void stbwingraph_SwapBuffers(void *win); -STB_EXTERN void stbwingraph_Priority(int n); - -STB_EXTERN void stbwingraph_MakeFonts(void *window, int font_base); -STB_EXTERN void stbwingraph_ShowWindow(void *window); -STB_EXTERN void *stbwingraph_CreateWindow(int primary, stbwingraph_window_proc func, void *data, char *text, int width, int height, int fullscreen, int resizeable, int dest_alpha, int stencil); -STB_EXTERN void *stbwingraph_CreateWindowSimple(stbwingraph_window_proc func, int width, int height); -STB_EXTERN void *stbwingraph_CreateWindowSimpleFull(stbwingraph_window_proc func, int fullscreen, int ww, int wh, int fw, int fh); -STB_EXTERN void stbwingraph_DestroyWindow(void *window); -STB_EXTERN void stbwingraph_ShowCursor(void *window, int visible); -STB_EXTERN float stbwingraph_GetTimestep(float minimum_time); -STB_EXTERN void stbwingraph_SetGLWindow(void *win); -typedef int (*stbwingraph_update)(float timestep, int real, int in_client); -STB_EXTERN int stbwingraph_MainLoop(stbwingraph_update func, float mintime); - -#ifdef STB_DEFINE -stbwingraph_hinstance stbwingraph_app; -stbwingraph_hwnd stbwingraph_primary_window; -int stbwingraph_request_fullscreen; -int stbwingraph_request_windowed; - -void stbwingraph_ods(char *str, ...) -{ - char buffer[1024]; - va_list v; - va_start(v,str); - vsprintf(buffer, str, v); - va_end(v); - OutputDebugString(buffer); -} - -int stbwingraph_MessageBox(stbwingraph_hwnd win, unsigned int type, char *caption, char *text, ...) -{ - va_list v; - char buffer[1024]; - va_start(v, text); - vsprintf(buffer, text, v); - va_end(v); - return MessageBox(win, buffer, caption, type); -} - -void stbwingraph_Priority(int n) -{ - int p; - switch (n) { - case -1: p = THREAD_PRIORITY_BELOW_NORMAL; break; - case 0: p = THREAD_PRIORITY_NORMAL; break; - case 1: p = THREAD_PRIORITY_ABOVE_NORMAL; break; - default: - if (n < 0) p = THREAD_PRIORITY_LOWEST; - else p = THREAD_PRIORITY_HIGHEST; - } - SetThreadPriority(GetCurrentThread(), p); -} - -static void stbwingraph_ResetResolution(void) -{ - ChangeDisplaySettings(NULL, 0); -} - -static void stbwingraph_RegisterResetResolution(void) -{ - static int done=0; - if (!done) { - done = 1; - atexit(stbwingraph_ResetResolution); - } -} - -int stbwingraph_ChangeResolution(unsigned int w, unsigned int h, unsigned int bits, int use_message_box) -{ - DEVMODE mode; - int res; - - int i, tries=0; - for (i=0; ; ++i) { - int success = EnumDisplaySettings(NULL, i, &mode); - if (!success) break; - if (mode.dmBitsPerPel == bits && mode.dmPelsWidth == w && mode.dmPelsHeight == h) { - ++tries; - success = ChangeDisplaySettings(&mode, CDS_FULLSCREEN); - if (success == DISP_CHANGE_SUCCESSFUL) { - stbwingraph_RegisterResetResolution(); - return TRUE; - } - break; - } - } - - if (!tries) { - if (use_message_box) - stbwingraph_MessageBox(stbwingraph_primary_window, MB_ICONERROR, NULL, "The resolution %d x %d x %d-bits is not supported.", w, h, bits); - return FALSE; - } - - // we tried but failed, so try explicitly doing it without specifying refresh rate - - // Win95 support logic - mode.dmBitsPerPel = bits; - mode.dmPelsWidth = w; - mode.dmPelsHeight = h; - mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; - - res = ChangeDisplaySettings(&mode, CDS_FULLSCREEN); - - switch (res) { - case DISP_CHANGE_SUCCESSFUL: - stbwingraph_RegisterResetResolution(); - return TRUE; - - case DISP_CHANGE_RESTART: - if (use_message_box) - stbwingraph_MessageBox(stbwingraph_primary_window, MB_ICONERROR, NULL, "Please set your desktop to %d-bit color and then try again."); - return FALSE; - - case DISP_CHANGE_FAILED: - if (use_message_box) - stbwingraph_MessageBox(stbwingraph_primary_window, MB_ICONERROR, NULL, "The hardware failed to change modes."); - return FALSE; - - case DISP_CHANGE_BADMODE: - if (use_message_box) - stbwingraph_MessageBox(stbwingraph_primary_window, MB_ICONERROR, NULL, "The resolution %d x %d x %d-bits is not supported.", w, h, bits); - return FALSE; - - default: - if (use_message_box) - stbwingraph_MessageBox(stbwingraph_primary_window, MB_ICONERROR, NULL, "An unknown error prevented a change to a %d x %d x %d-bit display.", w, h, bits); - return FALSE; - } -} - -int stbwingraph_SetPixelFormat(stbwingraph_hwnd win, int color_bits, int alpha_bits, int depth_bits, int stencil_bits, int accum_bits) -{ - HDC dc = GetDC(win); - PIXELFORMATDESCRIPTOR pfd = { sizeof(pfd) }; - int pixel_format; - - pfd.nVersion = 1; - pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER; - pfd.dwLayerMask = PFD_MAIN_PLANE; - pfd.iPixelType = PFD_TYPE_RGBA; - pfd.cColorBits = color_bits; - pfd.cAlphaBits = alpha_bits; - pfd.cDepthBits = depth_bits; - pfd.cStencilBits = stencil_bits; - pfd.cAccumBits = accum_bits; - - pixel_format = ChoosePixelFormat(dc, &pfd); - if (!pixel_format) return FALSE; - - if (!DescribePixelFormat(dc, pixel_format, sizeof(PIXELFORMATDESCRIPTOR), &pfd)) - return FALSE; - SetPixelFormat(dc, pixel_format, &pfd); - - return TRUE; -} - -typedef struct -{ - // app data - stbwingraph_window_proc func; - void *data; - // creation parameters - int color, alpha, depth, stencil, accum; - HWND share_window; - HWND window; - // internal data - HGLRC rc; - HDC dc; - int hide_mouse; - int in_client; - int active; - int did_share_lists; - int mx,my; // last mouse positions -} stbwingraph__window; - -static void stbwingraph__inclient(stbwingraph__window *win, int state) -{ - if (state != win->in_client) { - win->in_client = state; - if (win->hide_mouse) - ShowCursor(!state); - } -} - -static void stbwingraph__key(stbwingraph_event *e, int type, int key, stbwingraph__window *z) -{ - e->type = type; - e->key = key; - e->shift = (GetKeyState(VK_SHIFT) < 0); - e->ctrl = (GetKeyState(VK_CONTROL) < 0); - e->alt = (GetKeyState(VK_MENU) < 0); - if (z) { - e->mx = z->mx; - e->my = z->my; - } else { - e->mx = e->my = 0; - } - e->dx = e->dy = 0; -} - -static void stbwingraph__mouse(stbwingraph_event *e, int type, WPARAM wparam, LPARAM lparam, int capture, void *wnd, stbwingraph__window *z) -{ - static int captured = 0; - e->type = type; - e->mx = (short) LOWORD(lparam); - e->my = (short) HIWORD(lparam); - if (!z || z->mx == -(1 << 30)) { - e->dx = e->dy = 0; - } else { - e->dx = e->mx - z->mx; - e->dy = e->my - z->my; - } - e->shift = (wparam & MK_SHIFT) != 0; - e->ctrl = (wparam & MK_CONTROL) != 0; - e->alt = (wparam & MK_ALT) != 0; - if (z) { - z->mx = e->mx; - z->my = e->my; - } - if (capture) { - if (!captured && capture == 1) - SetCapture(wnd); - captured += capture; - if (!captured && capture == -1) - ReleaseCapture(); - if (captured < 0) captured = 0; - } -} - -static void stbwingraph__mousewheel(stbwingraph_event *e, int type, WPARAM wparam, LPARAM lparam, int capture, void *wnd, stbwingraph__window *z) -{ - // lparam seems bogus! - static int captured = 0; - e->type = type; - if (z) { - e->mx = z->mx; - e->my = z->my; - } - e->dx = e->dy = 0; - e->shift = (wparam & MK_SHIFT) != 0; - e->ctrl = (wparam & MK_CONTROL) != 0; - e->alt = (GetKeyState(VK_MENU) < 0); - e->key = ((int) wparam >> 16); -} - -int stbwingraph_force_update; -static int WINAPI stbwingraph_WinProc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam) -{ - int allow_default = TRUE; - stbwingraph_event e = { STBWGE__none }; - // the following line is wrong for 64-bit windows, but VC6 doesn't have GetWindowLongPtr - stbwingraph__window *z = (stbwingraph__window *) GetWindowLong(wnd, GWL_USERDATA); - - switch (msg) { - - case WM_CREATE: - { - LPCREATESTRUCT lpcs = (LPCREATESTRUCT) lparam; - assert(z == NULL); - z = (stbwingraph__window *) lpcs->lpCreateParams; - SetWindowLong(wnd, GWL_USERDATA, (LONG) z); - z->dc = GetDC(wnd); - if (stbwingraph_SetPixelFormat(wnd, z->color, z->alpha, z->depth, z->stencil, z->accum)) { - z->rc = wglCreateContext(z->dc); - if (z->rc) { - e.type = STBWGE_create; - z->did_share_lists = FALSE; - if (z->share_window) { - stbwingraph__window *y = (stbwingraph__window *) GetWindowLong(z->share_window, GWL_USERDATA); - if (wglShareLists(z->rc, y->rc)) - z->did_share_lists = TRUE; - } - wglMakeCurrent(z->dc, z->rc); - return 0; - } - } - return -1; - } - - case WM_PAINT: { - PAINTSTRUCT ps; - HDC hdc = BeginPaint(wnd, &ps); - SelectObject(hdc, GetStockObject(NULL_BRUSH)); - e.type = STBWGE_draw; - e.handle = wnd; - z->func(z->data, &e); - EndPaint(wnd, &ps); - return 0; - } - - case WM_DESTROY: - e.type = STBWGE_destroy; - e.handle = wnd; - if (z && z->func) - z->func(z->data, &e); - wglMakeCurrent(NULL, NULL) ; - if (z) { - if (z->rc) wglDeleteContext(z->rc); - z->dc = 0; - z->rc = 0; - } - if (wnd == stbwingraph_primary_window) - PostQuitMessage (0); - return 0; - - case WM_CHAR: stbwingraph__key(&e, STBWGE_char , wparam, z); break; - case WM_KEYDOWN: stbwingraph__key(&e, STBWGE_keydown, wparam, z); break; - case WM_KEYUP: stbwingraph__key(&e, STBWGE_keyup , wparam, z); break; - - case WM_NCMOUSEMOVE: stbwingraph__inclient(z,0); break; - case WM_MOUSEMOVE: stbwingraph__inclient(z,1); stbwingraph__mouse(&e, STBWGE_mousemove, wparam, lparam,0,wnd, z); break; - case WM_LBUTTONDOWN: stbwingraph__mouse(&e, STBWGE_leftdown, wparam, lparam,1,wnd, z); break; - case WM_MBUTTONDOWN: stbwingraph__mouse(&e, STBWGE_middledown, wparam, lparam,1,wnd, z); break; - case WM_RBUTTONDOWN: stbwingraph__mouse(&e, STBWGE_rightdown, wparam, lparam,1,wnd, z); break; - case WM_LBUTTONUP: stbwingraph__mouse(&e, STBWGE_leftup, wparam, lparam,-1,wnd, z); break; - case WM_MBUTTONUP: stbwingraph__mouse(&e, STBWGE_middleup, wparam, lparam,-1,wnd, z); break; - case WM_RBUTTONUP: stbwingraph__mouse(&e, STBWGE_rightup, wparam, lparam,-1,wnd, z); break; - case WM_MOUSEWHEEL: stbwingraph__mousewheel(&e, STBWGE_mousewheel, wparam, lparam,0,wnd, z); break; - - case WM_ACTIVATE: - allow_default = FALSE; - if (LOWORD(wparam)==WA_INACTIVE ) { - wglMakeCurrent(z->dc, NULL); - e.type = STBWGE_deactivate; - z->active = FALSE; - } else { - wglMakeCurrent(z->dc, z->rc); - e.type = STBWGE_activate; - z->active = TRUE; - } - e.handle = wnd; - z->func(z->data, &e); - return 0; - - case WM_SIZE: { - RECT rect; - allow_default = FALSE; - GetClientRect(wnd, &rect); - e.type = STBWGE_size; - e.width = rect.right; - e.height = rect.bottom; - e.handle = wnd; - z->func(z->data, &e); - return 0; - } - - default: - return DefWindowProc (wnd, msg, wparam, lparam); - } - - if (e.type != STBWGE__none) { - int n; - e.handle = wnd; - n = z->func(z->data, &e); - if (n == STBWINGRAPH_winproc_exit) { - PostQuitMessage(0); - n = 0; - } - if (n == STBWINGRAPH_winproc_update) { - stbwingraph_force_update = TRUE; - return 1; - } - if (n != STBWINGRAPH_unprocessed) - return n; - } - return DefWindowProc (wnd, msg, wparam, lparam); -} - -int stbwingraph_DefineClass(HINSTANCE hInstance, char *iconname) -{ - WNDCLASSEX wndclass; - - stbwingraph_app = hInstance; - - wndclass.cbSize = sizeof(wndclass); - wndclass.style = CS_OWNDC; - wndclass.lpfnWndProc = (WNDPROC) stbwingraph_WinProc; - wndclass.cbClsExtra = 0; - wndclass.cbWndExtra = 0; - wndclass.hInstance = hInstance; - wndclass.hIcon = LoadIcon(hInstance, iconname); - wndclass.hCursor = LoadCursor(NULL,IDC_ARROW); - wndclass.hbrBackground = GetStockObject(NULL_BRUSH); - wndclass.lpszMenuName = "zwingraph"; - wndclass.lpszClassName = "zwingraph"; - wndclass.hIconSm = NULL; - - if (!RegisterClassEx(&wndclass)) - return FALSE; - return TRUE; -} - -void stbwingraph_ShowWindow(void *window) -{ - stbwingraph_event e = { STBWGE_create_postshow }; - stbwingraph__window *z = (stbwingraph__window *) GetWindowLong(window, GWL_USERDATA); - ShowWindow(window, SW_SHOWNORMAL); - InvalidateRect(window, NULL, TRUE); - UpdateWindow(window); - e.handle = window; - z->func(z->data, &e); -} - -void *stbwingraph_CreateWindow(int primary, stbwingraph_window_proc func, void *data, char *text, - int width, int height, int fullscreen, int resizeable, int dest_alpha, int stencil) -{ - HWND win; - DWORD dwstyle; - stbwingraph__window *z = (stbwingraph__window *) malloc(sizeof(*z)); - - if (z == NULL) return NULL; - memset(z, 0, sizeof(*z)); - z->color = 24; - z->depth = 24; - z->alpha = dest_alpha; - z->stencil = stencil; - z->func = func; - z->data = data; - z->mx = -(1 << 30); - z->my = 0; - - if (primary) { - if (stbwingraph_request_windowed) - fullscreen = FALSE; - else if (stbwingraph_request_fullscreen) - fullscreen = TRUE; - } - - if (fullscreen) { - #ifdef STB_SIMPLE - stbwingraph_ChangeResolution(width, height, 32, 1); - #else - if (!stbwingraph_ChangeResolution(width, height, 32, 0)) - return NULL; - #endif - dwstyle = WS_POPUP | WS_CLIPSIBLINGS; - } else { - RECT rect; - dwstyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; - if (resizeable) - dwstyle |= WS_SIZEBOX | WS_MAXIMIZEBOX; - rect.top = 0; - rect.left = 0; - rect.right = width; - rect.bottom = height; - AdjustWindowRect(&rect, dwstyle, FALSE); - width = rect.right - rect.left; - height = rect.bottom - rect.top; - } - - win = CreateWindow("zwingraph", text ? text : "sample", dwstyle, - CW_USEDEFAULT,0, width, height, - NULL, NULL, stbwingraph_app, z); - - if (win == NULL) return win; - - if (primary) { - if (stbwingraph_primary_window) - stbwingraph_DestroyWindow(stbwingraph_primary_window); - stbwingraph_primary_window = win; - } - - { - stbwingraph_event e = { STBWGE_create }; - stbwingraph__window *z = (stbwingraph__window *) GetWindowLong(win, GWL_USERDATA); - z->window = win; - e.did_share_lists = z->did_share_lists; - e.handle = win; - if (z->func(z->data, &e) != STBWINGRAPH_do_not_show) - stbwingraph_ShowWindow(win); - } - - return win; -} - -void *stbwingraph_CreateWindowSimple(stbwingraph_window_proc func, int width, int height) -{ - int fullscreen = 0; - #ifndef _DEBUG - if (width == 640 && height == 480) fullscreen = 1; - if (width == 800 && height == 600) fullscreen = 1; - if (width == 1024 && height == 768) fullscreen = 1; - if (width == 1280 && height == 1024) fullscreen = 1; - if (width == 1600 && height == 1200) fullscreen = 1; - //@TODO: widescreen widths - #endif - return stbwingraph_CreateWindow(1, func, NULL, NULL, width, height, fullscreen, 1, 0, 0); -} - -void *stbwingraph_CreateWindowSimpleFull(stbwingraph_window_proc func, int fullscreen, int ww, int wh, int fw, int fh) -{ - if (fullscreen == -1) { - #ifdef _DEBUG - fullscreen = 0; - #else - fullscreen = 1; - #endif - } - - if (fullscreen) { - if (fw) ww = fw; - if (fh) wh = fh; - } - return stbwingraph_CreateWindow(1, func, NULL, NULL, ww, wh, fullscreen, 1, 0, 0); -} - -void stbwingraph_DestroyWindow(void *window) -{ - stbwingraph__window *z = (stbwingraph__window *) GetWindowLong(window, GWL_USERDATA); - DestroyWindow(window); - free(z); - if (stbwingraph_primary_window == window) - stbwingraph_primary_window = NULL; -} - -void stbwingraph_ShowCursor(void *window, int visible) -{ - int hide; - stbwingraph__window *win; - if (!window) - window = stbwingraph_primary_window; - win = (stbwingraph__window *) GetWindowLong((HWND) window, GWL_USERDATA); - hide = !visible; - if (hide != win->hide_mouse) { - win->hide_mouse = hide; - if (!hide) - ShowCursor(TRUE); - else if (win->in_client) - ShowCursor(FALSE); - } -} - -float stbwingraph_GetTimestep(float minimum_time) -{ - float elapsedTime; - double thisTime; - static double lastTime = -1; - - if (lastTime == -1) - lastTime = timeGetTime() / 1000.0 - minimum_time; - - for(;;) { - thisTime = timeGetTime() / 1000.0; - elapsedTime = (float) (thisTime - lastTime); - if (elapsedTime >= minimum_time) { - lastTime = thisTime; - return elapsedTime; - } - #if 1 - Sleep(2); - #endif - } -} - -void stbwingraph_SetGLWindow(void *win) -{ - stbwingraph__window *z = (stbwingraph__window *) GetWindowLong(win, GWL_USERDATA); - if (z) - wglMakeCurrent(z->dc, z->rc); -} - -void stbwingraph_MakeFonts(void *window, int font_base) -{ - wglUseFontBitmaps(GetDC(window ? window : stbwingraph_primary_window), 0, 256, font_base); -} - -// returns 1 if WM_QUIT, 0 if 'func' returned 0 -int stbwingraph_MainLoop(stbwingraph_update func, float mintime) -{ - int needs_drawing = FALSE; - MSG msg; - - int is_animating = TRUE; - if (mintime <= 0) mintime = 0.01f; - - for(;;) { - int n; - - is_animating = TRUE; - // wait for a message if: (a) we're animating and there's already a message - // or (b) we're not animating - if (!is_animating || PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { - stbwingraph_force_update = FALSE; - if (GetMessage(&msg, NULL, 0, 0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } else { - return 1; // WM_QUIT - } - - // only force a draw for certain messages... - // if I don't do this, we peg at 50% for some reason... must - // be a bug somewhere, because we peg at 100% when rendering... - // very weird... looks like NVIDIA is pumping some messages - // through our pipeline? well, ok, I guess if we can get - // non-user-generated messages we have to do this - if (!stbwingraph_force_update) { - switch (msg.message) { - case WM_MOUSEMOVE: - case WM_NCMOUSEMOVE: - break; - case WM_CHAR: - case WM_KEYDOWN: - case WM_KEYUP: - case WM_LBUTTONDOWN: - case WM_MBUTTONDOWN: - case WM_RBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MBUTTONUP: - case WM_RBUTTONUP: - case WM_TIMER: - case WM_SIZE: - case WM_ACTIVATE: - needs_drawing = TRUE; - break; - } - } else - needs_drawing = TRUE; - } - - // if another message, process that first - // @TODO: i don't think this is working, because I can't key ahead - // in the SVT demo app - if (PeekMessage(&msg, NULL, 0,0, PM_NOREMOVE)) - continue; - - // and now call update - if (needs_drawing || is_animating) { - int real=1, in_client=1; - if (stbwingraph_primary_window) { - stbwingraph__window *z = (stbwingraph__window *) GetWindowLong(stbwingraph_primary_window, GWL_USERDATA); - if (z && !z->active) { - real = 0; - } - if (z) - in_client = z->in_client; - } - - if (stbwingraph_primary_window) - stbwingraph_SetGLWindow(stbwingraph_primary_window); - n = func(stbwingraph_GetTimestep(mintime), real, in_client); - if (n == STBWINGRAPH_update_exit) - return 0; // update_quit - - is_animating = (n != STBWINGRAPH_update_pause); - - needs_drawing = FALSE; - } - } -} - -void stbwingraph_SwapBuffers(void *win) -{ - stbwingraph__window *z; - if (win == NULL) win = stbwingraph_primary_window; - z = (stbwingraph__window *) GetWindowLong(win, GWL_USERDATA); - if (z && z->dc) - SwapBuffers(z->dc); -} -#endif - -#ifdef STB_WINMAIN -void stbwingraph_main(void); - -char *stb_wingraph_commandline; - -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) -{ - { - char buffer[1024]; - // add spaces to either side of the string - buffer[0] = ' '; - strcpy(buffer+1, lpCmdLine); - strcat(buffer, " "); - if (strstr(buffer, " -reset ")) { - ChangeDisplaySettings(NULL, 0); - exit(0); - } - if (strstr(buffer, " -window ") || strstr(buffer, " -windowed ")) - stbwingraph_request_windowed = TRUE; - else if (strstr(buffer, " -full ") || strstr(buffer, " -fullscreen ")) - stbwingraph_request_fullscreen = TRUE; - } - stb_wingraph_commandline = lpCmdLine; - - stbwingraph_DefineClass(hInstance, "appicon"); - stbwingraph_main(); - - return 0; -} -#endif - -#undef STB_EXTERN -#ifdef STB_WINGRAPH_DISABLE_DEFINE_AT_END -#undef STB_DEFINE -#endif - -#endif // INCLUDE_STB_WINGRAPH_H diff --git a/third_party/stb/tests/pg_test/pg_test.c b/third_party/stb/tests/pg_test/pg_test.c deleted file mode 100644 index c028d5f870..0000000000 --- a/third_party/stb/tests/pg_test/pg_test.c +++ /dev/null @@ -1,124 +0,0 @@ -#define STB_DEFINE -#include "stb.h" -#define STB_PG_IMPLEMENTATION -#include "stb_pg.h" -#define STB_IMAGE_IMPLEMENTATION -#include "stb_image.h" -#define STB_IMAGE_WRITE_IMPLEMENTATION -#include "stb_image_write.h" - -static float *hf; -static int hf_width = 10001; -static int hf_height = 10001; - -static float get_height(float x, float y) -{ - float h00,h01,h10,h11,h0,h1; - int ix,iy; - if (x < 0) x = 0; - if (x > hf_width-1) x = (float) hf_width-1; - if (y < 0) y = 0; - if (y > hf_height-1) y = (float) hf_height-1; - ix = (int) x; x -= ix; - iy = (int) y; y -= iy; - h00 = hf[(iy+0)*hf_height+(ix+0)]; - h10 = hf[(iy+0)*hf_height+(ix+1)]; - h01 = hf[(iy+1)*hf_height+(ix+0)]; - h11 = hf[(iy+1)*hf_height+(ix+1)]; - h0 = stb_lerp(y, h00, h01); - h1 = stb_lerp(y, h10, h11); - return stb_lerp(x, h0, h1); -} - -void stbpg_tick(float dt) -{ - int i=0,j=0; - int step = 1; - - glUseProgram(0); - - glClearColor(0.6f,0.7f,1.0f,1.0f); - glClearDepth(1.0f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glDepthFunc(GL_LESS); - glEnable(GL_DEPTH_TEST); -#if 1 - glEnable(GL_CULL_FACE); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(60.0, 1920/1080.0f, 0.02f, 8000.0f); - //glOrtho(-8,8,-6,6, -100, 100); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glRotatef(-90, 1,0,0); // z-up - - { - float x,y; - stbpg_get_mouselook(&x,&y); - glRotatef(-y, 1,0,0); - glRotatef(-x, 0,0,1); - } - - { - static float cam_x = 1000; - static float cam_y = 1000; - static float cam_z = 700; - float x=0,y=0; - stbpg_get_keymove(&x,&y); - cam_x += x*dt*5.0f; - cam_y += y*dt*5.0f; - glTranslatef(-cam_x, -cam_y, -cam_z); - if (cam_x >= 0 && cam_x < hf_width && cam_y >= 0 && cam_y < hf_height) - cam_z = get_height(cam_x, cam_y) + 1.65f; // average eye height in meters - } - - for (j=501; j+1 < 1500+0*hf_height; j += step) { - glBegin(GL_QUAD_STRIP); - for (i=501; i < 1500+0*hf_width; i += step) { - static int flip=0; - if (flip) - glColor3f(0.5,0.5,0.5); - else - glColor3f(0.4f,0.4f,0.4f); - flip = !flip; - glVertex3f((float) i, (float) j+step,hf[(j+step)*hf_width+i]); - glVertex3f((float) i, (float) j ,hf[ j *hf_width+i]); - } - glEnd(); - } - - glBegin(GL_LINES); - glColor3f(1,0,0); glVertex3f(10,0,0); glVertex3f(0,0,0); - glColor3f(0,1,0); glVertex3f(0,10,0); glVertex3f(0,0,0); - glColor3f(0,0,1); glVertex3f(0,0,10); glVertex3f(0,0,0); - glEnd(); -#endif -} - -void stbpg_main(int argc, char **argv) -{ - int i,j; - - #if 0 - int w,h,c; - unsigned short *data = stbi_load_16("c:/x/ned_1m/test2.png", &w, &h, &c, 1); - stb_filewrite("c:/x/ned_1m/x73_y428_10012_10012.bin", data, w*h*2); - #else - unsigned short *data = stb_file("c:/x/ned_1m/x73_y428_10012_10012.bin", NULL); - int w=10012, h = 10012; - #endif - - hf = malloc(hf_width * hf_height * 4); - for (j=0; j < hf_height; ++j) - for (i=0; i < hf_width; ++i) - hf[j*hf_width+i] = data[j*w+i] / 32.0f; - - stbpg_gl_compat_version(1,1); - stbpg_windowed("terrain_edit", 1920, 1080); - stbpg_run(); - - return; -} diff --git a/third_party/stb/tests/pngsuite/16bit/basi0g16.png b/third_party/stb/tests/pngsuite/16bit/basi0g16.png deleted file mode 100644 index a9f28165ef..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/basi0g16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/basi2c16.png b/third_party/stb/tests/pngsuite/16bit/basi2c16.png deleted file mode 100644 index cd7e50f914..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/basi2c16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/basi4a16.png b/third_party/stb/tests/pngsuite/16bit/basi4a16.png deleted file mode 100644 index 51192e7311..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/basi4a16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/basi6a16.png b/third_party/stb/tests/pngsuite/16bit/basi6a16.png deleted file mode 100644 index 4181533ad8..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/basi6a16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/basn0g16.png b/third_party/stb/tests/pngsuite/16bit/basn0g16.png deleted file mode 100644 index e7c82f78eb..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/basn0g16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/basn2c16.png b/third_party/stb/tests/pngsuite/16bit/basn2c16.png deleted file mode 100644 index 50c1cb91a0..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/basn2c16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/basn4a16.png b/third_party/stb/tests/pngsuite/16bit/basn4a16.png deleted file mode 100644 index 8243644d07..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/basn4a16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/basn6a16.png b/third_party/stb/tests/pngsuite/16bit/basn6a16.png deleted file mode 100644 index 984a99525f..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/basn6a16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/bgai4a16.png b/third_party/stb/tests/pngsuite/16bit/bgai4a16.png deleted file mode 100644 index 51192e7311..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/bgai4a16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/bgan6a16.png b/third_party/stb/tests/pngsuite/16bit/bgan6a16.png deleted file mode 100644 index 984a99525f..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/bgan6a16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/bggn4a16.png b/third_party/stb/tests/pngsuite/16bit/bggn4a16.png deleted file mode 100644 index 13fd85ba19..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/bggn4a16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/bgyn6a16.png b/third_party/stb/tests/pngsuite/16bit/bgyn6a16.png deleted file mode 100644 index ae3e9be58a..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/bgyn6a16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/oi1n0g16.png b/third_party/stb/tests/pngsuite/16bit/oi1n0g16.png deleted file mode 100644 index e7c82f78eb..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/oi1n0g16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/oi1n2c16.png b/third_party/stb/tests/pngsuite/16bit/oi1n2c16.png deleted file mode 100644 index 50c1cb91a0..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/oi1n2c16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/oi2n0g16.png b/third_party/stb/tests/pngsuite/16bit/oi2n0g16.png deleted file mode 100644 index 14d64c583d..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/oi2n0g16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/oi2n2c16.png b/third_party/stb/tests/pngsuite/16bit/oi2n2c16.png deleted file mode 100644 index 4c2e3e3352..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/oi2n2c16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/oi4n0g16.png b/third_party/stb/tests/pngsuite/16bit/oi4n0g16.png deleted file mode 100644 index 69e73ede31..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/oi4n0g16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/oi4n2c16.png b/third_party/stb/tests/pngsuite/16bit/oi4n2c16.png deleted file mode 100644 index 93691e373a..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/oi4n2c16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/oi9n0g16.png b/third_party/stb/tests/pngsuite/16bit/oi9n0g16.png deleted file mode 100644 index 9248413576..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/oi9n0g16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/oi9n2c16.png b/third_party/stb/tests/pngsuite/16bit/oi9n2c16.png deleted file mode 100644 index f0512e49f2..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/oi9n2c16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/tbbn2c16.png b/third_party/stb/tests/pngsuite/16bit/tbbn2c16.png deleted file mode 100644 index dd3168e5c8..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/tbbn2c16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/tbgn2c16.png b/third_party/stb/tests/pngsuite/16bit/tbgn2c16.png deleted file mode 100644 index 85cec395c0..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/tbgn2c16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/16bit/tbwn0g16.png b/third_party/stb/tests/pngsuite/16bit/tbwn0g16.png deleted file mode 100644 index 99bdeed2b3..0000000000 Binary files a/third_party/stb/tests/pngsuite/16bit/tbwn0g16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/PngSuite.LICENSE b/third_party/stb/tests/pngsuite/PngSuite.LICENSE deleted file mode 100644 index 8d4d1d0777..0000000000 --- a/third_party/stb/tests/pngsuite/PngSuite.LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -PngSuite --------- - -Permission to use, copy, modify and distribute these images for any -purpose and without fee is hereby granted. - - -(c) Willem van Schaik, 1996, 2011 - diff --git a/third_party/stb/tests/pngsuite/corrupt/xc1n0g08.png b/third_party/stb/tests/pngsuite/corrupt/xc1n0g08.png deleted file mode 100644 index 9404227370..0000000000 Binary files a/third_party/stb/tests/pngsuite/corrupt/xc1n0g08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/corrupt/xc9n2c08.png b/third_party/stb/tests/pngsuite/corrupt/xc9n2c08.png deleted file mode 100644 index b11c2a7b40..0000000000 Binary files a/third_party/stb/tests/pngsuite/corrupt/xc9n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/corrupt/xcrn0g04.png b/third_party/stb/tests/pngsuite/corrupt/xcrn0g04.png deleted file mode 100644 index 48abba193a..0000000000 Binary files a/third_party/stb/tests/pngsuite/corrupt/xcrn0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/corrupt/xcsn0g01.png b/third_party/stb/tests/pngsuite/corrupt/xcsn0g01.png deleted file mode 100644 index 9863a262ca..0000000000 Binary files a/third_party/stb/tests/pngsuite/corrupt/xcsn0g01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/corrupt/xd0n2c08.png b/third_party/stb/tests/pngsuite/corrupt/xd0n2c08.png deleted file mode 100644 index 2f001610a8..0000000000 Binary files a/third_party/stb/tests/pngsuite/corrupt/xd0n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/corrupt/xd3n2c08.png b/third_party/stb/tests/pngsuite/corrupt/xd3n2c08.png deleted file mode 100644 index 9e4a3ff7ac..0000000000 Binary files a/third_party/stb/tests/pngsuite/corrupt/xd3n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/corrupt/xd9n2c08.png b/third_party/stb/tests/pngsuite/corrupt/xd9n2c08.png deleted file mode 100644 index 2c3b91aa4f..0000000000 Binary files a/third_party/stb/tests/pngsuite/corrupt/xd9n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/corrupt/xdtn0g01.png b/third_party/stb/tests/pngsuite/corrupt/xdtn0g01.png deleted file mode 100644 index 1a81abef82..0000000000 Binary files a/third_party/stb/tests/pngsuite/corrupt/xdtn0g01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/corrupt/xhdn0g08.png b/third_party/stb/tests/pngsuite/corrupt/xhdn0g08.png deleted file mode 100644 index fcb8737fa2..0000000000 Binary files a/third_party/stb/tests/pngsuite/corrupt/xhdn0g08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/corrupt/xlfn0g04.png b/third_party/stb/tests/pngsuite/corrupt/xlfn0g04.png deleted file mode 100644 index d9ec53ed94..0000000000 Binary files a/third_party/stb/tests/pngsuite/corrupt/xlfn0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/corrupt/xs1n0g01.png b/third_party/stb/tests/pngsuite/corrupt/xs1n0g01.png deleted file mode 100644 index 1817c5144f..0000000000 Binary files a/third_party/stb/tests/pngsuite/corrupt/xs1n0g01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/corrupt/xs2n0g01.png b/third_party/stb/tests/pngsuite/corrupt/xs2n0g01.png deleted file mode 100644 index b8147f2a84..0000000000 Binary files a/third_party/stb/tests/pngsuite/corrupt/xs2n0g01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/corrupt/xs4n0g01.png b/third_party/stb/tests/pngsuite/corrupt/xs4n0g01.png deleted file mode 100644 index 45237a1d29..0000000000 Binary files a/third_party/stb/tests/pngsuite/corrupt/xs4n0g01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/corrupt/xs7n0g01.png b/third_party/stb/tests/pngsuite/corrupt/xs7n0g01.png deleted file mode 100644 index 3f307f14ea..0000000000 Binary files a/third_party/stb/tests/pngsuite/corrupt/xs7n0g01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basi0g01.png b/third_party/stb/tests/pngsuite/primary/basi0g01.png deleted file mode 100644 index 556fa72704..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basi0g01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basi0g02.png b/third_party/stb/tests/pngsuite/primary/basi0g02.png deleted file mode 100644 index ce09821ef1..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basi0g02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basi0g04.png b/third_party/stb/tests/pngsuite/primary/basi0g04.png deleted file mode 100644 index 3853273f93..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basi0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basi0g08.png b/third_party/stb/tests/pngsuite/primary/basi0g08.png deleted file mode 100644 index faed8bec44..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basi0g08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basi2c08.png b/third_party/stb/tests/pngsuite/primary/basi2c08.png deleted file mode 100644 index 2aab44d42b..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basi2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basi3p01.png b/third_party/stb/tests/pngsuite/primary/basi3p01.png deleted file mode 100644 index 00a7cea6c2..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basi3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basi3p02.png b/third_party/stb/tests/pngsuite/primary/basi3p02.png deleted file mode 100644 index bb16b44b30..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basi3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basi3p04.png b/third_party/stb/tests/pngsuite/primary/basi3p04.png deleted file mode 100644 index b4e888e247..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basi3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basi3p08.png b/third_party/stb/tests/pngsuite/primary/basi3p08.png deleted file mode 100644 index 50a6d1cac7..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basi3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basi4a08.png b/third_party/stb/tests/pngsuite/primary/basi4a08.png deleted file mode 100644 index 398132be5f..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basi4a08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basi6a08.png b/third_party/stb/tests/pngsuite/primary/basi6a08.png deleted file mode 100644 index aecb32e0d9..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basi6a08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basn0g01.png b/third_party/stb/tests/pngsuite/primary/basn0g01.png deleted file mode 100644 index 1d722423aa..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basn0g01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basn0g02.png b/third_party/stb/tests/pngsuite/primary/basn0g02.png deleted file mode 100644 index 508332418f..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basn0g02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basn0g04.png b/third_party/stb/tests/pngsuite/primary/basn0g04.png deleted file mode 100644 index 0bf3687863..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basn0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basn0g08.png b/third_party/stb/tests/pngsuite/primary/basn0g08.png deleted file mode 100644 index 23c82379a2..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basn0g08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basn2c08.png b/third_party/stb/tests/pngsuite/primary/basn2c08.png deleted file mode 100644 index db5ad15865..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basn2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basn3p01.png b/third_party/stb/tests/pngsuite/primary/basn3p01.png deleted file mode 100644 index b145c2b8ef..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basn3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basn3p02.png b/third_party/stb/tests/pngsuite/primary/basn3p02.png deleted file mode 100644 index 8985b3d818..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basn3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basn3p04.png b/third_party/stb/tests/pngsuite/primary/basn3p04.png deleted file mode 100644 index 0fbf9e827b..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basn3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basn3p08.png b/third_party/stb/tests/pngsuite/primary/basn3p08.png deleted file mode 100644 index 0ddad07e5f..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basn3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basn4a08.png b/third_party/stb/tests/pngsuite/primary/basn4a08.png deleted file mode 100644 index 3e13052201..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basn4a08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/basn6a08.png b/third_party/stb/tests/pngsuite/primary/basn6a08.png deleted file mode 100644 index e608738763..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/basn6a08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/bgai4a08.png b/third_party/stb/tests/pngsuite/primary/bgai4a08.png deleted file mode 100644 index 398132be5f..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/bgai4a08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/bgan6a08.png b/third_party/stb/tests/pngsuite/primary/bgan6a08.png deleted file mode 100644 index e608738763..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/bgan6a08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/bgbn4a08.png b/third_party/stb/tests/pngsuite/primary/bgbn4a08.png deleted file mode 100644 index 7cbefc3bff..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/bgbn4a08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/bgwn6a08.png b/third_party/stb/tests/pngsuite/primary/bgwn6a08.png deleted file mode 100644 index a67ff205bb..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/bgwn6a08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s01i3p01.png b/third_party/stb/tests/pngsuite/primary/s01i3p01.png deleted file mode 100644 index 6c0fad1fc9..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s01i3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s01n3p01.png b/third_party/stb/tests/pngsuite/primary/s01n3p01.png deleted file mode 100644 index cb2c8c7826..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s01n3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s02i3p01.png b/third_party/stb/tests/pngsuite/primary/s02i3p01.png deleted file mode 100644 index 2defaed911..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s02i3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s02n3p01.png b/third_party/stb/tests/pngsuite/primary/s02n3p01.png deleted file mode 100644 index 2b1b669643..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s02n3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s03i3p01.png b/third_party/stb/tests/pngsuite/primary/s03i3p01.png deleted file mode 100644 index c23fdc4631..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s03i3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s03n3p01.png b/third_party/stb/tests/pngsuite/primary/s03n3p01.png deleted file mode 100644 index 6d96ee4f87..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s03n3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s04i3p01.png b/third_party/stb/tests/pngsuite/primary/s04i3p01.png deleted file mode 100644 index 0e710c2c39..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s04i3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s04n3p01.png b/third_party/stb/tests/pngsuite/primary/s04n3p01.png deleted file mode 100644 index 956396c45b..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s04n3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s05i3p02.png b/third_party/stb/tests/pngsuite/primary/s05i3p02.png deleted file mode 100644 index d14cbd351a..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s05i3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s05n3p02.png b/third_party/stb/tests/pngsuite/primary/s05n3p02.png deleted file mode 100644 index bf940f0576..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s05n3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s06i3p02.png b/third_party/stb/tests/pngsuite/primary/s06i3p02.png deleted file mode 100644 index 456ada3200..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s06i3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s06n3p02.png b/third_party/stb/tests/pngsuite/primary/s06n3p02.png deleted file mode 100644 index 501064dc25..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s06n3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s07i3p02.png b/third_party/stb/tests/pngsuite/primary/s07i3p02.png deleted file mode 100644 index 44b66bab9e..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s07i3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s07n3p02.png b/third_party/stb/tests/pngsuite/primary/s07n3p02.png deleted file mode 100644 index 6a582593d6..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s07n3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s08i3p02.png b/third_party/stb/tests/pngsuite/primary/s08i3p02.png deleted file mode 100644 index acf74f3fc4..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s08i3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s08n3p02.png b/third_party/stb/tests/pngsuite/primary/s08n3p02.png deleted file mode 100644 index b7094e1b4f..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s08n3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s09i3p02.png b/third_party/stb/tests/pngsuite/primary/s09i3p02.png deleted file mode 100644 index 0bfae8e456..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s09i3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s09n3p02.png b/third_party/stb/tests/pngsuite/primary/s09n3p02.png deleted file mode 100644 index 711ab82451..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s09n3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s32i3p04.png b/third_party/stb/tests/pngsuite/primary/s32i3p04.png deleted file mode 100644 index 0841910b72..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s32i3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s32n3p04.png b/third_party/stb/tests/pngsuite/primary/s32n3p04.png deleted file mode 100644 index fa58e3e3f6..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s32n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s33i3p04.png b/third_party/stb/tests/pngsuite/primary/s33i3p04.png deleted file mode 100644 index ab0dc14aba..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s33i3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s33n3p04.png b/third_party/stb/tests/pngsuite/primary/s33n3p04.png deleted file mode 100644 index 764f1a3dc7..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s33n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s34i3p04.png b/third_party/stb/tests/pngsuite/primary/s34i3p04.png deleted file mode 100644 index bd99039be4..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s34i3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s34n3p04.png b/third_party/stb/tests/pngsuite/primary/s34n3p04.png deleted file mode 100644 index 9cbc68b3b9..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s34n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s35i3p04.png b/third_party/stb/tests/pngsuite/primary/s35i3p04.png deleted file mode 100644 index e2a5e0a659..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s35i3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s35n3p04.png b/third_party/stb/tests/pngsuite/primary/s35n3p04.png deleted file mode 100644 index 90b892ebaf..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s35n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s36i3p04.png b/third_party/stb/tests/pngsuite/primary/s36i3p04.png deleted file mode 100644 index eb61b6f9a3..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s36i3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s36n3p04.png b/third_party/stb/tests/pngsuite/primary/s36n3p04.png deleted file mode 100644 index b38d179774..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s36n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s37i3p04.png b/third_party/stb/tests/pngsuite/primary/s37i3p04.png deleted file mode 100644 index 6e2b1e9b79..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s37i3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s37n3p04.png b/third_party/stb/tests/pngsuite/primary/s37n3p04.png deleted file mode 100644 index 4d3054da51..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s37n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s38i3p04.png b/third_party/stb/tests/pngsuite/primary/s38i3p04.png deleted file mode 100644 index a0a8a140ad..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s38i3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s38n3p04.png b/third_party/stb/tests/pngsuite/primary/s38n3p04.png deleted file mode 100644 index 1233ed048e..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s38n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s39i3p04.png b/third_party/stb/tests/pngsuite/primary/s39i3p04.png deleted file mode 100644 index 04fee93eae..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s39i3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s39n3p04.png b/third_party/stb/tests/pngsuite/primary/s39n3p04.png deleted file mode 100644 index c750100d55..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s39n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s40i3p04.png b/third_party/stb/tests/pngsuite/primary/s40i3p04.png deleted file mode 100644 index 68f358b822..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s40i3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/s40n3p04.png b/third_party/stb/tests/pngsuite/primary/s40n3p04.png deleted file mode 100644 index 864b6b9673..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/s40n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/tbbn0g04.png b/third_party/stb/tests/pngsuite/primary/tbbn0g04.png deleted file mode 100644 index 39a7050d27..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/tbbn0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/tbbn3p08.png b/third_party/stb/tests/pngsuite/primary/tbbn3p08.png deleted file mode 100644 index 0ede3574db..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/tbbn3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/tbgn3p08.png b/third_party/stb/tests/pngsuite/primary/tbgn3p08.png deleted file mode 100644 index 8cf2e6fb6a..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/tbgn3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/tbrn2c08.png b/third_party/stb/tests/pngsuite/primary/tbrn2c08.png deleted file mode 100644 index 5cca0d6210..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/tbrn2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/tbwn3p08.png b/third_party/stb/tests/pngsuite/primary/tbwn3p08.png deleted file mode 100644 index eacab7a144..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/tbwn3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/tbyn3p08.png b/third_party/stb/tests/pngsuite/primary/tbyn3p08.png deleted file mode 100644 index 656db0989a..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/tbyn3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/tm3n3p02.png b/third_party/stb/tests/pngsuite/primary/tm3n3p02.png deleted file mode 100644 index fb3ef1d0c5..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/tm3n3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/tp0n0g08.png b/third_party/stb/tests/pngsuite/primary/tp0n0g08.png deleted file mode 100644 index 333465fcdc..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/tp0n0g08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/tp0n2c08.png b/third_party/stb/tests/pngsuite/primary/tp0n2c08.png deleted file mode 100644 index fc6e42cb42..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/tp0n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/tp0n3p08.png b/third_party/stb/tests/pngsuite/primary/tp0n3p08.png deleted file mode 100644 index 69a69e5872..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/tp0n3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/tp1n3p08.png b/third_party/stb/tests/pngsuite/primary/tp1n3p08.png deleted file mode 100644 index a6c9f35a86..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/tp1n3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/z00n2c08.png b/third_party/stb/tests/pngsuite/primary/z00n2c08.png deleted file mode 100644 index 7669eb8385..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/z00n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/z03n2c08.png b/third_party/stb/tests/pngsuite/primary/z03n2c08.png deleted file mode 100644 index bfb10de8de..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/z03n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/z06n2c08.png b/third_party/stb/tests/pngsuite/primary/z06n2c08.png deleted file mode 100644 index b90ebc10f5..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/z06n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary/z09n2c08.png b/third_party/stb/tests/pngsuite/primary/z09n2c08.png deleted file mode 100644 index 5f191a78ee..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary/z09n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basi0g01.png b/third_party/stb/tests/pngsuite/primary_check/basi0g01.png deleted file mode 100644 index 96ed62dbed..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basi0g01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basi0g02.png b/third_party/stb/tests/pngsuite/primary_check/basi0g02.png deleted file mode 100644 index bb53098851..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basi0g02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basi0g04.png b/third_party/stb/tests/pngsuite/primary_check/basi0g04.png deleted file mode 100644 index 2efd4876b5..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basi0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basi0g08.png b/third_party/stb/tests/pngsuite/primary_check/basi0g08.png deleted file mode 100644 index 23952137c9..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basi0g08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basi2c08.png b/third_party/stb/tests/pngsuite/primary_check/basi2c08.png deleted file mode 100644 index 64ef3f8443..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basi2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basi3p01.png b/third_party/stb/tests/pngsuite/primary_check/basi3p01.png deleted file mode 100644 index a8599e9a55..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basi3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basi3p02.png b/third_party/stb/tests/pngsuite/primary_check/basi3p02.png deleted file mode 100644 index c911ea9cc2..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basi3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basi3p04.png b/third_party/stb/tests/pngsuite/primary_check/basi3p04.png deleted file mode 100644 index 750ef69dc5..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basi3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basi3p08.png b/third_party/stb/tests/pngsuite/primary_check/basi3p08.png deleted file mode 100644 index 39272c3592..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basi3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basi4a08.png b/third_party/stb/tests/pngsuite/primary_check/basi4a08.png deleted file mode 100644 index 1b7b3a5821..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basi4a08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basi6a08.png b/third_party/stb/tests/pngsuite/primary_check/basi6a08.png deleted file mode 100644 index c12484fc58..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basi6a08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basn0g01.png b/third_party/stb/tests/pngsuite/primary_check/basn0g01.png deleted file mode 100644 index 20f6404a20..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basn0g01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basn0g02.png b/third_party/stb/tests/pngsuite/primary_check/basn0g02.png deleted file mode 100644 index c4fae00c36..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basn0g02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basn0g04.png b/third_party/stb/tests/pngsuite/primary_check/basn0g04.png deleted file mode 100644 index 166e7db219..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basn0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basn0g08.png b/third_party/stb/tests/pngsuite/primary_check/basn0g08.png deleted file mode 100644 index 192c79215a..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basn0g08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basn2c08.png b/third_party/stb/tests/pngsuite/primary_check/basn2c08.png deleted file mode 100644 index d774b80097..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basn2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basn3p01.png b/third_party/stb/tests/pngsuite/primary_check/basn3p01.png deleted file mode 100644 index 77c580b00a..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basn3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basn3p02.png b/third_party/stb/tests/pngsuite/primary_check/basn3p02.png deleted file mode 100644 index 8427124ada..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basn3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basn3p04.png b/third_party/stb/tests/pngsuite/primary_check/basn3p04.png deleted file mode 100644 index f08c6e99d4..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basn3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basn3p08.png b/third_party/stb/tests/pngsuite/primary_check/basn3p08.png deleted file mode 100644 index 0fa8195a51..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basn3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basn4a08.png b/third_party/stb/tests/pngsuite/primary_check/basn4a08.png deleted file mode 100644 index d4e0a72898..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basn4a08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/basn6a08.png b/third_party/stb/tests/pngsuite/primary_check/basn6a08.png deleted file mode 100644 index 1f54e565df..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/basn6a08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/bgai4a08.png b/third_party/stb/tests/pngsuite/primary_check/bgai4a08.png deleted file mode 100644 index 23ec6ae530..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/bgai4a08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/bgan6a08.png b/third_party/stb/tests/pngsuite/primary_check/bgan6a08.png deleted file mode 100644 index 6cb76f2b43..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/bgan6a08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/bgbn4a08.png b/third_party/stb/tests/pngsuite/primary_check/bgbn4a08.png deleted file mode 100644 index 1086ccc09b..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/bgbn4a08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/bgwn6a08.png b/third_party/stb/tests/pngsuite/primary_check/bgwn6a08.png deleted file mode 100644 index 03a0a303d6..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/bgwn6a08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s01i3p01.png b/third_party/stb/tests/pngsuite/primary_check/s01i3p01.png deleted file mode 100644 index 45f8c619fb..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s01i3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s01n3p01.png b/third_party/stb/tests/pngsuite/primary_check/s01n3p01.png deleted file mode 100644 index a79ac1b08b..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s01n3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s02i3p01.png b/third_party/stb/tests/pngsuite/primary_check/s02i3p01.png deleted file mode 100644 index d84f40613e..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s02i3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s02n3p01.png b/third_party/stb/tests/pngsuite/primary_check/s02n3p01.png deleted file mode 100644 index 3b813c457e..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s02n3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s03i3p01.png b/third_party/stb/tests/pngsuite/primary_check/s03i3p01.png deleted file mode 100644 index 51367f7f8e..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s03i3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s03n3p01.png b/third_party/stb/tests/pngsuite/primary_check/s03n3p01.png deleted file mode 100644 index 7c44b736ef..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s03n3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s04i3p01.png b/third_party/stb/tests/pngsuite/primary_check/s04i3p01.png deleted file mode 100644 index ae326c1c4b..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s04i3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s04n3p01.png b/third_party/stb/tests/pngsuite/primary_check/s04n3p01.png deleted file mode 100644 index 55c63df538..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s04n3p01.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s05i3p02.png b/third_party/stb/tests/pngsuite/primary_check/s05i3p02.png deleted file mode 100644 index fd41d1d811..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s05i3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s05n3p02.png b/third_party/stb/tests/pngsuite/primary_check/s05n3p02.png deleted file mode 100644 index d6ab572633..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s05n3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s06i3p02.png b/third_party/stb/tests/pngsuite/primary_check/s06i3p02.png deleted file mode 100644 index 73a7b0c64f..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s06i3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s06n3p02.png b/third_party/stb/tests/pngsuite/primary_check/s06n3p02.png deleted file mode 100644 index e85eac8e8f..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s06n3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s07i3p02.png b/third_party/stb/tests/pngsuite/primary_check/s07i3p02.png deleted file mode 100644 index 08f61804f4..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s07i3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s07n3p02.png b/third_party/stb/tests/pngsuite/primary_check/s07n3p02.png deleted file mode 100644 index 029bc29051..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s07n3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s08i3p02.png b/third_party/stb/tests/pngsuite/primary_check/s08i3p02.png deleted file mode 100644 index 23d16c71e2..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s08i3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s08n3p02.png b/third_party/stb/tests/pngsuite/primary_check/s08n3p02.png deleted file mode 100644 index 4a46016665..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s08n3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s09i3p02.png b/third_party/stb/tests/pngsuite/primary_check/s09i3p02.png deleted file mode 100644 index ea14f9be0e..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s09i3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s09n3p02.png b/third_party/stb/tests/pngsuite/primary_check/s09n3p02.png deleted file mode 100644 index 7a822537f7..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s09n3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s32i3p04.png b/third_party/stb/tests/pngsuite/primary_check/s32i3p04.png deleted file mode 100644 index db4bef7eda..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s32i3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s32n3p04.png b/third_party/stb/tests/pngsuite/primary_check/s32n3p04.png deleted file mode 100644 index c250971bd8..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s32n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s33i3p04.png b/third_party/stb/tests/pngsuite/primary_check/s33i3p04.png deleted file mode 100644 index 0faaa74108..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s33i3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s33n3p04.png b/third_party/stb/tests/pngsuite/primary_check/s33n3p04.png deleted file mode 100644 index 599171c7b1..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s33n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s34i3p04.png b/third_party/stb/tests/pngsuite/primary_check/s34i3p04.png deleted file mode 100644 index ca0e5ebbe8..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s34i3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s34n3p04.png b/third_party/stb/tests/pngsuite/primary_check/s34n3p04.png deleted file mode 100644 index b175f59a6b..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s34n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s35i3p04.png b/third_party/stb/tests/pngsuite/primary_check/s35i3p04.png deleted file mode 100644 index ccb1b8aca1..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s35i3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s35n3p04.png b/third_party/stb/tests/pngsuite/primary_check/s35n3p04.png deleted file mode 100644 index 2c7219f00d..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s35n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s36i3p04.png b/third_party/stb/tests/pngsuite/primary_check/s36i3p04.png deleted file mode 100644 index d61491fac8..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s36i3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s36n3p04.png b/third_party/stb/tests/pngsuite/primary_check/s36n3p04.png deleted file mode 100644 index 1f50479e48..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s36n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s37i3p04.png b/third_party/stb/tests/pngsuite/primary_check/s37i3p04.png deleted file mode 100644 index 2906fa3116..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s37i3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s37n3p04.png b/third_party/stb/tests/pngsuite/primary_check/s37n3p04.png deleted file mode 100644 index 8931b859da..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s37n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s38i3p04.png b/third_party/stb/tests/pngsuite/primary_check/s38i3p04.png deleted file mode 100644 index becf5a1df6..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s38i3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s38n3p04.png b/third_party/stb/tests/pngsuite/primary_check/s38n3p04.png deleted file mode 100644 index 43f8c983f1..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s38n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s39i3p04.png b/third_party/stb/tests/pngsuite/primary_check/s39i3p04.png deleted file mode 100644 index b045ad5de0..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s39i3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s39n3p04.png b/third_party/stb/tests/pngsuite/primary_check/s39n3p04.png deleted file mode 100644 index d37d66d441..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s39n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s40i3p04.png b/third_party/stb/tests/pngsuite/primary_check/s40i3p04.png deleted file mode 100644 index dd2f7a11a2..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s40i3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/s40n3p04.png b/third_party/stb/tests/pngsuite/primary_check/s40n3p04.png deleted file mode 100644 index 6f8596ca14..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/s40n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/tbbn0g04.png b/third_party/stb/tests/pngsuite/primary_check/tbbn0g04.png deleted file mode 100644 index 8d9f7d52b0..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/tbbn0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/tbbn3p08.png b/third_party/stb/tests/pngsuite/primary_check/tbbn3p08.png deleted file mode 100644 index 706e6c4e5c..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/tbbn3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/tbgn3p08.png b/third_party/stb/tests/pngsuite/primary_check/tbgn3p08.png deleted file mode 100644 index fa5cdbc95a..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/tbgn3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/tbrn2c08.png b/third_party/stb/tests/pngsuite/primary_check/tbrn2c08.png deleted file mode 100644 index bbe748fd32..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/tbrn2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/tbwn3p08.png b/third_party/stb/tests/pngsuite/primary_check/tbwn3p08.png deleted file mode 100644 index 9ecd40470c..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/tbwn3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/tbyn3p08.png b/third_party/stb/tests/pngsuite/primary_check/tbyn3p08.png deleted file mode 100644 index 4fbdb36a33..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/tbyn3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/tm3n3p02.png b/third_party/stb/tests/pngsuite/primary_check/tm3n3p02.png deleted file mode 100644 index babdebefb5..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/tm3n3p02.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/tp0n0g08.png b/third_party/stb/tests/pngsuite/primary_check/tp0n0g08.png deleted file mode 100644 index 96dd89c3af..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/tp0n0g08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/tp0n2c08.png b/third_party/stb/tests/pngsuite/primary_check/tp0n2c08.png deleted file mode 100644 index 364e97e036..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/tp0n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/tp0n3p08.png b/third_party/stb/tests/pngsuite/primary_check/tp0n3p08.png deleted file mode 100644 index e5a29d6d62..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/tp0n3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/tp1n3p08.png b/third_party/stb/tests/pngsuite/primary_check/tp1n3p08.png deleted file mode 100644 index 9ecd40470c..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/tp1n3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/z00n2c08.png b/third_party/stb/tests/pngsuite/primary_check/z00n2c08.png deleted file mode 100644 index ecaa0d8bab..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/z00n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/z03n2c08.png b/third_party/stb/tests/pngsuite/primary_check/z03n2c08.png deleted file mode 100644 index ecaa0d8bab..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/z03n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/z06n2c08.png b/third_party/stb/tests/pngsuite/primary_check/z06n2c08.png deleted file mode 100644 index ecaa0d8bab..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/z06n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/primary_check/z09n2c08.png b/third_party/stb/tests/pngsuite/primary_check/z09n2c08.png deleted file mode 100644 index d869f992f8..0000000000 Binary files a/third_party/stb/tests/pngsuite/primary_check/z09n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/ccwn2c08.png b/third_party/stb/tests/pngsuite/unused/ccwn2c08.png deleted file mode 100644 index 47c24817b7..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/ccwn2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/ccwn3p08.png b/third_party/stb/tests/pngsuite/unused/ccwn3p08.png deleted file mode 100644 index 8bb2c10981..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/ccwn3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/cdfn2c08.png b/third_party/stb/tests/pngsuite/unused/cdfn2c08.png deleted file mode 100644 index 559e5261e7..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/cdfn2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/cdhn2c08.png b/third_party/stb/tests/pngsuite/unused/cdhn2c08.png deleted file mode 100644 index 3e07e8ecbd..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/cdhn2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/cdsn2c08.png b/third_party/stb/tests/pngsuite/unused/cdsn2c08.png deleted file mode 100644 index 076c32cc08..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/cdsn2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/cdun2c08.png b/third_party/stb/tests/pngsuite/unused/cdun2c08.png deleted file mode 100644 index 846033be6b..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/cdun2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/ch1n3p04.png b/third_party/stb/tests/pngsuite/unused/ch1n3p04.png deleted file mode 100644 index 17cd12dfc9..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/ch1n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/ch2n3p08.png b/third_party/stb/tests/pngsuite/unused/ch2n3p08.png deleted file mode 100644 index 25c17987a7..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/ch2n3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/cm0n0g04.png b/third_party/stb/tests/pngsuite/unused/cm0n0g04.png deleted file mode 100644 index 9fba5db3b8..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/cm0n0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/cm7n0g04.png b/third_party/stb/tests/pngsuite/unused/cm7n0g04.png deleted file mode 100644 index f7dc46e685..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/cm7n0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/cm9n0g04.png b/third_party/stb/tests/pngsuite/unused/cm9n0g04.png deleted file mode 100644 index dd70911adc..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/cm9n0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/cs3n2c16.png b/third_party/stb/tests/pngsuite/unused/cs3n2c16.png deleted file mode 100644 index bf5fd20a20..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/cs3n2c16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/cs3n3p08.png b/third_party/stb/tests/pngsuite/unused/cs3n3p08.png deleted file mode 100644 index f4a66237bf..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/cs3n3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/cs5n2c08.png b/third_party/stb/tests/pngsuite/unused/cs5n2c08.png deleted file mode 100644 index 40f947c33e..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/cs5n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/cs5n3p08.png b/third_party/stb/tests/pngsuite/unused/cs5n3p08.png deleted file mode 100644 index dfd6e6e6ec..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/cs5n3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/cs8n2c08.png b/third_party/stb/tests/pngsuite/unused/cs8n2c08.png deleted file mode 100644 index 8e01d3294f..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/cs8n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/cs8n3p08.png b/third_party/stb/tests/pngsuite/unused/cs8n3p08.png deleted file mode 100644 index a44066eb6e..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/cs8n3p08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/ct0n0g04.png b/third_party/stb/tests/pngsuite/unused/ct0n0g04.png deleted file mode 100644 index 40d1e062f8..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/ct0n0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/ct1n0g04.png b/third_party/stb/tests/pngsuite/unused/ct1n0g04.png deleted file mode 100644 index 3ba110aa76..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/ct1n0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/cten0g04.png b/third_party/stb/tests/pngsuite/unused/cten0g04.png deleted file mode 100644 index a6a56faf2b..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/cten0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/ctfn0g04.png b/third_party/stb/tests/pngsuite/unused/ctfn0g04.png deleted file mode 100644 index 353873ebbd..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/ctfn0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/ctgn0g04.png b/third_party/stb/tests/pngsuite/unused/ctgn0g04.png deleted file mode 100644 index 453f2b0a49..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/ctgn0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/cthn0g04.png b/third_party/stb/tests/pngsuite/unused/cthn0g04.png deleted file mode 100644 index 8fce253e6d..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/cthn0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/ctjn0g04.png b/third_party/stb/tests/pngsuite/unused/ctjn0g04.png deleted file mode 100644 index a77b8d2fee..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/ctjn0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/ctzn0g04.png b/third_party/stb/tests/pngsuite/unused/ctzn0g04.png deleted file mode 100644 index b4401c9cfc..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/ctzn0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/f00n0g08.png b/third_party/stb/tests/pngsuite/unused/f00n0g08.png deleted file mode 100644 index 45a0075967..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/f00n0g08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/f00n2c08.png b/third_party/stb/tests/pngsuite/unused/f00n2c08.png deleted file mode 100644 index d6a1ffff62..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/f00n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/f01n0g08.png b/third_party/stb/tests/pngsuite/unused/f01n0g08.png deleted file mode 100644 index 4a1107b463..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/f01n0g08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/f01n2c08.png b/third_party/stb/tests/pngsuite/unused/f01n2c08.png deleted file mode 100644 index 26fee958ce..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/f01n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/f02n0g08.png b/third_party/stb/tests/pngsuite/unused/f02n0g08.png deleted file mode 100644 index bfe410c5e7..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/f02n0g08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/f02n2c08.png b/third_party/stb/tests/pngsuite/unused/f02n2c08.png deleted file mode 100644 index e590f12348..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/f02n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/f03n0g08.png b/third_party/stb/tests/pngsuite/unused/f03n0g08.png deleted file mode 100644 index ed01e2923c..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/f03n0g08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/f03n2c08.png b/third_party/stb/tests/pngsuite/unused/f03n2c08.png deleted file mode 100644 index 758115059d..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/f03n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/f04n0g08.png b/third_party/stb/tests/pngsuite/unused/f04n0g08.png deleted file mode 100644 index 663fdae3e7..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/f04n0g08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/f04n2c08.png b/third_party/stb/tests/pngsuite/unused/f04n2c08.png deleted file mode 100644 index 3c8b5116e7..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/f04n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/f99n0g04.png b/third_party/stb/tests/pngsuite/unused/f99n0g04.png deleted file mode 100644 index 0b521c1d56..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/f99n0g04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/g03n0g16.png b/third_party/stb/tests/pngsuite/unused/g03n0g16.png deleted file mode 100644 index 41083ca80f..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/g03n0g16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/g03n2c08.png b/third_party/stb/tests/pngsuite/unused/g03n2c08.png deleted file mode 100644 index a9354dbee6..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/g03n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/g03n3p04.png b/third_party/stb/tests/pngsuite/unused/g03n3p04.png deleted file mode 100644 index 60396c95af..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/g03n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/g04n0g16.png b/third_party/stb/tests/pngsuite/unused/g04n0g16.png deleted file mode 100644 index 32395b76c9..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/g04n0g16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/g04n2c08.png b/third_party/stb/tests/pngsuite/unused/g04n2c08.png deleted file mode 100644 index a652b0ce87..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/g04n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/g04n3p04.png b/third_party/stb/tests/pngsuite/unused/g04n3p04.png deleted file mode 100644 index 5661cc3131..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/g04n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/g05n0g16.png b/third_party/stb/tests/pngsuite/unused/g05n0g16.png deleted file mode 100644 index 70b37f01e2..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/g05n0g16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/g05n2c08.png b/third_party/stb/tests/pngsuite/unused/g05n2c08.png deleted file mode 100644 index 932c136536..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/g05n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/g05n3p04.png b/third_party/stb/tests/pngsuite/unused/g05n3p04.png deleted file mode 100644 index 9619930585..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/g05n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/g07n0g16.png b/third_party/stb/tests/pngsuite/unused/g07n0g16.png deleted file mode 100644 index d6a47c2d57..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/g07n0g16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/g07n2c08.png b/third_party/stb/tests/pngsuite/unused/g07n2c08.png deleted file mode 100644 index 597346460f..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/g07n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/g07n3p04.png b/third_party/stb/tests/pngsuite/unused/g07n3p04.png deleted file mode 100644 index c73fb61365..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/g07n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/g10n0g16.png b/third_party/stb/tests/pngsuite/unused/g10n0g16.png deleted file mode 100644 index 85f2c958e9..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/g10n0g16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/g10n2c08.png b/third_party/stb/tests/pngsuite/unused/g10n2c08.png deleted file mode 100644 index b3039970c1..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/g10n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/g10n3p04.png b/third_party/stb/tests/pngsuite/unused/g10n3p04.png deleted file mode 100644 index 1b6a6be2ca..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/g10n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/g25n0g16.png b/third_party/stb/tests/pngsuite/unused/g25n0g16.png deleted file mode 100644 index a9f6787c7a..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/g25n0g16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/g25n2c08.png b/third_party/stb/tests/pngsuite/unused/g25n2c08.png deleted file mode 100644 index 03f505a64b..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/g25n2c08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/g25n3p04.png b/third_party/stb/tests/pngsuite/unused/g25n3p04.png deleted file mode 100644 index 4f943c6175..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/g25n3p04.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/pp0n2c16.png b/third_party/stb/tests/pngsuite/unused/pp0n2c16.png deleted file mode 100644 index 8f2aad7335..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/pp0n2c16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/pp0n6a08.png b/third_party/stb/tests/pngsuite/unused/pp0n6a08.png deleted file mode 100644 index 4ed7a30e4d..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/pp0n6a08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/ps1n0g08.png b/third_party/stb/tests/pngsuite/unused/ps1n0g08.png deleted file mode 100644 index 99625fa4ba..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/ps1n0g08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/ps1n2c16.png b/third_party/stb/tests/pngsuite/unused/ps1n2c16.png deleted file mode 100644 index 0c7a6b380e..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/ps1n2c16.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/ps2n0g08.png b/third_party/stb/tests/pngsuite/unused/ps2n0g08.png deleted file mode 100644 index 90b2979685..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/ps2n0g08.png and /dev/null differ diff --git a/third_party/stb/tests/pngsuite/unused/ps2n2c16.png b/third_party/stb/tests/pngsuite/unused/ps2n2c16.png deleted file mode 100644 index a4a181e4ec..0000000000 Binary files a/third_party/stb/tests/pngsuite/unused/ps2n2c16.png and /dev/null differ diff --git a/third_party/stb/tests/prerelease/stb_lib.h b/third_party/stb/tests/prerelease/stb_lib.h deleted file mode 100644 index 0a6eead203..0000000000 --- a/third_party/stb/tests/prerelease/stb_lib.h +++ /dev/null @@ -1,3305 +0,0 @@ -/* stb_lib.h - v1.00 - http://nothings.org/stb - no warranty is offered or implied; use this code at your own risk - - ============================================================================ - You MUST - - #define STB_LIB_IMPLEMENTATION - - in EXACTLY _one_ C or C++ file that includes this header, BEFORE the - include, like this: - - #define STB_LIB_IMPLEMENTATION - #include "stblib_files.h" - - All other files should just #include "stblib_files.h" without the #define. - ============================================================================ - -LICENSE - - See end of file for license information. - -CREDITS - - Written by Sean Barrett. - - Fixes: - Philipp Wiesemann Robert Nix - r-lyeh blackpawn - github:Mojofreem Ryan Whitworth - Vincent Isambart Mike Sartain - Eugene Opalev Tim Sjostrand - github:infatum Dave Butler -*/ - -#ifndef STB_INCLUDE_STB_LIB_H - -#include - -#if defined(_WIN32) && !defined(__MINGW32__) - #ifndef _CRT_SECURE_NO_WARNINGS - #define _CRT_SECURE_NO_WARNINGS - #endif - #ifndef _CRT_NONSTDC_NO_DEPRECATE - #define _CRT_NONSTDC_NO_DEPRECATE - #endif - #ifndef _CRT_NON_CONFORMING_SWPRINTFS - #define _CRT_NON_CONFORMING_SWPRINTFS - #endif - #if !defined(_MSC_VER) || _MSC_VER > 1700 - #include // _BitScanReverse - #endif -#endif - -#include // stdlib could have min/max -#include // need FILE -#include // stb_define_hash needs memcpy/memset -#include // stb_dirtree - -typedef unsigned char stb_uchar; -typedef unsigned char stb_uint8; -typedef unsigned int stb_uint; -typedef unsigned short stb_uint16; -typedef short stb_int16; -typedef signed char stb_int8; -#if defined(STB_USE_LONG_FOR_32_BIT_INT) || defined(STB_LONG32) - typedef unsigned long stb_uint32; - typedef long stb_int32; -#else - typedef unsigned int stb_uint32; - typedef int stb_int32; -#endif -typedef char stb__testsize2_16[sizeof(stb_uint16)==2 ? 1 : -1]; -typedef char stb__testsize2_32[sizeof(stb_uint32)==4 ? 1 : -1]; - -#ifdef _MSC_VER - typedef unsigned __int64 stb_uint64; - typedef __int64 stb_int64; - #define STB_IMM_UINT64(literalui64) (literalui64##ui64) -#else - // ?? - typedef unsigned long long stb_uint64; - typedef long long stb_int64; - #define STB_IMM_UINT64(literalui64) (literalui64##ULL) -#endif -typedef char stb__testsize2_64[sizeof(stb_uint64)==8 ? 1 : -1]; - -#ifdef __cplusplus - #define STB_EXTERN extern "C" -#else - #define STB_EXTERN extern -#endif - -// check for well-known debug defines -#if defined(DEBUG) || defined(_DEBUG) || defined(DBG) - #ifndef NDEBUG - #define STB_DEBUG - #endif -#endif - -#ifdef STB_DEBUG - #include -#endif -#endif // STB_INCLUDE_STB_LIB_H - -#ifdef STB_LIB_IMPLEMENTATION - #include - #include - #include - #include - #include - #ifndef _WIN32 - #include - #else - #include // _mktemp - #include // _rmdir - #endif - #include // stat()/_stat() - #include // stat()/_stat() -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// Miscellany -// - -#ifdef _WIN32 - #define stb_stricmp(a,b) stricmp(a,b) - #define stb_strnicmp(a,b,n) strnicmp(a,b,n) -#else - #define stb_stricmp(a,b) strcasecmp(a,b) - #define stb_strnicmp(a,b,n) strncasecmp(a,b,n) -#endif - -#ifndef STB_INCLUDE_STB_LIB_H -STB_EXTERN void stb_fatal(char *fmt, ...); -STB_EXTERN void stb_swap(void *p, void *q, size_t sz); -STB_EXTERN double stb_linear_remap(double x, double x_min, double x_max, - double out_min, double out_max); - -#define stb_arrcount(x) (sizeof(x)/sizeof((x)[0])) -#define stb_lerp(t,a,b) ( (a) + (t) * (float) ((b)-(a)) ) -#define stb_unlerp(t,a,b) ( ((t) - (a)) / (float) ((b) - (a)) ) - -#endif - - -#ifdef STB_LIB_IMPLEMENTATION -void stb_fatal(char *s, ...) -{ - va_list a; - va_start(a,s); - fputs("Fatal error: ", stderr); - vfprintf(stderr, s, a); - va_end(a); - fputs("\n", stderr); - #ifdef STB_DEBUG - #ifdef _MSC_VER - #ifndef _WIN64 - __asm int 3; // trap to debugger! - #else - __debugbreak(); - #endif - #else - __builtin_trap(); - #endif - #endif - exit(1); -} - -typedef struct { char d[4]; } stb__4; -typedef struct { char d[8]; } stb__8; - -// optimize the small cases, though you shouldn't be calling this for those! -void stb_swap(void *p, void *q, size_t sz) -{ - char buffer[256]; - if (p == q) return; - if (sz == 4) { - stb__4 temp = * ( stb__4 *) p; - * (stb__4 *) p = * ( stb__4 *) q; - * (stb__4 *) q = temp; - return; - } else if (sz == 8) { - stb__8 temp = * ( stb__8 *) p; - * (stb__8 *) p = * ( stb__8 *) q; - * (stb__8 *) q = temp; - return; - } - - while (sz > sizeof(buffer)) { - stb_swap(p, q, sizeof(buffer)); - p = (char *) p + sizeof(buffer); - q = (char *) q + sizeof(buffer); - sz -= sizeof(buffer); - } - - memcpy(buffer, p , sz); - memcpy(p , q , sz); - memcpy(q , buffer, sz); -} - -#ifdef stb_linear_remap -#undef stb_linear_remap -#endif - -double stb_linear_remap(double x, double x_min, double x_max, - double out_min, double out_max) -{ - return stb_lerp(stb_unlerp(x,x_min,x_max),out_min,out_max); -} - -#define stb_linear_remap(t,a,b,c,d) stb_lerp(stb_unlerp(t,a,b),c,d) -#endif // STB_LIB_IMPLEMENTATION - -#ifndef STB_INCLUDE_STB_LIB_H -// avoid unnecessary function call, but define function so its address can be taken -#ifndef stb_linear_remap -#define stb_linear_remap(t,a,b,c,d) stb_lerp(stb_unlerp(t,a,b),c,d) -#endif -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// cross-platform snprintf because they keep changing that, -// and with old compilers without vararg macros we can't write -// a macro wrapper to fix it up - -#ifndef STB_INCLUDE_STB_LIB_H -STB_EXTERN int stb_snprintf(char *s, size_t n, const char *fmt, ...); -STB_EXTERN int stb_vsnprintf(char *s, size_t n, const char *fmt, va_list v); -STB_EXTERN char *stb_sprintf(const char *fmt, ...); -#endif - -#ifdef STB_LIB_IMPLEMENTATION - -int stb_vsnprintf(char *s, size_t n, const char *fmt, va_list v) -{ - int res; - #ifdef _WIN32 - // Could use "_vsnprintf_s(s, n, _TRUNCATE, fmt, v)" ? - res = _vsnprintf(s,n,fmt,v); - #else - res = vsnprintf(s,n,fmt,v); - #endif - if (n) s[n-1] = 0; - // Unix returns length output would require, Windows returns negative when truncated. - return (res >= (int) n || res < 0) ? -1 : res; -} - -int stb_snprintf(char *s, size_t n, const char *fmt, ...) -{ - int res; - va_list v; - va_start(v,fmt); - res = stb_vsnprintf(s, n, fmt, v); - va_end(v); - return res; -} - -char *stb_sprintf(const char *fmt, ...) -{ - static char buffer[1024]; - va_list v; - va_start(v,fmt); - stb_vsnprintf(buffer,1024,fmt,v); - va_end(v); - return buffer; -} -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// Windows UTF8 filename handling -// -// Windows stupidly treats 8-bit filenames as some dopey code page, -// rather than utf-8. If we want to use utf8 filenames, we have to -// convert them to WCHAR explicitly and call WCHAR versions of the -// file functions. So, ok, we do. - - -#ifndef STB_INCLUDE_STB_LIB_H -#ifdef _WIN32 - #define stb__fopen(x,y) _wfopen((const wchar_t *)stb__from_utf8(x), (const wchar_t *)stb__from_utf8_alt(y)) - #define stb__windows(x,y) x -#else - #define stb__fopen(x,y) fopen(x,y) - #define stb__windows(x,y) y -#endif - - -typedef unsigned short stb__wchar; - -STB_EXTERN stb__wchar * stb_from_utf8(stb__wchar *buffer, char *str, int n); -STB_EXTERN char * stb_to_utf8 (char *buffer, stb__wchar *str, int n); - -STB_EXTERN stb__wchar *stb__from_utf8(char *str); -STB_EXTERN stb__wchar *stb__from_utf8_alt(char *str); -STB_EXTERN char *stb__to_utf8(stb__wchar *str); -#endif - -#ifdef STB_LIB_IMPLEMENTATION -stb__wchar * stb_from_utf8(stb__wchar *buffer, char *ostr, int n) -{ - unsigned char *str = (unsigned char *) ostr; - stb_uint32 c; - int i=0; - --n; - while (*str) { - if (i >= n) - return NULL; - if (!(*str & 0x80)) - buffer[i++] = *str++; - else if ((*str & 0xe0) == 0xc0) { - if (*str < 0xc2) return NULL; - c = (*str++ & 0x1f) << 6; - if ((*str & 0xc0) != 0x80) return NULL; - buffer[i++] = c + (*str++ & 0x3f); - } else if ((*str & 0xf0) == 0xe0) { - if (*str == 0xe0 && (str[1] < 0xa0 || str[1] > 0xbf)) return NULL; - if (*str == 0xed && str[1] > 0x9f) return NULL; // str[1] < 0x80 is checked below - c = (*str++ & 0x0f) << 12; - if ((*str & 0xc0) != 0x80) return NULL; - c += (*str++ & 0x3f) << 6; - if ((*str & 0xc0) != 0x80) return NULL; - buffer[i++] = c + (*str++ & 0x3f); - } else if ((*str & 0xf8) == 0xf0) { - if (*str > 0xf4) return NULL; - if (*str == 0xf0 && (str[1] < 0x90 || str[1] > 0xbf)) return NULL; - if (*str == 0xf4 && str[1] > 0x8f) return NULL; // str[1] < 0x80 is checked below - c = (*str++ & 0x07) << 18; - if ((*str & 0xc0) != 0x80) return NULL; - c += (*str++ & 0x3f) << 12; - if ((*str & 0xc0) != 0x80) return NULL; - c += (*str++ & 0x3f) << 6; - if ((*str & 0xc0) != 0x80) return NULL; - c += (*str++ & 0x3f); - // utf-8 encodings of values used in surrogate pairs are invalid - if ((c & 0xFFFFF800) == 0xD800) return NULL; - if (c >= 0x10000) { - c -= 0x10000; - if (i + 2 > n) return NULL; - buffer[i++] = 0xD800 | (0x3ff & (c >> 10)); - buffer[i++] = 0xDC00 | (0x3ff & (c )); - } - } else - return NULL; - } - buffer[i] = 0; - return buffer; -} - -char * stb_to_utf8(char *buffer, stb__wchar *str, int n) -{ - int i=0; - --n; - while (*str) { - if (*str < 0x80) { - if (i+1 > n) return NULL; - buffer[i++] = (char) *str++; - } else if (*str < 0x800) { - if (i+2 > n) return NULL; - buffer[i++] = 0xc0 + (*str >> 6); - buffer[i++] = 0x80 + (*str & 0x3f); - str += 1; - } else if (*str >= 0xd800 && *str < 0xdc00) { - stb_uint32 c; - if (i+4 > n) return NULL; - c = ((str[0] - 0xd800) << 10) + ((str[1]) - 0xdc00) + 0x10000; - buffer[i++] = 0xf0 + (c >> 18); - buffer[i++] = 0x80 + ((c >> 12) & 0x3f); - buffer[i++] = 0x80 + ((c >> 6) & 0x3f); - buffer[i++] = 0x80 + ((c ) & 0x3f); - str += 2; - } else if (*str >= 0xdc00 && *str < 0xe000) { - return NULL; - } else { - if (i+3 > n) return NULL; - buffer[i++] = 0xe0 + (*str >> 12); - buffer[i++] = 0x80 + ((*str >> 6) & 0x3f); - buffer[i++] = 0x80 + ((*str ) & 0x3f); - str += 1; - } - } - buffer[i] = 0; - return buffer; -} - -stb__wchar *stb__from_utf8(char *str) -{ - static stb__wchar buffer[4096]; - return stb_from_utf8(buffer, str, 4096); -} - -stb__wchar *stb__from_utf8_alt(char *str) -{ - static stb__wchar buffer[4096]; - return stb_from_utf8(buffer, str, 4096); -} - -char *stb__to_utf8(stb__wchar *str) -{ - static char buffer[4096]; - return stb_to_utf8(buffer, str, 4096); -} -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// qsort Compare Routines -// NOT THREAD SAFE - -#ifndef STB_INCLUDE_STB_LIB_H -STB_EXTERN int (*stb_intcmp(int offset))(const void *a, const void *b); -STB_EXTERN int (*stb_qsort_strcmp(int offset))(const void *a, const void *b); -STB_EXTERN int (*stb_qsort_stricmp(int offset))(const void *a, const void *b); -STB_EXTERN int (*stb_floatcmp(int offset))(const void *a, const void *b); -STB_EXTERN int (*stb_doublecmp(int offset))(const void *a, const void *b); -STB_EXTERN int (*stb_ucharcmp(int offset))(const void *a, const void *b); -STB_EXTERN int (*stb_charcmp(int offset))(const void *a, const void *b); -#endif - -#ifdef STB_LIB_IMPLEMENTATION -static int stb__intcmpoffset, stb__ucharcmpoffset, stb__strcmpoffset; -static int stb__floatcmpoffset, stb__doublecmpoffset, stb__charcmpoffset; - -int stb__intcmp(const void *a, const void *b) -{ - const int p = *(const int *) ((const char *) a + stb__intcmpoffset); - const int q = *(const int *) ((const char *) b + stb__intcmpoffset); - return p < q ? -1 : p > q; -} - -int stb__ucharcmp(const void *a, const void *b) -{ - const int p = *(const unsigned char *) ((const char *) a + stb__ucharcmpoffset); - const int q = *(const unsigned char *) ((const char *) b + stb__ucharcmpoffset); - return p < q ? -1 : p > q; -} - -int stb__charcmp(const void *a, const void *b) -{ - const int p = *(const char *) ((const char *) a + stb__ucharcmpoffset); - const int q = *(const char *) ((const char *) b + stb__ucharcmpoffset); - return p < q ? -1 : p > q; -} - -int stb__floatcmp(const void *a, const void *b) -{ - const float p = *(const float *) ((const char *) a + stb__floatcmpoffset); - const float q = *(const float *) ((const char *) b + stb__floatcmpoffset); - return p < q ? -1 : p > q; -} - -int stb__doublecmp(const void *a, const void *b) -{ - const double p = *(const double *) ((const char *) a + stb__doublecmpoffset); - const double q = *(const double *) ((const char *) b + stb__doublecmpoffset); - return p < q ? -1 : p > q; -} - -int stb__qsort_strcmp(const void *a, const void *b) -{ - const char *p = *(const char **) ((const char *) a + stb__strcmpoffset); - const char *q = *(const char **) ((const char *) b + stb__strcmpoffset); - return strcmp(p,q); -} - -int stb__qsort_stricmp(const void *a, const void *b) -{ - const char *p = *(const char **) ((const char *) a + stb__strcmpoffset); - const char *q = *(const char **) ((const char *) b + stb__strcmpoffset); - return stb_stricmp(p,q); -} - -int (*stb_intcmp(int offset))(const void *, const void *) -{ - stb__intcmpoffset = offset; - return &stb__intcmp; -} - -int (*stb_ucharcmp(int offset))(const void *, const void *) -{ - stb__ucharcmpoffset = offset; - return &stb__ucharcmp; -} - -int (*stb_charcmp(int offset))(const void *, const void *) -{ - stb__charcmpoffset = offset; - return &stb__ucharcmp; -} - -int (*stb_qsort_strcmp(int offset))(const void *, const void *) -{ - stb__strcmpoffset = offset; - return &stb__qsort_strcmp; -} - -int (*stb_qsort_stricmp(int offset))(const void *, const void *) -{ - stb__strcmpoffset = offset; - return &stb__qsort_stricmp; -} - -int (*stb_floatcmp(int offset))(const void *, const void *) -{ - stb__floatcmpoffset = offset; - return &stb__floatcmp; -} - -int (*stb_doublecmp(int offset))(const void *, const void *) -{ - stb__doublecmpoffset = offset; - return &stb__doublecmp; -} -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// String Processing -// - -#ifndef STB_INCLUDE_STB_LIB_H -#define stb_prefixi(s,t) (0==stb_strnicmp((s),(t),strlen(t))) - -enum stb_splitpath_flag -{ - STB_PATH = 1, - STB_FILE = 2, - STB_EXT = 4, - STB_PATH_FILE = STB_PATH + STB_FILE, - STB_FILE_EXT = STB_FILE + STB_EXT, - STB_EXT_NO_PERIOD = 8, -}; - -STB_EXTERN char * stb_skipwhite(char *s); -STB_EXTERN char * stb_trimwhite(char *s); -STB_EXTERN char * stb_skipnewline(char *s); -STB_EXTERN char * stb_strncpy(char *s, char *t, int n); -STB_EXTERN char * stb_substr(char *t, int n); -STB_EXTERN char * stb_duplower(char *s); -STB_EXTERN void stb_tolower (char *s); -STB_EXTERN char * stb_strchr2 (char *s, char p1, char p2); -STB_EXTERN char * stb_strrchr2(char *s, char p1, char p2); -STB_EXTERN char * stb_strtok(char *output, char *src, char *delimit); -STB_EXTERN char * stb_strtok_keep(char *output, char *src, char *delimit); -STB_EXTERN char * stb_strtok_invert(char *output, char *src, char *allowed); -STB_EXTERN char * stb_dupreplace(char *s, char *find, char *replace); -STB_EXTERN void stb_replaceinplace(char *s, char *find, char *replace); -STB_EXTERN char * stb_splitpath(char *output, char *src, int flag); -STB_EXTERN char * stb_splitpathdup(char *src, int flag); -STB_EXTERN char * stb_replacedir(char *output, char *src, char *dir); -STB_EXTERN char * stb_replaceext(char *output, char *src, char *ext); -STB_EXTERN void stb_fixpath(char *path); -STB_EXTERN char * stb_shorten_path_readable(char *path, int max_len); -STB_EXTERN int stb_suffix (char *s, char *t); -STB_EXTERN int stb_suffixi(char *s, char *t); -STB_EXTERN int stb_prefix (char *s, char *t); -STB_EXTERN char * stb_strichr(char *s, char t); -STB_EXTERN char * stb_stristr(char *s, char *t); -STB_EXTERN int stb_prefix_count(char *s, char *t); -STB_EXTERN const char * stb_plural(int n); // "s" or "" -STB_EXTERN size_t stb_strscpy(char *d, const char *s, size_t n); - -STB_EXTERN char **stb_tokens(char *src, char *delimit, int *count); -STB_EXTERN char **stb_tokens_nested(char *src, char *delimit, int *count, char *nest_in, char *nest_out); -STB_EXTERN char **stb_tokens_nested_empty(char *src, char *delimit, int *count, char *nest_in, char *nest_out); -STB_EXTERN char **stb_tokens_allowempty(char *src, char *delimit, int *count); -STB_EXTERN char **stb_tokens_stripwhite(char *src, char *delimit, int *count); -STB_EXTERN char **stb_tokens_withdelim(char *src, char *delimit, int *count); -STB_EXTERN char **stb_tokens_quoted(char *src, char *delimit, int *count); -// with 'quoted', allow delimiters to appear inside quotation marks, and don't -// strip whitespace inside them (and we delete the quotation marks unless they -// appear back to back, in which case they're considered escaped) -#endif // STB_INCLUDE_STB_LIB_H - -#ifdef STB_LIB_IMPLEMENTATION -#include - -size_t stb_strscpy(char *d, const char *s, size_t n) -{ - size_t len = strlen(s); - if (len >= n) { - if (n) d[0] = 0; - return 0; - } - strcpy(d,s); - return len + 1; -} - -const char *stb_plural(int n) -{ - return n == 1 ? "" : "s"; -} - -int stb_prefix(char *s, char *t) -{ - while (*t) - if (*s++ != *t++) - return 0; - return 1; -} - -int stb_prefix_count(char *s, char *t) -{ - int c=0; - while (*t) { - if (*s++ != *t++) - break; - ++c; - } - return c; -} - -int stb_suffix(char *s, char *t) -{ - size_t n = strlen(s); - size_t m = strlen(t); - if (m <= n) - return 0 == strcmp(s+n-m, t); - else - return 0; -} - -int stb_suffixi(char *s, char *t) -{ - size_t n = strlen(s); - size_t m = strlen(t); - if (m <= n) - return 0 == stb_stricmp(s+n-m, t); - else - return 0; -} - -// originally I was using this table so that I could create known sentinel -// values--e.g. change whitetable[0] to be true if I was scanning for whitespace, -// and false if I was scanning for nonwhite. I don't appear to be using that -// functionality anymore (I do for tokentable, though), so just replace it -// with isspace() -char *stb_skipwhite(char *s) -{ - while (isspace((unsigned char) *s)) ++s; - return s; -} - -char *stb_skipnewline(char *s) -{ - if (s[0] == '\r' || s[0] == '\n') { - if (s[0]+s[1] == '\r' + '\n') ++s; - ++s; - } - return s; -} - -char *stb_trimwhite(char *s) -{ - int i,n; - s = stb_skipwhite(s); - n = (int) strlen(s); - for (i=n-1; i >= 0; --i) - if (!isspace(s[i])) - break; - s[i+1] = 0; - return s; -} - -char *stb_strncpy(char *s, char *t, int n) -{ - strncpy(s,t,n); - s[n-1] = 0; - return s; -} - -char *stb_substr(char *t, int n) -{ - char *a; - int z = (int) strlen(t); - if (z < n) n = z; - a = (char *) malloc(n+1); - strncpy(a,t,n); - a[n] = 0; - return a; -} - -char *stb_duplower(char *s) -{ - char *p = strdup(s), *q = p; - while (*q) { - *q = tolower(*q); - ++q; - } - return p; -} - -void stb_tolower(char *s) -{ - while (*s) { - *s = tolower(*s); - ++s; - } -} - -char *stb_strchr2(char *s, char x, char y) -{ - for(; *s; ++s) - if (*s == x || *s == y) - return s; - return NULL; -} - -char *stb_strrchr2(char *s, char x, char y) -{ - char *r = NULL; - for(; *s; ++s) - if (*s == x || *s == y) - r = s; - return r; -} - -char *stb_strichr(char *s, char t) -{ - if (tolower(t) == toupper(t)) - return strchr(s,t); - return stb_strchr2(s, (char) tolower(t), (char) toupper(t)); -} - -char *stb_stristr(char *s, char *t) -{ - size_t n = strlen(t); - char *z; - if (n==0) return s; - while ((z = stb_strichr(s, *t)) != NULL) { - if (0==stb_strnicmp(z, t, n)) - return z; - s = z+1; - } - return NULL; -} - -static char *stb_strtok_raw(char *output, char *src, char *delimit, int keep, int invert) -{ - if (invert) { - while (*src && strchr(delimit, *src) != NULL) { - *output++ = *src++; - } - } else { - while (*src && strchr(delimit, *src) == NULL) { - *output++ = *src++; - } - } - *output = 0; - if (keep) - return src; - else - return *src ? src+1 : src; -} - -char *stb_strtok(char *output, char *src, char *delimit) -{ - return stb_strtok_raw(output, src, delimit, 0, 0); -} - -char *stb_strtok_keep(char *output, char *src, char *delimit) -{ - return stb_strtok_raw(output, src, delimit, 1, 0); -} - -char *stb_strtok_invert(char *output, char *src, char *delimit) -{ - return stb_strtok_raw(output, src, delimit, 1,1); -} - -static char **stb_tokens_raw(char *src_, char *delimit, int *count, - int stripwhite, int allow_empty, char *start, char *end) -{ - int nested = 0; - unsigned char *src = (unsigned char *) src_; - static char stb_tokentable[256]; // rely on static initializion to 0 - static char stable[256],etable[256]; - char *out; - char **result; - int num=0; - unsigned char *s; - - s = (unsigned char *) delimit; while (*s) stb_tokentable[*s++] = 1; - if (start) { - s = (unsigned char *) start; while (*s) stable[*s++] = 1; - s = (unsigned char *) end; if (s) while (*s) stable[*s++] = 1; - s = (unsigned char *) end; if (s) while (*s) etable[*s++] = 1; - } - stable[0] = 1; - - // two passes through: the first time, counting how many - s = (unsigned char *) src; - while (*s) { - // state: just found delimiter - // skip further delimiters - if (!allow_empty) { - stb_tokentable[0] = 0; - while (stb_tokentable[*s]) - ++s; - if (!*s) break; - } - ++num; - // skip further non-delimiters - stb_tokentable[0] = 1; - if (stripwhite == 2) { // quoted strings - while (!stb_tokentable[*s]) { - if (*s != '"') - ++s; - else { - ++s; - if (*s == '"') - ++s; // "" -> ", not start a string - else { - // begin a string - while (*s) { - if (s[0] == '"') { - if (s[1] == '"') s += 2; // "" -> " - else { ++s; break; } // terminating " - } else - ++s; - } - } - } - } - } else - while (nested || !stb_tokentable[*s]) { - if (stable[*s]) { - if (!*s) break; - if (end ? etable[*s] : nested) - --nested; - else - ++nested; - } - ++s; - } - if (allow_empty) { - if (*s) ++s; - } - } - // now num has the actual count... malloc our output structure - // need space for all the strings: strings won't be any longer than - // original input, since for every '\0' there's at least one delimiter - result = (char **) malloc(sizeof(*result) * (num+1) + (s-src+1)); - if (result == NULL) return result; - out = (char *) (result + (num+1)); - // second pass: copy out the data - s = (unsigned char *) src; - num = 0; - nested = 0; - while (*s) { - char *last_nonwhite; - // state: just found delimiter - // skip further delimiters - if (!allow_empty) { - stb_tokentable[0] = 0; - if (stripwhite) - while (stb_tokentable[*s] || isspace(*s)) - ++s; - else - while (stb_tokentable[*s]) - ++s; - } else if (stripwhite) { - while (isspace(*s)) ++s; - } - if (!*s) break; - // we're past any leading delimiters and whitespace - result[num] = out; - ++num; - // copy non-delimiters - stb_tokentable[0] = 1; - last_nonwhite = out-1; - if (stripwhite == 2) { - while (!stb_tokentable[*s]) { - if (*s != '"') { - if (!isspace(*s)) last_nonwhite = out; - *out++ = *s++; - } else { - ++s; - if (*s == '"') { - if (!isspace(*s)) last_nonwhite = out; - *out++ = *s++; // "" -> ", not start string - } else { - // begin a quoted string - while (*s) { - if (s[0] == '"') { - if (s[1] == '"') { *out++ = *s; s += 2; } - else { ++s; break; } // terminating " - } else - *out++ = *s++; - } - last_nonwhite = out-1; // all in quotes counts as non-white - } - } - } - } else { - while (nested || !stb_tokentable[*s]) { - if (!isspace(*s)) last_nonwhite = out; - if (stable[*s]) { - if (!*s) break; - if (end ? etable[*s] : nested) - --nested; - else - ++nested; - } - *out++ = *s++; - } - } - - if (stripwhite) // rewind to last non-whitespace char - out = last_nonwhite+1; - *out++ = '\0'; - - if (*s) ++s; // skip delimiter - } - s = (unsigned char *) delimit; while (*s) stb_tokentable[*s++] = 0; - if (start) { - s = (unsigned char *) start; while (*s) stable[*s++] = 1; - s = (unsigned char *) end; if (s) while (*s) stable[*s++] = 1; - s = (unsigned char *) end; if (s) while (*s) etable[*s++] = 1; - } - if (count != NULL) *count = num; - result[num] = 0; - return result; -} - -char **stb_tokens(char *src, char *delimit, int *count) -{ - return stb_tokens_raw(src,delimit,count,0,0,0,0); -} - -char **stb_tokens_nested(char *src, char *delimit, int *count, char *nest_in, char *nest_out) -{ - return stb_tokens_raw(src,delimit,count,0,0,nest_in,nest_out); -} - -char **stb_tokens_nested_empty(char *src, char *delimit, int *count, char *nest_in, char *nest_out) -{ - return stb_tokens_raw(src,delimit,count,0,1,nest_in,nest_out); -} - -char **stb_tokens_allowempty(char *src, char *delimit, int *count) -{ - return stb_tokens_raw(src,delimit,count,0,1,0,0); -} - -char **stb_tokens_stripwhite(char *src, char *delimit, int *count) -{ - return stb_tokens_raw(src,delimit,count,1,1,0,0); -} - -char **stb_tokens_quoted(char *src, char *delimit, int *count) -{ - return stb_tokens_raw(src,delimit,count,2,1,0,0); -} - -char *stb_dupreplace(char *src, char *find, char *replace) -{ - size_t len_find = strlen(find); - size_t len_replace = strlen(replace); - int count = 0; - - char *s,*p,*q; - - s = strstr(src, find); - if (s == NULL) return strdup(src); - do { - ++count; - s = strstr(s + len_find, find); - } while (s != NULL); - - p = (char *) malloc(strlen(src) + count * (len_replace - len_find) + 1); - if (p == NULL) return p; - q = p; - s = src; - for (;;) { - char *t = strstr(s, find); - if (t == NULL) { - strcpy(q,s); - assert(strlen(p) == strlen(src) + count*(len_replace-len_find)); - return p; - } - memcpy(q, s, t-s); - q += t-s; - memcpy(q, replace, len_replace); - q += len_replace; - s = t + len_find; - } -} - -void stb_replaceinplace(char *src, char *find, char *replace) -{ - size_t len_find = strlen(find); - size_t len_replace = strlen(replace); - int delta; - - char *s,*p,*q; - - delta = len_replace - len_find; - assert(delta <= 0); - if (delta > 0) return; - - p = strstr(src, find); - if (p == NULL) return; - - s = q = p; - while (*s) { - memcpy(q, replace, len_replace); - p += len_find; - q += len_replace; - s = strstr(p, find); - if (s == NULL) s = p + strlen(p); - memmove(q, p, s-p); - q += s-p; - p = s; - } - *q = 0; -} - -void stb_fixpath(char *path) -{ - for(; *path; ++path) - if (*path == '\\') - *path = '/'; -} - -void stb__add_section(char *buffer, char *data, int curlen, int newlen) -{ - if (newlen < curlen) { - int z1 = newlen >> 1, z2 = newlen-z1; - memcpy(buffer, data, z1-1); - buffer[z1-1] = '.'; - buffer[z1-0] = '.'; - memcpy(buffer+z1+1, data+curlen-z2+1, z2-1); - } else - memcpy(buffer, data, curlen); -} - -char * stb_shorten_path_readable(char *path, int len) -{ - static char buffer[1024]; - int n = strlen(path),n1,n2,r1,r2; - char *s; - if (n <= len) return path; - if (len > 1024) return path; - s = stb_strrchr2(path, '/', '\\'); - if (s) { - n1 = s - path + 1; - n2 = n - n1; - ++s; - } else { - n1 = 0; - n2 = n; - s = path; - } - // now we need to reduce r1 and r2 so that they fit in len - if (n1 < len>>1) { - r1 = n1; - r2 = len - r1; - } else if (n2 < len >> 1) { - r2 = n2; - r1 = len - r2; - } else { - r1 = n1 * len / n; - r2 = n2 * len / n; - if (r1 < len>>2) r1 = len>>2, r2 = len-r1; - if (r2 < len>>2) r2 = len>>2, r1 = len-r2; - } - assert(r1 <= n1 && r2 <= n2); - if (n1) - stb__add_section(buffer, path, n1, r1); - stb__add_section(buffer+r1, s, n2, r2); - buffer[len] = 0; - return buffer; -} - -static char *stb__splitpath_raw(char *buffer, char *path, int flag) -{ - int len=0,x,y, n = (int) strlen(path), f1,f2; - char *s = stb_strrchr2(path, '/', '\\'); - char *t = strrchr(path, '.'); - if (s && t && t < s) t = NULL; - if (s) ++s; - - if (flag == STB_EXT_NO_PERIOD) - flag |= STB_EXT; - - if (!(flag & (STB_PATH | STB_FILE | STB_EXT))) return NULL; - - f1 = s == NULL ? 0 : s-path; // start of filename - f2 = t == NULL ? n : t-path; // just past end of filename - - if (flag & STB_PATH) { - x = 0; if (f1 == 0 && flag == STB_PATH) len=2; - } else if (flag & STB_FILE) { - x = f1; - } else { - x = f2; - if (flag & STB_EXT_NO_PERIOD) - if (buffer[x] == '.') - ++x; - } - - if (flag & STB_EXT) - y = n; - else if (flag & STB_FILE) - y = f2; - else - y = f1; - - if (buffer == NULL) { - buffer = (char *) malloc(y-x + len + 1); - if (!buffer) return NULL; - } - - if (len) { strcpy(buffer, "./"); return buffer; } - strncpy(buffer, path+x, y-x); - buffer[y-x] = 0; - return buffer; -} - -char *stb_splitpath(char *output, char *src, int flag) -{ - return stb__splitpath_raw(output, src, flag); -} - -char *stb_splitpathdup(char *src, int flag) -{ - return stb__splitpath_raw(NULL, src, flag); -} - -char *stb_replacedir(char *output, char *src, char *dir) -{ - char buffer[4096]; - stb_splitpath(buffer, src, STB_FILE | STB_EXT); - if (dir) - sprintf(output, "%s/%s", dir, buffer); - else - strcpy(output, buffer); - return output; -} - -char *stb_replaceext(char *output, char *src, char *ext) -{ - char buffer[4096]; - stb_splitpath(buffer, src, STB_PATH | STB_FILE); - if (ext) - sprintf(output, "%s.%s", buffer, ext[0] == '.' ? ext+1 : ext); - else - strcpy(output, buffer); - return output; -} -#endif - - -////////////////////////////////////////////////////////////////////////////// -// -// stb_arr -// -// An stb_arr is directly useable as a pointer (use the actual type in your -// definition), but when it resizes, it returns a new pointer and you can't -// use the old one, so you have to be careful to copy-in-out as necessary. -// -// Use a NULL pointer as a 0-length array. -// -// float *my_array = NULL, *temp; -// -// // add elements on the end one at a time -// stb_arr_push(my_array, 0.0f); -// stb_arr_push(my_array, 1.0f); -// stb_arr_push(my_array, 2.0f); -// -// assert(my_array[1] == 2.0f); -// -// // add an uninitialized element at the end, then assign it -// *stb_arr_add(my_array) = 3.0f; -// -// // add three uninitialized elements at the end -// temp = stb_arr_addn(my_array,3); -// temp[0] = 4.0f; -// temp[1] = 5.0f; -// temp[2] = 6.0f; -// -// assert(my_array[5] == 5.0f); -// -// // remove the last one -// stb_arr_pop(my_array); -// -// assert(stb_arr_len(my_array) == 6); - - -#ifndef STB_INCLUDE_STB_LIB_H - -// simple functions written on top of other functions -#define stb_arr_empty(a) ( stb_arr_len(a) == 0 ) -#define stb_arr_add(a) ( stb_arr_addn((a),1) ) -#define stb_arr_push(a,v) ( *stb_arr_add(a)=(v) ) - -typedef struct -{ - int len, limit; - unsigned int signature; - unsigned int padding; // make it a multiple of 16 so preserve alignment mod 16 -} stb__arr; - -#define stb_arr_signature 0x51bada7b // ends with 0123 in decimal - -// access the header block stored before the data -#define stb_arrhead(a) /*lint --e(826)*/ (((stb__arr *) (a)) - 1) -#define stb_arrhead2(a) /*lint --e(826)*/ (((stb__arr *) (a)) - 1) - -#ifdef STB_DEBUG -#define stb_arr_check(a) assert(!a || stb_arrhead(a)->signature == stb_arr_signature) -#define stb_arr_check2(a) assert(!a || stb_arrhead2(a)->signature == stb_arr_signature) -#else -#define stb_arr_check(a) ((void) 0) -#define stb_arr_check2(a) ((void) 0) -#endif - -// ARRAY LENGTH - -// get the array length; special case if pointer is NULL -#define stb_arr_len(a) (a ? stb_arrhead(a)->len : 0) -#define stb_arr_len2(a) ((stb__arr *) (a) ? stb_arrhead2(a)->len : 0) -#define stb_arr_lastn(a) (stb_arr_len(a)-1) - -// check whether a given index is valid -- tests 0 <= i < stb_arr_len(a) -#define stb_arr_valid(a,i) (a ? (int) (i) < stb_arrhead(a)->len : 0) - -// change the array length so is is exactly N entries long, creating -// uninitialized entries as needed -#define stb_arr_setlen(a,n) \ - (stb__arr_setlen((void **) &(a), sizeof(a[0]), (n))) - -// change the array length so that N is a valid index (that is, so -// it is at least N entries long), creating uninitialized entries as needed -#define stb_arr_makevalid(a,n) \ - (stb_arr_len(a) < (n)+1 ? stb_arr_setlen(a,(n)+1),(a) : (a)) - -// remove the last element of the array, returning it -#define stb_arr_pop(a) ((stb_arr_check(a), (a))[--stb_arrhead(a)->len]) - -// access the last element in the array -#define stb_arr_last(a) ((stb_arr_check(a), (a))[stb_arr_len(a)-1]) - -// is iterator at end of list? -#define stb_arr_end(a,i) ((i) >= &(a)[stb_arr_len(a)]) - -// (internal) change the allocated length of the array -#define stb_arr__grow(a,n) (stb_arr_check(a), stb_arrhead(a)->len += (n)) - -// add N new uninitialized elements to the end of the array -#define stb_arr__addn(a,n) /*lint --e(826)*/ \ - ((stb_arr_len(a)+(n) > stb_arrcurmax(a)) \ - ? (stb__arr_addlen((void **) &(a),sizeof(*a),(n)),0) \ - : ((stb_arr__grow(a,n), 0))) - -// add N new uninitialized elements to the end of the array, and return -// a pointer to the first new one -#define stb_arr_addn(a,n) (stb_arr__addn((a),n),(a)+stb_arr_len(a)-(n)) - -// add N new uninitialized elements starting at index 'i' -#define stb_arr_insertn(a,i,n) (stb__arr_insertn((void **) &(a), sizeof(*a), i, n)) - -// insert an element at i -#define stb_arr_insert(a,i,v) (stb__arr_insertn((void **) &(a), sizeof(*a), i, 1), ((a)[i] = v)) - -// delete N elements from the middle starting at index 'i' -#define stb_arr_deleten(a,i,n) (stb__arr_deleten((void **) &(a), sizeof(*a), i, n)) - -// delete the i'th element -#define stb_arr_delete(a,i) stb_arr_deleten(a,i,1) - -// delete the i'th element, swapping down from the end -#define stb_arr_fastdelete(a,i) \ - (stb_swap(&a[i], &a[stb_arrhead(a)->len-1], sizeof(*a)), stb_arr_pop(a)) - - -// ARRAY STORAGE - -// get the array maximum storage; special case if NULL -#define stb_arrcurmax(a) (a ? stb_arrhead(a)->limit : 0) -#define stb_arrcurmax2(a) (a ? stb_arrhead2(a)->limit : 0) - -// set the maxlength of the array to n in anticipation of further growth -#define stb_arr_setsize(a,n) (stb_arr_check(a), stb__arr_setsize((void **) &(a),sizeof((a)[0]),n)) - -// make sure maxlength is large enough for at least N new allocations -#define stb_arr_atleast(a,n) (stb_arr_len(a)+(n) > stb_arrcurmax(a) \ - ? stb_arr_setsize((a), (n)) : 0) - -// make a copy of a given array (copies contents via 'memcpy'!) -#define stb_arr_copy(a) stb__arr_copy(a, sizeof((a)[0])) - -// compute the storage needed to store all the elements of the array -#define stb_arr_storage(a) (stb_arr_len(a) * sizeof((a)[0])) - -#define stb_arr_for(v,arr) for((v)=(arr); (v) < (arr)+stb_arr_len(arr); ++(v)) - -// IMPLEMENTATION - -STB_EXTERN void stb_arr_free_(void **p); -STB_EXTERN void *stb__arr_copy_(void *p, int elem_size); -STB_EXTERN void stb__arr_setsize_(void **p, int size, int limit); -STB_EXTERN void stb__arr_setlen_(void **p, int size, int newlen); -STB_EXTERN void stb__arr_addlen_(void **p, int size, int addlen); -STB_EXTERN void stb__arr_deleten_(void **p, int size, int loc, int n); -STB_EXTERN void stb__arr_insertn_(void **p, int size, int loc, int n); - -#define stb_arr_free(p) stb_arr_free_((void **) &(p)) - -#ifndef STBLIB_MALLOC_WRAPPER // @Todo - #define stb__arr_setsize stb__arr_setsize_ - #define stb__arr_setlen stb__arr_setlen_ - #define stb__arr_addlen stb__arr_addlen_ - #define stb__arr_deleten stb__arr_deleten_ - #define stb__arr_insertn stb__arr_insertn_ - #define stb__arr_copy stb__arr_copy_ -#else - #define stb__arr_addlen(p,s,n) stb__arr_addlen_(p,s,n,__FILE__,__LINE__) - #define stb__arr_setlen(p,s,n) stb__arr_setlen_(p,s,n,__FILE__,__LINE__) - #define stb__arr_setsize(p,s,n) stb__arr_setsize_(p,s,n,__FILE__,__LINE__) - #define stb__arr_deleten(p,s,i,n) stb__arr_deleten_(p,s,i,n,__FILE__,__LINE__) - #define stb__arr_insertn(p,s,i,n) stb__arr_insertn_(p,s,i,n,__FILE__,__LINE__) - #define stb__arr_copy(p,s) stb__arr_copy_(p,s,__FILE__,__LINE__) -#endif -#endif // STB_INCLUDE_STB_LIB_H - -#ifdef STB_LIB_IMPLEMENTATION -void stb_arr_malloc(void **target, void *context) -{ - stb__arr *q = (stb__arr *) malloc(sizeof(*q)); - q->len = q->limit = 0; - q->signature = stb_arr_signature; - *target = (void *) (q+1); -} - -static void * stb__arr_malloc(int size) -{ - return malloc(size); -} - -void * stb__arr_copy_(void *p, int elem_size) -{ - stb__arr *q; - if (p == NULL) return p; - q = (stb__arr *) malloc(sizeof(*q) + elem_size * stb_arrhead2(p)->limit); - stb_arr_check2(p); - memcpy(q, stb_arrhead2(p), sizeof(*q) + elem_size * stb_arrhead2(p)->len); - return q+1; -} - -void stb_arr_free_(void **pp) -{ - void *p = *pp; - stb_arr_check2(p); - if (p) { - stb__arr *q = stb_arrhead2(p); - free(q); - } - *pp = NULL; -} - -static void stb__arrsize_(void **pp, int size, int limit, int len) -{ - void *p = *pp; - stb__arr *a; - stb_arr_check2(p); - if (p == NULL) { - if (len == 0 && size == 0) return; - a = (stb__arr *) stb__arr_malloc(sizeof(*a) + size*limit); - a->limit = limit; - a->len = len; - a->signature = stb_arr_signature; - } else { - a = stb_arrhead2(p); - a->len = len; - if (a->limit < limit) { - void *p; - if (a->limit >= 4 && limit < a->limit * 2) - limit = a->limit * 2; - p = realloc(a, sizeof(*a) + limit*size); - if (p) { - a = (stb__arr *) p; - a->limit = limit; - } else { - // throw an error! - } - } - } - a->len = a->len < a->limit ? a->len : a->limit; - *pp = a+1; -} - -void stb__arr_setsize_(void **pp, int size, int limit) -{ - void *p = *pp; - stb_arr_check2(p); - stb__arrsize_(pp, size, limit, stb_arr_len2(p)); -} - -void stb__arr_setlen_(void **pp, int size, int newlen) -{ - void *p = *pp; - stb_arr_check2(p); - if (stb_arrcurmax2(p) < newlen || p == NULL) { - stb__arrsize_(pp, size, newlen, newlen); - } else { - stb_arrhead2(p)->len = newlen; - } -} - -void stb__arr_addlen_(void **p, int size, int addlen) -{ - stb__arr_setlen_(p, size, stb_arr_len2(*p) + addlen); -} - -void stb__arr_insertn_(void **pp, int size, int i, int n) -{ - void *p = *pp; - if (n) { - int z; - - if (p == NULL) { - stb__arr_addlen_(pp, size, n); - return; - } - - z = stb_arr_len2(p); - stb__arr_addlen_(&p, size, n); - memmove((char *) p + (i+n)*size, (char *) p + i*size, size * (z-i)); - } - *pp = p; -} - -void stb__arr_deleten_(void **pp, int size, int i, int n) -{ - void *p = *pp; - if (n) { - memmove((char *) p + i*size, (char *) p + (i+n)*size, size * (stb_arr_len2(p)-(i+n))); - stb_arrhead2(p)->len -= n; - } - *pp = p; -} -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// Hashing -// -// typical use for this is to make a power-of-two hash table. -// -// let N = size of table (2^n) -// let H = stb_hash(str) -// let S = stb_rehash(H) | 1 -// -// then hash probe sequence P(i) for i=0..N-1 -// P(i) = (H + S*i) & (N-1) -// -// the idea is that H has 32 bits of hash information, but the -// table has only, say, 2^20 entries so only uses 20 of the bits. -// then by rehashing the original H we get 2^12 different probe -// sequences for a given initial probe location. (So it's optimal -// for 64K tables and its optimality decreases past that.) -// -// ok, so I've added something that generates _two separate_ -// 32-bit hashes simultaneously which should scale better to -// very large tables. - -#ifndef STB_INCLUDE_STB_LIB_H -STB_EXTERN unsigned int stb_hash(char *str); -STB_EXTERN unsigned int stb_hashptr(void *p); -STB_EXTERN unsigned int stb_hashlen(char *str, int len); -STB_EXTERN unsigned int stb_rehash_improved(unsigned int v); -STB_EXTERN unsigned int stb_hash_fast(void *p, int len); -STB_EXTERN unsigned int stb_hash2(char *str, unsigned int *hash2_ptr); -STB_EXTERN unsigned int stb_hash_number(unsigned int hash); - -#define stb_rehash(x) ((x) + ((x) >> 6) + ((x) >> 19)) -#endif // STB_INCLUDE_STB_LIB_H - -#ifdef STB_LIB_IMPLEMENTATION -unsigned int stb_hash(char *str) -{ - unsigned int hash = 0; - while (*str) - hash = (hash << 7) + (hash >> 25) + *str++; - return hash + (hash >> 16); -} - -unsigned int stb_hashlen(char *str, int len) -{ - unsigned int hash = 0; - while (len-- > 0 && *str) - hash = (hash << 7) + (hash >> 25) + *str++; - return hash + (hash >> 16); -} - -unsigned int stb_hashptr(void *p) -{ - unsigned int x = (unsigned int)(size_t) p; - - // typically lacking in low bits and high bits - x = stb_rehash(x); - x += x << 16; - - // pearson's shuffle - x ^= x << 3; - x += x >> 5; - x ^= x << 2; - x += x >> 15; - x ^= x << 10; - return stb_rehash(x); -} - -unsigned int stb_rehash_improved(unsigned int v) -{ - return stb_hashptr((void *)(size_t) v); -} - -unsigned int stb_hash2(char *str, unsigned int *hash2_ptr) -{ - unsigned int hash1 = 0x3141592c; - unsigned int hash2 = 0x77f044ed; - while (*str) { - hash1 = (hash1 << 7) + (hash1 >> 25) + *str; - hash2 = (hash2 << 11) + (hash2 >> 21) + *str; - ++str; - } - *hash2_ptr = hash2 + (hash1 >> 16); - return hash1 + (hash2 >> 16); -} - -// Paul Hsieh hash -#define stb__get16_slow(p) ((p)[0] + ((p)[1] << 8)) -#if defined(_MSC_VER) - #define stb__get16(p) (*((unsigned short *) (p))) -#else - #define stb__get16(p) stb__get16_slow(p) -#endif - -unsigned int stb_hash_fast(void *p, int len) -{ - unsigned char *q = (unsigned char *) p; - unsigned int hash = len; - - if (len <= 0 || q == NULL) return 0; - - /* Main loop */ - if (((int)(size_t) q & 1) == 0) { - for (;len > 3; len -= 4) { - unsigned int val; - hash += stb__get16(q); - val = (stb__get16(q+2) << 11); - hash = (hash << 16) ^ hash ^ val; - q += 4; - hash += hash >> 11; - } - } else { - for (;len > 3; len -= 4) { - unsigned int val; - hash += stb__get16_slow(q); - val = (stb__get16_slow(q+2) << 11); - hash = (hash << 16) ^ hash ^ val; - q += 4; - hash += hash >> 11; - } - } - - /* Handle end cases */ - switch (len) { - case 3: hash += stb__get16_slow(q); - hash ^= hash << 16; - hash ^= q[2] << 18; - hash += hash >> 11; - break; - case 2: hash += stb__get16_slow(q); - hash ^= hash << 11; - hash += hash >> 17; - break; - case 1: hash += q[0]; - hash ^= hash << 10; - hash += hash >> 1; - break; - case 0: break; - } - - /* Force "avalanching" of final 127 bits */ - hash ^= hash << 3; - hash += hash >> 5; - hash ^= hash << 4; - hash += hash >> 17; - hash ^= hash << 25; - hash += hash >> 6; - - return hash; -} - -unsigned int stb_hash_number(unsigned int hash) -{ - hash ^= hash << 3; - hash += hash >> 5; - hash ^= hash << 4; - hash += hash >> 17; - hash ^= hash << 25; - hash += hash >> 6; - return hash; -} -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// Instantiated data structures -// -// This is an attempt to implement a templated data structure. -// -// Hash table: call stb_define_hash(TYPE,N,KEY,K1,K2,HASH,VALUE) -// TYPE -- will define a structure type containing the hash table -// N -- the name, will prefix functions named: -// N create -// N destroy -// N get -// N set, N add, N update, -// N remove -// KEY -- the type of the key. 'x == y' must be valid -// K1,K2 -- keys never used by the app, used as flags in the hashtable -// HASH -- a piece of code ending with 'return' that hashes key 'k' -// VALUE -- the type of the value. 'x = y' must be valid -// -// Note that stb_define_hash_base can be used to define more sophisticated -// hash tables, e.g. those that make copies of the key or use special -// comparisons (e.g. strcmp). - -#define STB_(prefix,name) stb__##prefix##name -#define STB__(prefix,name) prefix##name -#define STB__use(x) x -#define STB__skip(x) - -#define stb_declare_hash(PREFIX,TYPE,N,KEY,VALUE) \ - typedef struct stb__st_##TYPE TYPE;\ - PREFIX int STB__(N, init)(TYPE *h, int count);\ - PREFIX int STB__(N, memory_usage)(TYPE *h);\ - PREFIX TYPE * STB__(N, create)(void);\ - PREFIX TYPE * STB__(N, copy)(TYPE *h);\ - PREFIX void STB__(N, destroy)(TYPE *h);\ - PREFIX int STB__(N,get_flag)(TYPE *a, KEY k, VALUE *v);\ - PREFIX VALUE STB__(N,get)(TYPE *a, KEY k);\ - PREFIX int STB__(N, set)(TYPE *a, KEY k, VALUE v);\ - PREFIX int STB__(N, add)(TYPE *a, KEY k, VALUE v);\ - PREFIX int STB__(N, update)(TYPE*a,KEY k,VALUE v);\ - PREFIX int STB__(N, remove)(TYPE *a, KEY k, VALUE *v); - -#define STB_nocopy(x) (x) -#define STB_nodelete(x) 0 -#define STB_nofields -#define STB_nonullvalue(x) -#define STB_nullvalue(x) x -#define STB_safecompare(x) x -#define STB_nosafe(x) -#define STB_noprefix - -#ifdef __GNUC__ -#define STB__nogcc(x) -#else -#define STB__nogcc(x) x -#endif - -#define stb_define_hash_base(PREFIX,TYPE,FIELDS,N,NC,LOAD_FACTOR, \ - KEY,EMPTY,DEL,COPY,DISPOSE,SAFE, \ - VCOMPARE,CCOMPARE,HASH, \ - VALUE,HASVNULL,VNULL) \ - \ -typedef struct \ -{ \ - KEY k; \ - VALUE v; \ -} STB_(N,_hashpair); \ - \ -STB__nogcc( typedef struct stb__st_##TYPE TYPE; ) \ -struct stb__st_##TYPE { \ - FIELDS \ - STB_(N,_hashpair) *table; \ - unsigned int mask; \ - int count, limit; \ - int deleted; \ - \ - int delete_threshhold; \ - int grow_threshhold; \ - int shrink_threshhold; \ - unsigned char alloced, has_empty, has_del; \ - VALUE ev; VALUE dv; \ -}; \ - \ -static unsigned int STB_(N, hash)(KEY k) \ -{ \ - HASH \ -} \ - \ -PREFIX int STB__(N, init)(TYPE *h, int count) \ -{ \ - int i; \ - if (count < 4) count = 4; \ - h->limit = count; \ - h->count = 0; \ - h->mask = count-1; \ - h->deleted = 0; \ - h->grow_threshhold = (int) (count * LOAD_FACTOR); \ - h->has_empty = h->has_del = 0; \ - h->alloced = 0; \ - if (count <= 64) \ - h->shrink_threshhold = 0; \ - else \ - h->shrink_threshhold = (int) (count * (LOAD_FACTOR/2.25)); \ - h->delete_threshhold = (int) (count * (1-LOAD_FACTOR)/2); \ - h->table = (STB_(N,_hashpair)*) malloc(sizeof(h->table[0]) * count); \ - if (h->table == NULL) return 0; \ - /* ideally this gets turned into a memset32 automatically */ \ - for (i=0; i < count; ++i) \ - h->table[i].k = EMPTY; \ - return 1; \ -} \ - \ -PREFIX int STB__(N, memory_usage)(TYPE *h) \ -{ \ - return sizeof(*h) + h->limit * sizeof(h->table[0]); \ -} \ - \ -PREFIX TYPE * STB__(N, create)(void) \ -{ \ - TYPE *h = (TYPE *) malloc(sizeof(*h)); \ - if (h) { \ - if (STB__(N, init)(h, 16)) \ - h->alloced = 1; \ - else { free(h); h=NULL; } \ - } \ - return h; \ -} \ - \ -PREFIX void STB__(N, destroy)(TYPE *a) \ -{ \ - int i; \ - for (i=0; i < a->limit; ++i) \ - if (!CCOMPARE(a->table[i].k,EMPTY) && !CCOMPARE(a->table[i].k, DEL)) \ - DISPOSE(a->table[i].k); \ - free(a->table); \ - if (a->alloced) \ - free(a); \ -} \ - \ -static void STB_(N, rehash)(TYPE *a, int count); \ - \ -PREFIX int STB__(N,get_flag)(TYPE *a, KEY k, VALUE *v) \ -{ \ - unsigned int h = STB_(N, hash)(k); \ - unsigned int n = h & a->mask, s; \ - if (CCOMPARE(k,EMPTY)){ if (a->has_empty) *v = a->ev; return a->has_empty;}\ - if (CCOMPARE(k,DEL)) { if (a->has_del ) *v = a->dv; return a->has_del; }\ - if (CCOMPARE(a->table[n].k,EMPTY)) return 0; \ - SAFE(if (!CCOMPARE(a->table[n].k,DEL))) \ - if (VCOMPARE(a->table[n].k,k)) { *v = a->table[n].v; return 1; } \ - s = stb_rehash(h) | 1; \ - for(;;) { \ - n = (n + s) & a->mask; \ - if (CCOMPARE(a->table[n].k,EMPTY)) return 0; \ - SAFE(if (CCOMPARE(a->table[n].k,DEL)) continue;) \ - if (VCOMPARE(a->table[n].k,k)) \ - { *v = a->table[n].v; return 1; } \ - } \ -} \ - \ -HASVNULL( \ - PREFIX VALUE STB__(N,get)(TYPE *a, KEY k) \ - { \ - VALUE v; \ - if (STB__(N,get_flag)(a,k,&v)) return v; \ - else return VNULL; \ - } \ -) \ - \ -PREFIX int STB__(N,getkey)(TYPE *a, KEY k, KEY *kout) \ -{ \ - unsigned int h = STB_(N, hash)(k); \ - unsigned int n = h & a->mask, s; \ - if (CCOMPARE(k,EMPTY)||CCOMPARE(k,DEL)) return 0; \ - if (CCOMPARE(a->table[n].k,EMPTY)) return 0; \ - SAFE(if (!CCOMPARE(a->table[n].k,DEL))) \ - if (VCOMPARE(a->table[n].k,k)) { *kout = a->table[n].k; return 1; } \ - s = stb_rehash(h) | 1; \ - for(;;) { \ - n = (n + s) & a->mask; \ - if (CCOMPARE(a->table[n].k,EMPTY)) return 0; \ - SAFE(if (CCOMPARE(a->table[n].k,DEL)) continue;) \ - if (VCOMPARE(a->table[n].k,k)) \ - { *kout = a->table[n].k; return 1; } \ - } \ -} \ - \ -static int STB_(N,addset)(TYPE *a, KEY k, VALUE v, \ - int allow_new, int allow_old, int copy) \ -{ \ - unsigned int h = STB_(N, hash)(k); \ - unsigned int n = h & a->mask; \ - int b = -1; \ - if (CCOMPARE(k,EMPTY)) { \ - if (a->has_empty ? allow_old : allow_new) { \ - n=a->has_empty; a->ev = v; a->has_empty = 1; return !n; \ - } else return 0; \ - } \ - if (CCOMPARE(k,DEL)) { \ - if (a->has_del ? allow_old : allow_new) { \ - n=a->has_del; a->dv = v; a->has_del = 1; return !n; \ - } else return 0; \ - } \ - if (!CCOMPARE(a->table[n].k, EMPTY)) { \ - unsigned int s; \ - if (CCOMPARE(a->table[n].k, DEL)) \ - b = n; \ - else if (VCOMPARE(a->table[n].k,k)) { \ - if (allow_old) \ - a->table[n].v = v; \ - return !allow_new; \ - } \ - s = stb_rehash(h) | 1; \ - for(;;) { \ - n = (n + s) & a->mask; \ - if (CCOMPARE(a->table[n].k, EMPTY)) break; \ - if (CCOMPARE(a->table[n].k, DEL)) { \ - if (b < 0) b = n; \ - } else if (VCOMPARE(a->table[n].k,k)) { \ - if (allow_old) \ - a->table[n].v = v; \ - return !allow_new; \ - } \ - } \ - } \ - if (!allow_new) return 0; \ - if (b < 0) b = n; else --a->deleted; \ - a->table[b].k = copy ? COPY(k) : k; \ - a->table[b].v = v; \ - ++a->count; \ - if (a->count > a->grow_threshhold) \ - STB_(N,rehash)(a, a->limit*2); \ - return 1; \ -} \ - \ -PREFIX int STB__(N, set)(TYPE *a, KEY k, VALUE v){return STB_(N,addset)(a,k,v,1,1,1);}\ -PREFIX int STB__(N, add)(TYPE *a, KEY k, VALUE v){return STB_(N,addset)(a,k,v,1,0,1);}\ -PREFIX int STB__(N, update)(TYPE*a,KEY k,VALUE v){return STB_(N,addset)(a,k,v,0,1,1);}\ - \ -PREFIX int STB__(N, remove)(TYPE *a, KEY k, VALUE *v) \ -{ \ - unsigned int h = STB_(N, hash)(k); \ - unsigned int n = h & a->mask, s; \ - if (CCOMPARE(k,EMPTY)) { if (a->has_empty) { if(v)*v = a->ev; a->has_empty=0; return 1; } return 0; } \ - if (CCOMPARE(k,DEL)) { if (a->has_del ) { if(v)*v = a->dv; a->has_del =0; return 1; } return 0; } \ - if (CCOMPARE(a->table[n].k,EMPTY)) return 0; \ - if (SAFE(CCOMPARE(a->table[n].k,DEL) || ) !VCOMPARE(a->table[n].k,k)) { \ - s = stb_rehash(h) | 1; \ - for(;;) { \ - n = (n + s) & a->mask; \ - if (CCOMPARE(a->table[n].k,EMPTY)) return 0; \ - SAFE(if (CCOMPARE(a->table[n].k, DEL)) continue;) \ - if (VCOMPARE(a->table[n].k,k)) break; \ - } \ - } \ - DISPOSE(a->table[n].k); \ - a->table[n].k = DEL; \ - --a->count; \ - ++a->deleted; \ - if (v != NULL) \ - *v = a->table[n].v; \ - if (a->count < a->shrink_threshhold) \ - STB_(N, rehash)(a, a->limit >> 1); \ - else if (a->deleted > a->delete_threshhold) \ - STB_(N, rehash)(a, a->limit); \ - return 1; \ -} \ - \ -PREFIX TYPE * STB__(NC, copy)(TYPE *a) \ -{ \ - int i; \ - TYPE *h = (TYPE *) malloc(sizeof(*h)); \ - if (!h) return NULL; \ - if (!STB__(N, init)(h, a->limit)) { free(h); return NULL; } \ - h->count = a->count; \ - h->deleted = a->deleted; \ - h->alloced = 1; \ - h->ev = a->ev; h->dv = a->dv; \ - h->has_empty = a->has_empty; h->has_del = a->has_del; \ - memcpy(h->table, a->table, h->limit * sizeof(h->table[0])); \ - for (i=0; i < a->limit; ++i) \ - if (!CCOMPARE(h->table[i].k,EMPTY) && !CCOMPARE(h->table[i].k,DEL)) \ - h->table[i].k = COPY(h->table[i].k); \ - return h; \ -} \ - \ -static void STB_(N, rehash)(TYPE *a, int count) \ -{ \ - int i; \ - TYPE b; \ - STB__(N, init)(&b, count); \ - for (i=0; i < a->limit; ++i) \ - if (!CCOMPARE(a->table[i].k,EMPTY) && !CCOMPARE(a->table[i].k,DEL)) \ - STB_(N,addset)(&b, a->table[i].k, a->table[i].v,1,1,0); \ - free(a->table); \ - a->table = b.table; \ - a->mask = b.mask; \ - a->count = b.count; \ - a->limit = b.limit; \ - a->deleted = b.deleted; \ - a->delete_threshhold = b.delete_threshhold; \ - a->grow_threshhold = b.grow_threshhold; \ - a->shrink_threshhold = b.shrink_threshhold; \ -} - -#define STB_equal(a,b) ((a) == (b)) - -#define stb_define_hash(TYPE,N,KEY,EMPTY,DEL,HASH,VALUE) \ - stb_define_hash_base(STB_noprefix, TYPE,STB_nofields,N,NC,0.85f, \ - KEY,EMPTY,DEL,STB_nocopy,STB_nodelete,STB_nosafe, \ - STB_equal,STB_equal,HASH, \ - VALUE,STB_nonullvalue,0) - -#define stb_define_hash_vnull(TYPE,N,KEY,EMPTY,DEL,HASH,VALUE,VNULL) \ - stb_define_hash_base(STB_noprefix, TYPE,STB_nofields,N,NC,0.85f, \ - KEY,EMPTY,DEL,STB_nocopy,STB_nodelete,STB_nosafe, \ - STB_equal,STB_equal,HASH, \ - VALUE,STB_nullvalue,VNULL) - -////////////////////////////////////////////////////////////////////////////// -// -// stb_ptrmap -// -// An stb_ptrmap data structure is an O(1) hash table between pointers. One -// application is to let you store "extra" data associated with pointers, -// which is why it was originally called stb_extra. - -#ifndef STB_INCLUDE_STB_LIB_H -stb_declare_hash(STB_EXTERN, stb_ptrmap, stb_ptrmap_, void *, void *) -stb_declare_hash(STB_EXTERN, stb_idict, stb_idict_, stb_int32, stb_int32) - -STB_EXTERN void stb_ptrmap_delete(stb_ptrmap *e, void (*free_func)(void *)); -STB_EXTERN stb_ptrmap *stb_ptrmap_new(void); - -STB_EXTERN stb_idict * stb_idict_new_size(unsigned int size); -STB_EXTERN void stb_idict_remove_all(stb_idict *e); -#endif // STB_INCLUDE_STB_LIB_H - -#ifdef STB_LIB_IMPLEMENTATION - -#define STB_EMPTY ((void *) 2) -#define STB_EDEL ((void *) 6) - -stb_define_hash_base(STB_noprefix,stb_ptrmap, STB_nofields, stb_ptrmap_,stb_ptrmap_,0.85f, - void *,STB_EMPTY,STB_EDEL,STB_nocopy,STB_nodelete,STB_nosafe, - STB_equal,STB_equal,return stb_hashptr(k);, - void *,STB_nullvalue,NULL) - -stb_ptrmap *stb_ptrmap_new(void) -{ - return stb_ptrmap_create(); -} - -void stb_ptrmap_delete(stb_ptrmap *e, void (*free_func)(void *)) -{ - int i; - if (free_func) - for (i=0; i < e->limit; ++i) - if (e->table[i].k != STB_EMPTY && e->table[i].k != STB_EDEL) { - if (free_func == free) - free(e->table[i].v); // allow STB_MALLOC_WRAPPER to operate - else - free_func(e->table[i].v); - } - stb_ptrmap_destroy(e); -} - -// extra fields needed for stua_dict -#define STB_IEMPTY ((int) 1) -#define STB_IDEL ((int) 3) -stb_define_hash_base(STB_noprefix, stb_idict, STB_nofields, stb_idict_,stb_idict_,0.85f, - stb_int32,STB_IEMPTY,STB_IDEL,STB_nocopy,STB_nodelete,STB_nosafe, - STB_equal,STB_equal, - return stb_rehash_improved(k);,stb_int32,STB_nonullvalue,0) - -stb_idict * stb_idict_new_size(unsigned int size) -{ - stb_idict *e = (stb_idict *) malloc(sizeof(*e)); - if (e) { - // round up to power of 2 - while ((size & (size-1)) != 0) // while more than 1 bit is set - size += (size & ~(size-1)); // add the lowest set bit - stb_idict_init(e, size); - e->alloced = 1; - } - return e; -} - -void stb_idict_remove_all(stb_idict *e) -{ - int n; - for (n=0; n < e->limit; ++n) - e->table[n].k = STB_IEMPTY; - e->has_empty = e->has_del = 0; -} -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// SDICT: Hash Table for Strings (symbol table) -// -// if "use_arena=1", then strings will be copied -// into blocks and never freed until the sdict is freed; -// otherwise they're malloc()ed and free()d on the fly. -// (specify use_arena=1 if you never stb_sdict_remove) - -#ifndef STB_INCLUDE_STB_LIB_H -stb_declare_hash(STB_EXTERN, stb_sdict, stb_sdict_, char *, void *) - -STB_EXTERN stb_sdict * stb_sdict_new(void); -STB_EXTERN stb_sdict * stb_sdict_copy(stb_sdict*); -STB_EXTERN void stb_sdict_delete(stb_sdict *); -STB_EXTERN void * stb_sdict_change(stb_sdict *, char *str, void *p); -STB_EXTERN int stb_sdict_count(stb_sdict *d); - -STB_EXTERN int stb_sdict_internal_limit(stb_sdict *d); -STB_EXTERN char * stb_sdict_internal_key(stb_sdict *d, int n); -STB_EXTERN void * stb_sdict_internal_value(stb_sdict *d, int n); - -#define stb_sdict_for(d,i,q,z) \ - for(i=0; i < stb_sdict_internal_limit(d) ? (q=stb_sdict_internal_key(d,i),z=stb_sdict_internal_value(d,i),1) : 0; ++i) \ - if (q==NULL||q==(void *) 1);else // reversed makes macro friendly -#endif // STB_INCLUDE_STB_LIB_H - -#ifdef STB_LIB_IMPLEMENTATION - -// if in same translation unit, for speed, don't call accessors -#undef stb_sdict_for -#define stb_sdict_for(d,i,q,z) \ - for(i=0; i < (d)->limit ? (q=(d)->table[i].k,z=(d)->table[i].v,1) : 0; ++i) \ - if (q==NULL||q==(void *) 1);else // reversed makes macro friendly - -//#define STB_DEL ((void *) 1) -#define STB_SDEL ((char *) 1) - -stb_define_hash_base(STB_noprefix, stb_sdict, STB_nofields, stb_sdict_,stb_sdictinternal_, 0.85f, - char *, NULL, STB_SDEL, strdup, free, - STB_safecompare, !strcmp, STB_equal, return stb_hash(k);, - void *, STB_nullvalue, NULL) - -int stb_sdict_count(stb_sdict *a) -{ - return a->count; -} - -int stb_sdict_internal_limit(stb_sdict *a) -{ - return a->limit; -} -char* stb_sdict_internal_key(stb_sdict *a, int n) -{ - return a->table[n].k; -} -void* stb_sdict_internal_value(stb_sdict *a, int n) -{ - return a->table[n].v; -} - -stb_sdict * stb_sdict_new(void) -{ - stb_sdict *d = stb_sdict_create(); - if (d == NULL) return NULL; - return d; -} - -stb_sdict* stb_sdict_copy(stb_sdict *old) -{ - return stb_sdictinternal_copy(old); -} - -void stb_sdict_delete(stb_sdict *d) -{ - stb_sdict_destroy(d); -} - -void * stb_sdict_change(stb_sdict *d, char *str, void *p) -{ - void *q = stb_sdict_get(d, str); - stb_sdict_set(d, str, p); - return q; -} -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// File Processing -// - -#ifndef STB_INCLUDE_STB_LIB_H -#ifdef _MSC_VER - #define stb_rename(x,y) _wrename((const wchar_t *)stb__from_utf8(x), (const wchar_t *)stb__from_utf8_alt(y)) - #define stb_mktemp _mktemp -#else - #define stb_mktemp mktemp - #define stb_rename rename -#endif - -#define stb_filec (char *) stb_file -#define stb_fileu (unsigned char *) stb_file -STB_EXTERN void * stb_file(char *filename, size_t *length); -STB_EXTERN size_t stb_filelen(FILE *f); -STB_EXTERN int stb_filewrite(char *filename, void *data, size_t length); -STB_EXTERN int stb_filewritestr(char *filename, char *data); -STB_EXTERN char ** stb_stringfile(char *filename, int *len); -STB_EXTERN char * stb_fgets(char *buffer, int buflen, FILE *f); -STB_EXTERN char * stb_fgets_malloc(FILE *f); -STB_EXTERN int stb_fexists(char *filename); -STB_EXTERN int stb_fcmp(char *s1, char *s2); -STB_EXTERN int stb_feq(char *s1, char *s2); -STB_EXTERN time_t stb_ftimestamp(char *filename); -STB_EXTERN int stb_fullpath(char *abs, int abs_size, char *rel); - -STB_EXTERN int stb_copyfile(char *src, char *dest); -STB_EXTERN int stb_fread(void *data, size_t len, size_t count, void *f); -STB_EXTERN int stb_fwrite(void *data, size_t len, size_t count, void *f); -#endif // STB_INCLUDE_STB_LIB_H - -#ifdef STB_LIB_IMPLEMENTATION -#if defined(_MSC_VER) || defined(__MINGW32__) - #define stb__stat _stat -#else - #define stb__stat stat -#endif - -int stb_fexists(char *filename) -{ - struct stb__stat buf; - return stb__windows( - _wstat((const wchar_t *)stb__from_utf8(filename), &buf), - stat(filename,&buf) - ) == 0; -} - -time_t stb_ftimestamp(char *filename) -{ - struct stb__stat buf; - if (stb__windows( - _wstat((const wchar_t *)stb__from_utf8(filename), &buf), - stat(filename,&buf) - ) == 0) - { - return buf.st_mtime; - } else { - return 0; - } -} - -size_t stb_filelen(FILE *f) -{ - size_t len, pos; - pos = ftell(f); - fseek(f, 0, SEEK_END); - len = ftell(f); - fseek(f, pos, SEEK_SET); - return len; -} - -void *stb_file(char *filename, size_t *length) -{ - FILE *f = stb__fopen(filename, "rb"); - char *buffer; - size_t len, len2; - if (!f) return NULL; - len = stb_filelen(f); - buffer = (char *) malloc(len+2); // nul + extra - len2 = fread(buffer, 1, len, f); - if (len2 == len) { - if (length) *length = len; - buffer[len] = 0; - } else { - free(buffer); - buffer = NULL; - } - fclose(f); - return buffer; -} - -int stb_filewrite(char *filename, void *data, size_t length) -{ - FILE *f = stb__fopen(filename, "wb"); - if (f) { - unsigned char *data_ptr = (unsigned char *) data; - size_t remaining = length; - while (remaining > 0) { - size_t len2 = remaining > 65536 ? 65536 : remaining; - size_t len3 = fwrite(data_ptr, 1, len2, f); - if (len2 != len3) { - fprintf(stderr, "Failed while writing %s\n", filename); - break; - } - remaining -= len2; - data_ptr += len2; - } - fclose(f); - } - return f != NULL; -} - -int stb_filewritestr(char *filename, char *data) -{ - return stb_filewrite(filename, data, strlen(data)); -} - -char ** stb_stringfile(char *filename, int *plen) -{ - FILE *f = stb__fopen(filename, "rb"); - char *buffer, **list=NULL, *s; - size_t len, count, i; - - if (!f) return NULL; - len = stb_filelen(f); - buffer = (char *) malloc(len+1); - len = fread(buffer, 1, len, f); - buffer[len] = 0; - fclose(f); - - // two passes through: first time count lines, second time set them - for (i=0; i < 2; ++i) { - s = buffer; - if (i == 1) - list[0] = s; - count = 1; - while (*s) { - if (*s == '\n' || *s == '\r') { - // detect if both cr & lf are together - int crlf = (s[0] + s[1]) == ('\n' + '\r'); - if (i == 1) *s = 0; - if (crlf) ++s; - if (s[1]) { // it's not over yet - if (i == 1) list[count] = s+1; - ++count; - } - } - ++s; - } - if (i == 0) { - list = (char **) malloc(sizeof(*list) * (count+1) + len+1); - if (!list) return NULL; - list[count] = 0; - // recopy the file so there's just a single allocation to free - memcpy(&list[count+1], buffer, len+1); - free(buffer); - buffer = (char *) &list[count+1]; - if (plen) *plen = count; - } - } - return list; -} - -char * stb_fgets(char *buffer, int buflen, FILE *f) -{ - char *p; - buffer[0] = 0; - p = fgets(buffer, buflen, f); - if (p) { - int n = strlen(p)-1; - if (n >= 0) - if (p[n] == '\n') - p[n] = 0; - } - return p; -} - -char * stb_fgets_malloc(FILE *f) -{ - // avoid reallocing for small strings - char quick_buffer[800]; - quick_buffer[sizeof(quick_buffer)-2] = 0; - if (!fgets(quick_buffer, sizeof(quick_buffer), f)) - return NULL; - - if (quick_buffer[sizeof(quick_buffer)-2] == 0) { - int n = strlen(quick_buffer); - if (n > 0 && quick_buffer[n-1] == '\n') - quick_buffer[n-1] = 0; - return strdup(quick_buffer); - } else { - char *p; - char *a = strdup(quick_buffer); - int len = sizeof(quick_buffer)-1; - - while (!feof(f)) { - if (a[len-1] == '\n') break; - a = (char *) realloc(a, len*2); - p = &a[len]; - p[len-2] = 0; - if (!fgets(p, len, f)) - break; - if (p[len-2] == 0) { - len += strlen(p); - break; - } - len = len + (len-1); - } - if (a[len-1] == '\n') - a[len-1] = 0; - return a; - } -} - -int stb_fullpath(char *abs, int abs_size, char *rel) -{ - #ifdef _MSC_VER - return _fullpath(abs, rel, abs_size) != NULL; - #else - if (rel[0] == '/' || rel[0] == '~') { - if ((int) strlen(rel) >= abs_size) - return 0; - strcpy(abs,rel); - return 1; - } else { - int n; - getcwd(abs, abs_size); - n = strlen(abs); - if (n+(int) strlen(rel)+2 <= abs_size) { - abs[n] = '/'; - strcpy(abs+n+1, rel); - return 1; - } else { - return 0; - } - } - #endif -} - -static int stb_fcmp_core(FILE *f, FILE *g) -{ - char buf1[1024],buf2[1024]; - int n1,n2, res=0; - - while (1) { - n1 = fread(buf1, 1, sizeof(buf1), f); - n2 = fread(buf2, 1, sizeof(buf2), g); - res = memcmp(buf1,buf2,n1 < n2 ? n1 : n2); - if (res) - break; - if (n1 != n2) { - res = n1 < n2 ? -1 : 1; - break; - } - if (n1 == 0) - break; - } - - fclose(f); - fclose(g); - return res; -} - -int stb_fcmp(char *s1, char *s2) -{ - FILE *f = stb__fopen(s1, "rb"); - FILE *g = stb__fopen(s2, "rb"); - - if (f == NULL || g == NULL) { - if (f) fclose(f); - if (g) { - fclose(g); - return 1; - } - return f != NULL; - } - - return stb_fcmp_core(f,g); -} - -int stb_feq(char *s1, char *s2) -{ - FILE *f = stb__fopen(s1, "rb"); - FILE *g = stb__fopen(s2, "rb"); - - if (f == NULL || g == NULL) { - if (f) fclose(f); - if (g) fclose(g); - return f == g; - } - - // feq is faster because it shortcuts if they're different length - if (stb_filelen(f) != stb_filelen(g)) { - fclose(f); - fclose(g); - return 0; - } - - return !stb_fcmp_core(f,g); -} - -int stb_copyfile(char *src, char *dest) -{ - char raw_buffer[1024]; - char *buffer; - int buf_size = 65536; - - FILE *f, *g; - - // if file already exists at destination, do nothing - if (stb_feq(src, dest)) return 1; - - // open file - f = stb__fopen(src, "rb"); - if (f == NULL) return 0; - - // open file for writing - g = stb__fopen(dest, "wb"); - if (g == NULL) { - fclose(f); - return 0; - } - - buffer = (char *) malloc(buf_size); - if (buffer == NULL) { - buffer = raw_buffer; - buf_size = sizeof(raw_buffer); - } - - while (!feof(f)) { - int n = fread(buffer, 1, buf_size, f); - if (n != 0) - fwrite(buffer, 1, n, g); - } - - fclose(f); - if (buffer != raw_buffer) - free(buffer); - - fclose(g); - return 1; -} - -#define stb_fgetc(f) ((unsigned char) fgetc(f)) - -#if 0 -// strip the trailing '/' or '\\' from a directory so we can refer to it -// as a file for _stat() -char *stb_strip_final_slash(char *t) -{ - if (t[0]) { - char *z = t + strlen(t) - 1; - // *z is the last character - if (*z == '\\' || *z == '/') - if (z != t+2 || t[1] != ':') // but don't strip it if it's e.g. "c:/" - *z = 0; - if (*z == '\\') - *z = '/'; // canonicalize to make sure it matches db - } - return t; -} - -char *stb_strip_final_slash_regardless(char *t) -{ - if (t[0]) { - char *z = t + strlen(t) - 1; - // *z is the last character - if (*z == '\\' || *z == '/') - *z = 0; - if (*z == '\\') - *z = '/'; // canonicalize to make sure it matches db - } - return t; -} -#endif -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// Portable directory reading -// - -#ifndef STB_INCLUDE_STB_LIB_H -STB_EXTERN char **stb_readdir_files (char *dir); -STB_EXTERN char **stb_readdir_files_mask(char *dir, char *wild); -STB_EXTERN char **stb_readdir_subdirs(char *dir); -STB_EXTERN char **stb_readdir_subdirs_mask(char *dir, char *wild); -STB_EXTERN void stb_readdir_free (char **files); -STB_EXTERN char **stb_readdir_recursive(char *dir, char *filespec); -STB_EXTERN void stb_delete_directory_recursive(char *dir); - -// forward declare for implementation -STB_EXTERN int stb_wildmatchi(char *expr, char *candidate); -#endif // STB_INCLUDE_STB_LIB_H - - -#ifdef STB_LIB_IMPLEMENTATION - -#ifdef _MSC_VER -#include -#else -#include -#include -#endif - -void stb_readdir_free(char **files) -{ - char **f2 = files; - int i; - for (i=0; i < stb_arr_len(f2); ++i) - free(f2[i]); - stb_arr_free(f2); -} - -static int isdotdirname(char *name) -{ - if (name[0] == '.') - return (name[1] == '.') ? !name[2] : !name[1]; - return 0; -} - -static char **readdir_raw(char *dir, int return_subdirs, char *mask) -{ - char **results = NULL; - char buffer[4096], with_slash[4096]; - size_t n; - - #ifdef _MSC_VER - stb__wchar *ws; - struct _wfinddata_t data; - #ifdef _WIN64 - const intptr_t none = -1; - intptr_t z; - #else - const long none = -1; - long z; - #endif - #else // !_MSC_VER - const DIR *none = NULL; - DIR *z; - #endif - - n = stb_strscpy(buffer,dir,sizeof(buffer)); - if (!n || n >= sizeof(buffer)) - return NULL; - stb_fixpath(buffer); - n--; - - if (n > 0 && (buffer[n-1] != '/')) { - buffer[n++] = '/'; - } - buffer[n] = 0; - if (!stb_strscpy(with_slash,buffer,sizeof(with_slash))) - return NULL; - - #ifdef _MSC_VER - if (!stb_strscpy(buffer+n,"*.*",sizeof(buffer)-n)) - return NULL; - ws = stb__from_utf8(buffer); - z = _wfindfirst((const wchar_t *)ws, &data); - #else - z = opendir(dir); - #endif - - if (z != none) { - int nonempty = 1; - #ifndef _MSC_VER - struct dirent *data = readdir(z); - nonempty = (data != NULL); - #endif - - if (nonempty) { - - do { - int is_subdir; - #ifdef _MSC_VER - char *name = stb__to_utf8((stb__wchar *)data.name); - if (name == NULL) { - fprintf(stderr, "%s to convert '%S' to %s!\n", "Unable", data.name, "utf8"); - continue; - } - is_subdir = !!(data.attrib & _A_SUBDIR); - #else - char *name = data->d_name; - if (!stb_strscpy(buffer+n,name,sizeof(buffer)-n)) - break; - // Could follow DT_LNK, but would need to check for recursive links. - is_subdir = !!(data->d_type & DT_DIR); - #endif - - if (is_subdir == return_subdirs) { - if (!is_subdir || !isdotdirname(name)) { - if (!mask || stb_wildmatchi(mask, name)) { - char buffer[4096],*p=buffer; - if ( stb_snprintf(buffer, sizeof(buffer), "%s%s", with_slash, name) < 0 ) - break; - if (buffer[0] == '.' && buffer[1] == '/') - p = buffer+2; - stb_arr_push(results, strdup(p)); - } - } - } - } - #ifdef _MSC_VER - while (0 == _wfindnext(z, &data)); - #else - while ((data = readdir(z)) != NULL); - #endif - } - #ifdef _MSC_VER - _findclose(z); - #else - closedir(z); - #endif - } - return results; -} - -char **stb_readdir_files (char *dir) { return readdir_raw(dir, 0, NULL); } -char **stb_readdir_subdirs(char *dir) { return readdir_raw(dir, 1, NULL); } -char **stb_readdir_files_mask(char *dir, char *wild) { return readdir_raw(dir, 0, wild); } -char **stb_readdir_subdirs_mask(char *dir, char *wild) { return readdir_raw(dir, 1, wild); } - -int stb__rec_max=0x7fffffff; -static char **stb_readdir_rec(char **sofar, char *dir, char *filespec) -{ - char **files; - char ** dirs; - char **p; - - if (stb_arr_len(sofar) >= stb__rec_max) return sofar; - - files = stb_readdir_files_mask(dir, filespec); - stb_arr_for(p, files) { - stb_arr_push(sofar, strdup(*p)); - if (stb_arr_len(sofar) >= stb__rec_max) break; - } - stb_readdir_free(files); - if (stb_arr_len(sofar) >= stb__rec_max) return sofar; - - dirs = stb_readdir_subdirs(dir); - stb_arr_for(p, dirs) - sofar = stb_readdir_rec(sofar, *p, filespec); - stb_readdir_free(dirs); - return sofar; -} - -char **stb_readdir_recursive(char *dir, char *filespec) -{ - return stb_readdir_rec(NULL, dir, filespec); -} - -void stb_delete_directory_recursive(char *dir) -{ - char **list = stb_readdir_subdirs(dir); - int i; - for (i=0; i < stb_arr_len(list); ++i) - stb_delete_directory_recursive(list[i]); - stb_arr_free(list); - list = stb_readdir_files(dir); - for (i=0; i < stb_arr_len(list); ++i) - if (!remove(list[i])) { - // on windows, try again after making it writeable; don't ALWAYS - // do this first since that would be slow in the normal case - #ifdef _MSC_VER - _chmod(list[i], _S_IWRITE); - remove(list[i]); - #endif - } - stb_arr_free(list); - stb__windows(_rmdir,rmdir)(dir); -} -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// Checksums: CRC-32, ADLER32, SHA-1 -// -// CRC-32 and ADLER32 allow streaming blocks -// SHA-1 requires either a complete buffer, max size 2^32 - 73 -// or it can checksum directly from a file, max 2^61 - -#ifndef STB_INCLUDE_STB_LIB_H -#define STB_ADLER32_SEED 1 -#define STB_CRC32_SEED 0 // note that we logical NOT this in the code - -STB_EXTERN stb_uint stb_adler32 (stb_uint adler32, stb_uchar *buffer, stb_uint buflen); -STB_EXTERN stb_uint stb_crc32_block(stb_uint crc32 , stb_uchar *buffer, stb_uint buflen); -STB_EXTERN stb_uint stb_crc32 ( stb_uchar *buffer, stb_uint buflen); - -STB_EXTERN void stb_sha1( unsigned char output[20], stb_uchar *buffer, unsigned int len); -STB_EXTERN int stb_sha1_file(unsigned char output[20], char *file); -#endif // STB_INCLUDE_STB_LIB_H - -#ifdef STB_LIB_IMPLEMENTATION -stb_uint stb_crc32_block(stb_uint crc, unsigned char *buffer, stb_uint len) -{ - static stb_uint crc_table[256]; - stb_uint i,j,s; - crc = ~crc; - - if (crc_table[1] == 0) - for(i=0; i < 256; i++) { - for (s=i, j=0; j < 8; ++j) - s = (s >> 1) ^ (s & 1 ? 0xedb88320 : 0); - crc_table[i] = s; - } - for (i=0; i < len; ++i) - crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)]; - return ~crc; -} - -stb_uint stb_crc32(unsigned char *buffer, stb_uint len) -{ - return stb_crc32_block(0, buffer, len); -} - -stb_uint stb_adler32(stb_uint adler32, stb_uchar *buffer, stb_uint buflen) -{ - const unsigned long ADLER_MOD = 65521; - unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16; - unsigned long blocklen, i; - - blocklen = buflen % 5552; - while (buflen) { - for (i=0; i + 7 < blocklen; i += 8) { - s1 += buffer[0], s2 += s1; - s1 += buffer[1], s2 += s1; - s1 += buffer[2], s2 += s1; - s1 += buffer[3], s2 += s1; - s1 += buffer[4], s2 += s1; - s1 += buffer[5], s2 += s1; - s1 += buffer[6], s2 += s1; - s1 += buffer[7], s2 += s1; - - buffer += 8; - } - - for (; i < blocklen; ++i) - s1 += *buffer++, s2 += s1; - - s1 %= ADLER_MOD, s2 %= ADLER_MOD; - buflen -= blocklen; - blocklen = 5552; - } - return (s2 << 16) + s1; -} - -#define stb__big32(c) (((c)[0]<<24) + (c)[1]*65536 + (c)[2]*256 + (c)[3]) -static void stb__sha1(stb_uchar *chunk, stb_uint h[5]) -{ - int i; - stb_uint a,b,c,d,e; - stb_uint w[80]; - - for (i=0; i < 16; ++i) - w[i] = stb__big32(&chunk[i*4]); - for (i=16; i < 80; ++i) { - stb_uint t; - t = w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16]; - w[i] = (t + t) | (t >> 31); - } - - a = h[0]; - b = h[1]; - c = h[2]; - d = h[3]; - e = h[4]; - - #define STB__SHA1(k,f) \ - { \ - stb_uint temp = (a << 5) + (a >> 27) + (f) + e + (k) + w[i]; \ - e = d; \ - d = c; \ - c = (b << 30) + (b >> 2); \ - b = a; \ - a = temp; \ - } - - i=0; - for (; i < 20; ++i) STB__SHA1(0x5a827999, d ^ (b & (c ^ d)) ); - for (; i < 40; ++i) STB__SHA1(0x6ed9eba1, b ^ c ^ d ); - for (; i < 60; ++i) STB__SHA1(0x8f1bbcdc, (b & c) + (d & (b ^ c)) ); - for (; i < 80; ++i) STB__SHA1(0xca62c1d6, b ^ c ^ d ); - - #undef STB__SHA1 - - h[0] += a; - h[1] += b; - h[2] += c; - h[3] += d; - h[4] += e; -} - -void stb_sha1(stb_uchar output[20], stb_uchar *buffer, stb_uint len) -{ - unsigned char final_block[128]; - stb_uint end_start, final_len, j; - int i; - - stb_uint h[5]; - - h[0] = 0x67452301; - h[1] = 0xefcdab89; - h[2] = 0x98badcfe; - h[3] = 0x10325476; - h[4] = 0xc3d2e1f0; - - // we need to write padding to the last one or two - // blocks, so build those first into 'final_block' - - // we have to write one special byte, plus the 8-byte length - - // compute the block where the data runs out - end_start = len & ~63; - - // compute the earliest we can encode the length - if (((len+9) & ~63) == end_start) { - // it all fits in one block, so fill a second-to-last block - end_start -= 64; - } - - final_len = end_start + 128; - - // now we need to copy the data in - assert(end_start + 128 >= len+9); - assert(end_start < len || len < 64-9); - - j = 0; - if (end_start > len) - j = (stb_uint) - (int) end_start; - - for (; end_start + j < len; ++j) - final_block[j] = buffer[end_start + j]; - final_block[j++] = 0x80; - while (j < 128-5) // 5 byte length, so write 4 extra padding bytes - final_block[j++] = 0; - // big-endian size - final_block[j++] = len >> 29; - final_block[j++] = len >> 21; - final_block[j++] = len >> 13; - final_block[j++] = len >> 5; - final_block[j++] = len << 3; - assert(j == 128 && end_start + j == final_len); - - for (j=0; j < final_len; j += 64) { // 512-bit chunks - if (j+64 >= end_start+64) - stb__sha1(&final_block[j - end_start], h); - else - stb__sha1(&buffer[j], h); - } - - for (i=0; i < 5; ++i) { - output[i*4 + 0] = h[i] >> 24; - output[i*4 + 1] = h[i] >> 16; - output[i*4 + 2] = h[i] >> 8; - output[i*4 + 3] = h[i] >> 0; - } -} - -int stb_sha1_file(stb_uchar output[20], char *file) -{ - int i; - stb_uint64 length=0; - unsigned char buffer[128]; - - FILE *f = stb__fopen(file, "rb"); - stb_uint h[5]; - - if (f == NULL) return 0; // file not found - - h[0] = 0x67452301; - h[1] = 0xefcdab89; - h[2] = 0x98badcfe; - h[3] = 0x10325476; - h[4] = 0xc3d2e1f0; - - for(;;) { - int n = fread(buffer, 1, 64, f); - if (n == 64) { - stb__sha1(buffer, h); - length += n; - } else { - int block = 64; - - length += n; - - buffer[n++] = 0x80; - - // if there isn't enough room for the length, double the block - if (n + 8 > 64) - block = 128; - - // pad to end - memset(buffer+n, 0, block-8-n); - - i = block - 8; - buffer[i++] = (stb_uchar) (length >> 53); - buffer[i++] = (stb_uchar) (length >> 45); - buffer[i++] = (stb_uchar) (length >> 37); - buffer[i++] = (stb_uchar) (length >> 29); - buffer[i++] = (stb_uchar) (length >> 21); - buffer[i++] = (stb_uchar) (length >> 13); - buffer[i++] = (stb_uchar) (length >> 5); - buffer[i++] = (stb_uchar) (length << 3); - assert(i == block); - stb__sha1(buffer, h); - if (block == 128) - stb__sha1(buffer+64, h); - else - assert(block == 64); - break; - } - } - fclose(f); - - for (i=0; i < 5; ++i) { - output[i*4 + 0] = h[i] >> 24; - output[i*4 + 1] = h[i] >> 16; - output[i*4 + 2] = h[i] >> 8; - output[i*4 + 3] = h[i] >> 0; - } - - return 1; -} -#endif // STB_LIB_IMPLEMENTATION - -////////////////////////////////////////////////////////////////////////////// -// -// Random Numbers via Meresenne Twister or LCG -// - -#ifndef STB_INCLUDE_STB_LIB_H -STB_EXTERN unsigned long stb_srandLCG(unsigned long seed); -STB_EXTERN unsigned long stb_randLCG(void); -STB_EXTERN double stb_frandLCG(void); - -STB_EXTERN void stb_srand(unsigned long seed); -STB_EXTERN unsigned long stb_rand(void); -STB_EXTERN double stb_frand(void); -STB_EXTERN void stb_shuffle(void *p, size_t n, size_t sz, - unsigned long seed); -STB_EXTERN void stb_reverse(void *p, size_t n, size_t sz); - -STB_EXTERN unsigned long stb_randLCG_explicit(unsigned long seed); -#endif // STB_INCLUDE_STB_LIB_H - -#ifdef STB_LIB_IMPLEMENTATION -unsigned long stb_randLCG_explicit(unsigned long seed) -{ - return seed * 2147001325 + 715136305; -} - -static unsigned long stb__rand_seed=0; - -unsigned long stb_srandLCG(unsigned long seed) -{ - unsigned long previous = stb__rand_seed; - stb__rand_seed = seed; - return previous; -} - -unsigned long stb_randLCG(void) -{ - stb__rand_seed = stb__rand_seed * 2147001325 + 715136305; // BCPL generator - // shuffle non-random bits to the middle, and xor to decorrelate with seed - return 0x31415926 ^ ((stb__rand_seed >> 16) + (stb__rand_seed << 16)); -} - -double stb_frandLCG(void) -{ - return stb_randLCG() / ((double) (1 << 16) * (1 << 16)); -} - -void stb_shuffle(void *p, size_t n, size_t sz, unsigned long seed) -{ - char *a; - unsigned long old_seed; - int i; - if (seed) - old_seed = stb_srandLCG(seed); - a = (char *) p + (n-1) * sz; - - for (i=n; i > 1; --i) { - int j = stb_randLCG() % i; - stb_swap(a, (char *) p + j * sz, sz); - a -= sz; - } - if (seed) - stb_srandLCG(old_seed); -} - -void stb_reverse(void *p, size_t n, size_t sz) -{ - int i,j = n-1; - for (i=0; i < j; ++i,--j) { - stb_swap((char *) p + i * sz, (char *) p + j * sz, sz); - } -} - -// public domain Mersenne Twister by Michael Brundage -#define STB__MT_LEN 624 - -int stb__mt_index = STB__MT_LEN*sizeof(unsigned long)+1; -unsigned long stb__mt_buffer[STB__MT_LEN]; - -void stb_srand(unsigned long seed) -{ - int i; - unsigned long old = stb_srandLCG(seed); - for (i = 0; i < STB__MT_LEN; i++) - stb__mt_buffer[i] = stb_randLCG(); - stb_srandLCG(old); - stb__mt_index = STB__MT_LEN*sizeof(unsigned long); -} - -#define STB__MT_IA 397 -#define STB__MT_IB (STB__MT_LEN - STB__MT_IA) -#define STB__UPPER_MASK 0x80000000 -#define STB__LOWER_MASK 0x7FFFFFFF -#define STB__MATRIX_A 0x9908B0DF -#define STB__TWIST(b,i,j) ((b)[i] & STB__UPPER_MASK) | ((b)[j] & STB__LOWER_MASK) -#define STB__MAGIC(s) (((s)&1)*STB__MATRIX_A) - -unsigned long stb_rand() -{ - unsigned long * b = stb__mt_buffer; - int idx = stb__mt_index; - unsigned long s,r; - int i; - - if (idx >= STB__MT_LEN*sizeof(unsigned long)) { - if (idx > STB__MT_LEN*sizeof(unsigned long)) - stb_srand(0); - idx = 0; - i = 0; - for (; i < STB__MT_IB; i++) { - s = STB__TWIST(b, i, i+1); - b[i] = b[i + STB__MT_IA] ^ (s >> 1) ^ STB__MAGIC(s); - } - for (; i < STB__MT_LEN-1; i++) { - s = STB__TWIST(b, i, i+1); - b[i] = b[i - STB__MT_IB] ^ (s >> 1) ^ STB__MAGIC(s); - } - - s = STB__TWIST(b, STB__MT_LEN-1, 0); - b[STB__MT_LEN-1] = b[STB__MT_IA-1] ^ (s >> 1) ^ STB__MAGIC(s); - } - stb__mt_index = idx + sizeof(unsigned long); - - r = *(unsigned long *)((unsigned char *)b + idx); - - r ^= (r >> 11); - r ^= (r << 7) & 0x9D2C5680; - r ^= (r << 15) & 0xEFC60000; - r ^= (r >> 18); - - return r; -} - -double stb_frand(void) -{ - return stb_rand() / ((double) (1 << 16) * (1 << 16)); -} -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// wildcards and regexping -// - -#ifndef STB_INCLUDE_STB_LIB_H -STB_EXTERN int stb_wildmatch (char *expr, char *candidate); -STB_EXTERN int stb_wildmatchi(char *expr, char *candidate); -STB_EXTERN int stb_wildfind (char *expr, char *candidate); -STB_EXTERN int stb_wildfindi (char *expr, char *candidate); -#endif // STB_INCLUDE_STB_LIB_H - -#ifdef STB_LIB_IMPLEMENTATION -static int stb__match_qstring(char *candidate, char *qstring, int qlen, int insensitive) -{ - int i; - if (insensitive) { - for (i=0; i < qlen; ++i) - if (qstring[i] == '?') { - if (!candidate[i]) return 0; - } else - if (tolower(qstring[i]) != tolower(candidate[i])) - return 0; - } else { - for (i=0; i < qlen; ++i) - if (qstring[i] == '?') { - if (!candidate[i]) return 0; - } else - if (qstring[i] != candidate[i]) - return 0; - } - return 1; -} - -static int stb__find_qstring(char *candidate, char *qstring, int qlen, int insensitive) -{ - char c; - - int offset=0; - while (*qstring == '?') { - ++qstring; - --qlen; - ++candidate; - if (qlen == 0) return 0; - if (*candidate == 0) return -1; - } - - c = *qstring++; - --qlen; - if (insensitive) c = tolower(c); - - while (candidate[offset]) { - if (c == (insensitive ? tolower(candidate[offset]) : candidate[offset])) - if (stb__match_qstring(candidate+offset+1, qstring, qlen, insensitive)) - return offset; - ++offset; - } - - return -1; -} - -int stb__wildmatch_raw2(char *expr, char *candidate, int search, int insensitive) -{ - int where=0; - int start = -1; - - if (!search) { - // parse to first '*' - if (*expr != '*') - start = 0; - while (*expr != '*') { - if (!*expr) - return *candidate == 0 ? 0 : -1; - if (*expr == '?') { - if (!*candidate) return -1; - } else { - if (insensitive) { - if (tolower(*candidate) != tolower(*expr)) - return -1; - } else - if (*candidate != *expr) - return -1; - } - ++candidate, ++expr, ++where; - } - } else { - // 0-length search string - if (!*expr) - return 0; - } - - assert(search || *expr == '*'); - if (!search) - ++expr; - - // implicit '*' at this point - - while (*expr) { - int o=0; - // combine redundant * characters - while (expr[0] == '*') ++expr; - - // ok, at this point, expr[-1] == '*', - // and expr[0] != '*' - - if (!expr[0]) return start >= 0 ? start : 0; - - // now find next '*' - o = 0; - while (expr[o] != '*') { - if (expr[o] == 0) - break; - ++o; - } - // if no '*', scan to end, then match at end - if (expr[o] == 0 && !search) { - int z; - for (z=0; z < o; ++z) - if (candidate[z] == 0) - return -1; - while (candidate[z]) - ++z; - // ok, now check if they match - if (stb__match_qstring(candidate+z-o, expr, o, insensitive)) - return start >= 0 ? start : 0; - return -1; - } else { - // if yes '*', then do stb__find_qmatch on the intervening chars - int n = stb__find_qstring(candidate, expr, o, insensitive); - if (n < 0) - return -1; - if (start < 0) - start = where + n; - expr += o; - candidate += n+o; - } - - if (*expr == 0) { - assert(search); - return start; - } - - assert(*expr == '*'); - ++expr; - } - - return start >= 0 ? start : 0; -} - -int stb__wildmatch_raw(char *expr, char *candidate, int search, int insensitive) -{ - char buffer[256]; - // handle multiple search strings - char *s = strchr(expr, ';'); - char *last = expr; - while (s) { - int z; - // need to allow for non-writeable strings... assume they're small - if (s - last < 256) { - stb_strncpy(buffer, last, s-last+1); - z = stb__wildmatch_raw2(buffer, candidate, search, insensitive); - } else { - *s = 0; - z = stb__wildmatch_raw2(last, candidate, search, insensitive); - *s = ';'; - } - if (z >= 0) return z; - last = s+1; - s = strchr(last, ';'); - } - return stb__wildmatch_raw2(last, candidate, search, insensitive); -} - -int stb_wildmatch(char *expr, char *candidate) -{ - return stb__wildmatch_raw(expr, candidate, 0,0) >= 0; -} - -int stb_wildmatchi(char *expr, char *candidate) -{ - return stb__wildmatch_raw(expr, candidate, 0,1) >= 0; -} - -int stb_wildfind(char *expr, char *candidate) -{ - return stb__wildmatch_raw(expr, candidate, 1,0); -} - -int stb_wildfindi(char *expr, char *candidate) -{ - return stb__wildmatch_raw(expr, candidate, 1,1); -} - -#undef STB_LIB_IMPLEMENTATION -#endif // STB_LIB_IMPLEMENTATION - -#ifndef STB_INCLUDE_STB_LIB_H -#define STB_INCLUDE_STB_LIB_H -#undef STB_EXTERN -#endif - -/* ------------------------------------------------------------------------------- -This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------- -ALTERNATIVE A - MIT License -Copyright (c) 2017 Sean Barrett -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. ------------------------------------------------------------------------------- -ALTERNATIVE B - Public Domain (www.unlicense.org) -This is free and unencumbered software released into the public domain. -Anyone is free to copy, modify, publish, use, compile, sell, or distribute this -software, either in source code form or as a compiled binary, for any purpose, -commercial or non-commercial, and by any means. -In jurisdictions that recognize copyright laws, the author or authors of this -software dedicate any and all copyright interest in the software to the public -domain. We make this dedication for the benefit of the public at large and to -the detriment of our heirs and successors. We intend this dedication to be an -overt act of relinquishment in perpetuity of all present and future rights to -this software under copyright law. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- -*/ diff --git a/third_party/stb/tests/resample_test.cpp b/third_party/stb/tests/resample_test.cpp deleted file mode 100644 index 882dcc0fca..0000000000 --- a/third_party/stb/tests/resample_test.cpp +++ /dev/null @@ -1,1118 +0,0 @@ -#include -#include - -#if defined(_WIN32) && _MSC_VER > 1200 -#define STBIR_ASSERT(x) \ - if (!(x)) { \ - __debugbreak(); \ - } else -#else -#include -#define STBIR_ASSERT(x) assert(x) -#endif - -#define STBIR_MALLOC stbir_malloc -#define STBIR_FREE stbir_free - -class stbir_context { -public: - stbir_context() - { - size = 1000000; - memory = malloc(size); - } - - ~stbir_context() - { - free(memory); - } - - size_t size; - void* memory; -} g_context; - -void* stbir_malloc(size_t size, void* context) -{ - if (!context) - return malloc(size); - - stbir_context* real_context = (stbir_context*)context; - if (size > real_context->size) - return 0; - - return real_context->memory; -} - -void stbir_free(void* memory, void* context) -{ - if (!context) - free(memory); -} - -//#include -void stbir_progress(float p) -{ - //printf("%f\n", p); - STBIR_ASSERT(p >= 0 && p <= 1); -} - -#define STBIR_PROGRESS_REPORT stbir_progress - -#define STB_IMAGE_RESIZE_IMPLEMENTATION -#define STB_IMAGE_RESIZE_STATIC -#include "stb_image_resize.h" - -#define STB_IMAGE_WRITE_IMPLEMENTATION -#include "stb_image_write.h" - -#define STB_IMAGE_IMPLEMENTATION -#include "stb_image.h" - -#ifdef _WIN32 -#include -#include -#define mkdir(a, b) _mkdir(a) -#else -#include -#endif - -#define MT_SIZE 624 -static size_t g_aiMT[MT_SIZE]; -static size_t g_iMTI = 0; - -// Mersenne Twister implementation from Wikipedia. -// Avoiding use of the system rand() to be sure that our tests generate the same test data on any system. -void mtsrand(size_t iSeed) -{ - g_aiMT[0] = iSeed; - for (size_t i = 1; i < MT_SIZE; i++) - { - size_t inner1 = g_aiMT[i - 1]; - size_t inner2 = (g_aiMT[i - 1] >> 30); - size_t inner = inner1 ^ inner2; - g_aiMT[i] = (0x6c078965 * inner) + i; - } - - g_iMTI = 0; -} - -size_t mtrand() -{ - if (g_iMTI == 0) - { - for (size_t i = 0; i < MT_SIZE; i++) - { - size_t y = (0x80000000 & (g_aiMT[i])) + (0x7fffffff & (g_aiMT[(i + 1) % MT_SIZE])); - g_aiMT[i] = g_aiMT[(i + 397) % MT_SIZE] ^ (y >> 1); - if ((y % 2) == 1) - g_aiMT[i] = g_aiMT[i] ^ 0x9908b0df; - } - } - - size_t y = g_aiMT[g_iMTI]; - y = y ^ (y >> 11); - y = y ^ ((y << 7) & (0x9d2c5680)); - y = y ^ ((y << 15) & (0xefc60000)); - y = y ^ (y >> 18); - - g_iMTI = (g_iMTI + 1) % MT_SIZE; - - return y; -} - - -inline float mtfrand() -{ - const int ninenine = 999999; - return (float)(mtrand() % ninenine)/ninenine; -} - -static void resizer(int argc, char **argv) -{ - unsigned char* input_pixels; - unsigned char* output_pixels; - int w, h; - int n; - int out_w, out_h; - input_pixels = stbi_load(argv[1], &w, &h, &n, 0); - out_w = w*3; - out_h = h*3; - output_pixels = (unsigned char*) malloc(out_w*out_h*n); - //stbir_resize_uint8_srgb(input_pixels, w, h, 0, output_pixels, out_w, out_h, 0, n, -1,0); - stbir_resize_uint8(input_pixels, w, h, 0, output_pixels, out_w, out_h, 0, n); - stbi_write_png("output.png", out_w, out_h, n, output_pixels, 0); - exit(0); -} - -static void performance(int argc, char **argv) -{ - unsigned char* input_pixels; - unsigned char* output_pixels; - int w, h, count; - int n, i; - int out_w, out_h, srgb=1; - input_pixels = stbi_load(argv[1], &w, &h, &n, 0); - #if 0 - out_w = w/4; out_h = h/4; count=100; // 1 - #elif 0 - out_w = w*2; out_h = h/4; count=20; // 2 // note this is structured pessimily, would be much faster to downsample vertically first - #elif 0 - out_w = w/4; out_h = h*2; count=50; // 3 - #elif 0 - out_w = w*3; out_h = h*3; count=2; srgb=0; // 4 - #else - out_w = w*3; out_h = h*3; count=2; // 5 // this is dominated by linear->sRGB conversion - #endif - - output_pixels = (unsigned char*) malloc(out_w*out_h*n); - for (i=0; i < count; ++i) - if (srgb) - stbir_resize_uint8_srgb(input_pixels, w, h, 0, output_pixels, out_w, out_h, 0, n,-1,0); - else - stbir_resize(input_pixels, w, h, 0, output_pixels, out_w, out_h, 0, STBIR_TYPE_UINT8, n,-1, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, STBIR_COLORSPACE_LINEAR, NULL); - exit(0); -} - -void test_suite(int argc, char **argv); - -int main(int argc, char** argv) -{ - //resizer(argc, argv); - //performance(argc, argv); - - test_suite(argc, argv); - return 0; -} - -void resize_image(const char* filename, float width_percent, float height_percent, stbir_filter filter, stbir_edge edge, stbir_colorspace colorspace, const char* output_filename) -{ - int w, h, n; - - unsigned char* input_data = stbi_load(filename, &w, &h, &n, 0); - if (!input_data) - { - printf("Input image could not be loaded\n"); - return; - } - - int out_w = (int)(w * width_percent); - int out_h = (int)(h * height_percent); - - unsigned char* output_data = (unsigned char*)malloc(out_w * out_h * n); - - stbir_resize(input_data, w, h, 0, output_data, out_w, out_h, 0, STBIR_TYPE_UINT8, n, STBIR_ALPHA_CHANNEL_NONE, 0, edge, edge, filter, filter, colorspace, &g_context); - - stbi_image_free(input_data); - - stbi_write_png(output_filename, out_w, out_h, n, output_data, 0); - - free(output_data); -} - -template -void convert_image(const F* input, T* output, int length) -{ - double f = (pow(2.0, 8.0 * sizeof(T)) - 1) / (pow(2.0, 8.0 * sizeof(F)) - 1); - for (int i = 0; i < length; i++) - output[i] = (T)(((double)input[i]) * f); -} - -template -void test_format(const char* file, float width_percent, float height_percent, stbir_datatype type, stbir_colorspace colorspace) -{ - int w, h, n; - unsigned char* input_data = stbi_load(file, &w, &h, &n, 0); - - if (input_data == NULL) - return; - - - int new_w = (int)(w * width_percent); - int new_h = (int)(h * height_percent); - - T* T_data = (T*)malloc(w * h * n * sizeof(T)); - memset(T_data, 0, w*h*n*sizeof(T)); - convert_image(input_data, T_data, w * h * n); - - T* output_data = (T*)malloc(new_w * new_h * n * sizeof(T)); - - stbir_resize(T_data, w, h, 0, output_data, new_w, new_h, 0, type, n, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, colorspace, &g_context); - - free(T_data); - stbi_image_free(input_data); - - unsigned char* char_data = (unsigned char*)malloc(new_w * new_h * n * sizeof(char)); - convert_image(output_data, char_data, new_w * new_h * n); - - char output[200]; - sprintf(output, "test-output/type-%d-%d-%d-%d-%s", type, colorspace, new_w, new_h, file); - stbi_write_png(output, new_w, new_h, n, char_data, 0); - - free(char_data); - free(output_data); -} - -void convert_image_float(const unsigned char* input, float* output, int length) -{ - for (int i = 0; i < length; i++) - output[i] = ((float)input[i])/255; -} - -void convert_image_float(const float* input, unsigned char* output, int length) -{ - for (int i = 0; i < length; i++) - output[i] = (unsigned char)(stbir__saturate(input[i]) * 255); -} - -void test_float(const char* file, float width_percent, float height_percent, stbir_datatype type, stbir_colorspace colorspace) -{ - int w, h, n; - unsigned char* input_data = stbi_load(file, &w, &h, &n, 0); - - if (input_data == NULL) - return; - - int new_w = (int)(w * width_percent); - int new_h = (int)(h * height_percent); - - float* T_data = (float*)malloc(w * h * n * sizeof(float)); - convert_image_float(input_data, T_data, w * h * n); - - float* output_data = (float*)malloc(new_w * new_h * n * sizeof(float)); - - stbir_resize_float_generic(T_data, w, h, 0, output_data, new_w, new_h, 0, n, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, colorspace, &g_context); - - free(T_data); - stbi_image_free(input_data); - - unsigned char* char_data = (unsigned char*)malloc(new_w * new_h * n * sizeof(char)); - convert_image_float(output_data, char_data, new_w * new_h * n); - - char output[200]; - sprintf(output, "test-output/type-%d-%d-%d-%d-%s", type, colorspace, new_w, new_h, file); - stbi_write_png(output, new_w, new_h, n, char_data, 0); - - free(char_data); - free(output_data); -} - -void test_channels(const char* file, float width_percent, float height_percent, int channels) -{ - int w, h, n; - unsigned char* input_data = stbi_load(file, &w, &h, &n, 0); - - if (input_data == NULL) - return; - - int new_w = (int)(w * width_percent); - int new_h = (int)(h * height_percent); - - unsigned char* channels_data = (unsigned char*)malloc(w * h * channels * sizeof(unsigned char)); - - for (int i = 0; i < w * h; i++) - { - int input_position = i * n; - int output_position = i * channels; - - for (int c = 0; c < channels; c++) - channels_data[output_position + c] = input_data[input_position + stbir__min(c, n)]; - } - - unsigned char* output_data = (unsigned char*)malloc(new_w * new_h * channels * sizeof(unsigned char)); - - stbir_resize_uint8_srgb(channels_data, w, h, 0, output_data, new_w, new_h, 0, channels, STBIR_ALPHA_CHANNEL_NONE, 0); - - free(channels_data); - stbi_image_free(input_data); - - char output[200]; - sprintf(output, "test-output/channels-%d-%d-%d-%s", channels, new_w, new_h, file); - stbi_write_png(output, new_w, new_h, channels, output_data, 0); - - free(output_data); -} - -void test_subpixel(const char* file, float width_percent, float height_percent, float s1, float t1) -{ - int w, h, n; - unsigned char* input_data = stbi_load(file, &w, &h, &n, 0); - - if (input_data == NULL) - return; - - s1 = ((float)w - 1 + s1)/w; - t1 = ((float)h - 1 + t1)/h; - - int new_w = (int)(w * width_percent); - int new_h = (int)(h * height_percent); - - unsigned char* output_data = (unsigned char*)malloc(new_w * new_h * n * sizeof(unsigned char)); - - stbir_resize_region(input_data, w, h, 0, output_data, new_w, new_h, 0, STBIR_TYPE_UINT8, n, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, 0, 0, s1, t1); - - stbi_image_free(input_data); - - char output[200]; - sprintf(output, "test-output/subpixel-%d-%d-%f-%f-%s", new_w, new_h, s1, t1, file); - stbi_write_png(output, new_w, new_h, n, output_data, 0); - - free(output_data); -} - -void test_subpixel_region(const char* file, float width_percent, float height_percent, float s0, float t0, float s1, float t1) -{ - int w, h, n; - unsigned char* input_data = stbi_load(file, &w, &h, &n, 0); - - if (input_data == NULL) - return; - - int new_w = (int)(w * width_percent); - int new_h = (int)(h * height_percent); - - unsigned char* output_data = (unsigned char*)malloc(new_w * new_h * n * sizeof(unsigned char)); - - stbir_resize_region(input_data, w, h, 0, output_data, new_w, new_h, 0, STBIR_TYPE_UINT8, n, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, s0, t0, s1, t1); - - stbi_image_free(input_data); - - char output[200]; - sprintf(output, "test-output/subpixel-region-%d-%d-%f-%f-%f-%f-%s", new_w, new_h, s0, t0, s1, t1, file); - stbi_write_png(output, new_w, new_h, n, output_data, 0); - - free(output_data); -} - -void test_subpixel_command(const char* file, float width_percent, float height_percent, float x_scale, float y_scale, float x_offset, float y_offset) -{ - int w, h, n; - unsigned char* input_data = stbi_load(file, &w, &h, &n, 0); - - if (input_data == NULL) - return; - - int new_w = (int)(w * width_percent); - int new_h = (int)(h * height_percent); - - unsigned char* output_data = (unsigned char*)malloc(new_w * new_h * n * sizeof(unsigned char)); - - stbir_resize_subpixel(input_data, w, h, 0, output_data, new_w, new_h, 0, STBIR_TYPE_UINT8, n, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, x_scale, y_scale, x_offset, y_offset); - - stbi_image_free(input_data); - - char output[200]; - sprintf(output, "test-output/subpixel-command-%d-%d-%f-%f-%f-%f-%s", new_w, new_h, x_scale, y_scale, x_offset, y_offset, file); - stbi_write_png(output, new_w, new_h, n, output_data, 0); - - free(output_data); -} - -unsigned int* pixel(unsigned int* buffer, int x, int y, int c, int w, int n) -{ - return &buffer[y*w*n + x*n + c]; -} - -void test_premul() -{ - unsigned int input[2 * 2 * 4]; - unsigned int output[1 * 1 * 4]; - unsigned int output2[2 * 2 * 4]; - - memset(input, 0, sizeof(input)); - - // First a test to make sure premul is working properly. - - // Top left - solid red - *pixel(input, 0, 0, 0, 2, 4) = 255; - *pixel(input, 0, 0, 3, 2, 4) = 255; - - // Bottom left - solid red - *pixel(input, 0, 1, 0, 2, 4) = 255; - *pixel(input, 0, 1, 3, 2, 4) = 255; - - // Top right - transparent green - *pixel(input, 1, 0, 1, 2, 4) = 255; - *pixel(input, 1, 0, 3, 2, 4) = 25; - - // Bottom right - transparent green - *pixel(input, 1, 1, 1, 2, 4) = 255; - *pixel(input, 1, 1, 3, 2, 4) = 25; - - stbir_resize(input, 2, 2, 0, output, 1, 1, 0, STBIR_TYPE_UINT32, 4, 3, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_BOX, STBIR_COLORSPACE_LINEAR, &g_context); - - float r = (float)255 / 4294967296; - float g = (float)255 / 4294967296; - float ra = (float)255 / 4294967296; - float ga = (float)25 / 4294967296; - float a = (ra + ga) / 2; - - STBIR_ASSERT(output[0] == (unsigned int)(r * ra / 2 / a * 4294967296 + 0.5f)); // 232 - STBIR_ASSERT(output[1] == (unsigned int)(g * ga / 2 / a * 4294967296 + 0.5f)); // 23 - STBIR_ASSERT(output[2] == 0); - STBIR_ASSERT(output[3] == (unsigned int)(a * 4294967296 + 0.5f)); // 140 - - // Now a test to make sure it doesn't clobber existing values. - - // Top right - completely transparent green - *pixel(input, 1, 0, 1, 2, 4) = 255; - *pixel(input, 1, 0, 3, 2, 4) = 0; - - // Bottom right - completely transparent green - *pixel(input, 1, 1, 1, 2, 4) = 255; - *pixel(input, 1, 1, 3, 2, 4) = 0; - - stbir_resize(input, 2, 2, 0, output2, 2, 2, 0, STBIR_TYPE_UINT32, 4, 3, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_BOX, STBIR_COLORSPACE_LINEAR, &g_context); - - STBIR_ASSERT(*pixel(output2, 0, 0, 0, 2, 4) == 255); - STBIR_ASSERT(*pixel(output2, 0, 0, 1, 2, 4) == 0); - STBIR_ASSERT(*pixel(output2, 0, 0, 2, 2, 4) == 0); - STBIR_ASSERT(*pixel(output2, 0, 0, 3, 2, 4) == 255); - - STBIR_ASSERT(*pixel(output2, 0, 1, 0, 2, 4) == 255); - STBIR_ASSERT(*pixel(output2, 0, 1, 1, 2, 4) == 0); - STBIR_ASSERT(*pixel(output2, 0, 1, 2, 2, 4) == 0); - STBIR_ASSERT(*pixel(output2, 0, 1, 3, 2, 4) == 255); - - STBIR_ASSERT(*pixel(output2, 1, 0, 0, 2, 4) == 0); - STBIR_ASSERT(*pixel(output2, 1, 0, 1, 2, 4) == 255); - STBIR_ASSERT(*pixel(output2, 1, 0, 2, 2, 4) == 0); - STBIR_ASSERT(*pixel(output2, 1, 0, 3, 2, 4) == 0); - - STBIR_ASSERT(*pixel(output2, 1, 1, 0, 2, 4) == 0); - STBIR_ASSERT(*pixel(output2, 1, 1, 1, 2, 4) == 255); - STBIR_ASSERT(*pixel(output2, 1, 1, 2, 2, 4) == 0); - STBIR_ASSERT(*pixel(output2, 1, 1, 3, 2, 4) == 0); -} - -// test that splitting a pow-2 image into tiles produces identical results -void test_subpixel_1() -{ - unsigned char image[8 * 8]; - - mtsrand(0); - - for (int i = 0; i < sizeof(image); i++) - image[i] = mtrand() & 255; - - unsigned char output_data[16 * 16]; - - stbir_resize_region(image, 8, 8, 0, output_data, 16, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, 0, 0, 1, 1); - - unsigned char output_left[8 * 16]; - unsigned char output_right[8 * 16]; - - stbir_resize_region(image, 8, 8, 0, output_left, 8, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, 0, 0, 0.5f, 1); - stbir_resize_region(image, 8, 8, 0, output_right, 8, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, 0.5f, 0, 1, 1); - - for (int x = 0; x < 8; x++) - { - for (int y = 0; y < 16; y++) - { - STBIR_ASSERT(output_data[y * 16 + x] == output_left[y * 8 + x]); - STBIR_ASSERT(output_data[y * 16 + x + 8] == output_right[y * 8 + x]); - } - } - - stbir_resize_subpixel(image, 8, 8, 0, output_left, 8, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, 2, 2, 0, 0); - stbir_resize_subpixel(image, 8, 8, 0, output_right, 8, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, 2, 2, 8, 0); - - {for (int x = 0; x < 8; x++) - { - for (int y = 0; y < 16; y++) - { - STBIR_ASSERT(output_data[y * 16 + x] == output_left[y * 8 + x]); - STBIR_ASSERT(output_data[y * 16 + x + 8] == output_right[y * 8 + x]); - } - }} -} - -// test that replicating an image and using a subtile of it produces same results as wraparound -void test_subpixel_2() -{ - unsigned char image[8 * 8]; - - mtsrand(0); - - for (int i = 0; i < sizeof(image); i++) - image[i] = mtrand() & 255; - - unsigned char large_image[32 * 32]; - - for (int x = 0; x < 8; x++) - { - for (int y = 0; y < 8; y++) - { - for (int i = 0; i < 4; i++) - { - for (int j = 0; j < 4; j++) - large_image[j*4*8*8 + i*8 + y*4*8 + x] = image[y*8 + x]; - } - } - } - - unsigned char output_data_1[16 * 16]; - unsigned char output_data_2[16 * 16]; - - stbir_resize(image, 8, 8, 0, output_data_1, 16, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_WRAP, STBIR_EDGE_WRAP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context); - stbir_resize_region(large_image, 32, 32, 0, output_data_2, 16, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_WRAP, STBIR_EDGE_WRAP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, 0.25f, 0.25f, 0.5f, 0.5f); - - {for (int x = 0; x < 16; x++) - { - for (int y = 0; y < 16; y++) - STBIR_ASSERT(output_data_1[y * 16 + x] == output_data_2[y * 16 + x]); - }} - - stbir_resize_subpixel(large_image, 32, 32, 0, output_data_2, 16, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_WRAP, STBIR_EDGE_WRAP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, 2, 2, 16, 16); - - {for (int x = 0; x < 16; x++) - { - for (int y = 0; y < 16; y++) - STBIR_ASSERT(output_data_1[y * 16 + x] == output_data_2[y * 16 + x]); - }} -} - -// test that 0,0,1,1 subpixel produces same result as no-rect -void test_subpixel_3() -{ - unsigned char image[8 * 8]; - - mtsrand(0); - - for (int i = 0; i < sizeof(image); i++) - image[i] = mtrand() & 255; - - unsigned char output_data_1[32 * 32]; - unsigned char output_data_2[32 * 32]; - - stbir_resize_region(image, 8, 8, 0, output_data_1, 32, 32, 0, STBIR_TYPE_UINT8, 1, 0, STBIR_ALPHA_CHANNEL_NONE, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_LINEAR, NULL, 0, 0, 1, 1); - stbir_resize_uint8(image, 8, 8, 0, output_data_2, 32, 32, 0, 1); - - for (int x = 0; x < 32; x++) - { - for (int y = 0; y < 32; y++) - STBIR_ASSERT(output_data_1[y * 32 + x] == output_data_2[y * 32 + x]); - } - - stbir_resize_subpixel(image, 8, 8, 0, output_data_1, 32, 32, 0, STBIR_TYPE_UINT8, 1, 0, STBIR_ALPHA_CHANNEL_NONE, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_LINEAR, NULL, 4, 4, 0, 0); - - {for (int x = 0; x < 32; x++) - { - for (int y = 0; y < 32; y++) - STBIR_ASSERT(output_data_1[y * 32 + x] == output_data_2[y * 32 + x]); - }} -} - -// test that 1:1 resample using s,t=0,0,1,1 with bilinear produces original image -void test_subpixel_4() -{ - unsigned char image[8 * 8]; - - mtsrand(0); - - for (int i = 0; i < sizeof(image); i++) - image[i] = mtrand() & 255; - - unsigned char output[8 * 8]; - - stbir_resize_region(image, 8, 8, 0, output, 8, 8, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_TRIANGLE, STBIR_FILTER_TRIANGLE, STBIR_COLORSPACE_LINEAR, &g_context, 0, 0, 1, 1); - STBIR_ASSERT(memcmp(image, output, 8 * 8) == 0); - - stbir_resize_subpixel(image, 8, 8, 0, output, 8, 8, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_TRIANGLE, STBIR_FILTER_TRIANGLE, STBIR_COLORSPACE_LINEAR, &g_context, 1, 1, 0, 0); - STBIR_ASSERT(memcmp(image, output, 8 * 8) == 0); -} - -static unsigned int image88_int[8][8]; -static unsigned char image88 [8][8]; -static unsigned char output88[8][8]; -static unsigned char output44[4][4]; -static unsigned char output22[2][2]; -static unsigned char output11[1][1]; - -void resample_88(stbir_filter filter) -{ - stbir_resize_uint8_generic(image88[0],8,8,0, output88[0],8,8,0, 1,-1,0, STBIR_EDGE_CLAMP, filter, STBIR_COLORSPACE_LINEAR, NULL); - stbir_resize_uint8_generic(image88[0],8,8,0, output44[0],4,4,0, 1,-1,0, STBIR_EDGE_CLAMP, filter, STBIR_COLORSPACE_LINEAR, NULL); - stbir_resize_uint8_generic(image88[0],8,8,0, output22[0],2,2,0, 1,-1,0, STBIR_EDGE_CLAMP, filter, STBIR_COLORSPACE_LINEAR, NULL); - stbir_resize_uint8_generic(image88[0],8,8,0, output11[0],1,1,0, 1,-1,0, STBIR_EDGE_CLAMP, filter, STBIR_COLORSPACE_LINEAR, NULL); -} - -void verify_box(void) -{ - int i,j,t; - - resample_88(STBIR_FILTER_BOX); - - for (i=0; i < sizeof(image88); ++i) - STBIR_ASSERT(image88[0][i] == output88[0][i]); - - t = 0; - for (j=0; j < 4; ++j) - for (i=0; i < 4; ++i) { - int n = image88[j*2+0][i*2+0] - + image88[j*2+0][i*2+1] - + image88[j*2+1][i*2+0] - + image88[j*2+1][i*2+1]; - STBIR_ASSERT(output44[j][i] == ((n+2)>>2) || output44[j][i] == ((n+1)>>2)); // can't guarantee exact rounding due to numerical precision - t += n; - } - STBIR_ASSERT(output11[0][0] == ((t+32)>>6) || output11[0][0] == ((t+31)>>6)); // can't guarantee exact rounding due to numerical precision -} - -void verify_filter_normalized(stbir_filter filter, int output_size, unsigned int value) -{ - int i, j; - unsigned int output[64]; - - stbir_resize(image88_int[0], 8, 8, 0, output, output_size, output_size, 0, STBIR_TYPE_UINT32, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, filter, filter, STBIR_COLORSPACE_LINEAR, NULL); - - for (j = 0; j < output_size; ++j) - for (i = 0; i < output_size; ++i) - STBIR_ASSERT(value == output[j*output_size + i]); -} - -float round2(float f) -{ - return (float) floor(f+0.5f); // round() isn't C standard pre-C99 -} - -void test_filters(void) -{ - int i,j; - - mtsrand(0); - - for (i=0; i < sizeof(image88); ++i) - image88[0][i] = mtrand() & 255; - verify_box(); - - for (i=0; i < sizeof(image88); ++i) - image88[0][i] = 0; - image88[4][4] = 255; - verify_box(); - - for (j=0; j < 8; ++j) - for (i=0; i < 8; ++i) - image88[j][i] = (j^i)&1 ? 255 : 0; - verify_box(); - - for (j=0; j < 8; ++j) - for (i=0; i < 8; ++i) - image88[j][i] = i&2 ? 255 : 0; - verify_box(); - - int value = 64; - - for (j = 0; j < 8; ++j) - for (i = 0; i < 8; ++i) - image88_int[j][i] = value; - - verify_filter_normalized(STBIR_FILTER_BOX, 8, value); - verify_filter_normalized(STBIR_FILTER_TRIANGLE, 8, value); - verify_filter_normalized(STBIR_FILTER_CUBICBSPLINE, 8, value); - verify_filter_normalized(STBIR_FILTER_CATMULLROM, 8, value); - verify_filter_normalized(STBIR_FILTER_MITCHELL, 8, value); - - verify_filter_normalized(STBIR_FILTER_BOX, 4, value); - verify_filter_normalized(STBIR_FILTER_TRIANGLE, 4, value); - verify_filter_normalized(STBIR_FILTER_CUBICBSPLINE, 4, value); - verify_filter_normalized(STBIR_FILTER_CATMULLROM, 4, value); - verify_filter_normalized(STBIR_FILTER_MITCHELL, 4, value); - - verify_filter_normalized(STBIR_FILTER_BOX, 2, value); - verify_filter_normalized(STBIR_FILTER_TRIANGLE, 2, value); - verify_filter_normalized(STBIR_FILTER_CUBICBSPLINE, 2, value); - verify_filter_normalized(STBIR_FILTER_CATMULLROM, 2, value); - verify_filter_normalized(STBIR_FILTER_MITCHELL, 2, value); - - verify_filter_normalized(STBIR_FILTER_BOX, 1, value); - verify_filter_normalized(STBIR_FILTER_TRIANGLE, 1, value); - verify_filter_normalized(STBIR_FILTER_CUBICBSPLINE, 1, value); - verify_filter_normalized(STBIR_FILTER_CATMULLROM, 1, value); - verify_filter_normalized(STBIR_FILTER_MITCHELL, 1, value); - - { - // This test is designed to produce coefficients that are very badly denormalized. - unsigned int v = 556; - - unsigned int input[100 * 100]; - unsigned int output[11 * 11]; - - for (j = 0; j < 100 * 100; ++j) - input[j] = v; - - stbir_resize(input, 100, 100, 0, output, 11, 11, 0, STBIR_TYPE_UINT32, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_TRIANGLE, STBIR_FILTER_TRIANGLE, STBIR_COLORSPACE_LINEAR, NULL); - - for (j = 0; j < 11 * 11; ++j) - STBIR_ASSERT(v == output[j]); - } - - { - // Now test the trapezoid filter for downsampling. - unsigned int input[3 * 1]; - unsigned int output[2 * 1]; - - input[0] = 0; - input[1] = 255; - input[2] = 127; - - stbir_resize(input, 3, 1, 0, output, 2, 1, 0, STBIR_TYPE_UINT32, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_BOX, STBIR_COLORSPACE_LINEAR, NULL); - - STBIR_ASSERT(output[0] == (unsigned int)round2((float)(input[0] * 2 + input[1]) / 3)); - STBIR_ASSERT(output[1] == (unsigned int)round2((float)(input[2] * 2 + input[1]) / 3)); - - stbir_resize(input, 1, 3, 0, output, 1, 2, 0, STBIR_TYPE_UINT32, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_BOX, STBIR_COLORSPACE_LINEAR, NULL); - - STBIR_ASSERT(output[0] == (unsigned int)round2((float)(input[0] * 2 + input[1]) / 3)); - STBIR_ASSERT(output[1] == (unsigned int)round2((float)(input[2] * 2 + input[1]) / 3)); - } - - { - // Now test the trapezoid filter for upsampling. - unsigned int input[2 * 1]; - unsigned int output[3 * 1]; - - input[0] = 0; - input[1] = 255; - - stbir_resize(input, 2, 1, 0, output, 3, 1, 0, STBIR_TYPE_UINT32, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_BOX, STBIR_COLORSPACE_LINEAR, NULL); - - STBIR_ASSERT(output[0] == input[0]); - STBIR_ASSERT(output[1] == (input[0] + input[1]) / 2); - STBIR_ASSERT(output[2] == input[1]); - - stbir_resize(input, 1, 2, 0, output, 1, 3, 0, STBIR_TYPE_UINT32, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_BOX, STBIR_COLORSPACE_LINEAR, NULL); - - STBIR_ASSERT(output[0] == input[0]); - STBIR_ASSERT(output[1] == (input[0] + input[1]) / 2); - STBIR_ASSERT(output[2] == input[1]); - } - - // checkerboard - { - unsigned char input[64][64]; - unsigned char output[16][16]; - int i,j; - for (j=0; j < 64; ++j) - for (i=0; i < 64; ++i) - input[j][i] = (i^j)&1 ? 255 : 0; - stbir_resize_uint8_generic(input[0], 64, 64, 0, output[0],16,16,0, 1,-1,0,STBIR_EDGE_WRAP,STBIR_FILTER_DEFAULT,STBIR_COLORSPACE_LINEAR,0); - for (j=0; j < 16; ++j) - for (i=0; i < 16; ++i) - STBIR_ASSERT(output[j][i] == 128); - stbir_resize_uint8_srgb_edgemode(input[0], 64, 64, 0, output[0],16,16,0, 1,-1,0,STBIR_EDGE_WRAP); - for (j=0; j < 16; ++j) - for (i=0; i < 16; ++i) - STBIR_ASSERT(output[j][i] == 188); - - - } - - { - // Test trapezoid box filter - unsigned char input[2 * 1]; - unsigned char output[127 * 1]; - - input[0] = 0; - input[1] = 255; - - stbir_resize(input, 2, 1, 0, output, 127, 1, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_BOX, STBIR_COLORSPACE_LINEAR, NULL); - STBIR_ASSERT(output[0] == 0); - STBIR_ASSERT(output[127 / 2 - 1] == 0); - STBIR_ASSERT(output[127 / 2] == 128); - STBIR_ASSERT(output[127 / 2 + 1] == 255); - STBIR_ASSERT(output[126] == 255); - stbi_write_png("test-output/trapezoid-upsample-horizontal.png", 127, 1, 1, output, 0); - - stbir_resize(input, 1, 2, 0, output, 1, 127, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_BOX, STBIR_COLORSPACE_LINEAR, NULL); - STBIR_ASSERT(output[0] == 0); - STBIR_ASSERT(output[127 / 2 - 1] == 0); - STBIR_ASSERT(output[127 / 2] == 128); - STBIR_ASSERT(output[127 / 2 + 1] == 255); - STBIR_ASSERT(output[126] == 255); - stbi_write_png("test-output/trapezoid-upsample-vertical.png", 1, 127, 1, output, 0); - } -} - -#define UMAX32 4294967295U - -static void write32(const char *filename, stbir_uint32 *output, int w, int h) -{ - stbir_uint8 *data = (stbir_uint8*) malloc(w*h*3); - for (int i=0; i < w*h*3; ++i) - data[i] = output[i]>>24; - stbi_write_png(filename, w, h, 3, data, 0); - free(data); -} - -static void test_32(void) -{ - int w=100,h=120,x,y, out_w,out_h; - stbir_uint32 *input = (stbir_uint32*) malloc(4 * 3 * w * h); - stbir_uint32 *output = (stbir_uint32*) malloc(4 * 3 * 3*w * 3*h); - for (y=0; y < h; ++y) { - for (x=0; x < w; ++x) { - input[y*3*w + x*3 + 0] = x * ( UMAX32/w ); - input[y*3*w + x*3 + 1] = y * ( UMAX32/h ); - input[y*3*w + x*3 + 2] = UMAX32/2; - } - } - out_w = w*33/16; - out_h = h*33/16; - stbir_resize(input,w,h,0,output,out_w,out_h,0,STBIR_TYPE_UINT32,3,-1,0,STBIR_EDGE_CLAMP,STBIR_EDGE_CLAMP,STBIR_FILTER_DEFAULT,STBIR_FILTER_DEFAULT,STBIR_COLORSPACE_LINEAR,NULL); - write32("test-output/seantest_1.png", output,out_w,out_h); - - out_w = w*16/33; - out_h = h*16/33; - stbir_resize(input,w,h,0,output,out_w,out_h,0,STBIR_TYPE_UINT32,3,-1,0,STBIR_EDGE_CLAMP,STBIR_EDGE_CLAMP,STBIR_FILTER_DEFAULT,STBIR_FILTER_DEFAULT,STBIR_COLORSPACE_LINEAR,NULL); - write32("test-output/seantest_2.png", output,out_w,out_h); -} - - -void test_suite(int argc, char **argv) -{ - int i; - const char *barbara; - - mkdir("test-output", 777); - - if (argc > 1) - barbara = argv[1]; - else - barbara = "barbara.png"; - - // check what cases we need normalization for -#if 1 - { - float x, y; - for (x = -1; x < 1; x += 0.05f) { - float sums[5] = { 0 }; - float o; - for (o = -5; o <= 5; ++o) { - sums[0] += stbir__filter_mitchell(x + o, 1); - sums[1] += stbir__filter_catmullrom(x + o, 1); - sums[2] += stbir__filter_cubic(x + o, 1); - sums[3] += stbir__filter_triangle(x + o, 1); - sums[4] += stbir__filter_trapezoid(x + o, 0.5f); - } - for (i = 0; i < 5; ++i) - STBIR_ASSERT(sums[i] >= 1.0 - 0.001 && sums[i] <= 1.0 + 0.001); - } - -#if 1 - for (y = 0.11f; y < 1; y += 0.01f) { // Step - for (x = -1; x < 1; x += 0.05f) { // Phase - float sums[5] = { 0 }; - float o; - for (o = -5; o <= 5; o += y) { - sums[0] += y * stbir__filter_mitchell(x + o, 1); - sums[1] += y * stbir__filter_catmullrom(x + o, 1); - sums[2] += y * stbir__filter_cubic(x + o, 1); - sums[4] += y * stbir__filter_trapezoid(x + o, 0.5f); - sums[3] += y * stbir__filter_triangle(x + o, 1); - } - for (i = 0; i < 3; ++i) - STBIR_ASSERT(sums[i] >= 1.0 - 0.0170 && sums[i] <= 1.0 + 0.0170); - } - } -#endif - } -#endif - -#if 0 // linear_to_srgb_uchar table - for (i=0; i < 256; ++i) { - float f = stbir__srgb_to_linear((i-0.5f)/255.0f); - printf("%9d, ", (int) ((f) * (1<<28))); - if ((i & 7) == 7) - printf("\n"); - } -#endif - - // old tests that hacky fix worked on - test that - // every uint8 maps to itself - for (i = 0; i < 256; i++) { - float f = stbir__srgb_to_linear(float(i) / 255); - int n = stbir__linear_to_srgb_uchar(f); - STBIR_ASSERT(n == i); - } - - // new tests that hacky fix failed for - test that - // values adjacent to uint8 round to nearest uint8 - for (i = 0; i < 256; i++) { - for (float y = -0.42f; y <= 0.42f; y += 0.01f) { - float f = stbir__srgb_to_linear((i+y) / 255.0f); - int n = stbir__linear_to_srgb_uchar(f); - STBIR_ASSERT(n == i); - } - } - - test_filters(); - - test_subpixel_1(); - test_subpixel_2(); - test_subpixel_3(); - test_subpixel_4(); - - test_premul(); - - test_32(); - - // Some tests to make sure errors don't pop up with strange filter/dimension combinations. - stbir_resize(image88, 8, 8, 0, output88, 4, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context); - stbir_resize(image88, 8, 8, 0, output88, 4, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_BOX, STBIR_COLORSPACE_SRGB, &g_context); - stbir_resize(image88, 8, 8, 0, output88, 16, 4, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context); - stbir_resize(image88, 8, 8, 0, output88, 16, 4, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_BOX, STBIR_COLORSPACE_SRGB, &g_context); - - int barbara_width, barbara_height, barbara_channels; - stbi_image_free(stbi_load(barbara, &barbara_width, &barbara_height, &barbara_channels, 0)); - - int res = 10; - // Downscaling - {for (int i = 0; i <= res; i++) - { - float t = (float)i/res; - float scale = 0.5; - float out_scale = 2.0f/3; - float x_shift = (barbara_width*out_scale - barbara_width*scale) * t; - float y_shift = (barbara_height*out_scale - barbara_height*scale) * t; - - test_subpixel_command(barbara, scale, scale, out_scale, out_scale, x_shift, y_shift); - }} - - // Upscaling - {for (int i = 0; i <= res; i++) - { - float t = (float)i/res; - float scale = 2; - float out_scale = 3; - float x_shift = (barbara_width*out_scale - barbara_width*scale) * t; - float y_shift = (barbara_height*out_scale - barbara_height*scale) * t; - - test_subpixel_command(barbara, scale, scale, out_scale, out_scale, x_shift, y_shift); - }} - - // Downscaling - {for (int i = 0; i <= res; i++) - { - float t = (float)i/res / 2; - test_subpixel_region(barbara, 0.25f, 0.25f, t, t, t+0.5f, t+0.5f); - }} - - // No scaling - {for (int i = 0; i <= res; i++) - { - float t = (float)i/res / 2; - test_subpixel_region(barbara, 0.5f, 0.5f, t, t, t+0.5f, t+0.5f); - }} - - // Upscaling - {for (int i = 0; i <= res; i++) - { - float t = (float)i/res / 2; - test_subpixel_region(barbara, 1, 1, t, t, t+0.5f, t+0.5f); - }} - - {for (i = 0; i < 10; i++) - test_subpixel(barbara, 0.5f, 0.5f, (float)i / 10, 1); - } - - {for (i = 0; i < 10; i++) - test_subpixel(barbara, 0.5f, 0.5f, 1, (float)i / 10); - } - - {for (i = 0; i < 10; i++) - test_subpixel(barbara, 2, 2, (float)i / 10, 1); - } - - {for (i = 0; i < 10; i++) - test_subpixel(barbara, 2, 2, 1, (float)i / 10); - } - - // Channels test - test_channels(barbara, 0.5f, 0.5f, 1); - test_channels(barbara, 0.5f, 0.5f, 2); - test_channels(barbara, 0.5f, 0.5f, 3); - test_channels(barbara, 0.5f, 0.5f, 4); - - test_channels(barbara, 2, 2, 1); - test_channels(barbara, 2, 2, 2); - test_channels(barbara, 2, 2, 3); - test_channels(barbara, 2, 2, 4); - - // filter tests - resize_image(barbara, 2, 2, STBIR_FILTER_BOX , STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-upsample-nearest.png"); - resize_image(barbara, 2, 2, STBIR_FILTER_TRIANGLE , STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-upsample-bilinear.png"); - resize_image(barbara, 2, 2, STBIR_FILTER_CUBICBSPLINE, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-upsample-bicubic.png"); - resize_image(barbara, 2, 2, STBIR_FILTER_CATMULLROM , STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-upsample-catmullrom.png"); - resize_image(barbara, 2, 2, STBIR_FILTER_MITCHELL , STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-upsample-mitchell.png"); - - resize_image(barbara, 0.5f, 0.5f, STBIR_FILTER_BOX , STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-downsample-nearest.png"); - resize_image(barbara, 0.5f, 0.5f, STBIR_FILTER_TRIANGLE , STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-downsample-bilinear.png"); - resize_image(barbara, 0.5f, 0.5f, STBIR_FILTER_CUBICBSPLINE, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-downsample-bicubic.png"); - resize_image(barbara, 0.5f, 0.5f, STBIR_FILTER_CATMULLROM , STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-downsample-catmullrom.png"); - resize_image(barbara, 0.5f, 0.5f, STBIR_FILTER_MITCHELL , STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-downsample-mitchell.png"); - - {for (i = 10; i < 100; i++) - { - char outname[200]; - sprintf(outname, "test-output/barbara-width-%d.jpg", i); - resize_image(barbara, (float)i / 100, 1, STBIR_FILTER_CATMULLROM, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, outname); - }} - - {for (i = 110; i < 500; i += 10) - { - char outname[200]; - sprintf(outname, "test-output/barbara-width-%d.jpg", i); - resize_image(barbara, (float)i / 100, 1, STBIR_FILTER_CATMULLROM, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, outname); - }} - - {for (i = 10; i < 100; i++) - { - char outname[200]; - sprintf(outname, "test-output/barbara-height-%d.jpg", i); - resize_image(barbara, 1, (float)i / 100, STBIR_FILTER_CATMULLROM, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, outname); - }} - - {for (i = 110; i < 500; i += 10) - { - char outname[200]; - sprintf(outname, "test-output/barbara-height-%d.jpg", i); - resize_image(barbara, 1, (float)i / 100, STBIR_FILTER_CATMULLROM, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, outname); - }} - - {for (i = 50; i < 200; i += 10) - { - char outname[200]; - sprintf(outname, "test-output/barbara-width-height-%d.jpg", i); - resize_image(barbara, 100 / (float)i, (float)i / 100, STBIR_FILTER_CATMULLROM, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, outname); - }} - - test_format(barbara, 0.5, 2.0, STBIR_TYPE_UINT16, STBIR_COLORSPACE_SRGB); - test_format(barbara, 0.5, 2.0, STBIR_TYPE_UINT16, STBIR_COLORSPACE_LINEAR); - test_format(barbara, 2.0, 0.5, STBIR_TYPE_UINT16, STBIR_COLORSPACE_SRGB); - test_format(barbara, 2.0, 0.5, STBIR_TYPE_UINT16, STBIR_COLORSPACE_LINEAR); - - test_format(barbara, 0.5, 2.0, STBIR_TYPE_UINT32, STBIR_COLORSPACE_SRGB); - test_format(barbara, 0.5, 2.0, STBIR_TYPE_UINT32, STBIR_COLORSPACE_LINEAR); - test_format(barbara, 2.0, 0.5, STBIR_TYPE_UINT32, STBIR_COLORSPACE_SRGB); - test_format(barbara, 2.0, 0.5, STBIR_TYPE_UINT32, STBIR_COLORSPACE_LINEAR); - - test_float(barbara, 0.5, 2.0, STBIR_TYPE_FLOAT, STBIR_COLORSPACE_SRGB); - test_float(barbara, 0.5, 2.0, STBIR_TYPE_FLOAT, STBIR_COLORSPACE_LINEAR); - test_float(barbara, 2.0, 0.5, STBIR_TYPE_FLOAT, STBIR_COLORSPACE_SRGB); - test_float(barbara, 2.0, 0.5, STBIR_TYPE_FLOAT, STBIR_COLORSPACE_LINEAR); - - // Edge behavior tests - resize_image("hgradient.png", 2, 2, STBIR_FILTER_CATMULLROM, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR, "test-output/hgradient-clamp.png"); - resize_image("hgradient.png", 2, 2, STBIR_FILTER_CATMULLROM, STBIR_EDGE_WRAP, STBIR_COLORSPACE_LINEAR, "test-output/hgradient-wrap.png"); - - resize_image("vgradient.png", 2, 2, STBIR_FILTER_CATMULLROM, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR, "test-output/vgradient-clamp.png"); - resize_image("vgradient.png", 2, 2, STBIR_FILTER_CATMULLROM, STBIR_EDGE_WRAP, STBIR_COLORSPACE_LINEAR, "test-output/vgradient-wrap.png"); - - resize_image("1px-border.png", 2, 2, STBIR_FILTER_CATMULLROM, STBIR_EDGE_REFLECT, STBIR_COLORSPACE_LINEAR, "test-output/1px-border-reflect.png"); - resize_image("1px-border.png", 2, 2, STBIR_FILTER_CATMULLROM, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR, "test-output/1px-border-clamp.png"); - - // sRGB tests - resize_image("gamma_colors.jpg", .5f, .5f, STBIR_FILTER_CATMULLROM, STBIR_EDGE_REFLECT, STBIR_COLORSPACE_SRGB, "test-output/gamma_colors.jpg"); - resize_image("gamma_2.2.jpg", .5f, .5f, STBIR_FILTER_CATMULLROM, STBIR_EDGE_REFLECT, STBIR_COLORSPACE_SRGB, "test-output/gamma_2.2.jpg"); - resize_image("gamma_dalai_lama_gray.jpg", .5f, .5f, STBIR_FILTER_CATMULLROM, STBIR_EDGE_REFLECT, STBIR_COLORSPACE_SRGB, "test-output/gamma_dalai_lama_gray.jpg"); -} diff --git a/third_party/stb/tests/resample_test_c.c b/third_party/stb/tests/resample_test_c.c deleted file mode 100644 index e7e353100a..0000000000 --- a/third_party/stb/tests/resample_test_c.c +++ /dev/null @@ -1,8 +0,0 @@ -#define STB_IMAGE_RESIZE_IMPLEMENTATION -#define STB_IMAGE_RESIZE_STATIC -#include "stb_image_resize.h" - -// Just to make sure it will build properly with a c compiler - -int main() { -} diff --git a/third_party/stb/tests/resize.dsp b/third_party/stb/tests/resize.dsp deleted file mode 100644 index 0aa1bbaf9c..0000000000 --- a/third_party/stb/tests/resize.dsp +++ /dev/null @@ -1,94 +0,0 @@ -# Microsoft Developer Studio Project File - Name="resize" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=resize - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "resize.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "resize.mak" CFG="resize - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "resize - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "resize - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "resize - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /W3 /GX /Z7 /O2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 - -!ELSEIF "$(CFG)" == "resize - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /WX /Gm /GX /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "resize - Win32 Release" -# Name "resize - Win32 Debug" -# Begin Source File - -SOURCE=.\resample_test.cpp -# End Source File -# Begin Source File - -SOURCE=..\stb_image_resize.h -# End Source File -# End Target -# End Project diff --git a/third_party/stb/tests/sdf/sdf_test.c b/third_party/stb/tests/sdf/sdf_test.c deleted file mode 100644 index d5b0ca0e37..0000000000 --- a/third_party/stb/tests/sdf/sdf_test.c +++ /dev/null @@ -1,152 +0,0 @@ -#define STB_DEFINE -#include "stb.h" - -#define STB_TRUETYPE_IMPLEMENTATION -#include "stb_truetype.h" - -#define STB_IMAGE_WRITE_IMPLEMENTATION -#include "stb_image_write.h" - -// used both to compute SDF and in 'shader' -float sdf_size = 32.0; // the larger this is, the better large font sizes look -float pixel_dist_scale = 64.0; // trades off precision w/ ability to handle *smaller* sizes -int onedge_value = 128; -int padding = 3; // not used in shader - -typedef struct -{ - float advance; - signed char xoff; - signed char yoff; - unsigned char w,h; - unsigned char *data; -} fontchar; - -fontchar fdata[128]; - -#define BITMAP_W 1200 -#define BITMAP_H 800 -unsigned char bitmap[BITMAP_H][BITMAP_W][3]; - -char *sample = "This is goofy text, size %d!"; -char *small_sample = "This is goofy text, size %d! Really needs in-shader supersampling to look good."; - -void blend_pixel(int x, int y, int color, float alpha) -{ - int i; - for (i=0; i < 3; ++i) - bitmap[y][x][i] = (unsigned char) (stb_lerp(alpha, bitmap[y][x][i], color)+0.5); // round -} - -void draw_char(float px, float py, char c, float relative_scale) -{ - int x,y; - fontchar *fc = &fdata[c]; - float fx0 = px + fc->xoff*relative_scale; - float fy0 = py + fc->yoff*relative_scale; - float fx1 = fx0 + fc->w*relative_scale; - float fy1 = fy0 + fc->h*relative_scale; - int ix0 = (int) floor(fx0); - int iy0 = (int) floor(fy0); - int ix1 = (int) ceil(fx1); - int iy1 = (int) ceil(fy1); - // clamp to viewport - if (ix0 < 0) ix0 = 0; - if (iy0 < 0) iy0 = 0; - if (ix1 > BITMAP_W) ix1 = BITMAP_W; - if (iy1 > BITMAP_H) iy1 = BITMAP_H; - - for (y=iy0; y < iy1; ++y) { - for (x=ix0; x < ix1; ++x) { - float sdf_dist, pix_dist; - float bmx = stb_linear_remap(x, fx0, fx1, 0, fc->w); - float bmy = stb_linear_remap(y, fy0, fy1, 0, fc->h); - int v00,v01,v10,v11; - float v0,v1,v; - int sx0 = (int) bmx; - int sx1 = sx0+1; - int sy0 = (int) bmy; - int sy1 = sy0+1; - // compute lerp weights - bmx = bmx - sx0; - bmy = bmy - sy0; - // clamp to edge - sx0 = stb_clamp(sx0, 0, fc->w-1); - sx1 = stb_clamp(sx1, 0, fc->w-1); - sy0 = stb_clamp(sy0, 0, fc->h-1); - sy1 = stb_clamp(sy1, 0, fc->h-1); - // bilinear texture sample - v00 = fc->data[sy0*fc->w+sx0]; - v01 = fc->data[sy0*fc->w+sx1]; - v10 = fc->data[sy1*fc->w+sx0]; - v11 = fc->data[sy1*fc->w+sx1]; - v0 = stb_lerp(bmx,v00,v01); - v1 = stb_lerp(bmx,v10,v11); - v = stb_lerp(bmy,v0 ,v1 ); - #if 0 - // non-anti-aliased - if (v > onedge_value) - blend_pixel(x,y,0,1.0); - #else - // Following math can be greatly simplified - - // convert distance in SDF value to distance in SDF bitmap - sdf_dist = stb_linear_remap(v, onedge_value, onedge_value+pixel_dist_scale, 0, 1); - // convert distance in SDF bitmap to distance in output bitmap - pix_dist = sdf_dist * relative_scale; - // anti-alias by mapping 1/2 pixel around contour from 0..1 alpha - v = stb_linear_remap(pix_dist, -0.5f, 0.5f, 0, 1); - if (v > 1) v = 1; - if (v > 0) - blend_pixel(x,y,0,v); - #endif - } - } -} - - -void print_text(float x, float y, char *text, float scale) -{ - int i; - for (i=0; text[i]; ++i) { - if (fdata[text[i]].data) - draw_char(x,y,text[i],scale); - x += fdata[text[i]].advance * scale; - } -} - -int main(int argc, char **argv) -{ - int ch; - float scale, ypos; - stbtt_fontinfo font; - void *data = stb_file("c:/windows/fonts/times.ttf", NULL); - stbtt_InitFont(&font, data, 0); - - scale = stbtt_ScaleForPixelHeight(&font, sdf_size); - - for (ch=32; ch < 127; ++ch) { - fontchar fc; - int xoff,yoff,w,h, advance; - fc.data = stbtt_GetCodepointSDF(&font, scale, ch, padding, onedge_value, pixel_dist_scale, &w, &h, &xoff, &yoff); - fc.xoff = xoff; - fc.yoff = yoff; - fc.w = w; - fc.h = h; - stbtt_GetCodepointHMetrics(&font, ch, &advance, NULL); - fc.advance = advance * scale; - fdata[ch] = fc; - } - - ypos = 60; - memset(bitmap, 255, sizeof(bitmap)); - print_text(400, ypos+30, stb_sprintf("sdf bitmap height %d", (int) sdf_size), 30/sdf_size); - ypos += 80; - for (scale = 8.0; scale < 120.0; scale *= 1.33f) { - print_text(80, ypos+scale, stb_sprintf(scale == 8.0 ? small_sample : sample, (int) scale), scale / sdf_size); - ypos += scale*1.05f + 20; - } - - stbi_write_png("sdf_test.png", BITMAP_W, BITMAP_H, 3, bitmap, 0); - return 0; -} diff --git a/third_party/stb/tests/sdf/sdf_test_arial_16.png b/third_party/stb/tests/sdf/sdf_test_arial_16.png deleted file mode 100644 index 3d2bc1e487..0000000000 Binary files a/third_party/stb/tests/sdf/sdf_test_arial_16.png and /dev/null differ diff --git a/third_party/stb/tests/sdf/sdf_test_times_16.png b/third_party/stb/tests/sdf/sdf_test_times_16.png deleted file mode 100644 index c76e7b96c4..0000000000 Binary files a/third_party/stb/tests/sdf/sdf_test_times_16.png and /dev/null differ diff --git a/third_party/stb/tests/sdf/sdf_test_times_50.png b/third_party/stb/tests/sdf/sdf_test_times_50.png deleted file mode 100644 index bf4974f009..0000000000 Binary files a/third_party/stb/tests/sdf/sdf_test_times_50.png and /dev/null differ diff --git a/third_party/stb/tests/stb.c b/third_party/stb/tests/stb.c deleted file mode 100644 index 5a0b6eb939..0000000000 --- a/third_party/stb/tests/stb.c +++ /dev/null @@ -1,3328 +0,0 @@ -/* - * Unit tests for "stb.h" - */ - -//#include -#include -#include -#include -#include -#include - -#ifdef _WIN32 -#include -#endif - -//#define STB_FASTMALLOC -#ifdef _DEBUG -#define STB_MALLOC_WRAPPER_DEBUG -#endif -#ifndef _M_AMD64 -#define STB_NPTR -#endif -#define STB_DEFINE -#include "stb.h" - -//#include "stb_file.h" -//#include "stb_pixel32.h" - -//#define DEBUG_BLOCK -#ifdef DEBUG_BLOCK -#include -#endif - -#ifdef STB_FASTMALLOC -#error "can't use FASTMALLOC with threads" -#endif - -int count; -void c(int truth, char *error) -{ - if (!truth) { - fprintf(stderr, "Test failed: %s\n", error); - ++count; - } -} - - -#if 0 -void show(void) -{ - #ifdef _WIN32 - SYSTEM_INFO x; - GetSystemInfo(&x); - printf("%d\n", x.dwPageSize); - #endif -} -#endif - -void test_classes(void) -{ - unsigned char size_base[32], size_shift[32]; - int class_to_pages[256]; - int class_to_size[256], cl; - int lg, size, wasted_pages; - int kAlignShift = 3; - int kAlignment = 1 << kAlignShift; - int kMaxSize = 8 * 4096; - int kPageShift = 12; - int kPageSize = (1 << kPageShift); - int next_class = 1; - int alignshift = kAlignShift; - int last_lg = -1; - - for (lg = 0; lg < kAlignShift; lg++) { - size_base[lg] = 1; - size_shift[lg] = kAlignShift; - } - - for (size = kAlignment; size <= kMaxSize; size += (1 << alignshift)) { - int lg = stb_log2_floor(size); - if (lg > last_lg) { - // Increase alignment every so often. - // - // Since we double the alignment every time size doubles and - // size >= 128, this means that space wasted due to alignment is - // at most 16/128 i.e., 12.5%. Plus we cap the alignment at 256 - // bytes, so the space wasted as a percentage starts falling for - // sizes > 2K. - if ((lg >= 7) && (alignshift < 8)) { - alignshift++; - } - size_base[lg] = next_class - ((size-1) >> alignshift); - size_shift[lg] = alignshift; - } - - class_to_size[next_class] = size; - last_lg = lg; - - next_class++; - } - - // Initialize the number of pages we should allocate to split into - // small objects for a given class. - wasted_pages = 0; - for (cl = 1; cl < next_class; cl++) { - // Allocate enough pages so leftover is less than 1/8 of total. - // This bounds wasted space to at most 12.5%. - size_t psize = kPageSize; - const size_t s = class_to_size[cl]; - while ((psize % s) > (psize >> 3)) { - psize += kPageSize; - } - class_to_pages[cl] = psize >> kPageShift; - wasted_pages += psize; - } - - printf("TCMalloc can waste as much as %d memory on one-shot allocations\n", wasted_pages); - - - return; -} - -#ifdef STB_STUA -void test_script(void) -{ - stua_run_script( - "var g = (2+3)*5 + 3*(2+1) + ((7)); \n" - "func sprint(x) _print(x) _print(' ') x end;\n" - "func foo(y) var q = func(x) sprint(x) end; q end;\n " - "var z=foo(5); z(77);\n" - "func counter(z) func(x) z=z+1 end end\n" - "var q=counter(0), p=counter(5);\n" - "sprint(q()) sprint(p()) sprint(q()) sprint(p()) sprint(q()) sprint(p())\n" - "var x=2222;\n" - "if 1 == 2 then 3333 else 4444 end; => x; sprint(x);\n" - "var x1 = sprint(1.5e3); \n" - "var x2 = sprint(.5); \n" - "var x3 = sprint(1.); \n" - "var x4 = sprint(1.e3); \n" - "var x5 = sprint(1e3); \n" - "var x6 = sprint(0.5e3); \n" - "var x7 = sprint(.5e3); \n" - " func sum(x,y) x+y end \n" - " func sumfunc(a) sum+{x=a} end \n" - " var q = sumfunc(3) \n" - " var p = sumfunc(20) \n" - " var d = sprint(q(5)) - sprint(q(8)) \n" - " var e = sprint(p(5)) - sprint(p(8)) \n" - " func test3(x) \n" - " sprint(x) \n" - " x = x+3 \n" - " sprint(x) \n" - " x+5 \n" - " end \n" - " var y = test3(4); \n" - " func fib(x) \n" - " if x < 3 then \n" - " 1 \n" - " else \n" - " fib(x-1) + fib(x-2); \n" - " end \n" - " end \n" - " \n" - " func fib2(x) \n" - " var a=1 \n" - " var b=1 \n" - " sprint(a) \n" - " sprint(b) \n" - " while x > 2 do \n" - " var c=a+b \n" - " a=b \n" - " b=c \n" - " sprint(b) \n" - " x=x-1 \n" - " end \n" - " b \n" - " end \n" - " \n" - " func assign(z) \n" - " var y = { 'this', 'is', 'a', 'lame', 'day', 'to', 'die'} \n" - " y[3] = z \n" - " var i = 0 \n" - " while y[i] != nil do \n" - " sprint(y[i]) \n" - " i = i+1 \n" - " end \n" - " end \n" - " \n" - " sprint(fib(12)); \n" - " assign(\"good\"); \n" - " fib2(20); \n" - " sprint('ok'); \n" - " sprint(-5); \n" - " // final comment with no newline" - ); -} -#endif - -#ifdef STB_THREADS -extern void __stdcall Sleep(unsigned long); - -void * thread_1(void *x) -{ - Sleep(80); - printf("thread 1\n"); fflush(stdout); - return (void *) 2; -} - -void * thread_2(void *y) -{ - stb_work(thread_1, NULL, y); - Sleep(50); - printf("thread 2\n"); fflush(stdout); - return (void *) 3; -} - -stb_semaphore stest; -stb_mutex mutex; -volatile int tc1, tc2; - -void *thread_3(void *p) -{ - stb_mutex_begin(mutex); - ++tc1; - stb_mutex_end(mutex); - stb_sem_waitfor(stest); - stb_mutex_begin(mutex); - ++tc2; - stb_mutex_end(mutex); - return NULL; -} - -void test_threads(void) -{ - volatile int a=0,b=0; - //stb_work_numthreads(2); - stb_work(thread_2, (void *) &a, (void *) &b); - while (a==0 || b==0) { - Sleep(10); - //printf("a=%d b=%d\n", a, b); - } - c(a==2 && b == 3, "stb_thread"); - stb_work_numthreads(4); - stest = stb_sem_new(8); - mutex = stb_mutex_new(); - stb_work(thread_3, NULL, NULL); - stb_work(thread_3, NULL, NULL); - stb_work(thread_3, NULL, NULL); - stb_work(thread_3, NULL, NULL); - stb_work(thread_3, NULL, NULL); - stb_work(thread_3, NULL, NULL); - stb_work(thread_3, NULL, NULL); - stb_work(thread_3, NULL, NULL); - while (tc1 < 4) - Sleep(10); - c(tc1 == 4, "stb_work 1"); - stb_sem_release(stest); - stb_sem_release(stest); - stb_sem_release(stest); - stb_sem_release(stest); - stb_sem_release(stest); - stb_sem_release(stest); - stb_sem_release(stest); - stb_sem_release(stest); - Sleep(40); - while (tc1 != 8 || tc2 != 8) - Sleep(10); - c(tc1 == 8 && tc2 == 8, "stb_work 2"); - stb_work_numthreads(2); - stb_work(thread_3, NULL, NULL); - stb_work(thread_3, NULL, NULL); - stb_work(thread_3, NULL, NULL); - stb_work(thread_3, NULL, NULL); - while (tc1 < 10) - Sleep(10); - c(tc1 == 10, "stb_work 1"); - stb_sem_release(stest); - stb_sem_release(stest); - stb_sem_release(stest); - stb_sem_release(stest); - - Sleep(100); - stb_sem_delete(stest); - stb_mutex_delete(mutex); -} -#else -void test_threads(void) -{ -} -#endif - -void *thread4(void *p) -{ - return NULL; -} - -#ifdef STB_THREADS -stb_threadqueue *tq; -stb_sync synch; -stb_mutex msum; - -volatile int thread_sum; - -void *consume1(void *p) -{ - volatile int *q = (volatile int *) p; - for(;;) { - int z; - stb_threadq_get_block(tq, &z); - stb_mutex_begin(msum); - thread_sum += z; - *q += z; - stb_mutex_end(msum); - stb_sync_reach(synch); - } -} - -void test_threads2(void) -{ - int array[256],i,n=0; - volatile int which[4]; - synch = stb_sync_new(); - stb_sync_set_target(synch,2); - stb_work_reach(thread4, NULL, NULL, synch); - stb_sync_reach_and_wait(synch); - printf("ok\n"); - - tq = stb_threadq_new(4, 1, TRUE,TRUE); - msum = stb_mutex_new(); - thread_sum = 0; - stb_sync_set_target(synch, 65); - for (i=0; i < 4; ++i) { - which[i] = 0; - stb_create_thread(consume1, (int *) &which[i]); - } - for (i=1; i <= 64; ++i) { - array[i] = i; - n += i; - stb_threadq_add_block(tq, &array[i]); - } - stb_sync_reach_and_wait(synch); - stb_barrier(); - c(thread_sum == n, "stb_threadq 1"); - c(which[0] + which[1] + which[2] + which[3] == n, "stb_threadq 2"); - printf("(Distribution: %d %d %d %d)\n", which[0], which[1], which[2], which[3]); - - stb_sync_delete(synch); - stb_threadq_delete(tq); - stb_mutex_delete(msum); -} -#else -void test_threads2(void) -{ -} -#endif - -char tc[] = "testing compression test quick test voila woohoo what the hell"; - -char storage1[1 << 23]; -int test_compression(char *buffer, int length) -{ - char *storage2; - int c_len = stb_compress(storage1, buffer, length); - int dc_len; - printf("Compressed %d to %d\n", length, c_len); - dc_len = stb_decompress_length(storage1); - storage2 = malloc(dc_len); - dc_len = stb_decompress(storage2, storage1, c_len); - if (dc_len != length) { free(storage2); return -1; } - if (memcmp(buffer, storage2, length) != 0) { free(storage2); return -1; } - free(storage2); - return c_len; -} - -#if 0 -int test_en_compression(char *buffer, int length) -{ - int c_len = stb_en_compress(storage1, buffer, length); - int dc_len; - printf("Encompressed %d to %d\n", length, c_len); - dc_len = stb_en_decompress(storage2, storage1, c_len); - if (dc_len != length) return -1; - if (memcmp(buffer, storage2, length) != 0) return -1; - return c_len; -} -#endif - -#define STR_x "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -#define STR_y "yyyyyyyyyyyyyyyyyy" - -#define STR_xy STR_x STR_y -#define STR_xyyxy STR_xy STR_y STR_xy - -#define STR_1 "testing" -#define STR_2 STR_xyyxy STR_xy STR_xyyxy STR_xyyxy STR_xy STR_xyyxy -#define STR_3 "buh" - -char buffer[] = STR_1 "\r\n" STR_2 STR_2 STR_2 "\n" STR_3; -char str1[] = STR_1; -char str2[] = STR_2 STR_2 STR_2; -char str3[] = STR_3; - -int sum(short *s) -{ - int i,total=0; - for (i=0; i < stb_arr_len(s); ++i) - total += s[i]; - return total; -} - -stb_uint stb_adler32_old(stb_uint adler32, stb_uchar *buffer, stb_uint buflen) -{ - const stb_uint ADLER_MOD = 65521; - stb_uint s1 = adler32 & 0xffff; - stb_uint s2 = adler32 >> 16; - - while (buflen-- > 0) { // NOTE: much faster implementations are possible! - s1 += *buffer++; if (s1 > ADLER_MOD) s1 -= ADLER_MOD; - s2 += s1 ; if (s2 > ADLER_MOD) s2 -= ADLER_MOD; - } - return (s2 << 16) + s1; -} - -static int sample_test[3][5] = -{ - { 1,2,3,4,5 }, - { 6,7,8,9,10, }, - { 11,12,13,14,15 }, -}; - -typedef struct { unsigned short x,y,z; } struct1; -typedef struct { double a; int x,y,z; } struct2; - -char *args_raw[] = { "foo", "-dxrf", "bar", "-ts" }; -char *args[8]; - -void do_compressor(int,char**); -void test_sha1(void); - -int alloc_num, alloc_size; -void dumpfunc(void *ptr, int sz, char *file, int line) -{ - printf("%p (%6d) -- %3d:%s\n", ptr, sz, line, file); - alloc_size += sz; - alloc_num += 1; -} - -char *expects(stb_matcher *m, char *s, int result, int len, char *str) -{ - int res2,len2=0; - res2 = stb_lex(m, s, &len2); - c(result == res2 && len == len2, str); - return s + len; -} - -void test_lex(void) -{ - stb_matcher *m = stb_lex_matcher(); - // tok_en5 .3 20.1 20. .20 .1 - char *s = "tok_en5.3 20.1 20. .20.1"; - - stb_lex_item(m, "[a-zA-Z_][a-zA-Z0-9_]*", 1 ); - stb_lex_item(m, "[0-9]*\\.?[0-9]*" , 2 ); - stb_lex_item(m, "[\r\n\t ]+" , 3 ); - stb_lex_item(m, "." , -99 ); - s=expects(m,s,1,7, "stb_lex 1"); - s=expects(m,s,2,2, "stb_lex 2"); - s=expects(m,s,3,1, "stb_lex 3"); - s=expects(m,s,2,4, "stb_lex 4"); - s=expects(m,s,3,1, "stb_lex 5"); - s=expects(m,s,2,3, "stb_lex 6"); - s=expects(m,s,3,1, "stb_lex 7"); - s=expects(m,s,2,3, "stb_lex 8"); - s=expects(m,s,2,2, "stb_lex 9"); - s=expects(m,s,0,0, "stb_lex 10"); - stb_matcher_free(m); -} - -typedef struct Btest -{ - struct Btest stb_bst_fields(btest_); - int v; -} Btest; - -stb_bst(Btest, btest_, BT2,bt2,v, int, a - b) - -void bst_test(void) -{ - Btest *root = NULL, *t; - int items[500], sorted[500]; - int i,j,z; - for (z=0; z < 10; ++z) { - for (i=0; i < 500; ++i) - items[i] = stb_rand() & 0xfffffff; - - // check for collisions, and retrry if so - memcpy(sorted, items, sizeof(sorted)); - qsort(sorted, 500, sizeof(sorted[0]), stb_intcmp(0)); - for (i=1; i < 500; ++i) - if (sorted[i-1] == sorted[i]) - break; - if (i != 500) { --z; break; } - - for (i=0; i < 500; ++i) { - t = malloc(sizeof(*t)); - t->v = items[i]; - root = btest_insert(root, t); - #ifdef STB_DEBUG - btest__validate(root,1); - #endif - for (j=0; j <= i; ++j) - c(btest_find(root, items[j]) != NULL, "stb_bst 1"); - for ( ; j < 500; ++j) - c(btest_find(root, items[j]) == NULL, "stb_bst 2"); - } - - t = btest_first(root); - for (i=0; i < 500; ++i) - t = btest_next(root,t); - c(t == NULL, "stb_bst 5"); - t = btest_last(root); - for (i=0; i < 500; ++i) - t = btest_prev(root,t); - c(t == NULL, "stb_bst 6"); - - memcpy(sorted, items, sizeof(sorted)); - qsort(sorted, 500, sizeof(sorted[0]), stb_intcmp(0)); - t = btest_first(root); - for (i=0; i < 500; ++i) { - assert(t->v == sorted[i]); - t = btest_next(root, t); - } - assert(t == NULL); - - if (z==1) - stb_reverse(items, 500, sizeof(items[0])); - else if (z) - stb_shuffle(items, 500, sizeof(items[0]), stb_rand()); - - for (i=0; i < 500; ++i) { - t = btest_find(root, items[i]); - assert(t != NULL); - root = btest_remove(root, t); - c(btest_find(root, items[i]) == NULL, "stb_bst 5"); - #ifdef STB_DEBUG - btest__validate(root, 1); - #endif - for (j=0; j <= i; ++j) - c(btest_find(root, items[j]) == NULL, "stb_bst 3"); - for ( ; j < 500; ++j) - c(btest_find(root, items[j]) != NULL, "stb_bst 4"); - free(t); - } - } -} - -extern void stu_uninit(void); - -stb_define_sort(sort_int, int, *a < *b) - -stb_rand_define(prime_rand, 1) -void test_packed_floats(void); -void test_parser_generator(void); - -void rec_print(stb_dirtree2 *d, int depth) -{ - int i; - for (i=0; i < depth; ++i) printf(" "); - printf("%s (%d)\n", d->relpath, stb_arr_len(d->files)); - for (i=0; i < stb_arr_len(d->subdirs); ++i) - rec_print(d->subdirs[i], depth+1); - d->weight = (float) stb_arr_len(d->files); -} - -#ifdef MAIN_TEST -int main(int argc, char **argv) -{ - char *z; - stb__wchar buffer7[1024],buffer9[1024]; - char buffer8[4096]; - FILE *f; - char *p1 = "foo/bar\\baz/test.xyz"; - char *p2 = "foo/.bar"; - char *p3 = "foo.bar"; - char *p4 = "foo/bar"; - char *wildcards[] = { "*foo*", "*bar", "baz", "*1*2*3*", "*/CVS/repository", "*oof*" }; - char **s; - char buf[256], *p; - int n,len2,*q,i; - stb_matcher *mt=NULL; - - if (argc > 1) { - do_compressor(argc,argv); - return 0; - } - test_classes(); - //show(); - - //stb_malloc_check_counter(2,2); - //_CrtSetBreakAlloc(10398); - - stbprint("Checking {!if} the {$fancy} print function {#works}? - should\n"); - stbprint(" - align\n"); - stbprint("But {#3this}} {one}} - shouldn't\n"); - - #if 0 - { - int i; - char **s = stb_readdir_recursive("/sean", NULL); - stb_dirtree *d = stb_dirtree_from_files_relative("", s, stb_arr_len(s)); - stb_dirtree **e; - rec_print(d, 0); - e = stb_summarize_tree(d,12,4); - for (i=0; i < stb_arr_len(e); ++i) { - printf("%s\n", e[i]->fullpath); - } - stb_arr_free(e); - - stb_fatal("foo"); - } - #endif - - stb_("Started stb.c"); - test_threads2(); - test_threads(); - - for (i=0; i < 1023 && 5+77*i < 0xd800; ++i) - buffer7[i] = 5+77*i; - buffer7[i++] = 0xd801; - buffer7[i++] = 0xdc02; - buffer7[i++] = 0xdbff; - buffer7[i++] = 0xdfff; - buffer7[i] = 0; - p = stb_to_utf8(buffer8, buffer7, sizeof(buffer8)); - c(p != NULL, "stb_to_utf8"); - if (p != NULL) { - stb_from_utf8(buffer9, buffer8, sizeof(buffer9)/2); - c(!memcmp(buffer7, buffer9, i*2), "stb_from_utf8"); - } - - z = "foo.*[bd]ak?r"; - c( stb_regex(z, "muggle man food is barfy") == 1, "stb_regex 1"); - c( stb_regex("foo.*bar", "muggle man food is farfy") == 0, "stb_regex 2"); - c( stb_regex("[^a-zA-Z]foo[^a-zA-Z]", "dfoobar xfood") == 0, "stb_regex 3"); - c( stb_regex(z, "muman foob is bakrfy") == 1, "stb_regex 4"); - z = "foo.*[bd]bk?r"; - c( stb_regex(z, "muman foob is bakrfy") == 0, "stb_regex 5"); - c( stb_regex(z, "muman foob is bbkrfy") == 1, "stb_regex 6"); - - stb_regex(NULL,NULL); - - #if 0 - test_parser_generator(); - stb_wrapper_listall(dumpfunc); - if (alloc_num) - printf("Memory still in use: %d allocations of %d bytes.\n", alloc_num, alloc_size); - #endif - - test_script(); - p = stb_file("sieve.stua", NULL); - if (p) { - stua_run_script(p); - free(p); - } - stua_uninit(); - - //stb_wrapper_listall(dumpfunc); - printf("Memory still in use: %d allocations of %d bytes.\n", alloc_num, alloc_size); - - c(stb_alloc_count_alloc == stb_alloc_count_free, "stb_alloc 0"); - - bst_test(); - - c(stb_alloc_count_alloc == stb_alloc_count_free, "stb_alloc 0"); - -#if 0 - // stb_block - { - int inuse=0, freespace=0; - int *x = malloc(10000*sizeof(*x)); - stb_block *b = stb_block_new(1, 10000); - #define BLOCK_COUNT 1000 - int *p = malloc(sizeof(*p) * BLOCK_COUNT); - int *l = malloc(sizeof(*l) * BLOCK_COUNT); - int i, n, k = 0; - - memset(x, 0, 10000 * sizeof(*x)); - - n = 0; - while (n < BLOCK_COUNT && k < 1000) { - l[n] = 16 + (rand() & 31); - p[n] = stb_block_alloc(b, l[n], 0); - if (p[n] == 0) - break; - inuse += l[n]; - - freespace = 0; - for (i=0; i < b->len; ++i) - freespace += b->freelist[i].len; - assert(freespace + inuse == 9999); - - for (i=0; i < l[n]; ++i) - x[ p[n]+i ] = p[n]; - ++n; - - if (k > 20) { - int sz; - i = (stb_rand() % n); - sz = l[i]; - stb_block_free(b, p[i], sz); - inuse -= sz; - p[i] = p[n-1]; - l[i] = l[n-1]; - --n; - - freespace = 0; - for (i=0; i < b->len; ++i) - freespace += b->freelist[i].len; - assert(freespace + inuse == 9999); - } - - - ++k; - - // validate - if ((k % 50) == 0) { - int j; - for (j=0; j < n; ++j) { - for (i=0; i < l[j]; ++i) - assert(x[ p[j]+i ] == p[j]); - } - } - - if ((k % 200) == 0) { - stb_block_compact_freelist(b); - } - } - - for (i=0; i < n; ++i) - stb_block_free(b, p[i], l[i]); - - stb_block_destroy(b); - free(p); - free(l); - free(x); - } - - blockfile_test(); -#endif - - mt = stb_lex_matcher(); - for (i=0; i < 5; ++i) - stb_lex_item_wild(mt, wildcards[i], i+1); - - c(1==stb_lex(mt, "this is a foo in the middle",NULL), "stb_matcher_match 1"); - c(0==stb_lex(mt, "this is a bar in the middle",NULL), "stb_matcher_match 2"); - c(0==stb_lex(mt, "this is a baz in the middle",NULL), "stb_matcher_match 3"); - c(2==stb_lex(mt, "this is a bar",NULL), "stb_matcher_match 4"); - c(0==stb_lex(mt, "this is a baz",NULL), "stb_matcher_match 5"); - c(3==stb_lex(mt, "baz",NULL), "stb_matcher_match 6"); - c(4==stb_lex(mt, "1_2_3_4",NULL), "stb_matcher_match 7"); - c(0==stb_lex(mt, "1 3 3 3 3 2 ",NULL), "stb_matcher_match 8"); - c(4==stb_lex(mt, "1 3 3 3 2 3 ",NULL), "stb_matcher_match 9"); - c(5==stb_lex(mt, "C:/sean/prj/old/gdmag/mipmap/hqp/adol-c/CVS/Repository",NULL), "stb_matcher_match 10"); - stb_matcher_free(mt); - - { - #define SSIZE 500000 - static int arr[SSIZE],arr2[SSIZE]; - int i,good; - for (i=0; i < SSIZE; ++i) - arr2[i] = stb_rand(); - memcpy(arr,arr2,sizeof(arr)); - printf("stb_define_sort:\n"); - sort_int(arr, SSIZE); - good = 1; - for (i=0; i+1 < SSIZE; ++i) - if (arr[i] > arr[i+1]) - good = 0; - c(good, "stb_define_sort"); - printf("qsort:\n"); - qsort(arr2, SSIZE, sizeof(arr2[0]), stb_intcmp(0)); - printf("done\n"); - // check for bugs - memset(arr, 0, sizeof(arr[0]) * 1000); - sort_int(arr, 1000); - } - - - c(stb_alloc_count_alloc == stb_alloc_count_free, "stb_alloc -2"); - - c( stb_is_prime( 2), "stb_is_prime 1"); - c( stb_is_prime( 3), "stb_is_prime 2"); - c( stb_is_prime( 5), "stb_is_prime 3"); - c( stb_is_prime( 7), "stb_is_prime 4"); - c(!stb_is_prime( 9), "stb_is_prime 5"); - c( stb_is_prime(11), "stb_is_prime 6"); - c(!stb_is_prime(25), "stb_is_prime 7"); - c(!stb_is_prime(27), "stb_is_prime 8"); - c( stb_is_prime(29), "stb_is_prime 9"); - c( stb_is_prime(31), "stb_is_prime a"); - c(!stb_is_prime(33), "stb_is_prime b"); - c(!stb_is_prime(35), "stb_is_prime c"); - c(!stb_is_prime(36), "stb_is_prime d"); - - for (n=7; n < 64; n += 3) { - int i; - stb_perfect s; - unsigned int *p = malloc(n * sizeof(*p)); - for (i=0; i < n; ++i) - p[i] = i*i; - c(stb_perfect_create(&s, p, n), "stb_perfect_hash 1"); - stb_perfect_destroy(&s); - for (i=0; i < n; ++i) - p[i] = stb_rand(); - c(stb_perfect_create(&s, p, n), "stb_perfect_hash 2"); - stb_perfect_destroy(&s); - for (i=0; i < n; ++i) - p[i] = (0x80000000 >> stb_log2_ceil(n>>1)) * i; - c(stb_perfect_create(&s, p, n), "stb_perfect_hash 2"); - stb_perfect_destroy(&s); - for (i=0; i < n; ++i) - p[i] = (int) malloc(1024); - c(stb_perfect_create(&s, p, n), "stb_perfect_hash 3"); - stb_perfect_destroy(&s); - for (i=0; i < n; ++i) - free((void *) p[i]); - free(p); - } - printf("Maximum attempts required to find perfect hash: %d\n", - stb_perfect_hash_max_failures); - - p = "abcdefghijklmnopqrstuvwxyz"; - c(stb_ischar('c', p), "stb_ischar 1"); - c(stb_ischar('x', p), "stb_ischar 2"); - c(!stb_ischar('#', p), "stb_ischar 3"); - c(!stb_ischar('X', p), "stb_ischar 4"); - p = "0123456789"; - c(!stb_ischar('c', p), "stb_ischar 5"); - c(!stb_ischar('x', p), "stb_ischar 6"); - c(!stb_ischar('#', p), "stb_ischar 7"); - c(!stb_ischar('X', p), "stb_ischar 8"); - p = "#####"; - c(!stb_ischar('c', p), "stb_ischar a"); - c(!stb_ischar('x', p), "stb_ischar b"); - c(stb_ischar('#', p), "stb_ischar c"); - c(!stb_ischar('X', p), "stb_ischar d"); - p = "xXyY"; - c(!stb_ischar('c', p), "stb_ischar e"); - c(stb_ischar('x', p), "stb_ischar f"); - c(!stb_ischar('#', p), "stb_ischar g"); - c(stb_ischar('X', p), "stb_ischar h"); - - c(stb_alloc_count_alloc == stb_alloc_count_free, "stb_alloc 1"); - - q = stb_wordwrapalloc(15, "How now brown cow. Testinglishously. Okey dokey"); - // How now brown - // cow. Testinglis - // hously. Okey - // dokey - c(stb_arr_len(q) == 8, "stb_wordwrap 8"); - c(q[2] == 14 && q[3] == 15, "stb_wordwrap 9"); - c(q[4] == 29 && q[5] == 12, "stb_wordwrap 10"); - stb_arr_free(q); - - q = stb_wordwrapalloc(20, "How now brown cow. Testinglishously. Okey dokey"); - // How now brown cow. - // Testinglishously. - // Okey dokey - c(stb_arr_len(q) == 6, "stb_wordwrap 1"); - c(q[0] == 0 && q[1] == 18, "stb_wordwrap 2"); - c(q[2] == 19 && q[3] == 17, "stb_wordwrap 3"); - c(q[4] == 37 && q[5] == 10, "stb_wordwrap 4"); - stb_arr_free(q); - - q = stb_wordwrapalloc(12, "How now brown cow. Testinglishously. Okey dokey"); - // How now - // brown cow. - // Testinglisho - // usly. Okey - // dokey - c(stb_arr_len(q) == 10, "stb_wordwrap 5"); - c(q[4] == 19 && q[5] == 12, "stb_wordwrap 6"); - c(q[6] == 31 && q[3] == 10, "stb_wordwrap 7"); - stb_arr_free(q); - - //test_script(); - - //test_packed_floats(); - - c(stb_alloc_count_alloc == stb_alloc_count_free, "stb_alloc 0"); - if (stb_alloc_count_alloc != stb_alloc_count_free) { - printf("%d allocs, %d frees\n", stb_alloc_count_alloc, stb_alloc_count_free); - } - test_lex(); - - mt = stb_regex_matcher(".*foo.*bar.*"); - c(stb_matcher_match(mt, "foobarx") == 1, "stb_matcher_match 1"); - c(stb_matcher_match(mt, "foobar") == 1, "stb_matcher_match 2"); - c(stb_matcher_match(mt, "foo bar") == 1, "stb_matcher_match 3"); - c(stb_matcher_match(mt, "fo foo ba ba bar ba") == 1, "stb_matcher_match 4"); - c(stb_matcher_match(mt, "fo oo oo ba ba bar foo") == 0, "stb_matcher_match 5"); - stb_free(mt); - - mt = stb_regex_matcher(".*foo.?bar.*"); - c(stb_matcher_match(mt, "abfoobarx") == 1, "stb_matcher_match 6"); - c(stb_matcher_match(mt, "abfoobar") == 1, "stb_matcher_match 7"); - c(stb_matcher_match(mt, "abfoo bar") == 1, "stb_matcher_match 8"); - c(stb_matcher_match(mt, "abfoo bar") == 0, "stb_matcher_match 9"); - c(stb_matcher_match(mt, "abfo foo ba ba bar ba") == 0, "stb_matcher_match 10"); - c(stb_matcher_match(mt, "abfo oo oo ba ba bar foo") == 0, "stb_matcher_match 11"); - stb_free(mt); - - mt = stb_regex_matcher(".*m((foo|bar)*baz)m.*"); - c(stb_matcher_match(mt, "abfoobarx") == 0, "stb_matcher_match 12"); - c(stb_matcher_match(mt, "a mfoofoofoobazm d") == 1, "stb_matcher_match 13"); - c(stb_matcher_match(mt, "a mfoobarbazfoom d") == 0, "stb_matcher_match 14"); - c(stb_matcher_match(mt, "a mbarbarfoobarbazm d") == 1, "stb_matcher_match 15"); - c(stb_matcher_match(mt, "a mfoobarfoo bazm d") == 0, "stb_matcher_match 16"); - c(stb_matcher_match(mt, "a mm foobarfoobarfoobar ") == 0, "stb_matcher_match 17"); - stb_free(mt); - - mt = stb_regex_matcher("f*|z"); - c(stb_matcher_match(mt, "fz") == 0, "stb_matcher_match 0a"); - c(stb_matcher_match(mt, "ff") == 1, "stb_matcher_match 0b"); - c(stb_matcher_match(mt, "z") == 1, "stb_matcher_match 0c"); - stb_free(mt); - - mt = stb_regex_matcher("m(f|z*)n"); - c(stb_matcher_match(mt, "mfzn") == 0, "stb_matcher_match 0d"); - c(stb_matcher_match(mt, "mffn") == 0, "stb_matcher_match 0e"); - c(stb_matcher_match(mt, "mzn") == 1, "stb_matcher_match 0f"); - c(stb_matcher_match(mt, "mn") == 1, "stb_matcher_match 0g"); - c(stb_matcher_match(mt, "mzfn") == 0, "stb_matcher_match 0f"); - - c(stb_matcher_find(mt, "manmanmannnnnnnmmmmmmmmm ") == 0, "stb_matcher_find 1"); - c(stb_matcher_find(mt, "manmanmannnnnnnmmmmmmmmm ") == 0, "stb_matcher_find 2"); - c(stb_matcher_find(mt, "manmanmannnnnnnmmmmmmmmmffzzz ") == 0, "stb_matcher_find 3"); - c(stb_matcher_find(mt, "manmanmannnnnnnmmmmmmmmmnfzzz ") == 1, "stb_matcher_find 4"); - c(stb_matcher_find(mt, "mmmfn aanmannnnnnnmmmmmm fzzz ") == 1, "stb_matcher_find 5"); - c(stb_matcher_find(mt, "mmmzzn anmannnnnnnmmmmmm fzzz ") == 1, "stb_matcher_find 6"); - c(stb_matcher_find(mt, "mm anmannnnnnnmmmmmm fzmzznzz ") == 1, "stb_matcher_find 7"); - c(stb_matcher_find(mt, "mm anmannnnnnnmmmmmm fzmzzfnzz ") == 0, "stb_matcher_find 8"); - c(stb_matcher_find(mt, "manmfnmannnnnnnmmmmmmmmmffzzz ") == 1, "stb_matcher_find 9"); - stb_free(mt); - - mt = stb_regex_matcher(".*m((foo|bar)*|baz)m.*"); - c(stb_matcher_match(mt, "abfoobarx") == 0, "stb_matcher_match 18"); - c(stb_matcher_match(mt, "a mfoofoofoobazm d") == 0, "stb_matcher_match 19"); - c(stb_matcher_match(mt, "a mfoobarbazfoom d") == 0, "stb_matcher_match 20"); - c(stb_matcher_match(mt, "a mbazm d") == 1, "stb_matcher_match 21"); - c(stb_matcher_match(mt, "a mfoobarfoom d") == 1, "stb_matcher_match 22"); - c(stb_matcher_match(mt, "a mm foobarfoobarfoobar ") == 1, "stb_matcher_match 23"); - stb_free(mt); - - mt = stb_regex_matcher("[a-fA-F]..[^]a-zA-Z]"); - c(stb_matcher_match(mt, "Axx1") == 1, "stb_matcher_match 24"); - c(stb_matcher_match(mt, "Fxx1") == 1, "stb_matcher_match 25"); - c(stb_matcher_match(mt, "Bxx]") == 0, "stb_matcher_match 26"); - c(stb_matcher_match(mt, "Cxxz") == 0, "stb_matcher_match 27"); - c(stb_matcher_match(mt, "gxx[") == 0, "stb_matcher_match 28"); - c(stb_matcher_match(mt, "-xx0") == 0, "stb_matcher_match 29"); - stb_free(mt); - - c(stb_wildmatch("foo*bar", "foobarx") == 0, "stb_wildmatch 0a"); - c(stb_wildmatch("foo*bar", "foobar") == 1, "stb_wildmatch 1a"); - c(stb_wildmatch("foo*bar", "foo bar") == 1, "stb_wildmatch 2a"); - c(stb_wildmatch("foo*bar", "fo foo ba ba bar ba") == 0, "stb_wildmatch 3a"); - c(stb_wildmatch("foo*bar", "fo oo oo ba ba ar foo") == 0, "stb_wildmatch 4a"); - - c(stb_wildmatch("*foo*bar*", "foobar") == 1, "stb_wildmatch 1b"); - c(stb_wildmatch("*foo*bar*", "foo bar") == 1, "stb_wildmatch 2b"); - c(stb_wildmatch("*foo*bar*", "fo foo ba ba bar ba") == 1, "stb_wildmatch 3b"); - c(stb_wildmatch("*foo*bar*", "fo oo oo ba ba ar foo") == 0, "stb_wildmatch 4b"); - - c(stb_wildmatch("foo*bar*", "foobarx") == 1, "stb_wildmatch 1c"); - c(stb_wildmatch("foo*bar*", "foobabar") == 1, "stb_wildmatch 2c"); - c(stb_wildmatch("foo*bar*", "fo foo ba ba bar ba") == 0, "stb_wildmatch 3c"); - c(stb_wildmatch("foo*bar*", "fo oo oo ba ba ar foo") == 0, "stb_wildmatch 4c"); - - c(stb_wildmatch("*foo*bar", "foobar") == 1, "stb_wildmatch 1d"); - c(stb_wildmatch("*foo*bar", "foo bar") == 1, "stb_wildmatch 2d"); - c(stb_wildmatch("*foo*bar", "fo foo ba ba bar ba") == 0, "stb_wildmatch 3d"); - c(stb_wildmatch("*foo*bar", "fo oo oo ba ba ar foo") == 0, "stb_wildmatch 4d"); - - c(stb_wildfind("foo*bar", "xyfoobarx") == 2, "stb_wildfind 0a"); - c(stb_wildfind("foo*bar", "aaafoobar") == 3, "stb_wildfind 1a"); - c(stb_wildfind("foo*bar", "foo bar") == 0, "stb_wildfind 2a"); - c(stb_wildfind("foo*bar", "fo foo ba ba bar ba") == 3, "stb_wildfind 3a"); - c(stb_wildfind("foo*bar", "fo oo oo ba ba ar foo") == -1, "stb_wildfind 4a"); - - c(stb_wildmatch("*foo*;*bar*", "foobar") == 1, "stb_wildmatch 1e"); - c(stb_wildmatch("*foo*;*bar*", "afooa") == 1, "stb_wildmatch 2e"); - c(stb_wildmatch("*foo*;*bar*", "abara") == 1, "stb_wildmatch 3e"); - c(stb_wildmatch("*foo*;*bar*", "abaza") == 0, "stb_wildmatch 4e"); - c(stb_wildmatch("*foo*;*bar*", "foboar") == 0, "stb_wildmatch 5e"); - - test_sha1(); - - n = sizeof(args_raw)/sizeof(args_raw[0]); - memcpy(args, args_raw, sizeof(args_raw)); - s = stb_getopt(&n, args); - c(n >= 1 && !strcmp(args[1], "bar" ), "stb_getopt 1"); - c(stb_arr_len(s) >= 2 && !strcmp(s[2] , "r" ), "stb_getopt 2"); - stb_getopt_free(s); - - n = sizeof(args_raw)/sizeof(args_raw[0]); - memcpy(args, args_raw, sizeof(args_raw)); - s = stb_getopt_param(&n, args, "f"); - c(stb_arr_len(s) >= 3 && !strcmp(s[3] , "fbar"), "stb_getopt 3"); - stb_getopt_free(s); - - n = sizeof(args_raw)/sizeof(args_raw[0]); - memcpy(args, args_raw, sizeof(args_raw)); - s = stb_getopt_param(&n, args, "x"); - c(stb_arr_len(s) >= 2 && !strcmp(s[1] , "xrf" ), "stb_getopt 4"); - stb_getopt_free(s); - - n = sizeof(args_raw)/sizeof(args_raw[0]); - memcpy(args, args_raw, sizeof(args_raw)); - s = stb_getopt_param(&n, args, "s"); - c(s == NULL && n == 0 , "stb_getopt 5"); - stb_getopt_free(s); - -#if 0 - c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, -1, -1) == 1, "stb_csample_int 1"); - c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, 1, -3) == 2, "stb_csample_int 2"); - c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, 12, -2) == 5, "stb_csample_int 3"); - c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, 15, 1) == 10, "stb_csample_int 4"); - c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, 5, 4) == 15, "stb_csample_int 5"); - c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, 3, 3) == 14, "stb_csample_int 6"); - c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, -2, 5) == 11, "stb_csample_int 7"); - c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, -7, 0) == 1, "stb_csample_int 8"); - c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, 2, 1) == 8, "stb_csample_int 9"); -#endif - - c(!strcmp(stb_splitpath(buf, p1, STB_PATH ), "foo/bar\\baz/"), "stb_splitpath 1"); - c(!strcmp(stb_splitpath(buf, p1, STB_FILE ), "test"), "stb_splitpath 2"); - c(!strcmp(stb_splitpath(buf, p1, STB_EXT ), ".xyz"), "stb_splitpath 3"); - c(!strcmp(stb_splitpath(buf, p1, STB_PATH_FILE ), "foo/bar\\baz/test"), "stb_splitpath 4"); - c(!strcmp(stb_splitpath(buf, p1, STB_FILE_EXT ), "test.xyz"), "stb_splitpath 5"); - - c(!strcmp(stb_splitpath(buf, p2, STB_PATH ), "foo/"), "stb_splitpath 6"); - c(!strcmp(stb_splitpath(buf, p2, STB_FILE ), ""), "stb_splitpath 7"); - c(!strcmp(stb_splitpath(buf, p2, STB_EXT ), ".bar"), "stb_splitpath 8"); - c(!strcmp(stb_splitpath(buf, p2, STB_PATH_FILE ), "foo/"), "stb_splitpath 9"); - c(!strcmp(stb_splitpath(buf, p2, STB_FILE_EXT ), ".bar"), "stb_splitpath 10"); - - c(!strcmp(stb_splitpath(buf, p3, STB_PATH ), "./"), "stb_splitpath 11"); - c(!strcmp(stb_splitpath(buf, p3, STB_FILE ), "foo"), "stb_splitpath 12"); - c(!strcmp(stb_splitpath(buf, p3, STB_EXT ), ".bar"), "stb_splitpath 13"); - c(!strcmp(stb_splitpath(buf, p3, STB_PATH_FILE ), "foo"), "stb_splitpath 14"); - - c(!strcmp(stb_splitpath(buf, p4, STB_PATH ), "foo/"), "stb_splitpath 16"); - c(!strcmp(stb_splitpath(buf, p4, STB_FILE ), "bar"), "stb_splitpath 17"); - c(!strcmp(stb_splitpath(buf, p4, STB_EXT ), ""), "stb_splitpath 18"); - c(!strcmp(stb_splitpath(buf, p4, STB_PATH_FILE ), "foo/bar"), "stb_splitpath 19"); - c(!strcmp(stb_splitpath(buf, p4, STB_FILE_EXT ), "bar"), "stb_splitpath 20"); - - c(!strcmp(p=stb_dupreplace("testfootffooo foo fox", "foo", "brap"), "testbraptfbrapo brap fox"), "stb_dupreplace 1"); free(p); - c(!strcmp(p=stb_dupreplace("testfootffooo foo fox", "foo", "" ), "testtfo fox" ), "stb_dupreplace 2"); free(p); - c(!strcmp(p=stb_dupreplace("abacab", "a", "aba"), "abababacabab" ), "stb_dupreplace 3"); free(p); - - -#if 0 - m = stb_mml_parse("xy<&f>"); - c(m != NULL, "stb_mml_parse 1"); - if (m) { - c(!strcmp(m->child[0]->child[0]->child[1]->tag, "d"), "stb_mml_parse 2"); - c(!strcmp(m->child[0]->child[1]->leaf_data, "<&f>"), "stb_mml_parse 3"); - } - if (m) - stb_mml_free(m); - c(stb_alloc_count_alloc == stb_alloc_count_free, "stb_alloc 1"); - if (stb_alloc_count_alloc != stb_alloc_count_free) { - printf("%d allocs, %d frees\n", stb_alloc_count_alloc, stb_alloc_count_free); - } -#endif - - c(stb_linear_remap(3.0f,0,8,1,2) == 1.375, "stb_linear_remap()"); - - c(stb_bitreverse(0x1248fec8) == 0x137f1248, "stb_bitreverse() 1"); - c(stb_bitreverse8(0x4e) == 0x72, "stb_bitreverse8() 1"); - c(stb_bitreverse8(0x31) == 0x8c, "stb_bitreverse8() 2"); - for (n=1; n < 255; ++n) { - unsigned int m = stb_bitreverse8((uint8) n); - c(stb_bitreverse8((uint8) m) == (unsigned int) n, "stb_bitreverse8() 3"); - } - - for (n=2; n <= 31; ++n) { - c(stb_is_pow2 ((1 << n) ) == 1 , "stb_is_pow2() 1"); - c(stb_is_pow2 ((1 << n)+1) == 0 , "stb_is_pow2() 2"); - c(stb_is_pow2 ((1 << n)-1) == 0 , "stb_is_pow2() 3"); - - c(stb_log2_floor((1 << n) ) == n , "stb_log2_floor() 1"); - c(stb_log2_floor((1 << n)+1) == n , "stb_log2_floor() 2"); - c(stb_log2_floor((1 << n)-1) == n-1, "stb_log2_floor() 3"); - - c(stb_log2_ceil ((1 << n) ) == n , "stb_log2_ceil() 1"); - c(stb_log2_ceil ((1 << n)+1) == n+1, "stb_log2_ceil() 2"); - c(stb_log2_ceil ((1 << n)-1) == n , "stb_log2_ceil() 3"); - - c(stb_bitreverse(1 << n) == 1U << (31-n), "stb_bitreverse() 2"); - } - - c(stb_log2_floor(0) == -1, "stb_log2_floor() 4"); - c(stb_log2_ceil (0) == -1, "stb_log2_ceil () 4"); - - c(stb_log2_floor(-1) == 31, "stb_log2_floor() 5"); - c(stb_log2_ceil (-1) == 32, "stb_log2_ceil () 5"); - - c(stb_bitcount(0xffffffff) == 32, "stb_bitcount() 1"); - c(stb_bitcount(0xaaaaaaaa) == 16, "stb_bitcount() 2"); - c(stb_bitcount(0x55555555) == 16, "stb_bitcount() 3"); - c(stb_bitcount(0x00000000) == 0, "stb_bitcount() 4"); - - c(stb_lowbit8(0xf0) == 4, "stb_lowbit8 1"); - c(stb_lowbit8(0x10) == 4, "stb_lowbit8 2"); - c(stb_lowbit8(0xf3) == 0, "stb_lowbit8 3"); - c(stb_lowbit8(0xf8) == 3, "stb_lowbit8 4"); - c(stb_lowbit8(0x60) == 5, "stb_lowbit8 5"); - - for (n=0; n < sizeof(buf); ++n) - buf[n] = 0; - - for (n = 0; n < 200000; ++n) { - unsigned int k = stb_rand(); - int i,z=0; - for (i=0; i < 32; ++i) - if (k & (1 << i)) ++z; - c(stb_bitcount(k) == z, "stb_bitcount() 5"); - - buf[k >> 24] = 1; - - if (k != 0) { - if (stb_is_pow2(k)) { - c(stb_log2_floor(k) == stb_log2_ceil(k), "stb_is_pow2() 1"); - c(k == 1U << stb_log2_floor(k), "stb_is_pow2() 2"); - } else { - c(stb_log2_floor(k) == stb_log2_ceil(k)-1, "stb_is_pow2() 3"); - } - } - - c(stb_bitreverse(stb_bitreverse(n)) == (uint32) n, "stb_bitreverse() 3"); - } - - // make sure reasonable coverage from stb_rand() - for (n=0; n < sizeof(buf); ++n) - c(buf[n] != 0, "stb_rand()"); - - for (n=0; n < sizeof(buf); ++n) - buf[n] = 0; - - for (n=0; n < 60000; ++n) { - float z = (float) stb_frand(); - int n = (int) (z * sizeof(buf)); - c(z >= 0 && z < 1, "stb_frand() 1"); - c(n >= 0 && n < sizeof(buf), "stb_frand() 2"); - buf[n] = 1; - } - - // make sure reasonable coverage from stb_frand(), - // e.g. that the range remap isn't incorrect - for (n=0; n < sizeof(buf); ++n) - c(buf[n] != 0, "stb_frand()"); - - - // stb_arr - { - short *s = NULL; - - c(sum(s) == 0, "stb_arr 1"); - - stb_arr_add(s); s[0] = 3; - stb_arr_push(s,7); - - c( stb_arr_valid(s,1), "stb_arr 2"); - c(!stb_arr_valid(s,2), "stb_arr 3"); - - // force a realloc - stb_arr_push(s,0); - stb_arr_push(s,0); - stb_arr_push(s,0); - stb_arr_push(s,0); - - c(sum(s) == 10, "stb_arr 4"); - stb_arr_push(s,0); - s[0] = 1; s[1] = 5; s[2] = 20; - c(sum(s) == 26, "stb_arr 5"); - stb_arr_setlen(s,2); - c(sum(s) == 6, "stb_arr 6"); - stb_arr_setlen(s,1); - c(sum(s) == 1, "stb_arr 7"); - stb_arr_setlen(s,0); - c(sum(s) == 0, "stb_arr 8"); - - stb_arr_push(s,3); - stb_arr_push(s,4); - stb_arr_push(s,5); - stb_arr_push(s,6); - stb_arr_push(s,7); - stb_arr_deleten(s,1,3); - c(stb_arr_len(s)==2 && sum(s) == 10, "stb_arr_9"); - - stb_arr_push(s,2); - // 3 7 2 - stb_arr_insertn(s,2,2); - // 3 7 x x 2 - s[2] = 5; - s[3] = 6; - c(s[0]==3 && s[1] == 7 && s[2] == 5 && s[3] == 6 && s[4] == 2, "stb_arr 10"); - stb_arr_free(s); - } - - #if 1 - f= stb_fopen("data/stb.test", "wb"); - fwrite(buffer, 1, sizeof(buffer)-1, f); - stb_fclose(f, stb_keep_yes); - #ifndef WIN32 - sleep(1); // andLinux has some synchronization problem here - #endif - #else - f= fopen("data/stb.test", "wb"); - fwrite(buffer, 1, sizeof(buffer)-1, f); - fclose(f); - #endif - if (!stb_fexists("data/stb.test")) { - fprintf(stderr, "Error: couldn't open file just written, or stb_fexists() is broken.\n"); - } - - f = fopen("data/stb.test", "rb"); - // f = NULL; // test stb_fatal() - if (!f) { stb_fatal("Error: couldn't open file just written\n"); } - else { - char temp[4]; - int len1 = stb_filelen(f), len2; - int n1,n2; - if (fread(temp,1,4,f) == 0) { - int n = ferror(f); - if (n) { stb_fatal("Error reading from stream: %d", n); } - if (feof(f)) stb_fatal("Weird, read 0 bytes and hit eof"); - stb_fatal("Read 0, but neither feof nor ferror is true"); - } - fclose(f); - p = stb_file("data/stb.test", &len2); - if (p == NULL) stb_fatal("Error: stb_file() failed"); - c(len1 == sizeof(buffer)-1, "stb_filelen()"); - c(len2 == sizeof(buffer)-1, "stb_file():n"); - c(memcmp(p, buffer, sizeof(buffer)-1) == 0, "stb_file()"); - c(strcmp(p, buffer)==0, "stb_file() terminated"); - free(p); - - s = stb_stringfile("data/stb.test", &n1); - c(n1 == 3, "stb_stringfile():n"); - n2 = 0; - while (s[n2]) ++n2; - c(n1 == n2, "stb_stringfile():n length matches the non-NULL strings"); - if (n2 == 3) { - c(strcmp(s[0],str1)==0, "stb_stringfile()[0]"); - c(strcmp(s[1],str2)==0, "stb_stringfile()[1]"); - c(strcmp(s[2],str3)==0, "stb_stringfile()[2] (no terminating newlines)"); - } - free(s); - - f = fopen("data/stb.test", "rb"); - stb_fgets(buf, sizeof(buf), f); - //c(strcmp(buf, str1)==0, "stb_fgets()"); - p = stb_fgets_malloc(f); - n1 = strlen(p); - n2 = strlen(str2); - c(strcmp(p, str2)==0, "stb_fgets_malloc()"); - free(p); - stb_fgets(buf, sizeof(buf), f); - c(strcmp(buf, str3)==0, "stb_fgets()3"); - } - - c( stb_prefix("foobar", "foo"), "stb_prefix() 1"); - c(!stb_prefix("foo", "foobar"), "stb_prefix() 2"); - c( stb_prefix("foob", "foob" ), "stb_prefix() 3"); - - stb_strncpy(buf, "foobar", 6); c(strcmp(buf,"fooba" )==0, "stb_strncpy() 1"); - stb_strncpy(buf, "foobar", 8); c(strcmp(buf,"foobar")==0, "stb_strncpy() 2"); - - c(!strcmp(p=stb_duplower("FooBar"), "foobar"), "stb_duplower()"); free(p); - strcpy(buf, "FooBar"); - stb_tolower(buf); - c(!strcmp(buf, "foobar"), "stb_tolower()"); - - p = stb_strtok(buf, "foo=ba*r", "#=*"); - c(!strcmp(buf, "foo" ), "stb_strtok() 1"); - c(!strcmp(p , "ba*r"), "stb_strtok() 2"); - p = stb_strtok(buf, "foobar", "#=*"); - c(*p == 0, "stb_strtok() 3"); - - c(!strcmp(stb_skipwhite(" \t\n foo"), "foo"), "stb_skipwhite()"); - - s = stb_tokens("foo == ba*r", "#=*", NULL); - c(!strcmp(s[0], "foo "), "stb_tokens() 1"); - c(!strcmp(s[1], " ba"), "stb_tokens() 2"); - c(!strcmp(s[2], "r"), "stb_tokens() 3"); - c(s[3] == 0, "stb_tokens() 4"); - free(s); - - s = stb_tokens_allowempty("foo == ba*r", "#=*", NULL); - c(!strcmp(s[0], "foo "), "stb_tokens_allowempty() 1"); - c(!strcmp(s[1], "" ), "stb_tokens_allowempty() 2"); - c(!strcmp(s[2], " ba"), "stb_tokens_allowempty() 3"); - c(!strcmp(s[3], "r"), "stb_tokens_allowempty() 4"); - c(s[4] == 0, "stb_tokens_allowempty() 5"); - free(s); - - s = stb_tokens_stripwhite("foo == ba*r", "#=*", NULL); - c(!strcmp(s[0], "foo"), "stb_tokens_stripwhite() 1"); - c(!strcmp(s[1], "" ), "stb_tokens_stripwhite() 2"); - c(!strcmp(s[2], "ba"), "stb_tokens_stripwhite() 3"); - c(!strcmp(s[3], "r"), "stb_tokens_stripwhite() 4"); - c(s[4] == 0, "stb_tokens_stripwhite() 5"); - free(s); - - s = stb_tokens_quoted("foo =\"=\" ba*\"\"r \" foo\" bah ", "#=*", NULL); - c(!strcmp(s[0], "foo"), "stb_tokens_quoted() 1"); - c(!strcmp(s[1], "= ba"), "stb_tokens_quoted() 2"); - c(!strcmp(s[2], "\"r foo bah"), "stb_tokens_quoted() 3"); - c(s[3] == 0, "stb_tokens_quoted() 4"); - free(s); - - - p = stb_file("stb.h", &len2); - if (p) { - uint32 z = stb_adler32_old(1, p, len2); - uint32 x = stb_adler32 (1, p, len2); - c(z == x, "stb_adler32() 1"); - memset(p,0xff,len2); - z = stb_adler32_old((65520<<16) + 65520, p, len2); - x = stb_adler32 ((65520<<16) + 65520, p, len2); - c(z == x, "stb_adler32() 2"); - free(p); - } - - // stb_hheap - { - #define HHEAP_COUNT 100000 - void **p = malloc(sizeof(*p) * HHEAP_COUNT); - int i, j; - #if 0 - stb_hheap *h2, *h = stb_newhheap(sizeof(struct1),0); - - for (i=0; i < HHEAP_COUNT; ++i) - p[i] = stb_halloc(h); - stb_shuffle(p, HHEAP_COUNT, sizeof(*p), stb_rand()); - for (i=0; i < HHEAP_COUNT; ++i) - stb_hfree(p[i]); - - c(h->num_alloc == 0, "stb_hheap 1"); - stb_delhheap(h); - - h = stb_newhheap(sizeof(struct1),0); - h2 = stb_newhheap(sizeof(struct2),8); - - for (i=0; i < HHEAP_COUNT; ++i) { - if (i & 1) - p[i] = stb_halloc(h); - else { - p[i] = stb_halloc(h2); - c((((int) p[i]) & 4) == 0, "stb_hheap 2"); - } - } - - stb_shuffle(p, HHEAP_COUNT, sizeof(*p), stb_rand()); - for (i=0; i < HHEAP_COUNT; ++i) - stb_hfree(p[i]); - - c(h->num_alloc == 0, "stb_hheap 3"); - c(h2->num_alloc == 0, "stb_hheap 4"); - - stb_delhheap(h); - stb_delhheap(h2); - #else - for (i=0; i < HHEAP_COUNT; ++i) - p[i] = malloc(32); - stb_shuffle(p, HHEAP_COUNT, sizeof(*p), stb_rand()); - for (i=0; i < HHEAP_COUNT; ++i) - free(p[i]); - #endif - - // now use the same array of pointers to do pointer set operations - for (j=100; j < HHEAP_COUNT; j += 25000) { - stb_ps *ps = NULL; - for (i=0; i < j; ++i) - ps = stb_ps_add(ps, p[i]); - - for (i=0; i < HHEAP_COUNT; ++i) - c(stb_ps_find(ps, p[i]) == (i < j), "stb_ps 1"); - c(stb_ps_count(ps) == j, "stb_ps 1b"); - - for (i=j; i < HHEAP_COUNT; ++i) - ps = stb_ps_add(ps, p[i]); - - for (i=0; i < j; ++i) - ps = stb_ps_remove(ps, p[i]); - - for (i=0; i < HHEAP_COUNT; ++i) - c(stb_ps_find(ps, p[i]) == !(i < j), "stb_ps 2"); - - stb_ps_delete(ps); - } - - #define HHEAP_COUNT2 100 - // now use the same array of pointers to do pointer set operations - for (j=1; j < 40; ++j) { - stb_ps *ps = NULL; - for (i=0; i < j; ++i) - ps = stb_ps_add(ps, p[i]); - - for (i=0; i < HHEAP_COUNT2; ++i) - c(stb_ps_find(ps, p[i]) == (i < j), "stb_ps 3"); - c(stb_ps_count(ps) == j, "stb_ps 3b"); - - for (i=j; i < HHEAP_COUNT2; ++i) - ps = stb_ps_add(ps, p[i]); - - for (i=0; i < j; ++i) - ps = stb_ps_remove(ps, p[i]); - - for (i=0; i < HHEAP_COUNT2; ++i) - c(stb_ps_find(ps, p[i]) == !(i < j), "stb_ps 4"); - - stb_ps_delete(ps); - } - - free(p); - } - - - n = test_compression(tc, sizeof(tc)); - c(n >= 0, "stb_compress()/stb_decompress() 1"); - - p = stb_file("stb.h", &len2); - if (p) { - FILE *f = fopen("data/stb_h.z", "wb"); - if (stb_compress_stream_start(f)) { - int i; - void *q; - int len3; - - for (i=0; i < len2; ) { - int n = stb_rand() % 10; - if (n <= 6) n = 1 + stb_rand()%16; - else if (n <= 8) n = 20 + stb_rand() % 1000; - else n = 15000; - if (i + n > len2) n = len2 - i; - stb_write(p + i, n); - i += n; - } - stb_compress_stream_end(1); - - q = stb_decompress_fromfile("data/stb_h.z", &len3); - c(len3 == len2, "stb_compress_stream 2"); - if (len2 == len3) - c(!memcmp(p,q,len2), "stb_compress_stream 3"); - if (q) free(q); - } else { - c(0, "stb_compress_stream 1"); - } - - free(p); - stb_compress_window(65536*4); - } - - p = stb_file("stb.h", &len2); - if (p) { - n = test_compression(p, len2); - c(n >= 0, "stb_compress()/stb_decompress() 2"); - #if 0 - n = test_en_compression(p, len2); - c(n >= 0, "stb_en_compress()/stb_en_decompress() 2"); - #endif - free(p); - } else { - fprintf(stderr, "No stb.h to compression test.\n"); - } - - p = stb_file("data/test.bmp", &len2); - if (p) { - n = test_compression(p, len2); - c(n == 106141, "stb_compress()/stb_decompress() 4"); - #if 0 - n = test_en_compression(p, len2); - c(n >= 0, "stb_en_compress()/stb_en_decompress() 4"); - #endif - free(p); - } - - // the hardcoded compressed lengths being verified _could_ - // change if you changed the compressor parameters; but pure - // performance optimizations shouldn't change them - p = stb_file("data/cantrbry.zip", &len2); - if (p) { - n = test_compression(p, len2); - c(n == 642787, "stb_compress()/stb_decompress() 3"); - #if 0 - n = test_en_compression(p, len2); - c(n >= 0, "stb_en_compress()/stb_en_decompress() 3"); - #endif - free(p); - } - - p = stb_file("data/bible.txt", &len2); - if (p) { - n = test_compression(p, len2); - c(n == 2022520, "stb_compress()/stb_decompress() 4"); - #if 0 - n = test_en_compression(p, len2); - c(n >= 0, "stb_en_compress()/stb_en_decompress() 4"); - #endif - free(p); - } - - { - int len = 1 << 25, o=0; // 32MB - char *buffer = malloc(len); - int i; - for (i=0; i < 8192; ++i) - buffer[o++] = (char) stb_rand(); - for (i=0; i < (1 << 15); ++i) - buffer[o++] = 1; - for (i=0; i < 64; ++i) - buffer[o++] = buffer[i]; - for (i=0; i < (1 << 21); ++i) - buffer[o++] = 2; - for (i=0; i < 64; ++i) - buffer[o++] = buffer[i]; - for (i=0; i < (1 << 21); ++i) - buffer[o++] = 3; - for (i=0; i < 8192; ++i) - buffer[o++] = buffer[i]; - for (i=0; i < (1 << 21); ++i) - buffer[o++] = 4; - assert(o < len); - stb_compress_window(1 << 24); - i = test_compression(buffer, len); - c(n >= 0, "stb_compress() 6"); - free(buffer); - } - - #ifdef STB_THREADS - stb_thread_cleanup(); - #endif - stb_ischar(0,NULL); - stb_wrapper_listall(dumpfunc); - printf("Memory still in use: %d allocations of %d bytes.\n", alloc_num, alloc_size); - - // force some memory checking - for (n=1; n < 20; ++n) - malloc(1 << n); - - printf("Finished stb.c with %d errors.\n", count); - - #ifdef _MSC_VER - if (count) - __asm int 3; - #endif - - return 0; -} - -#endif - - - - - -// NIST test vectors - -struct -{ - int length; - char *message; - char *digest; -} sha1_tests[] = -{ - 24, -"616263", -"a9993e364706816aba3e25717850c26c9cd0d89d", - - 1304, -"ec29561244ede706b6eb30a1c371d74450a105c3f9735f7fa9fe38cf67f304a5736a106e" -"92e17139a6813b1c81a4f3d3fb9546ab4296fa9f722826c066869edacd73b25480351858" -"13e22634a9da44000d95a281ff9f264ecce0a931222162d021cca28db5f3c2aa24945ab1" -"e31cb413ae29810fd794cad5dfaf29ec43cb38d198fe4ae1da2359780221405bd6712a53" -"05da4b1b737fce7cd21c0eb7728d08235a9011", -"970111c4e77bcc88cc20459c02b69b4aa8f58217", - - 2096, -"5fc2c3f6a7e79dc94be526e5166a238899d54927ce470018fbfd668fd9dd97cbf64e2c91" -"584d01da63be3cc9fdff8adfefc3ac728e1e335b9cdc87f069172e323d094b47fa1e652a" -"fe4d6aa147a9f46fda33cacb65f3aa12234746b9007a8c85fe982afed7815221e43dba55" -"3d8fe8a022cdac1b99eeeea359e5a9d2e72e382dffa6d19f359f4f27dc3434cd27daeeda" -"8e38594873398678065fbb23665aba9309d946135da0e4a4afdadff14db18e85e71dd93c" -"3bf9faf7f25c8194c4269b1ee3d9934097ab990025d9c3aaf63d5109f52335dd3959d38a" -"e485050e4bbb6235574fc0102be8f7a306d6e8de6ba6becf80f37415b57f9898a5824e77" -"414197422be3d36a6080", - "0423dc76a8791107d14e13f5265b343f24cc0f19", - - 2888, -"0f865f46a8f3aed2da18482aa09a8f390dc9da07d51d1bd10fe0bf5f3928d5927d08733d" -"32075535a6d1c8ac1b2dc6ba0f2f633dc1af68e3f0fa3d85e6c60cb7b56c239dc1519a00" -"7ea536a07b518ecca02a6c31b46b76f021620ef3fc6976804018380e5ab9c558ebfc5cb1" -"c9ed2d974722bf8ab6398f1f2b82fa5083f85c16a5767a3a07271d67743f00850ce8ec42" -"8c7f22f1cf01f99895c0c844845b06a06cecb0c6cf83eb55a1d4ebc44c2c13f6f7aa5e0e" -"08abfd84e7864279057abc471ee4a45dbbb5774afa24e51791a0eada11093b88681fe30b" -"aa3b2e94113dc63342c51ca5d1a6096d0897b626e42cb91761058008f746f35465465540" -"ad8c6b8b60f7e1461b3ce9e6529625984cb8c7d46f07f735be067588a0117f23e34ff578" -"00e2bbe9a1605fde6087fb15d22c5d3ac47566b8c448b0cee40373e5ba6eaa21abee7136" -"6afbb27dbbd300477d70c371e7b8963812f5ed4fb784fb2f3bd1d3afe883cdd47ef32bea" -"ea", - "6692a71d73e00f27df976bc56df4970650d90e45", - - 3680, -"4893f1c763625f2c6ce53aacf28026f14b3cd8687e1a1d3b60a81e80fcd1e2b038f9145a" -"b64a0718f948f7c3c9ac92e3d86fb669a5257da1a18c776291653688338210a3242120f1" -"01788e8acc9110db9258b1554bf3d26602516ea93606a25a7f566c0c758fb39ecd9d876b" -"c5d8abc1c3205095382c2474cb1f8bbdb45c2c0e659cb0fc703ec607a5de6bcc7a28687d" -"b1ee1c8f34797bb2441d5706d210df8c2d7d65dbded36414d063c117b52a51f7a4eb9cac" -"0782e008b47459ed5acac0bc1f20121087f992ad985511b33c866d18e63f585478ee5a5e" -"654b19d81231d98683ae3f0533565aba43dce408d7e3c4c6be11d8f05165f29c9dcb2030" -"c4ee31d3a04e7421aa92c3231a1fc07e50e95fea7389a5e65891afaba51cf55e36a9d089" -"bf293accb356d5d06547307d6e41456d4ed146a056179971c56521c83109bf922866186e" -"184a99a96c7bb96df8937e35970e438412a2b8d744cf2ad87cb605d4232e976f9f151697" -"76e4e5b6b786132c966b25fc56d815c56c819af5e159aa39f8a93d38115f5580cda93bc0" -"73c30b39920e726fe861b72483a3f886269ab7a8eefe952f35d25c4eb7f443f4f3f26e43" -"d51fb54591e6a6dad25fcdf5142033084e5624bdd51435e77dea86b8", - "dc5859dd5163c4354d5d577b855fa98e37f04384", - - 4472, -"cf494c18a4e17bf03910631471bca5ba7edea8b9a63381e3463517961749848eb03abefd" -"4ce676dece3740860255f57c261a558aa9c7f11432f549a9e4ce31d8e17c79450ce2ccfc" -"148ad904aedfb138219d7052088520495355dadd90f72e6f69f9c6176d3d45f113f275b7" -"fbc2a295784d41384cd7d629b23d1459a22e45fd5097ec9bf65fa965d3555ec77367903c" -"32141065fc24da5c56963d46a2da3c279e4035fb2fb1c0025d9dda5b9e3443d457d92401" -"a0d3f58b48469ecb1862dc975cdbe75ca099526db8b0329b03928206f084c633c04eef5e" -"8e377f118d30edf592504be9d2802651ec78aeb02aea167a03fc3e23e5fc907c324f283f" -"89ab37e84687a9c74ccf055402db95c29ba2c8d79b2bd4fa96459f8e3b78e07e923b8119" -"8267492196ecb71e01c331f8df245ec5bdf8d0e05c91e63bb299f0f6324895304dda721d" -"39410458f117c87b7dd6a0ee734b79fcbe482b2c9e9aa0cef03a39d4b0c86de3bc34b4aa" -"dabfa373fd2258f7c40c187744d237080762382f547a36adb117839ca72f8ebbc5a20a07" -"e86f4c8bb923f5787698d278f6db0040e76e54645bb0f97083995b34b9aa445fc4244550" -"58795828dd00c32471ec402a307f5aa1b37b1a86d6dae3bcbfbe9ba41cab0beeabf489af" -"0073d4b3837d3f14b815120bc3602d072b5aeefcdec655fe756b660eba7dcf34675acbce" -"317746270599424b9248791a0780449c1eabbb9459cc1e588bfd74df9b1b711c85c09d8a" -"a171b309281947e8f4b6ac438753158f4f36fa", - "4c17926feb6e87f5bca7890d8a5cde744f231dab", - - 5264, -"8236153781bd2f1b81ffe0def1beb46f5a70191142926651503f1b3bb1016acdb9e7f7ac" -"ced8dd168226f118ff664a01a8800116fd023587bfba52a2558393476f5fc69ce9c65001" -"f23e70476d2cc81c97ea19caeb194e224339bcb23f77a83feac5096f9b3090c51a6ee6d2" -"04b735aa71d7e996d380b80822e4dfd43683af9c7442498cacbea64842dfda238cb09992" -"7c6efae07fdf7b23a4e4456e0152b24853fe0d5de4179974b2b9d4a1cdbefcbc01d8d311" -"b5dda059136176ea698ab82acf20dd490be47130b1235cb48f8a6710473cfc923e222d94" -"b582f9ae36d4ca2a32d141b8e8cc36638845fbc499bce17698c3fecae2572dbbd4705524" -"30d7ef30c238c2124478f1f780483839b4fb73d63a9460206824a5b6b65315b21e3c2f24" -"c97ee7c0e78faad3df549c7ca8ef241876d9aafe9a309f6da352bec2caaa92ee8dca3928" -"99ba67dfed90aef33d41fc2494b765cb3e2422c8e595dabbfaca217757453fb322a13203" -"f425f6073a9903e2dc5818ee1da737afc345f0057744e3a56e1681c949eb12273a3bfc20" -"699e423b96e44bd1ff62e50a848a890809bfe1611c6787d3d741103308f849a790f9c015" -"098286dbacfc34c1718b2c2b77e32194a75dda37954a320fa68764027852855a7e5b5274" -"eb1e2cbcd27161d98b59ad245822015f48af82a45c0ed59be94f9af03d9736048570d6e3" -"ef63b1770bc98dfb77de84b1bb1708d872b625d9ab9b06c18e5dbbf34399391f0f8aa26e" -"c0dac7ff4cb8ec97b52bcb942fa6db2385dcd1b3b9d567aaeb425d567b0ebe267235651a" -"1ed9bf78fd93d3c1dd077fe340bb04b00529c58f45124b717c168d07e9826e33376988bc" -"5cf62845c2009980a4dfa69fbc7e5a0b1bb20a5958ca967aec68eb31dd8fccca9afcd30a" -"26bab26279f1bf6724ff", - "11863b483809ef88413ca9b0084ac4a5390640af", - - 6056, -"31ec3c3636618c7141441294fde7e72366a407fa7ec6a64a41a7c8dfda150ca417fac868" -"1b3c5be253e3bff3ab7a5e2c01b72790d95ee09b5362be835b4d33bd20e307c3c702aa15" -"60cdc97d190a1f98b1c78e9230446e31d60d25155167f73e33ed20cea27b2010514b57ba" -"b05ed16f601e6388ea41f714b0f0241d2429022e37623c11156f66dd0fa59131d8401dba" -"f502cffb6f1d234dcb53e4243b5cf9951688821586a524848123a06afa76ab8058bcfa72" -"27a09ce30d7e8cb100c8877bb7a81b615ee6010b8e0daced7cc922c971940b757a9107de" -"60b8454dda3452e902092e7e06faa57c20aadc43c8012b9d28d12a8cd0ba0f47ab4b377f" -"316902e6dff5e4f2e4a9b9de1e4359f344e66d0565bd814091e15a25d67d89cf6e30407b" -"36b2654762bbe53a6f204b855a3f9108109e351825cf9080c89764c5f74fb4afef89d804" -"e7f7d097fd89d98171d63eaf11bd719df44c5a606be0efea358e058af2c265b2da2623fd" -"afc62b70f0711d0150625b55672060cea6a253c590b7db1427a536d8a51085756d1e6ada" -"41d9d506b5d51bcae41249d16123b7df7190e056777a70feaf7d9f051fdbbe45cbd60fc6" -"295dda84d4ebbd7284ad44be3ee3ba57c8883ead603519b8ad434e3bf630734a9243c00a" -"a07366b8f88621ec6176111f0418c66b20ff9a93009f43432aaea899dad0f4e3ae72e9ab" -"a3f678f140118eb7117230c357a5caa0fe36c4e6cf1957bbe7499f9a68b0f1536e476e53" -"457ed826d9dea53a6ded52e69052faaa4d3927b9a3f9e8b435f424b941bf2d9cd6849874" -"42a44d5acaa0da6d9f390d1a0dd6c19af427f8bb7c082ae405a8dd535dea76aa360b4faa" -"d786093e113424bb75b8cc66c41af637a7b2acdca048a501417919cf9c5cd3b2fa668860" -"d08b6717eea6f125fa1b0bae1dbb52aafce8ae2deaf92aeb5be003fb9c09fedbc286ffb5" -"e16ad8e07e725faa46ebc35500cf205fc03250075ddc050c263814b8d16d141db4ca289f" -"386719b28a09a8e5934722202beb3429899b016dfeb972fee487cdd8d18f8a681042624f" -"51", - "f43937922444421042f76756fbed0338b354516f", - - 6848, -"21b9a9686ec200456c414f2e6963e2d59e8b57e654eced3d4b57fe565b51c9045c697566" -"44c953178f0a64a6e44d1b46f58763c6a71ce4c373b0821c0b3927a64159c32125ec916b" -"6edd9bf41c3d80725b9675d6a97c8a7e3b662fac9dbcf6379a319a805b5341a8d360fe00" -"5a5c9ac1976094fea43566d66d220aee5901bd1f2d98036b2d27eb36843e94b2e5d1f09c" -"738ec826de6e0034cf8b1dca873104c5c33704cae290177d491d65f307c50a69b5c81936" -"a050e1fe2b4a6f296e73549323b6a885c3b54ee5eca67aa90660719126b590163203909e" -"470608f157f033f017bcf48518bf17d63380dabe2bc9ac7d8efe34aedcae957aeb68f10c" -"8ad02c4465f1f2b029d5fbb8e8538d18be294394b54b0ee6e67a79fce11731604f3ac4f8" -"d6ffa9ef3d2081f3d1c99ca107a7bf3d624324a7978ec38af0bcd0d7ee568572328b212b" -"9dc831efb7880e3f4d6ca7e25f8e80d73913fb8edfffd758ae4df61b4140634a92f49314" -"6138ebdcdaa083ea72d52a601230aa6f77874dcad9479f5bcac3763662cc30cb99823c5f" -"f469dcbd64c028286b0e579580fd3a17b56b099b97bf62d555798f7a250e08b0e4f238c3" -"fcf684198bd48a68c208a6268be2bb416eda3011b523388bce8357b7f26122640420461a" -"bcabcb5004519adfa2d43db718bce7d0c8f1b4645c89315c65df1f0842e5741244bba3b5" -"10801d2a446818635d0e8ffcd80c8a6f97ca9f878793b91780ee18eb6c2b99ffac3c38ef" -"b7c6d3af0478317c2b9c421247eba8209ea677f984e2398c7c243696a12df2164417f602" -"d7a1d33809c865b73397550ff33fe116166ae0ddbccd00e2b6fc538733830ac39c328018" -"bcb87ac52474ad3cce8780d6002e14c6734f814cb551632bcc31965c1cd23d048b9509a4" -"e22ab88f76a6dba209d5dd2febd1413a64d32be8574a22341f2a14e4bd879abb35627ef1" -"35c37be0f80843006a7cc7158d2bb2a71bf536b36de20ca09bb5b674e5c408485106e6fa" -"966e4f2139779b46f6010051615b5b41cda12d206d48e436b9f75d7e1398a656abb0087a" -"a0eb453368fc1ecc71a31846080f804d7b67ad6a7aa48579c3a1435eff7577f4e6004d46" -"aac4130293f6f62ae6d50c0d0c3b9876f0728923a94843785966a27555dd3ce68602e7d9" -"0f7c7c552f9bda4969ec2dc3e30a70620db6300e822a93e633ab9a7a", - "5d4d18b24b877092188a44be4f2e80ab1d41e795", - - 7640, -"1c87f48f4409c3682e2cf34c63286dd52701b6c14e08669851a6dc8fa15530ad3bef692c" -"7d2bf02238644561069df19bdec3bccae5311fce877afc58c7628d08d32d9bd2dc1df0a6" -"24360e505944219d211f33bff62e9ff2342ac86070240a420ccaf14908e6a93c1b27b6e2" -"0324e522199e83692805cc4c7f3ea66f45a490a50d4dd558aa8e052c45c1a5dfad452674" -"edc7149024c09024913f004ceee90577ff3eaec96a1eebbdc98b440ffeb0cad9c6224efc" -"9267d2c192b53dc012fb53010926e362ef9d4238d00df9399f6cbb9acc389a7418007a6c" -"a926c59359e3608b548bdeece213f4e581d02d273781dffe26905ec161956f6dfe1c008d" -"6da8165d08f8062eea88e80c055b499f6ff8204ffdb303ab132d9b0cba1e5675f3525bbe" -"4cf2c3f2b00506f58336b36aefd865d37827f2fad7d1e59105b52f1596ea19f848037dfe" -"dc9136e824ead5505e2995d4c0769276548835430667f333fc77375125b29c1b1535602c" -"10fe161864f49a98fc274ae7335a736be6bf0a98cd019d120b87881103f86c0a6efadd8c" -"aa405b6855c384141b4f8751cc42dc0cb2913382210baaa84fe242ca66679472d815c08b" -"f3d1a7c6b5705a3de17ad157522de1eb90c568a8a1fbcbb422cca293967bb14bfdd91bc5" -"a9c4d2774dee524057e08f937f3e2bd8a04ced0fc7b16fb78a7b16ee9c6447d99e53d846" -"3726c59066af25c317fc5c01f5dc9125809e63a55f1cd7bdf7f995ca3c2655f4c7ab940f" -"2aa48bc3808961eb48b3a03c731ce627bb67dd0037206c5f2c442fc72704258548c6a9db" -"e16da45e40da009dc8b2600347620eff8361346116b550087cb9e2ba6b1d6753622e8b22" -"85589b90a8e93902aa17530104455699a1829efef153327639b2ae722d5680fec035575c" -"3b48d9ec8c8e9550e15338cc76b203f3ab597c805a8c6482676deabc997a1e4ba857a889" -"97ceba32431443c53d4d662dd5532aa177b373c93bf93122b72ed7a3189e0fa171dfabf0" -"520edf4b9d5caef595c9a3a13830c190cf84bcf9c3596aadb2a674fbc2c951d135cb7525" -"3ee6c59313444f48440a381e4b95f5086403beb19ff640603394931f15d36b1cc9f3924f" -"794c965d4449bfbdd8b543194335bdf70616dc986b49582019ac2bf8e68cfd71ec67e0aa" -"dff63db39e6a0ef207f74ec6108fae6b13f08a1e6ae01b813cb7ee40961f95f5be189c49" -"c43fbf5c594f5968e4e820a1d38f105f2ff7a57e747e4d059ffb1d0788b7c3c772b9bc1f" -"e147c723aca999015230d22c917730b935e902092f83e0a8e6db9a75d2626e0346e67e40" -"8d5b815439dab8ccb8ea23f828fff6916c4047", - "32e0f5d40ceec1fbe45ddd151c76c0b3fef1c938", - - 8432, -"084f04f8d44b333dca539ad2f45f1d94065fbb1d86d2ccf32f9486fe98f7c64011160ec0" -"cd66c9c7478ed74fde7945b9c2a95cbe14cedea849978cc2d0c8eb0df48d4834030dfac2" -"b043e793b6094a88be76b37f836a4f833467693f1aa331b97a5bbc3dbd694d96ce19d385" -"c439b26bc16fc64919d0a5eab7ad255fbdb01fac6b2872c142a24aac69b9a20c4f2f07c9" -"923c9f0220256b479c11c90903193d4e8f9e70a9dbdf796a49ca5c12a113d00afa844694" -"de942601a93a5c2532031308ad63c0ded048633935f50a7e000e9695c1efc1e59c426080" -"a7d1e69a93982a408f1f6a4769078f82f6e2b238b548e0d4af271adfa15aa02c5d7d7052" -"6e00095ffb7b74cbee4185ab54385f2707e8362e8bd1596937026f6d95e700340b6338ce" -"ba1ee854a621ce1e17a016354016200b1f98846aa46254ab15b7a128b1e840f494b2cdc9" -"daccf14107c1e149a7fc27d33121a5cc31a4d74ea6945816a9b7a83850dc2c11d26d767e" -"ec44c74b83bfd2ef8a17c37626ed80be10262fe63cf9f804b8460c16d62ae63c8dd0d124" -"1d8aaac5f220e750cb68d8631b162d80afd6b9bf929875bf2e2bc8e2b30e05babd8336be" -"31e41842673a66a68f0c5acd4d7572d0a77970f42199a4da26a56df6aad2fe420e0d5e34" -"448eb2ed33afbfb35dffaba1bf92039df89c038bae3e11c02ea08aba5240c10ea88a45a1" -"d0a8631b269bec99a28b39a3fc5b6b5d1381f7018f15638cc5274ab8dc56a62b2e9e4fee" -"f172be20170b17ec72ff67b81c15299f165810222f6a001a281b5df1153a891206aca89e" -"e7baa761a5af7c0493a3af840b9219e358b1ec1dd301f35d4d241b71ad70337bda42f0ea" -"dc9434a93ed28f96b6ea073608a314a7272fefd69d030cf22ee6e520b848fa705ed6160f" -"e54bd3bf5e89608506e882a16aced9c3cf80657cd03749f34977ced9749caa9f52b683e6" -"4d96af371b293ef4e5053a8ea9422df9dd8be45d5574730f660e79bf4cbaa5f3c93a79b4" -"0f0e4e86e0fd999ef4f26c509b0940c7a3eaf1f87c560ad89aff43cd1b9d4863aa3ebc41" -"a3dd7e5b77372b6953dae497fc7f517efe99e553052e645e8be6a3aeb362900c75ce712d" -"fcba712c4c25583728db9a883302939655ef118d603e13fcf421d0cea0f8fb7c49224681" -"d013250defa7d4fd64b69b0b52e95142e4cc1fb6332486716a82a3b02818b25025ccd283" -"198b07c7d9e08519c3c52c655db94f423912b9dc1c95f2315e44be819477e7ff6d2e3ccd" -"daa6da27722aaadf142c2b09ce9472f7fd586f68b64d71fc653decebb4397bf7af30219f" -"25c1d496514e3c73b952b8aa57f4a2bbf7dcd4a9e0456aaeb653ca2d9fa7e2e8a532b173" -"5c4609e9c4f393dd70901393e898ed704db8e9b03b253357f333a66aba24495e7c3d1ad1" -"b5200b7892554b59532ac63af3bdef590b57bd5df4fbf38d2b3fa540fa5bf89455802963" -"036bd173fe3967ed1b7d", - "ee976e4ad3cad933b283649eff9ffdb41fcccb18", - - 9224, -"bd8320703d0cac96a96aeefa3abf0f757456bf42b3e56f62070fc03e412d3b8f4e4e427b" -"c47c4600bb423b96de6b4910c20bc5c476c45feb5b429d4b35088813836fa5060ceb26db" -"bb9162e4acd683ef879a7e6a0d6549caf0f0482de8e7083d03ed2f583de1b3ef505f4b2c" -"cd8a23d86c09d47ba05093c56f21a82c815223d777d0cabb7ee4550423b5deb6690f9394" -"1862ae41590ea7a580dda79229d141a786215d75f77e74e1db9a03c9a7eb39eb35adf302" -"5e26eb31ca2d2ca507edca77d9e7cfcfd136784f2117a2afafa87fa468f08d07d720c933" -"f61820af442d260d172a0a113494ca169d33a3aeaacdcc895b356398ed85a871aba769f6" -"071abd31e9f2f5834721d0fef6f6ee0fc0e38760b6835dfcc7dbefb592e1f0c3793af7ad" -"f748786d3364f3cfd5686b1a18711af220e3637d8fad08c553ce9d5dc1183d48e8337b16" -"1fe69b50e1920316dbffec07425b5d616a805a699576590e0939f5c965bce6c7342d314a" -"c37b9c4d30166567c4f633f182de4d6b00e20a1c762789f915eaa1c89ac31b85222b1f05" -"403dedd94db9ce75ff4e49923d1999d032695fa0a1c595617830c3c9a7ab758732fcec26" -"85ae14350959b6a5f423ef726587e186b055a8daf6fa8fdefa02841b2fdbca1616dcee78" -"c685fc6dcc09f24a36097572eba3c37a3eabe98bc23836085f63ef71a54b4488615d83b2" -"6ed28c9fce78852df9b6cf8a75ca3899a7567298e91bc4ffdd04ffab0066b43b8286a4bb" -"555c78808496b252c6e0e4d153631f11f68baf88630e052acc2af5d2af2e22e4f23bb630" -"314c561a577455f86b6727bcad3c19d3e271404dec30af3d9dd0ed63cd9fa708aadfa12a" -"500ef2d99a6b71e137b56ba90036975b88004b45f577ef800f0fb3cf97577dc9da37253b" -"8675e5c8bb7e0bd26564f19eca232fb25f280f82e014424c9fbdd1411d7556e5d7906bb8" -"62206316ba03385cd820c54c82ed35b36735bc486b1885d84053eba036c1ebfb5422d93d" -"a71c53deda7f74db07cd4959cdfa898ba37080d76b564d344b124dd7b80cd70ed3b52a6c" -"f9c9a32695d134bd39eb11ddeecdac86c808e469bd8a7995b667c452e7d9a54d5c85bcf6" -"d5ffdc27d491bc06f438f02c7cf018073431587c78ba08d18a8daccb2d3b26136f612ade" -"c673f3cd5eb83412b29652d55a10d0d6238d0b5365db272c917349450aff062c36191cfc" -"d45660819083f89cd42ecae9e26934a020cafeb9b2b68d544edf59574c0ca159fd195dbf" -"3e3e74244d942fffdbd4ed7f626219bab88b5a07e50b09a832d3e8ad82091114e54f2c35" -"6b48e55e36589ebad3ac6077cb7b1827748b00670df65bbf0a2e65caad3f8a97d654d64e" -"1c7dad171cafbc37110d2f7ca66524dc08fe60593e914128bd95f41137bfe819b5ca835f" -"e5741344b5c907ce20a35f4f48726141c6398e753ed9d46d3692050628c78859d5014fe4" -"dd3708e58d4d9807f8dac540492e32fa579491717ad4145c9efc24cf95605660b2e09b89" -"9369b74d3ebff41e707917ff314d93e6ac8dfd643ef2c087cd9912005b4b2681da01a369" -"42a756a3e22123cbf38c429373c6a8663130c24b24b2690b000013960b1c46a32d1d5397" -"47", - "2df09b10933afedfcd3f2532dfd29e7cb6213859", - - 10016, -"7a94978bec7f5034b12c96b86498068db28cd2726b676f54d81d8d7350804cc106bead8a" -"252b465a1f413b1c41e5697f8cece49ec0dea4dfb9fa7b1bfe7a4a00981875b420d094bb" -"1ce86c1b8c2e1dbebf819c176b926409fdec69042e324e71d7a8d75006f5a11f512811fe" -"6af88a12f450e327950b18994dfc3f740631beda6c78bca5fe23d54e6509120e05cd1842" -"d3639f1466cf26585030e5b4aefe0404fe900afc31e1980f0193579085342f1803c1ba27" -"0568f80eaf92440c4f2186b736f6ab9dc7b7522ccdcfc8cf12b6375a2d721aa89b5ef482" -"112a42c31123aebabcb485d0e72d6b6b70c44e12d2da98d1f87fa9df4f37847e1ffec823" -"1b8be3d737d282ddb9cc4b95937acfa0f028ba450def4d134a7d0fc88119bf7296e18cd4" -"4f56890b661b5b72ddfa34c29228067e13caf08eb3b7fd29de800df9a9ae137aad4a81a4" -"16a301c9f74b66c0e163e243b3187996b36eb569de3d9c007d78df91f9b554eef0eaa663" -"88754ce20460b75d95e2d0747229a1502a5652cf39ca58e1daa0e9321d7ab3093981cd70" -"23a7ee956030dd70177028a66ad619ad0629e631f91228b7c5db8e81b276d3b168c1edb1" -"bc0888d1cbcbb23245c2d8e40c1ff14bfe13f9c70e93a1939a5c45eef9351e795374b9e1" -"b5c3a7bd642477ba7233e1f590ab44a8232c53099a3c0a6ffe8be8b7ca7b58e6fedf700f" -"6f03dd7861ee1ef857e3f1a32a2e0baa591d0c7ca04cb231cc254d29cda873f00d68f465" -"00d6101cfdc2e8004c1f333d8007325d06ffe6b0ff7b80f24ba51928e65aa3cb78752028" -"27511207b089328bb60264595a2cebfc0b84d9899f5eca7ea3e1d2f0f053b4e67f975500" -"7ff3705ca4178ab9c15b29dd99494135f35befbcec05691d91f6361cad9c9a32e0e65577" -"f14d8dc66515081b51d09e3f6c25eea868cf519a83e80c935968cae6fce949a646ad53c5" -"6ee1f07dda23daef3443310bc04670afedb1a0132a04cb64fa84b4af4b3dc501044849cd" -"dd4adb8d733d1eac9c73afa4f7d75864c87787f4033ffe5ba707cbc14dd17bd1014b8b61" -"509c1f55a25cf6c0cbe49e4ddcc9e4de3fa38f7203134e4c7404ee52ef30d0b3f4e69bcc" -"7d0b2e4d8e60d9970e02cc69d537cfbc066734eb9f690a174e0194ca87a6fadad3883d91" -"6bd1700a052b26deee832701590d67e6f78938eac7c4beef3061a3474dd90dd588c1cd6e" -"6a4cda85b110fd08a30dcd85a3ebde910283366a17a100db920885600db7578be46bcfa6" -"4765ba9a8d6d5010cb1766d5a645e48365ed785e4b1d8c7c233c76291c92ef89d70bc77f" -"bf37d7ce9996367e5b13b08242ce73971f1e0c6ff2d7920fb9c821768a888a7fe0734908" -"33efb854cbf482aed5cb594fb715ec82a110130664164db488666d6198279006c1aa521f" -"9cf04250476c934eba0914fd586f62d6c5825b8cf82cd7ef915d93106c506ea6760fd8b0" -"bf39875cd1036b28417de54783173446026330ef701c3a6e5b6873b2025a2c1666bb9e41" -"a40adb4a81c1052047dabe2ad092df2ae06d6d67b87ac90be7d826ca647940c4da264cad" -"43c32a2bb8d5e27f87414e6887561444a80ed879ce91af13e0fbd6af1b5fa497ad0cbd2e" -"7f0f898f52f9e4710de2174e55ad07c45f8ead3b02cac6c811becc51e72324f2439099a0" -"5740090c1b165ecae7dec0b341d60a88f46d7ad8624aac231a90c93fad61fcfbbea12503" -"59fcd203862a6b0f1d71ac43db6c58a6b60c2c546edc12dd658998e8", - "f32e70862a16e3e8b199e9d81a9949d66f812cad", - - 10808, -"88dd7f273acbe799219c23184782ac0b07bade2bc46b4f8adbd25ed3d59c0fd3e2931638" -"837d31998641bbb7374c7f03d533ca60439ac4290054ff7659cc519bdda3dff2129a7bdb" -"66b3300068931ade382b7b813c970c8e15469187d25cb04b635403dc50ea6c65ab38a97c" -"431f28a41ae81c16192bd0c103f03b8fa815d6ea5bf0aa7fa534ad413b194eb12eb74f5d" -"62b3d3a7411eb8c8b09a261542bf6880acbdfb617a42e577009e482992253712f8d4c8bd" -"1c386bad068c7aa10a22111640041f0c35dabd0de00ebf6cd82f89cbc49325df12419278" -"ec0d5ebb670577b2fe0c3e0840c5dd0dc5b3da00669eed8ead380f968b00d42f4967faec" -"c131425fce1f7edb01cbec7e96d3c26fa6390a659e0ab069ef3edadc07e077bb816f1b22" -"98830a0fe2b393693bb79f41feca89577c5230e0a6c34b860dc1fdb10d85aa054481082c" -"494779d59ba798fcd817116c3059b7831857d0364352b354ce3b960fbb61a1b8a04d47ca" -"a0ead52a9bea4bada2646cdbaec211f391dac22f2c5b8748e36bfc3d4e8ea45131ca7f52" -"af09df21babe776fcecbb5c5dfa352c790ab27b9a5e74242bbd23970368dbefd7c3c74d1" -"61ae01c7e13c65b415f38aa660f51b69ea1c9a504fe1ad31987cb9b26a4db2c37d7b326c" -"50dbc8c91b13925306ff0e6098532dee7282a99c3ddf99f9e1024301f76e31e58271870b" -"d94b9356e892a6a798d422a48c7fd5b80efe855a4925cc93b8cf27badec5498338e2b538" -"70758b45d3e7a2fa059ed88df320a65e0a7cf87fa7e63b74cea1b7371e221f8004726642" -"30d4d57945a85b23d58f248c8cd06ccfabfa969ab8cb78317451fab60e4fdfa796e2e2a8" -"b46405839a91266d37e8d38bae545fb4060c357923b86d62f5d59d7bef5af20fbb9c7fb4" -"2c6fd487748ed3b9973dbf4b1f2c9615129fa10d21cc49c622842c37c01670be71715765" -"a98814634efbdee66bf3420f284dbd3efafc8a9117a8b9a72d9b81aa53ded78c409f3f90" -"bad6e30d5229e26f4f0cea7ee82c09e3b60ec0e768f35a7fb9007b869f9bfc49c518f648" -"3c951d3b6e22505453266ec4e7fe6a80dbe6a2458a1d6cd93044f2955607412091009c7d" -"6cd81648a3b0603c92bfdff9ec3c0104b07ed2105962ca7c56ede91cb932073c337665e2" -"409387549f9a46da05bc21c5126bd4b084bc2c06ab1019c51df30581aa4464ab92978c13" -"f6d7c7ac8d30a78f982b9a43181bbe3c3eb9f7a1230b3e53b98a3c2a028317827fbe8cf6" -"ec5e3e6b2a084d517d472b25f72fab3a34415bba488f14e7f621cfa72396ba40890e8c60" -"b04815601a0819c9bebc5e18b95e04be3f9c156bd7375d8cc8a97c13ce0a3976123419fa" -"592631317ca638c1182be06886f9663d0e8e6839573df8f52219eeb5381482a6a1681a64" -"173660bfbb6d98bf06ee31e601ee99b4b99b5671ed0253260b3077ed5b977c6a79b4ff9a" -"08efd3cba5c39bec1a1e9807d40bbf0c988e0fd071cf2155ed7b014c88683cd869783a95" -"4cbfced9c0e80c3a92d45b508985cbbc533ba868c0dc4f112e99400345cf7524e42bf234" -"5a129e53da4051c429af2ef09aba33ae3c820ec1529132a203bd2b81534f2e865265f55c" -"9395caf0e0d3e1762c95eaaec935e765dc963b3e0d0a04b28373ab560fa9ba5ca71ced5d" -"17bb8b56f314f6f0d0bc8104b3f1835eca7eaac15adf912cf9a6945cfd1de392342dd596" -"d67e7ffcb7e086a6c1ea318aa2e0c2b5c2da079078232c637de0d317a1f26640bc1dac5b" -"e8699b53edc86e4bfdfaf797a2ae350bf4ea29790face675c4d2e85b8f37a694c91f6a14" -"1fd561274392ee6ee1a14424d5c134a69bcb4333079400f03615952fc4c99bf03f5733a8" -"dc71524269fc5c648371f5f3098314d9d10258", - "08632c75676571a5db5971f5d99cb8de6bf1792a", - - 11600, -"85d43615942fcaa449329fd1fe9efb17545eb252cac752228f1e9d90955a3cf4e72cb116" -"3c3d8e93ccb7e4826206ff58b3e05009ee82ab70943db3f18a32925d6d5aed1525c91673" -"bd33846571af815b09bb236466807d935b5816a8be8e9becbe65d05d765bcc0bc3ae66c2" -"5320ebe9fff712aa5b4931548b76b0fd58f6be6b83554435587b1725873172e130e1a3ca" -"3d9d0425f4632d79cca0683780f266a0633230e4f3b25f87b0c390092f7b13c66ab5e31b" -"5a58dbcac8dd26a0600bf85507057bb36e870dfae76da8847875a1a52e4596d5b4b0a211" -"2435d27e1dc8dd5016d60feaf2838746d436a2983457b72e3357059b2bf1e9148bb0551a" -"e2b27d5a39abd3d1a62c36331e26668e8baabc2a1ef218b5e7a51a9ca35795bcd54f403a" -"188eafafb30d82896e45ddaea4f418629a1fb76a0f539c7114317bac1e2a8fba5a868bce" -"40abd40f6b9ced3fa8c0329b4de5ca03cc84d75b8746ef31e6c8d0a0a79b4f747690928e" -"be327f8bbe9374a0df4c39c845bf3322a49fda9455b36db5a9d6e4ea7d4326cf0e0f7cd8" -"0ff74538f95cec01a38c188d1243221e9272ccc1053e30787c4cf697043cca6fc3730d2a" -"431ecbf60d73ee667a3ab114c68d578c66dc1c659b346cb148c053980190353f6499bfef" -"acfd1d73838d6dc1188c74dd72b690fb0481eee481a3fd9af1d4233f05d5ae33a7b10d7d" -"d643406cb1f88d7dd1d77580dcbee6f757eeb2bfbcc940f2cddb820b2718264b1a64115c" -"b85909352c44b13d4e70bbb374a8594d8af7f41f65b221bf54b8d1a7f8f9c7da563550cb" -"2b062e7a7f21d5e07dd9da8d82e5a89074627597551c745718094c2eb316ca077526d27f" -"9a589c461d891dc7cd1bc20ba3f464da53c97924219c87a0f683dfb3b3ac8793c59e78ac" -"fac109439221ac599a6fd8d2754946d6bcba60784805f7958c9e34ff287ad1dbbc888848" -"fa80cc4200dbb8c5e4224535906cbffdd0237a77a906c10ced740f9c0ce7821f2dbf8c8d" -"7d41ecfcc7dfdc0846b98c78b765d01fb1eb15ff39149ab592e5dd1152665304bba85bbf" -"4705751985aaaf31245361554d561a2337e3daeef58a826492fd886d5f18ef568c1e772e" -"f6461170407695e3254eb7bf0c683811ddde5960140d959114998f08bdb24a104095987d" -"3255d590e0dbd41ae32b1ae4f4ea4a4f011de1388034231e034756870c9f2d9f23788723" -"27055a7de2b5e931dfb53e7780b6d4294bf094e08567025b026db9203b681565a1d52f30" -"318d0ebe49471b22ba5fd62e1ed6c8966c99b853c9062246a1ace51ef7523c7bf93bef53" -"d8a9cb96d6a04f0da1eca888df66e0380a72525a7ecc6115d08569a66248f6ba34e2341b" -"fd01a78f7b3c1cfe0754e0d26cba2fa3f951ef14d5749ff8933b8aba06fa40fb570b467c" -"54ce0d3f0bed21e998e5a36b3bc2f9e1ae29c4bab59c121af6fad67c0b45959cd6a86194" -"14b90b4535fb95f86ca7e64502acc135eff4f8a3abe9dde84238fab7a7d402454a3f07ad" -"ec05ec94b2891e0879037fae6acaa31dcecf3f85236ade946f5ad69ad4077beb65099285" -"38ee09f2bc38e5704da67b5006b5e39cd765aafcd740c7dadb99d0c547126e1324610fcb" -"7353dac2c110e803fca2b17485b1c4b78690bc4f867e6f043b2568889f67985a465a48eb" -"ee915200589e915756d4968d26529c3ffe3dbe70e84c682ad08a0c68db571634fbb0210d" -"c1b16b8b725886465c8c51f36a5e27d0f78e5643e051d3bddd512ce511f6bdf3dfe42759" -"00c5fea9d248c2b3f36911ed0ff41a19f6445521f251724657ea8f795b3ead0928a1657f" -"308dd7c7c1e7e490d9849df43becfa5cc25ed09ef614fd69ddc7e5e3147623901d647876" -"fb60077ffc48c51ed7d02b35f6802e3715fc708a0c88b82fe9cba0a442d38d09ca5ae483" -"21487bdef1794e7636bf7457dd2b51a391880c34d229438347e5fec8555fe263f08ba87b" -"b16dcde529248a477628067d13d0cb3bf51776f4d39fb3fbc5f669e91019323e40360e4b" -"78b6584f077bf9e03b66", - "ab7213f6becb980d40dc89fbda0ca39f225a2d33", - - 12392, -"7ae3ca60b3a96be914d24980fb5652eb68451fed5fa47abe8e771db8301fbd5331e64753" -"93d96a4010d6551701e5c23f7ecb33bec7dd7bade21381e9865d410c383a139cb4863082" -"8e9372bd197c5b5788b6599853e8487bddfd395e537772fdd706b6a1de59c695d63427da" -"0dc3261bce2e1ae3cd6de90ec45ecd7e5f14580f5672b6ccd8f9336330dffcd6a3612a74" -"975afc08fb136450e25dc6b071ddfc28fca89d846c107fd2e4bd7a19a4ff6f482d62896d" -"a583c3277e23ab5e537a653112cdf2306043b3cc39f5280bd744fe81d66f497b95650e7d" -"dfd704efcb929b13e00c3e3a7d3cd53878af8f1506d9de05dba9c39a92604b394ea25acb" -"a2cda7b4ae8b08098ba3f0fdea15359df76517be84377f33631c844313ac335aa0d590fe" -"c472d805521f0905d44ca40d7391b292184105acd142c083761c1a038c4f5ed869ea3696" -"99592a37817f64cb4205b66be1f1de6fa47a08e1bf1a94312fe61a29e71bab242af95a7b" -"38d4fb412c682b30256d91e2a46b634535d02b495240cbdb842cbe17cba6a2b94073f3d5" -"f9621ac92ddda66f98bed997216466b4bb0579d58945f8d7450808d9e285d4f1709d8a1d" -"416aa57d4a1a72bfcbfecdda33de2cff3e90e0cc60c897c4663224fc5bbe8316a83c1773" -"802837a57bc7e9238173ed41ea32fe5fe38e546014a16d5e80700d9bac7a84bb03902f31" -"79e641f86f6bc383d656daf69801499633fb367ea7593195934c72bc9bf9624c0c845ebf" -"c36eb7ad4b22fdfb45ca7d4f0d6708c69a21f6eaa6db6bde0f0bd9dc7ec9c6e24626d0a7" -"8fbeeed4b391f871e80e6a9d207165832d4ff689296f9bca15dc03c7c0381659ea5335eb" -"aafdc3e50d18e46b00f1844870d09c25afcdb0ff1ae69dd8f94f91aca6095ba6f2b6e594" -"c4acfe9903485d21b684e31a6acc2162d40e1a7bb8114a860a07e76f5265666555f2418d" -"f11ef8f7499656d12215f5da8d7d041ac72648d15d7661ad93b24f3f071334b0921d5bb0" -"6f2c7ab09f5034518b5ae21cec379373e87d51c77d44a70c2337606aadeb9036716fd920" -"a824e7ae18ce3de9f0ec3456f3454027d8c476b3f1854b240c309f6f9786fa8a073915d9" -"7a019ce99aec3260c5f6b6346cd9c41cb9267f4475958e45289965548238c6b9f91a8784" -"b4e0957ba8b73956012c9a2fc3428434b1c1679f6ed2a3e8e2c90238df428622046f668e" -"e2b053f55e64ffd45600e05a885e3264af573bacee93d23d72a0222b5442ac80bc0a8b79" -"4c2afcf3bc881d20c111f57e3450b50a703f3db1fc5de2076a006f3b7eed694b93269874" -"3b03c2ed2684bad445e69a692e744c7ac3a04f1e0e52b7a6708076d1fbffdb3f1c995828" -"7d5f884e29407030f2db06811092efd80ae08da9daec39744c5ecd3ca771663b8f4968d4" -"2a88c2c9821c73ae2a5a4d9e2551f82c03583b9c4dea775423b4748d24eb604e8ee3159b" -"a6de9bea5b22eed6264e011734ed02b2c74ce06dda890b8604ed7ba49e7bf30e28c9871b" -"e90f5cead67eaf52b5d3181c822b10701219b28ef6f6bebfa278e38acf863e2a1d4b1e40" -"fd8a0ac6ce31054446301046148bf10dc3ae3385e2026e7762bdc8003ffebc4263191a59" -"c72f4f90db03e7d52808506b33bfe1dfa53f1a3daa152e83974fbe56cfd4e8f4e7f7806a" -"084b9d0795b858100eced0b5355a72446f37779d6c67ade60a627b8077ae1f3996b03bc3" -"a5c290651c8609f0d879fbf578cbab35086e1159dd6ddbe3bf7fb5654edcc8f09e4f80d0" -"258c9376d7c53fb68f78d333b18b70170d9a11070790c956f5744c78c986b1baf08b7631" -"7a65c5f07ae6f57eb0e65488659324d29709e3735623d0426e90aa8c4629bb080881150c" -"02be1c004da84414ac001c2eb6138c26388f5a36d594f3acef0e69e2cb43b870efa84da0" -"cff9c923a9880202aed64ad76260f53c45bb1584b3e388a909d13586094b924680006a1d" -"25d4dd36c579a8ec9d3fa63c082d977a5a5021440b5314b51850f2daa6e6af6ae88cb5b1" -"44242bceb1d4771e641101f8abfc3a9b19f2de64e35e76458ad22072ba57925d73015de5" -"66c66fcaa28fdc656f90de967ad51afd331e246d74ed469d63dd7d219935c59984bd9629" -"09d1af296eb3121d782650e7d038063bab5fa854aac77de5ffebeb53d263f521e3fc02ac" -"70", - "b0e15d39025f5263e3efa255c1868d4a37041382", - - 13184, -"fa922061131282d91217a9ff07463843ae34ff7f8c28b6d93b23f1ea031d5020aa92f660" -"8c3d3df0ee24a8958fd41af880ee454e36e26438defb2de8f09c018607c967d2f0e8b80a" -"00c91c0eabe5b4c253e319b45e6106ff8bf0516f866020e5ba3f59fd669c5aeff310ebb3" -"85007069d01c64f72d2b02f4ec0b45c5ecf313056afcb52b17e08b666d01fecc42adb5b4" -"9ea00c60cacac2e0a953f1324bdd44aec00964a22a3cb33916a33da10d74ec6c6577fb37" -"5dc6ac8a6ad13e00cba419a8636d4daac8383a2e98fe90790cde7b59cfaa17c410a52abc" -"d68b127593d2fcbafd30578d195d890e981ae09e6772cb4382404a4e09f1a33c958b57db" -"ccee54ae335b6c91443206a0c100135647b844f226417a1f70317fd350d9f3789d81894a" -"aff4730072401aaeb8b713ead4394e2e64b6917d6eee2549af7bd0952f12035719065320" -"ca0d2dfe2847c6a2357c52bee4a676b12bafff66597bd479aa29299c1896f63a7523a85a" -"b7b916c5930ab66b4d191103cefc74f2f7e0e96e354f65e355ae43959a0af1880d14ea9d" -"1569e4fd47174aba7f5decb430b3f6baf80a1ef27855227b62487250d3602970e423423c" -"7ca90920685bcf75adfbe2a61ce5bd9228947b32f567927cb1a5bd8727c03aef91d6367b" -"ae7d86fd15c0977ac965a88b0d7236037aefb8d24eec8d2a07c633e031a7b9147c4c7714" -"110bfc7e261448a5d0f73c3619664e1c533c81a0acbf95d502227a33f84f0b8249e3f9fa" -"5c7905a8192b7313fc56bb20679e81333d32c797ac5162204a0eaa0e64507635921c485b" -"8f17c4e2484667a733197529e2a833eed83c57229b11bd820b5a5b78f1867787dbc217ea" -"28bfba785fb545cbc5a840a12eea428213e1aaa4e50a900ba13efcf4a5345574c2481c5d" -"927ada610bba567a55630c89d905db3d9b67fe36c9cc3d6a947664c83e69f51c74711a33" -"df66dd3ff6af9b7c1605b614d4798b4192b9a4b1508f2e2ec5aaad7eaea1ee8867353db9" -"b8d7d9a6f16aa5f339492073238c979082879aee7f94ac4be8133eaacbaedfb044e2ad4e" -"93ba0fa071dea615a5cd80d1d2678f4f93ae5a4bc9cdf3df345a29ec41d8febb23805ce4" -"2541036f3f05c63ae736f79a29802045fad9f370cabf843458c1b636ca41f387fd7821c9" -"1abbd1946afcb9186b936403233f28a5b467595131a6bc07b0873e51a08de66b5d7709a6" -"02c1bd0e7f6e8f4beb0579c51bda0e0c738ef876fcd9a40ab7873c9c31c1d63a588eebc7" -"8d9a0ae6fa35cd1a269e0d2bc68252cbd7c08d79e96f0aa6be22a016136a2b8abe9d3c9c" -"f9d60eeafe3dbc76d489b24d68c36167df4c38cf2b21cf03dc5e659e39018c3490f1237e" -"ca3f85b742ab0045d86a899c4126ad60a147cbc95b71814c274d6478668df41eb32acfb4" -"bbf024fb4e3d6be0b60653a0471afc3037ab67dcb00a2b2e24b26911e1880136e56106b7" -"f3c570fbe6f311d94624cb001914ff96fbbf481f71686aa17be0850568058fc1ee8900b4" -"7af5cf51c5ed9e00a8b532c131f42513f6b8df14a9bbc2e9ede5a560681184d41a147552" -"edfbdef98d95e6a7793229d25ba9b0b395a020aa1c0731de89e662246d59ec22e5d8f4b4" -"6fbc048efcffbc234744c5c66417070f9c751c81788f04691ccb1a09d60c46f6f73375bf" -"e2e646cf6290069541a8dfe216374c925e94d06ece72e851e81d3e8acd011f82526c2f9f" -"55955c6752dc10e93153ab58627e30fa2c573e4042954337982eec1f741be058c85bad86" -"bf3a02ed96d3201dadd48bd4de8105200dfcbcc400c3c3dd717abfc562ebe338b14b1eb5" -"ecbe9227661e49c58bf8233770d813faafc78b05711135adcc4ce4c65095ca0bdc1debc0" -"b6e5d195dbc582ce94b3afa14a422edf9b69abd7ae869a78c3a26fb50ef7122ec5af8d0c" -"78ef082ca114f8817c3d93b31809870caea2eb9533fa767c2954efb9ba07e4f1077e9f9b" -"be845661eabea2c91079321477a7c167c7234528d63d6aabbe723e0e337b2e61138a310a" -"3fd04368aa4215b7af9d0334a8a74681bcb86b4af87a0329a1ed9dc7c9aef14521785eda" -"0eeb97bdff8c9945fd0ee04e84d0dae091a69c0bfcdcd4150878fed839c0db6565fc1fed" -"0e7d6ae2efde7a59d58a9fb3b07e6f7cea51ba93f771c18b2eafa252d7fe171085776052" -"a6a17e6858f0a20b7e8be54413523989bf20a028a84d9ce98b78e6ee0b8362df49de5344" -"b409cc322354672a21ea383e870d047551a3af71aaf2f44f49a859cf001e61b592dd036f" -"c6625bf7b91ea0fb78c1563cceb8c4345bf4a9fbe6ee2b6bf5e81083", - "8b6d59106f04300cb57c7c961945cd77f3536b0a", - - 13976, -"162cca41155de90f6e4b76a34261be6666ef65bdb92b5831b47604ce42e0c6c8d2eda265" -"ab9a3716809bf2e745e7831a41768d0f6349a268d9ac6e6adfb832a5d51b75d7951cf60e" -"03d9e40de6d351f1f6ade5143531cf32839401ca6dfb9dc7473daa607aeb0c3d1e8eb3db" -"cc2f1231ad1dd394d7eac9d8dab726b895b1ee774fdcabc8031063ecfa41c71a9f03ad23" -"904cc056f17c76a1059c43faffe30dfd157fdfd7d792e162bf7a889109550a0fc4c41523" -"2af0c0d72dcbc2595299e1a1c2aeae549f7970e994c15e0ab02f113d740d38c32a4d8ec0" -"79cd099d37d954ab7ef2800902cdf7c7a19fb14b3c98aaf4c6ad93fe9a9bc7a61229828e" -"55ad4d6270d1bdbca9975d450f9be91e5699bd7ee22e8c9c22e355cf1f6793f3551cb510" -"c1d5cd363bdf8cab063e6e49a6383221f1188d64692c1f84c910a696de2e72fb9886193f" -"61ab6b41ad0ea894d37ff1261bf1fd1f187e0d0c38ab223d99ec6d6b1e6b079fc305e24e" -"2d9500c98676e2d587434495d6e107b193c06fb12d5d8eaa7b0c001d08f4d91cae5bdcae" -"6624ee755e95ca8e4c5ef5b903d7f5ba438abeffd6f16d82d88138f157e7a50d1c91fb50" -"c770f6d222fcbf6daf791b1f8379e3b157a3b496ddb2e71650c1c4ac4fc5f2aceb5b3228" -"ffc44e15c02d4baa9434e60928a93f21bc91cfd3c2719f53a8c9bcd2f2dee65a8bbc88f9" -"5d7ced211fc3b04f6e8b74eb2026d66fd57fa0cccea43f0a0381782e6fee5660afed674d" -"cb2c28cb54d2bdbbaf78e534b0742ede6b5e659b46cd516d5362a194dd0822f6417935c4" -"ff05815b118fe5687cd8b050240015cfe449d9dfde1f4fdb105586e429b2c1849aac2791" -"ef73bc54603190eba39037ec057e784bb92d497e705dfcde2addb3514b4f1926f12d5440" -"850935779019b23bd0f2977a8c9478c424a7eaaeec04f3743a77bee2bec3937412e707bc" -"92a070046e2f9c35fe5cc3f755bbb91a182e683591ab7e8cff40633730546e81522f588f" -"07bdf142b78e115d2a22d2eb5664fcdb7574c1ee5ba9abd307d7d29078cd5223c222fc69" -"60324c40cc639be84dad96b01059efce7b08538ebef89bafab834609c7e82774a14e5be6" -"62067edba6111efa8ae270f5066442b17e3f31a793581c8a3f96d92921ec26981594e28a" -"08987d020b97ad2ba5c662836e35fd3fd954bcec52b579528913959d0d942fbf1c4b9910" -"ba010c3700359a4eb7616541257f0f7727cc71b580cc903f718ecc408a315b6bbfa7f6e3" -"beb9d258804bd2731ee2fb75e763281baf1effc4690a23d5f952ab5d4311d4f5885af2eb" -"f27cad9f6d84692cb903064bbd11ca751f919b4811b7722c6ec80c360521e34d357b5c8b" -"ba6d42e5c632730f53add99ab8aa9c607b6796216753086ede158bc670d04900aca66ce8" -"357bd72d19fb147b5fde8ee4df6a0184573a2e65ba3fd3a0cb04dac5eb36d17d2f639a6e" -"b602645f3ab4da9de4c9999d6506e8e242a5a3216f9e79a4202558ecdc74249ad3caaf90" -"71b4e653338b48b3ba3e9daf1e51e49384268d63f37ce87c6335de79175cdf542d661bcd" -"74b8f5107d6ab492f54b7c3c31257ecb0b426b77ed2e2ed22bbfdaf49653e1d54e5988fa" -"d71397546f9955659f22b3a4117fc823a1e87d6fb6fb8ab7d302a1316975e8baf0c0adbd" -"35455655f6a596b6ac3be7c9a8ea34166119d5e70dfbc1aa6e14ff98eff95e94ef576656" -"5d368ec8857fb0b029bcb990d420a5ca6bc7ab08053eb4dbfc4612a345d56faefc5e03a4" -"43520b224de776a5b618e1aa16edc513d5fcefcd413031b0ddc958a6fca45d108fbde065" -"3cf2d11cb00a71cd35f57993875598b4e33e2384623a0986859105d511c717c21d6534bf" -"69fd3d7cf1682e4fc25298d90df951e77a316996beac61bb7078988118c906548af92cfe" -"72cd4b102ffad584e5e721a0cdb5621ed07dda8955d84bea57a5afa4ba06289ddfac3a9e" -"765538fd9392fc7904cedb65e38cd90967f01845ff819777a22d199f608e62c13e6ba98b" -"40824b38c784bdb41d62c4014fc7e8d93be52695e975e54d1ff92b412f451177143d74a6" -"bde0ee53a986043ab465a1ef315ac4c538e775ef4178fde5f2ea560a364de18b8fe9578a" -"ad80027c3fd32dcf0967d9d03789b1cdf19040762f626289cf3af8afe5a8e0a152d9258e" -"981872c1ec95cd7f8d65812e55cb5cbd8db61b3f068a23d9652372dfbf18d43a663c5a0d" -"026b0898e383ce5c95b0ba7fb5ed6b7304c7c9d3ba64f38d1dc579465148ccfa7271f2e3" -"e0e97e9ddac7c0874f0f396cf07851638a734df393687b7b0343afd1652ff32a2da17b3a" -"4c99d79c02256c73f32625527e5666594a8a42a12135eddb022e743371b3ab7b12ad6785" -"7635eed03558ac673d17280769b2368056276d5d72f5dbc75525f8a7558bd90b544aa6cb" -"dd964e6c70be79441969bfdf471f17a2dc0c92", - "6144c4786145852e2a01b20604c369d1b9721019", - - 14768, -"c9bed88d93806b89c2d028866842e6542ab88c895228c96c1f9f05125f8697c7402538b0" -"6465b7ae33daef847500f73d20c598c86e4804e633e1c4466e61f3ed1e9baadc5723bbed" -"9455a2ff4f99b852cfe6aa3442852ade0b18e4995ddab4250928165a9441de108d4a293d" -"1d95935de022aa17f366a31d4f4c4c54557a4235a9d56473444787ddc5c06c87087aef24" -"fa8280b7ac74d76ba685e4be7dc705e5a8a97c6c8fbd201ee5bf522438d23371c60c155d" -"93352f8fb8cc9421fe4b66ffabad46909c2c1099944fc55ed424c90aecca4f50d0331153" -"2e2844c3ff8ecb495de7ab26941cbf177b79ad7b05f918b713c417da8cf6e67db0a2dcee" -"a9179d8d636191759e13955f4244f0c4f2d88842e3015641ef0417d6e54144e8246e4591" -"6823e2c6e39bfa3b90b97781c44981710689f2ce20e70a26760d65f9971b291e12338461" -"8b3b56710dde2afaa2d46b0e2164d5c9482729350a0e256b2aa6b3fb099b618ebd7c11ca" -"62bdf176b502aedfdf9be57a8e4adbca4a4d6d8407984af2f6635f95a1e4930e375eb53f" -"245ab2ade5340c281bda87afded1268e537955c9819168bd60fd440533c75c9b1865e03f" -"de3a301d165f97aa6da236cf39cf3e49512f6350224f8d76ff02d0d3b9a99e5f70b23b9f" -"a85f72849fc98790df246c3a0f4437940e60d42b4317f72e2eb055d343a614f7f9648005" -"1e4dff186dff476462d9ced24dbb82eaa60cbbf6a0026e64001da36d30f529f48f3688b1" -"0ce9378ef3f50f5106e5007cd0eb037136254fda4f20d048769bd51a9d8d09a1e469a482" -"6aa0e25b6267b5a96abcb6e919a362fdd7b683d2f2dcec40ee5969311c07f6066ee22f36" -"89ca08381c85bea470040e9541e7a451cd43d62c2aa292a9dc4b95e3a7c4de2ba29663f3" -"8d5002eb64ceba6934bb1b0e2e55fba7fa706b514ebeeae1be4dd882d6512da066246a05" -"1d8bd042593bd0513e9cc47806ccdc7097e75bc75b8603834c85cd084e0ade3cc2c2b7e8" -"586eac62249f9769f5bdcd50e24e515f257548762db9adf3ee0846d67cfcd723d85d9588" -"09e6dd406f4c2637557c356fc52490a2a0763429ee298a1c72c098bb810e740c15faffc6" -"1e80cf6e18f86dc0e29bc150ce43ca71f5729356cd966277fd8b32366f6263c3a761b13d" -"544a631a25e1c4c8dea8d794abed47ccb4069d20f1dcb54e40a673ffb5f7b2eb31fb7d44" -"36fd8252f92dc35bb9a18fc55099b17e0807e79caf4f9641ee4bbbc2d6922508bcfae236" -"475bf78bc796548bc8d60659e816af68e5e43352fa64b5086c97c22c60ddcbbbefb9d9ef" -"7cd57c64454604793910f4f90aedb4fb824a86061a93bb79c9b0272a1ad0d24e8165f099" -"ef6f14a6a4fea09845f280022e061804090d7ab79f7bddcbef264b6f7d4e9971eddb9ca7" -"d0e79a8dbe7cff2fa59f514a608d66ae8c44d5e69745aa1b19995e366812064567d3ca20" -"9e12994c901d1b1f489be7253615f7c339b5581afd4d262e879ab8480ecb18990d3db61f" -"96895dcde9c065e645f52baafefcbe34d072dba373fd1c786fd56c3f3284be7260eaff9a" -"6a8348b762ed59e20ea443313b1164db53c3989c32fcae5b366f190b9548e8cff46df961" -"350369b490354ed8e530a91f5072967eff45c63540862fb2deab02b3ae05deac65414368" -"ac3549f277da92b692947de47cba9c1579526931e31c3490c1d3605f9bafcf468c2e9b47" -"981407ea40b0b59754621943095a2d4f4ba266ac545fe7447e54f69555a7ac9ff1e8f001" -"834fa65f2d4523061726e4d3bf4680519032dc21b7389e9f3229e4c2295d354482f8b803" -"b06ca3a8cb3ff786e60f6bc59dd3a5bfed63b0aa493bab78e97bbefb6633534d84de826f" -"4e2ccc3069050d50a2caace6c9de15ffc2656988d94b736e5688df0351a3a6a4c875cd99" -"ef304f3cc7a0585df2b0b3e6c62f86bba0d43de47b80c4eec1c4f98e60a36188219919cf" -"36dc10ee11e174a67d226ad9e71f02a7fca26ad67a4862773f3defc6a747545314063e5f" -"ce7a3f890ec57daa5532acfd027739832437c8a58dcbe11c2842e60e8ca64979d081fbd5" -"a1a028f59317212fb5869abc689a156171d69e4f4c93b949c3459904c00192d3603cd184" -"48d64b843c57f34aee7830f313e58e2abc41b44be46a96c845ffebcb7120e21d1d751046" -"c072adf65dd901a39c8019742054be5e159ea88d0885ee05fcd4c189bafe5abb68603186" -"5dc570b9342fa7f41fd5c1c87e68371ab19a83c82ae1d890c678102d5da8e6c29845657c" -"027ba07362cba4d24950ab38e747925e22ce8df9eaec1ae2c6d23374b360c8352feb6cb9" -"913e4fc49bde6caf5293030d0d234a8ecd616023cc668262591f812de208738e5336a9e6" -"9f9be2479b86be1e1369761518dfc93797ed3a55308878a944581eba50bc9c7f7a0e75c7" -"6a28acd95b277857726f3f684eefc215e0a696f47d65d30431d710d957c08ef96682b385" -"0ee5ba1c8417aafc1af2846a127ec155b4b7fb369e90eb3a5c3793a3389bbc6b532ca32b" -"f5e1f03c2280e71c6e1ae21312d4ff163eee16ebb1fdee8e887bb0d453829b4e6ed5fa70" -"8f2053f29b81e277be46", - "a757ead499a6ec3d8ab9814f839117354ae563c8" -}; - -void test_sha1(void) -{ - unsigned char buffer[4000]; - int i; - for (i=0; i < sizeof(sha1_tests) / sizeof(sha1_tests[0]); ++i) { - stb_uint len = sha1_tests[i].length / 8; - unsigned char digest[20], fdig[20]; - unsigned int h; - assert(len <= sizeof(buffer)); - assert(strlen(sha1_tests[i].message) == len*2); - assert(strlen(sha1_tests[i].digest) == 20 * 2); - for (h=0; h < len; ++h) { - char v[3]; - v[0] = sha1_tests[i].message[h*2]; - v[1] = sha1_tests[i].message[h*2+1]; - v[2] = 0; - buffer[h] = (unsigned char) strtol(v, NULL, 16); - } - stb_sha1(digest, buffer, len); - for (h=0; h < 20; ++h) { - char v[3]; - int res; - v[0] = sha1_tests[i].digest[h*2]; - v[1] = sha1_tests[i].digest[h*2+1]; - v[2] = 0; - res = digest[h] == strtol(v, NULL, 16); - c(res, sha1_tests[i].digest); - if (!res) - break; - } - { - int z; - FILE *f = fopen("data/test.bin", "wb"); - if (!f) stb_fatal("Couldn't write to test.bin"); - fwrite(buffer, len, 1, f); - fclose(f); - #ifdef _WIN32 - z = stb_sha1_file(fdig, "data/test.bin"); - if (!z) stb_fatal("Couldn't digest test.bin"); - c(memcmp(digest, fdig, 20)==0, "stb_sh1_file"); - #endif - } - } -} - - -#if 0 - -stb__obj zero, one; - -void test_packed_floats(void) -{ - stb__obj *p; - float x,y,*q; - clock_t a,b,c; - int i; - stb_float_init(); - for (i=-10; i < 10; ++i) { - float f = (float) pow(10,i); - float g = f * 10; - float delta = (g - f) / 10000; - while (f < g) { - stb__obj z = stb_float(f); - float k = stb_getfloat(z); - float p = stb_getfloat_table(z); - assert((z & 1) == 1); - assert(f == k); - assert(k == p); - f += delta; - } - } - - zero = stb_float(0); - one = stb_float(1); - - p = malloc(8192 * 4); - for (i=0; i < 8192; ++i) - p[i] = stb_rand(); - for (i=0; i < 8192; ++i) - if ((stb_rand() & 31) < 28) - p[i] = zero; - - q = malloc(4 * 1024); - - a = clock(); - - x = y = 0; - for (i=0; i < 200000000; ++i) - q[i&1023] = stb_getfloat_table(p[i&8191]); - b = clock(); - for (i=0; i < 200000000; ++i) - q[i&1023] = stb_getfloat_table2(p[i&8191]); - c = clock(); - free(p); - - free(q); - - printf("Table: %d\nIFs: %d\n", b-a, c-b); -} -#endif - - -void do_compressor(int argc,char**argv) -{ - char *p; - size_t slen; - int len; - - int window; - if (argc == 2) { - p = stb_file(argv[1], &slen); - len = (int) slen; - if (p) { - int dlen, clen = stb_compress_tofile("data/dummy.bin", p, len); - char *q = stb_decompress_fromfile("data/dummy.bin", &dlen); - - if (len != dlen) { - printf("FAILED %d -> %d\n", len, clen); - } else { - int z = memcmp(q,p,dlen); - if (z != 0) - printf("FAILED %d -> %d\n", len, clen); - else - printf("%d -> %d\n", len, clen); - } - } - return; - } - - window = atoi(argv[1]); - if (window && argc == 4) { - p = stb_file(argv[3], &slen); - len = (int) slen; - if (p) { - stb_compress_hashsize(window); - stb_compress_tofile(argv[2], p, len); - } - } else if (argc == 3) { - p = stb_decompress_fromfile(argv[2], &len); - if (p) { - FILE *f = fopen(argv[1], "wb"); - fwrite(p,1,len,f); - fclose(f); - } else { - fprintf(stderr, "FAILED.\n"); - } - } else { - fprintf(stderr, "Usage: stb \n" - " or stb \n"); - } -} - -#if 0 -// naive backtracking implementation -int wildmatch(char *expr, char *candidate) -{ - while(*expr) { - if (*expr == '?') { - if (!*candidate) return 0; - ++candidate; - ++expr; - } else if (*expr == '*') { - ++expr; - while (*expr == '*' || *expr =='?') ++expr; - // '*' at end of expression matches anything - if (!*expr) return 1; - // now scan candidate 'til first match - while (*candidate) { - if (*candidate == *expr) { - // check this candidate - if (stb_wildmatch(expr+1, candidate+1)) - return 1; - // if not, then backtrack - } - ++candidate; - } - } else { - if (*expr != *candidate) - return 0; - ++expr, ++candidate; - } - } - return *candidate != 0; -} - -int stb_matcher_find_slow(stb_matcher *m, char *str) -{ - int result = 1; - int i,j,y,z; - uint16 *previous = NULL; - uint16 *current = NULL; - uint16 *temp; - - stb_arr_setsize(previous, 4); - stb_arr_setsize(current, 4); - - previous = stb__add_if_inactive(m, previous, m->start_node); - previous = stb__eps_closure(m,previous); - if (stb__clear_goalcheck(m, previous)) - goto done; - - while (*str) { - y = stb_arr_len(previous); - for (i=0; i < y; ++i) { - stb_nfa_node *n = &m->nodes[previous[i]]; - z = stb_arr_len(n->out); - for (j=0; j < z; ++j) { - if (n->out[j].match == *str) - current = stb__add_if_inactive(m, current, n->out[j].node); - else if (n->out[j].match == -1) { - if (*str != '\n') - current = stb__add_if_inactive(m, current, n->out[j].node); - } else if (n->out[j].match < -1) { - int z = -n->out[j].match - 2; - if (m->charset[(uint8) *str] & (1 << z)) - current = stb__add_if_inactive(m, current, n->out[j].node); - } - } - } - ++str; - stb_arr_setlen(previous, 0); - - temp = previous; - previous = current; - current = temp; - - if (!m->match_start) - previous = stb__add_if_inactive(m, previous, m->start_node); - previous = stb__eps_closure(m,previous); - if (stb__clear_goalcheck(m, previous)) - goto done; - } - - result=0; - -done: - stb_arr_free(previous); - stb_arr_free(current); - - return result; -} -#endif - - - - - - -////////////////////////////////////////////////////////////////////////// -// -// stb_parser -// -// Generates an LR(1) parser from a grammar, and can parse with it - - - -// Symbol representations -// -// Client: Internal: -// - c=0 e aka epsilon -// - c=1 $ aka end of string -// > 0 2<=c= 0 ? encode_term(x) : encode_nonterm(x)) - -stb_bitset **compute_first(short ** productions) -{ - int i, changed; - stb_bitset **first = malloc(sizeof(*first) * num_symbols); - - assert(symset); - for (i=0; i < num_symbols; ++i) - first[i] = stb_bitset_new(0, symset); - - for (i=END; i < first_nonterm; ++i) - stb_bitset_setbit(first[i], i); - - for (i=0; i < stb_arr_len(productions); ++i) { - if (productions[i][2] == 0) { - int nt = encode_nonterm(productions[i][0]); - stb_bitset_setbit(first[nt], EPS); - } - } - - do { - changed = 0; - for (i=0; i < stb_arr_len(productions); ++i) { - int j, nt = encode_nonterm(productions[i][0]); - for (j=2; productions[i][j]; ++j) { - int z = encode_symbol(productions[i][j]); - changed |= stb_bitset_unioneq_changed(first[nt], first[z], symset); - if (!stb_bitset_testbit(first[z], EPS)) - break; - } - if (!productions[i][j] && !stb_bitset_testbit(first[nt], EPS)) { - stb_bitset_setbit(first[nt], EPS); - changed = 1; - } - } - } while (changed); - return first; -} - -stb_bitset **compute_follow(short ** productions, stb_bitset **first, int start) -{ - int i,j,changed; - stb_bitset **follow = malloc(sizeof(*follow) * num_symbols); - - assert(symset); - for (i=0; i < num_symbols; ++i) - follow[i] = (i >= first_nonterm ? stb_bitset_new(0, symset) : NULL); - - stb_bitset_setbit(follow[start], END); - do { - changed = 0; - for (i=0; i < stb_arr_len(productions); ++i) { - int nt = encode_nonterm(productions[i][0]); - for (j=2; productions[i][j]; ++j) { - if (productions[i][j] < 0) { - int k,z = encode_nonterm(productions[i][j]); - for (k=j+1; productions[i][k]; ++k) { - int q = encode_symbol(productions[i][k]); - changed |= stb_bitset_unioneq_changed(follow[z], first[q], symset); - if (!stb_bitset_testbit(first[q], EPS)) - break; - } - if (!productions[i][k] == 0) - changed |= stb_bitset_unioneq_changed(follow[z], follow[nt], symset); - } - } - } - } while (changed); - - for (i=first_nonterm; i < num_symbols; ++i) - stb_bitset_clearbit(follow[i], EPS); - - return follow; -} - -void first_for_prod_plus_sym(stb_bitset **first, stb_bitset *out, short *prod, int symbol) -{ - stb_bitset_clearall(out, symset); - for(;*prod;++prod) { - int z = encode_symbol(*prod); - stb_bitset_unioneq_changed(out, first[z], symset); - if (!stb_bitset_testbit(first[z], EPS)) - return; - } - stb_bitset_unioneq_changed(out, first[symbol], symset); -} - -#define Item(p,c,t) ((void *) (size_t) (((t) << 18) + ((c) << 12) + ((p) << 2))) -#define ItemProd(i) ((((uint32) (size_t) (i)) >> 2) & 1023) -#define ItemCursor(i) ((((uint32) (size_t) (i)) >> 12) & 63) -#define ItemLookahead(i) (((uint32) (size_t) (i)) >> 18) - -static void pc(stb_ps *p) -{ -} - -typedef struct -{ - short *prod; - int prod_num; -} ProdRef; - -typedef struct -{ - stb_bitset **first; - stb_bitset **follow; - short ** prod; - ProdRef ** prod_by_nt; -} Grammar; - -stb_ps *itemset_closure(Grammar g, stb_ps *set) -{ - stb_bitset *lookahead; - int changed,i,j,k, list_len; - if (set == NULL) return set; - lookahead = stb_bitset_new(0, symset); - do { - void **list = stb_ps_getlist(set, &list_len); - changed = 0; - for (i=0; i < list_len; ++i) { - ProdRef *prod; - int nt, *looklist; - int p = ItemProd(list[i]), c = ItemCursor(list[i]), t = ItemLookahead(list[i]); - if (g.prod[p][c] >= 0) continue; - nt = encode_nonterm(g.prod[p][c]); - first_for_prod_plus_sym(g.first, lookahead, g.prod[p]+c+1, t); - looklist = stb_bitset_getlist(lookahead, 1, first_nonterm); - - prod = g.prod_by_nt[nt]; - for (j=0; j < stb_arr_len(prod); ++j) { - assert(prod[j].prod[0] == g.prod[p][c]); - // matched production; now iterate terminals - for (k=0; k < stb_arr_len(looklist); ++k) { - void *item = Item(prod[j].prod_num,2,looklist[k]); - if (!stb_ps_find(set, item)) { - changed = 1; - set = stb_ps_add(set, item); - pc(set); - } - } - } - stb_arr_free(looklist); - } - free(list); - } while (changed); - free(lookahead); - return set; -} - -stb_ps *itemset_goto(Grammar g, stb_ps *set, int sym) -{ - int i, listlen; - void **list = stb_ps_fastlist(set, &listlen); - stb_ps *out = NULL; - for (i=0; i < listlen; ++i) { - int p,c; - if (!stb_ps_fastlist_valid(list[i])) continue; - p = ItemProd(list[i]), c = ItemCursor(list[i]); - if (encode_symbol(g.prod[p][c]) == sym) { - void *z = Item(p,c+1,ItemLookahead(list[i])); - if (!stb_ps_find(out, z)) - out = stb_ps_add(out, z); - pc(out); - } - } - return itemset_closure(g, out); -} - -void itemset_all_nextsym(Grammar g, stb_bitset *out, stb_ps *set) -{ - int i, listlen; - void **list = stb_ps_fastlist(set, &listlen); - stb_bitset_clearall(out, symset); - pc(set); - for (i=0; i < listlen; ++i) { - if (stb_ps_fastlist_valid(list[i])) { - int p = ItemProd(list[i]); - int c = ItemCursor(list[i]); - if (g.prod[p][c]) - stb_bitset_setbit(out, encode_symbol(g.prod[p][c])); - } - } -} - -stb_ps ** generate_items(Grammar g, int start_prod) -{ - stb_ps ** all=NULL; - int i,j,k; - stb_bitset *try = stb_bitset_new(0,symset); - stb_ps *set = NULL; - void *item = Item(start_prod, 2, END); - set = stb_ps_add(set, item); - pc(set); - set = itemset_closure(g, set); - pc(set); - stb_arr_push(all, set); - for (i = 0; i < stb_arr_len(all); ++i) { - // only try symbols that appear in all[i]... there's a smarter way to do this, - // which is to take all[i], and divide it up by symbol - pc(all[i]); - itemset_all_nextsym(g, try, all[i]); - for (j = 1; j < num_symbols; ++j) { - if (stb_bitset_testbit(try, j)) { - stb_ps *out; - if (stb_arr_len(all) > 4) pc(all[4]); - if (i == 1 && j == 29) { - if (stb_arr_len(all) > 4) pc(all[4]); - out = itemset_goto(g, all[i], j); - if (stb_arr_len(all) > 4) pc(all[4]); - } else - out = itemset_goto(g, all[i], j); - pc(out); - if (stb_arr_len(all) > 4) pc(all[4]); - if (out != NULL) { - // add it to the array if it's not already there - for (k=0; k < stb_arr_len(all); ++k) - if (stb_ps_eq(all[k], out)) - break; - if (k == stb_arr_len(all)) { - stb_arr_push(all, out); - pc(out); - if (stb_arr_len(all) > 4) pc(all[4]); - } else - stb_ps_delete(out); - } - } - } - } - free(try); - return all; -} - -typedef struct -{ - int num_stack; - int function; -} Reduction; - -typedef struct -{ - short *encode_term; - Reduction *reductions; - short **action_goto; // terminals are action, nonterminals are goto - int start; - int end_term; -} Parser; - -enum -{ - A_error, A_accept, A_shift, A_reduce, A_conflict -}; - -typedef struct -{ - uint8 type; - uint8 cursor; - short prod; - short value; -} Action; - -Parser *parser_create(short **productions, int num_prod, int start_nt, int end_term) -{ - short *mini_rule = malloc(4 * sizeof(mini_rule[0])); - Action *actions; - Grammar g; - stb_ps ** sets; - Parser *p = malloc(sizeof(*p)); - int i,j,n; - stb_bitset *mapped; - int min_s=0, max_s=0, termset, ntset, num_states, num_reductions, init_prod; - - int synth_start; - - // remap sparse terminals and nonterminals - - for (i=0; i < num_prod; ++i) { - for (j=2; productions[i][j]; ++j) { - if (productions[i][j] < min_s) min_s = productions[i][j]; - if (productions[i][j] > max_s) max_s = productions[i][j]; - } - } - synth_start = --min_s; - - termset = (max_s + 32) >> 5; - ntset = (~min_s + 32) >> 5; - memset(encode_term, 0, sizeof(encode_term)); - memset(encode_nonterm, 0, sizeof(encode_nonterm)); - - mapped = stb_bitset_new(0, termset); - n = 2; - for (i=0; i < num_prod; ++i) - for (j=2; productions[i][j]; ++j) - if (productions[i][j] > 0) - if (!stb_bitset_testbit(mapped, productions[i][j])) { - stb_bitset_setbit(mapped, productions[i][j]); - encode_term[productions[i][j]] = n++; - } - free(mapped); - - first_nonterm = n; - - mapped = stb_bitset_new(0, ntset); - for (i=0; i < num_prod; ++i) - for (j=2; productions[i][j]; ++j) - if (productions[i][j] < 0) - if (!stb_bitset_testbit(mapped, ~productions[i][j])) { - stb_bitset_setbit(mapped, ~productions[i][j]); - encode_nonterm[~productions[i][j]] = n++; - } - free(mapped); - - // add a special start state for internal processing - p->start = n++; - encode_nonterm[synth_start] = p->start; - mini_rule[0] = synth_start; - mini_rule[1] = -32768; - mini_rule[2] = start_nt; - mini_rule[3] = 0; - - p->end_term = end_term; - - num_symbols = n; - - // create tables - g.prod = NULL; - g.prod_by_nt = malloc(num_symbols * sizeof(g.prod_by_nt[0])); - for (i=0; i < num_symbols; ++i) - g.prod_by_nt[i] = NULL; - - for (i=0; i < num_prod; ++i) { - stb_arr_push(g.prod, productions[i]); - } - init_prod = stb_arr_len(g.prod); - stb_arr_push(g.prod, mini_rule); - - num_reductions = stb_arr_len(g.prod); - p->reductions = malloc(num_reductions * sizeof(*p->reductions)); - - symset = (num_symbols + 31) >> 5; - g.first = compute_first(g.prod); - g.follow = compute_follow(g.prod, g.first, p->start); - - for (i=0; i < stb_arr_len(g.prod); ++i) { - ProdRef pr = { g.prod[i], i }; - stb_arr_push(g.prod_by_nt[encode_nonterm(g.prod[i][0])], pr); - } - - sets = generate_items(g, init_prod); - - num_states = stb_arr_len(sets); - // now generate tables - - actions = malloc(sizeof(*actions) * first_nonterm); - p->action_goto = (short **) stb_array_block_alloc(num_states, sizeof(short) * num_symbols); - for (i=0; i < num_states; ++i) { - int j,n; - void **list = stb_ps_getlist(sets[i], &n); - memset(actions, 0, sizeof(*actions) * first_nonterm); - for (j=0; j < n; ++j) { - int p = ItemProd(list[j]), c = ItemCursor(list[j]), t = ItemLookahead(list[j]); - if (g.prod[p][c] == 0) { - if (p == init_prod) { - // @TODO: check for conflicts - assert(actions[t].type == A_error || actions[t].type == A_accept); - actions[t].type = A_accept; - } else { - // reduce production p - if (actions[t].type == A_reduce) { - // is it the same reduction we already have? - if (actions[t].prod != p) { - // no, it's a reduce-reduce conflict! - printf("Reduce-reduce conflict for rule %d and %d, lookahead %d\n", p, actions[t].prod, t); - // @TODO: use precedence - actions[t].type = A_conflict; - } - } else if (actions[t].type == A_shift) { - printf("Shift-reduce conflict for rule %d and %d, lookahead %d\n", actions[t].prod, p, t); - actions[t].type = A_conflict; - } else if (actions[t].type == A_accept) { - assert(0); - } else if (actions[t].type == A_error) { - actions[t].type = A_reduce; - actions[t].prod = p; - } - } - } else if (g.prod[p][c] > 0) { - int a = encode_symbol(g.prod[p][c]), k; - stb_ps *out = itemset_goto(g, sets[i], a); - for (k=0; k < stb_arr_len(sets); ++k) - if (stb_ps_eq(sets[k], out)) - break; - assert(k < stb_arr_len(sets)); - // shift k - if (actions[a].type == A_shift) { - if (actions[a].value != k) { - printf("Shift-shift conflict! Rule %d and %d with lookahead %d/%d\n", actions[a].prod, p, a,t); - actions[a].type = A_conflict; - } - } else if (actions[a].type == A_reduce) { - printf("Shift-reduce conflict for rule %d and %d, lookahead %d/%d\n", p, actions[a].prod, a,t); - actions[a].type = A_conflict; - } else if (actions[a].type == A_accept) { - assert(0); - } else if (actions[a].type == A_error) { - actions[a].type = A_shift; - actions[a].prod = p; - actions[a].cursor = c; - actions[a].value = k; - } - } - } - // @TODO: recompile actions into p->action_goto - } - - free(mini_rule); - stb_pointer_array_free(g.first , num_symbols); free(g.first ); - stb_pointer_array_free(g.follow, num_symbols); free(g.follow); - stb_arr_free(g.prod); - for (i=0; i < num_symbols; ++i) - stb_arr_free(g.prod_by_nt[i]); - free(g.prod_by_nt); - for (i=0; i < stb_arr_len(sets); ++i) - stb_ps_delete(sets[i]); - stb_arr_free(sets); - - return p; -} - -void parser_destroy(Parser *p) -{ - free(p); -} - -#if 0 -enum nonterm -{ - N_globals = -50, - N_global, N_vardef, N_varinitlist, N_varinit, N_funcdef, N_optid, N_optparamlist, - N_paramlist, N_param, N_optinit, N_optcomma, N_statements, N_statement, - N_optexpr, N_assign, N_if, N_ifcore, N_else, N_dictdef, N_dictdef2, - N_dictdefitem, N_expr, - N__last -}; - -short grammar[][10] = -{ - { N_globals , 0, N_globals, N_global }, - { N_globals , 0 }, - { N_global , 0, N_vardef }, - { N_global , 0, N_funcdef }, - { N_vardef , 0, ST_var, N_varinitlist, }, - { N_varinitlist, 0, N_varinitlist, ',', N_varinit }, - { N_varinitlist, 0, N_varinit, }, - { N_varinit , 0, ST_id, N_optinit, }, - { N_funcdef , 0, ST_func, N_optid, '(', N_optparamlist, ')', N_statements, ST_end }, - { N_optid , 0, ST_id }, - { N_optid , 0, }, - { N_optparamlist, 0, }, - { N_optparamlist, 0, N_paramlist, N_optcomma }, - { N_paramlist , 0, N_paramlist, ',', N_param }, - { N_paramlist , 0, N_param }, - { N_param , 0, ST_id, N_optinit }, - { N_optinit , 0, '=', N_expr }, - { N_optinit , 0, }, - { N_optcomma , 0, ',' }, - { N_optcomma , 0, }, - { N_statements , 0, N_statements, N_statement }, - { N_statement , 0, N_statement, ';' }, - { N_statement , 0, N_varinit }, - { N_statement , 0, ST_return, N_expr }, - { N_statement , 0, ST_break , N_optexpr }, - { N_optexpr , 0, N_expr }, - { N_optexpr , 0, }, - { N_statement , 0, ST_continue }, - { N_statement , 0, N_assign }, - { N_assign , 0, N_expr, '=', N_assign }, - //{ N_assign , 0, N_expr }, - { N_statement , 0, ST_while, N_expr, N_statements, ST_end }, - { N_statement , 0, ST_if, N_if, }, - { N_if , 0, N_ifcore, ST_end, }, - { N_ifcore , 0, N_expr, ST_then, N_statements, N_else, ST_end }, - { N_else , 0, ST_elseif, N_ifcore }, - { N_else , 0, ST_else, N_statements }, - { N_else , 0, }, - { N_dictdef , 0, N_dictdef2, N_optcomma }, - { N_dictdef2 , 0, N_dictdef2, ',', N_dictdefitem }, - { N_dictdef2 , 0, N_dictdefitem }, - { N_dictdefitem, 0, ST_id, '=', N_expr }, - { N_dictdefitem, 0, N_expr }, - { N_expr , 0, ST_number }, - { N_expr , 0, ST_string }, - { N_expr , 0, ST_id }, - { N_expr , 0, N_funcdef }, - { N_expr , 0, '-', N_expr }, - { N_expr , 0, '{', N_dictdef, '}' }, - { N_expr , 0, '(', N_expr, ')' }, - { N_expr , 0, N_expr, '.', ST_id }, - { N_expr , 0, N_expr, '[', N_expr, ']' }, - { N_expr , 0, N_expr, '(', N_dictdef, ')' }, -#if 0 -#define BINOP(op) { N_expr, 0, N_expr, op, N_expr } - BINOP(ST_and), BINOP(ST_or), BINOP(ST_eq), BINOP(ST_ne), - BINOP(ST_le), BINOP(ST_ge), BINOP('>') , BINOP('<' ), - BINOP('&'), BINOP('|'), BINOP('^'), BINOP('+'), BINOP('-'), - BINOP('*'), BINOP('/'), BINOP('%'), -#undef BINOP -#endif -}; - -short *grammar_list[stb_arrcount(grammar)]; - -void test_parser_generator(void) -{ - Parser *p; - int i; - assert(N__last <= 0); - for (i=0; i < stb_arrcount(grammar); ++i) - grammar_list[i] = grammar[i]; - p = parser_create(grammar_list, stb_arrcount(grammar), N_globals, 0); - parser_destroy(p); -} -#endif - - -#if 0 -// stb_threadtest.c - - -#include -#define STB_DEFINE -//#define STB_THREAD_TEST -#include "../stb.h" - -#define NUM_WORK 100 - -void *work_consumer(void *p) -{ - stb__thread_sleep(20); - return NULL; -} - -int pass; -stb_threadqueue *tq1, *tq2, *tq3, *tq4; -volatile float t1,t2; - -// with windows.h -// Worked correctly with 100,000,000 enqueue/dequeue WAITLESS -// (770 passes, 170000 per pass) -// Worked correctly with 2,500,000 enqueue/dequeue !WAITLESS -// (15 passes, 170000 per pass) -// Worked correctly with 1,500,000 enqueue/dequeue WAITLESS && STB_THREAD_TEST -// (9 passes, 170000 per pass) -// without windows.h -// Worked correctly with 1,000,000 enqueue/dequeue WAITLESS && STB_THREAD_TEST -// (6 passes, 170000 per pass) -// Worked correctly with 500,000 enqueue/dequeue !WAITLESS && STB_THREAD_TEST -// (3 passes, 170000 per pass) -// Worked correctly with 1,000,000 enqueue/dequeue WAITLESS -// (15 passes, 170000 per pass) -#define WAITLESS - -volatile int table[1000*1000*10]; - -void wait(int n) -{ -#ifndef WAITLESS - int j; - float y; - for (j=0; j < n; ++j) - y += 1 / (t1+j); - t2 = y; -#endif -} - -void *tq1_consumer(void *p) -{ - for(;;) { - int z; - float y = 0; - stb_threadq_get_block(tq1, &z); - wait(5000); - table[z] = pass; - } -} - -void *tq2_consumer(void *p) -{ - for(;;) { - int z; - if (stb_threadq_get(tq2, &z)) - table[z] = pass; - wait(1000); - } -} - -void *tq3_consumer(void *p) -{ - for(;;) { - int z; - stb_threadq_get_block(tq3, &z); - table[z] = pass; - wait(500); - } -} - -void *tq4_consumer(void *p) -{ - for (;;) { - int z; - stb_threadq_get_block(tq4, &z); - table[z] = pass; - wait(500); - } -} - -typedef struct -{ - int start, end; - stb_threadqueue *tq; - int delay; -} write_data; - -void *writer(void *q) -{ - int i; - write_data *p = (write_data *) q; - for (i=p->start; i < p->end; ++i) { - stb_threadq_add_block(p->tq, &i); - #ifndef WAITLESS - if (p->delay) stb__thread_sleep(p->delay); - else { - int j; - float z = 0; - for (j=0; j <= 20; ++j) - z += 1 / (t1+j); - t2 = z; - } - #endif - } - return NULL; -} - -write_data info[256]; -int pos; - -void start_writer(int z, int count, stb_threadqueue *tq, int delay) -{ - info[z].start = pos; - info[z].end = pos+count; - info[z].tq = tq; - info[z].delay = delay; - stb_create_thread(writer, &info[z]); - pos += count; -} - -int main(int argc, char **argv) -{ - int i; - stb_sync s = stb_sync_new(); - stb_sync_set_target(s, NUM_WORK+1); - stb_work_numthreads(2); - for (i=0; i < NUM_WORK; ++i) { - stb_work_reach(work_consumer, NULL, NULL, s); - } - printf("Started stb_work test.\n"); - - t1 = 1; - - // create the queues - tq1 = stb_threadq_new(4, 4, TRUE , TRUE); - tq2 = stb_threadq_new(4, 4, TRUE , FALSE); - tq3 = stb_threadq_new(4, 4, FALSE, TRUE); - tq4 = stb_threadq_new(4, 4, FALSE, FALSE); - - // start the consumers - stb_create_thread(tq1_consumer, NULL); - stb_create_thread(tq1_consumer, NULL); - stb_create_thread(tq1_consumer, NULL); - - stb_create_thread(tq2_consumer, NULL); - - stb_create_thread(tq3_consumer, NULL); - stb_create_thread(tq3_consumer, NULL); - stb_create_thread(tq3_consumer, NULL); - stb_create_thread(tq3_consumer, NULL); - stb_create_thread(tq3_consumer, NULL); - stb_create_thread(tq3_consumer, NULL); - stb_create_thread(tq3_consumer, NULL); - - stb_create_thread(tq4_consumer, NULL); - - for (pass=1; pass <= 5000; ++pass) { - int z = 0; - int last_n = -1; - int identical = 0; - pos = 0; - start_writer(z++, 50000, tq1, 0); - start_writer(z++, 50000, tq1, 0); - start_writer(z++, 50000, tq1, 0); - - start_writer(z++, 5000, tq2, 1); - start_writer(z++, 3000, tq2, 3); - start_writer(z++, 2000, tq2, 5); - - start_writer(z++, 5000, tq3, 3); - - start_writer(z++, 5000, tq4, 3); - #ifndef WAITLESS - stb__thread_sleep(8000); - #endif - for(;;) { - int n =0; - for (i=0; i < pos; ++i) { - if (table[i] == pass) - ++n; - } - if (n == pos) break; - if (n == last_n) { - ++identical; - if (identical == 3) { - printf("Problem slots:\n"); - for (i=0; i < pos; ++i) { - if (table[i] != pass) printf("%d ", i); - } - printf("\n"); - } else { - if (identical < 3) - printf("Processed %d of %d\n", n, pos); - else - printf("."); - } - } else { - identical = 0; - printf("Processed %d of %d\n", n, pos); - } - last_n = n; - #ifdef WAITLESS - stb__thread_sleep(750); - #else - stb__thread_sleep(3000); - #endif - } - printf("Finished pass %d\n", pass); - } - - stb_sync_reach_and_wait(s); - printf("stb_work test completed ok.\n"); - return 0; -} -#endif - - -#if 0 -////////////////////////////////////////////////////////////////////////////// -// -// collapse tree leaves up to parents until we only have N nodes -// useful for cmirror summaries - -typedef struct stb_summary_tree -{ - struct stb_summary_tree **children; - int num_children; - float weight; -} stb_summary_tree; - -STB_EXTERN void *stb_summarize_tree(void *tree, int limit, float reweight); - -#ifdef STB_DEFINE - -typedef struct stb_summary_tree2 -{ - STB__ARR(struct stb_summary_tree2 *) children; - int num_children; - float weight; - float weight_with_all_children; - float makes_target_weight; - float weight_at_target; - stb_summary_tree *original; - struct stb_summary_tree2 *target; - STB__ARR(struct stb_summary_tree2 *) targeters; -} stb_summary_tree2; - -static stb_summary_tree2 *stb__summarize_clone(stb_summary_tree *t) -{ - int i; - stb_summary_tree2 *s; - s = (stb_summary_tree2 *) malloc(sizeof(*s)); - s->original = t; - s->weight = t->weight; - s->weight_with_all_children = 0; - s->weight_at_target = 0; - s->target = NULL; - s->targeters = NULL; - s->num_children = t->num_children; - s->children = NULL; - for (i=0; i < s->num_children; ++i) - stb_arr_push(s->children, stb__summarize_clone(t->children[i])); - return s; -} - -static float stb__summarize_compute_targets(stb_summary_tree2 *parent, stb_summary_tree2 *node, float reweight, float weight) -{ - float total = 0; - if (node->weight == 0 && node->num_children == 1 && parent) { - node->target = parent; - return stb__summarize_compute_targets(parent, node->children[0], reweight, weight*reweight); - } else { - float total=0; - int i; - for (i=0; i < node->num_children; ++i) - total += stb__summarize_compute_targets(node, node->children[i], reweight, reweight); - node->weight_with_all_children = total + node->weight; - if (parent && node->weight_with_all_children) { - node->target = parent; - node->weight_at_target = node->weight_with_all_children * weight; - node->makes_target_weight = node->weight_at_target + parent->weight; - stb_arr_push(parent->targeters, node); - } else { - node->target = NULL; - node->weight_at_target = node->weight; - node->makes_target_weight = 0; - } - return node->weight_with_all_children * weight; - } -} - -static stb_summary_tree2 ** stb__summarize_make_array(STB__ARR(stb_summary_tree2 *) all, stb_summary_tree2 *tree) -{ - int i; - stb_arr_push(all, tree); - for (i=0; i < tree->num_children; ++i) - all = stb__summarize_make_array(all, tree->children[i]); - return all; -} - -typedef stb_summary_tree2 * stb__stree2; -stb_define_sort(stb__summarysort, stb__stree2, (*a)->makes_target_weight < (*b)->makes_target_weight) - -void *stb_summarize_tree(void *tree, int limit, float reweight) -{ - int i,j,k; - STB__ARR(stb_summary_tree *) ret=NULL; - STB__ARR(stb_summary_tree2 *) all=NULL; - - // first clone the tree so we can manipulate it - stb_summary_tree2 *t = stb__summarize_clone((stb_summary_tree *) tree); - if (reweight < 1) reweight = 1; - - // now compute how far up the tree each node would get pushed - // there's no value in pushing a node up to an empty node with - // only one child, so we keep pushing it up - stb__summarize_compute_targets(NULL, t, reweight, 1); - - all = stb__summarize_make_array(all, t); - - // now we want to iteratively find the smallest 'makes_target_weight', - // update that, and then fix all the others (which will be all descendents) - // to do this efficiently, we need a heap or a sorted binary tree - // what we have is an array. maybe we can insertion sort the array? - stb__summarysort(all, stb_arr_len(all)); - - for (i=0; i < stb_arr_len(all) - limit; ++i) { - stb_summary_tree2 *src, *dest; - src = all[i]; - dest = all[i]->target; - if (src->makes_target_weight == 0) continue; - assert(dest != NULL); - - for (k=0; k < stb_arr_len(all); ++k) - if (all[k] == dest) - break; - assert(k != stb_arr_len(all)); - assert(i < k); - - // move weight from all[i] to target - src->weight = dest->makes_target_weight; - src->weight = 0; - src->makes_target_weight = 0; - // recompute effect of other descendents - for (j=0; j < stb_arr_len(dest->targeters); ++j) { - if (dest->targeters[j]->weight) { - dest->targeters[j]->makes_target_weight = dest->weight + dest->targeters[j]->weight_at_target; - assert(dest->targeters[j]->makes_target_weight <= dest->weight_with_all_children); - } - } - STB_(stb__summarysort,_ins_sort)(all+i, stb_arr_len(all)-i); - } - // now the elements in [ i..stb_arr_len(all) ) are the relevant ones - for (; i < stb_arr_len(all); ++i) - stb_arr_push(ret, all[i]->original); - - // now free all our temp data - for (i=0; i < stb_arr_len(all); ++i) { - stb_arr_free(all[i]->children); - free(all[i]); - } - stb_arr_free(all); - return ret; -} -#endif - -#endif diff --git a/third_party/stb/tests/stb.dsp b/third_party/stb/tests/stb.dsp deleted file mode 100644 index 5361ea1642..0000000000 --- a/third_party/stb/tests/stb.dsp +++ /dev/null @@ -1,240 +0,0 @@ -# Microsoft Developer Studio Project File - Name="stb" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=stb - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "stb.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "stb.mak" CFG="stb - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "stb - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "stb - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "stb - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MT /W3 /GX /Z7 /O2 /Ob2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "GRID_TEST" /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 - -!ELSEIF "$(CFG)" == "stb - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug\stb" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /GX /Zi /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "TT_TEST" /FR /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /pdbtype:sept -# SUBTRACT LINK32 /force - -!ENDIF - -# Begin Target - -# Name "stb - Win32 Release" -# Name "stb - Win32 Debug" -# Begin Source File - -SOURCE=.\grid_reachability.c -# End Source File -# Begin Source File - -SOURCE=.\stb.c -# End Source File -# Begin Source File - -SOURCE=..\stb.h -# End Source File -# Begin Source File - -SOURCE=..\stb_c_lexer.h -# End Source File -# Begin Source File - -SOURCE=..\stb_connected_components.h -# End Source File -# Begin Source File - -SOURCE=..\stb_divide.h -# End Source File -# Begin Source File - -SOURCE=..\stb_dxt.h -# End Source File -# Begin Source File - -SOURCE=..\stb_easy_font.h -# End Source File -# Begin Source File - -SOURCE=..\stb_herringbone_wang_tile.h -# End Source File -# Begin Source File - -SOURCE=..\stb_image.h -# End Source File -# Begin Source File - -SOURCE=..\stb_image_resize.h -# End Source File -# Begin Source File - -SOURCE=..\stb_image_write.h -# End Source File -# Begin Source File - -SOURCE=..\stb_leakcheck.h -# End Source File -# Begin Source File - -SOURCE=..\stb_malloc.h -# End Source File -# Begin Source File - -SOURCE=..\stb_perlin.h -# End Source File -# Begin Source File - -SOURCE=..\stb_pg.h -# End Source File -# Begin Source File - -SOURCE=..\stb_rect_pack.h -# End Source File -# Begin Source File - -SOURCE=..\stb_sprintf.h -# End Source File -# Begin Source File - -SOURCE=.\stb_static.c -# End Source File -# Begin Source File - -SOURCE=..\stb_textedit.h -# End Source File -# Begin Source File - -SOURCE=..\stb_tilemap_editor.h -# End Source File -# Begin Source File - -SOURCE=..\stb_truetype.h -# End Source File -# Begin Source File - -SOURCE=..\stb_vorbis.c -# End Source File -# Begin Source File - -SOURCE=..\stb_voxel_render.h -# End Source File -# Begin Source File - -SOURCE=..\stretchy_buffer.h -# End Source File -# Begin Source File - -SOURCE=.\stretchy_buffer_test.c -# End Source File -# Begin Source File - -SOURCE=.\test_c_compilation.c -# End Source File -# Begin Source File - -SOURCE=.\test_c_lexer.c -# End Source File -# Begin Source File - -SOURCE=.\test_dxt.c -# End Source File -# Begin Source File - -SOURCE=.\test_easyfont.c -# End Source File -# Begin Source File - -SOURCE=.\test_image.c -# End Source File -# Begin Source File - -SOURCE=.\test_image_write.c -# End Source File -# Begin Source File - -SOURCE=.\test_perlin.c -# End Source File -# Begin Source File - -SOURCE=.\test_sprintf.c -# End Source File -# Begin Source File - -SOURCE=.\test_truetype.c -# End Source File -# Begin Source File - -SOURCE=.\test_vorbis.c -# End Source File -# Begin Source File - -SOURCE=.\test_voxel.c -# End Source File -# Begin Source File - -SOURCE=.\textedit_sample.c -# End Source File -# End Target -# End Project diff --git a/third_party/stb/tests/stb.dsw b/third_party/stb/tests/stb.dsw deleted file mode 100644 index ef3c43e798..0000000000 --- a/third_party/stb/tests/stb.dsw +++ /dev/null @@ -1,185 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "c_lexer_test"=.\c_lexer_test.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "herringbone"=.\herringbone.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "herringbone_map"=.\herringbone_map.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "image_test"=.\image_test.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "make_readme"=..\tools\make_readme.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "pg_test"=.\pg_test\pg_test.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "resize"=.\resize.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "stb"=.\stb.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name stb_cpp - End Project Dependency - Begin Project Dependency - Project_Dep_Name image_test - End Project Dependency - Begin Project Dependency - Project_Dep_Name stretch_test - End Project Dependency - Begin Project Dependency - Project_Dep_Name c_lexer_test - End Project Dependency -}}} - -############################################################################### - -Project: "stb_cpp"=.\stb_cpp.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "stblib"=.\stblib.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "stretch_test"=.\stretch_test.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "unicode"=..\tools\unicode\unicode.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "vorbseek"=.\vorbseek\vorbseek.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/third_party/stb/tests/stb_cpp.cpp b/third_party/stb/tests/stb_cpp.cpp deleted file mode 100644 index f992108ed2..0000000000 --- a/third_party/stb/tests/stb_cpp.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#define WIN32_MEAN_AND_LEAN -#define WIN32_LEAN_AND_MEAN -//#include -#include -#define STB_DEFINE -#ifndef _M_AMD64 -#define STB_NPTR -#endif -#define STB_ONLY -#include "stb.h" -//#include "stb_file.h" - -int count; -void c(int truth, char *error) -{ - if (!truth) { - fprintf(stderr, "Test failed: %s\n", error); - ++count; - } -} - -char *expects(stb_matcher *m, char *s, int result, int len, char *str) -{ - int res2,len2=0; - res2 = stb_lex(m, s, &len2); - c(result == res2 && len == len2, str); - return s + len; -} - -void test_lex(void) -{ - stb_matcher *m = stb_lex_matcher(); - // tok_en5 .3 20.1 20. .20 .1 - char *s = "tok_en5.3 20.1 20. .20.1"; - - stb_lex_item(m, "[a-zA-Z_][a-zA-Z0-9_]*", 1 ); - stb_lex_item(m, "[0-9]*\\.?[0-9]*" , 2 ); - stb_lex_item(m, "[\r\n\t ]+" , 3 ); - stb_lex_item(m, "." , -99 ); - s=expects(m,s,1,7, "stb_lex 1"); - s=expects(m,s,2,2, "stb_lex 2"); - s=expects(m,s,3,1, "stb_lex 3"); - s=expects(m,s,2,4, "stb_lex 4"); - s=expects(m,s,3,1, "stb_lex 5"); - s=expects(m,s,2,3, "stb_lex 6"); - s=expects(m,s,3,1, "stb_lex 7"); - s=expects(m,s,2,3, "stb_lex 8"); - s=expects(m,s,2,2, "stb_lex 9"); - s=expects(m,s,0,0, "stb_lex 10"); - stb_matcher_free(m); -} - -int main(int argc, char **argv) -{ - char *p; - p = "abcdefghijklmnopqrstuvwxyz"; - c(stb_ischar('c', p), "stb_ischar 1"); - c(stb_ischar('x', p), "stb_ischar 2"); - c(!stb_ischar('#', p), "stb_ischar 3"); - c(!stb_ischar('X', p), "stb_ischar 4"); - p = "0123456789"; - c(!stb_ischar('c', p), "stb_ischar 5"); - c(!stb_ischar('x', p), "stb_ischar 6"); - c(!stb_ischar('#', p), "stb_ischar 7"); - c(!stb_ischar('X', p), "stb_ischar 8"); - p = "#####"; - c(!stb_ischar('c', p), "stb_ischar a"); - c(!stb_ischar('x', p), "stb_ischar b"); - c(stb_ischar('#', p), "stb_ischar c"); - c(!stb_ischar('X', p), "stb_ischar d"); - p = "xXyY"; - c(!stb_ischar('c', p), "stb_ischar e"); - c(stb_ischar('x', p), "stb_ischar f"); - c(!stb_ischar('#', p), "stb_ischar g"); - c(stb_ischar('X', p), "stb_ischar h"); - - test_lex(); - - if (count) { - _getch(); - } - return 0; -} diff --git a/third_party/stb/tests/stb_cpp.dsp b/third_party/stb/tests/stb_cpp.dsp deleted file mode 100644 index 8bf9975aa7..0000000000 --- a/third_party/stb/tests/stb_cpp.dsp +++ /dev/null @@ -1,98 +0,0 @@ -# Microsoft Developer Studio Project File - Name="stb_cpp" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=stb_cpp - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "stb_cpp.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "stb_cpp.mak" CFG="stb_cpp - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "stb_cpp - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "stb_cpp - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "stb_cpp - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "stb_cpp - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug\stb_cpp" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /GX /Zd /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "stb_cpp - Win32 Release" -# Name "stb_cpp - Win32 Debug" -# Begin Source File - -SOURCE=.\stb_cpp.cpp -# End Source File -# Begin Source File - -SOURCE=..\stb_vorbis.c -# End Source File -# Begin Source File - -SOURCE=.\test_cpp_compilation.cpp -# End Source File -# End Target -# End Project diff --git a/third_party/stb/tests/stblib.dsp b/third_party/stb/tests/stblib.dsp deleted file mode 100644 index c43513dd17..0000000000 --- a/third_party/stb/tests/stblib.dsp +++ /dev/null @@ -1,102 +0,0 @@ -# Microsoft Developer Studio Project File - Name="stblib" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=stblib - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "stblib.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "stblib.mak" CFG="stblib - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "stblib - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "stblib - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "stblib - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "stblib - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "stblib - Win32 Release" -# Name "stblib - Win32 Debug" -# Begin Source File - -SOURCE=.\prerelease\stb_lib.h -# End Source File -# Begin Source File - -SOURCE=..\stb_regex.h -# End Source File -# Begin Source File - -SOURCE=.\stblib_test.c -# End Source File -# Begin Source File - -SOURCE=.\stblib_test_companion.c -# End Source File -# End Target -# End Project diff --git a/third_party/stb/tests/stblib_test.c b/third_party/stb/tests/stblib_test.c deleted file mode 100644 index 9f2e176015..0000000000 --- a/third_party/stb/tests/stblib_test.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "prerelease/stb_lib.h" -#define STB_LIB_IMPLEMENTATION -#include "prerelease/stb_lib.h" - -//#define STB_REGEX_IMPLEMENTATION -//#include "stb_regex.h" - -int main(int argc, char **argv) -{ - -} \ No newline at end of file diff --git a/third_party/stb/tests/stblib_test_companion.c b/third_party/stb/tests/stblib_test_companion.c deleted file mode 100644 index 88f233cfeb..0000000000 --- a/third_party/stb/tests/stblib_test_companion.c +++ /dev/null @@ -1,4 +0,0 @@ -//#include "stb_regex.h" -//#include "stb_regex.h" -#include "prerelease/stb_lib.h" -#include "prerelease/stb_lib.h" diff --git a/third_party/stb/tests/stretch_test.c b/third_party/stb/tests/stretch_test.c deleted file mode 100644 index 8caf43f645..0000000000 --- a/third_party/stb/tests/stretch_test.c +++ /dev/null @@ -1,28 +0,0 @@ -// check that stb_truetype compiles with no stb_rect_pack.h -#define STB_TRUETYPE_IMPLEMENTATION -#include "stb_truetype.h" - -#include "stretchy_buffer.h" -#include - -int main(int arg, char **argv) -{ - int i; - int *arr = NULL; - - for (i=0; i < 1000000; ++i) - sb_push(arr, i); - - assert(sb_count(arr) == 1000000); - for (i=0; i < 1000000; ++i) - assert(arr[i] == i); - - sb_free(arr); - arr = NULL; - - for (i=0; i < 1000; ++i) - sb_add(arr, 1000); - assert(sb_count(arr) == 1000000); - - return 0; -} \ No newline at end of file diff --git a/third_party/stb/tests/stretch_test.dsp b/third_party/stb/tests/stretch_test.dsp deleted file mode 100644 index dd0442c26c..0000000000 --- a/third_party/stb/tests/stretch_test.dsp +++ /dev/null @@ -1,89 +0,0 @@ -# Microsoft Developer Studio Project File - Name="stretch_test" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=stretch_test - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "stretch_test.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "stretch_test.mak" CFG="stretch_test - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "stretch_test - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "stretch_test - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "stretch_test - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /I "..\.." /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "TT_TEST" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "stretch_test - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "stretch_test___Win32_Debug" -# PROP BASE Intermediate_Dir "stretch_test___Win32_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug\stretch_test" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "stretch_test - Win32 Release" -# Name "stretch_test - Win32 Debug" -# Begin Source File - -SOURCE=.\stretch_test.c -# End Source File -# End Target -# End Project diff --git a/third_party/stb/tests/stretchy_buffer_test.c b/third_party/stb/tests/stretchy_buffer_test.c deleted file mode 100644 index 5ced5bc3ab..0000000000 --- a/third_party/stb/tests/stretchy_buffer_test.c +++ /dev/null @@ -1 +0,0 @@ -#include "stretchy_buffer.h" \ No newline at end of file diff --git a/third_party/stb/tests/test_c_compilation.c b/third_party/stb/tests/test_c_compilation.c deleted file mode 100644 index 40bc5a4b91..0000000000 --- a/third_party/stb/tests/test_c_compilation.c +++ /dev/null @@ -1,41 +0,0 @@ -#define STB_SPRINTF_IMPLEMENTATION -#include "stb_sprintf.h" - -#define STB_PERLIN_IMPLEMENTATION -#define STB_IMAGE_WRITE_IMPLEMENTATION -#define STB_C_LEXER_IMPLEMENTATIOn -#define STB_DIVIDE_IMPLEMENTATION -#define STB_IMAGE_IMPLEMENTATION -#define STB_HERRINGBONE_WANG_TILE_IMEPLEMENTATIOn -#define STB_IMAGE_RESIZE_IMPLEMENTATION -#define STB_RECT_PACK_IMPLEMENTATION -#define STB_VOXEL_RENDER_IMPLEMENTATION -#define STB_EASY_FONT_IMPLEMENTATION - -#include "stb_herringbone_wang_tile.h" -#include "stb_image.h" -#include "stb_image_write.h" -#include "stb_perlin.h" -#include "stb_c_lexer.h" -#include "stb_divide.h" -#include "stb_image_resize.h" -#include "stb_rect_pack.h" - -#define STB_DXT_IMPLEMENTATION -#include "stb_dxt.h" - -#define STBVOX_CONFIG_MODE 1 -#include "stb_voxel_render.h" - -#define STBTE_DRAW_RECT(x0,y0,x1,y1,color) 0 -#define STBTE_DRAW_TILE(x,y,id,highlight,data) 0 -#define STB_TILEMAP_EDITOR_IMPLEMENTATION -#include "stb_tilemap_editor.h" - - -int quicktest(void) -{ - char buffer[999]; - stbsp_sprintf(buffer, "test%%test"); - return 0; -} \ No newline at end of file diff --git a/third_party/stb/tests/test_c_lexer.c b/third_party/stb/tests/test_c_lexer.c deleted file mode 100644 index 579ed5d0b5..0000000000 --- a/third_party/stb/tests/test_c_lexer.c +++ /dev/null @@ -1 +0,0 @@ -#include "stb_c_lexer.h" diff --git a/third_party/stb/tests/test_cpp_compilation.cpp b/third_party/stb/tests/test_cpp_compilation.cpp deleted file mode 100644 index 96ecf9d0aa..0000000000 --- a/third_party/stb/tests/test_cpp_compilation.cpp +++ /dev/null @@ -1,148 +0,0 @@ -#include "stb_sprintf.h" -#define STB_SPRINTF_IMPLEMENTATION -#include "stb_sprintf.h" - -#define STB_IMAGE_WRITE_STATIC - -#define STB_IMAGE_WRITE_IMPLEMENTATION -#define STB_TRUETYPE_IMPLEMENTATION -#define STB_PERLIN_IMPLEMENTATION -#define STB_DXT_IMPLEMENATION -#define STB_C_LEXER_IMPLEMENTATIOn -#define STB_DIVIDE_IMPLEMENTATION -#define STB_IMAGE_IMPLEMENTATION -#define STB_HERRINGBONE_WANG_TILE_IMPLEMENTATION -#define STB_RECT_PACK_IMPLEMENTATION -#define STB_VOXEL_RENDER_IMPLEMENTATION -#define STB_CONNECTED_COMPONENTS_IMPLEMENTATION - -#define STBI_MALLOC my_malloc -#define STBI_FREE my_free -#define STBI_REALLOC my_realloc - -void *my_malloc(size_t) { return 0; } -void *my_realloc(void *, size_t) { return 0; } -void my_free(void *) { } - -#include "stb_image.h" -#include "stb_rect_pack.h" -#include "stb_truetype.h" -#include "stb_image_write.h" -#include "stb_perlin.h" -#include "stb_dxt.h" -#include "stb_c_lexer.h" -#include "stb_divide.h" -#include "stb_herringbone_wang_tile.h" - -#define STBCC_GRID_COUNT_X_LOG2 10 -#define STBCC_GRID_COUNT_Y_LOG2 10 -#include "stb_connected_components.h" - -#define STBVOX_CONFIG_MODE 1 -#include "stb_voxel_render.h" - -#define STBTE_DRAW_RECT(x0,y0,x1,y1,color) do ; while(0) -#define STBTE_DRAW_TILE(x,y,id,highlight,data) do ; while(0) -#define STB_TILEMAP_EDITOR_IMPLEMENTATION -#include "stb_tilemap_editor.h" - -#include "stb_easy_font.h" - -#define STB_LEAKCHECK_IMPLEMENTATION -#include "stb_leakcheck.h" - -#define STB_IMAGE_RESIZE_IMPLEMENTATION -#include "stb_image_resize.h" - -#include "stretchy_buffer.h" - - - -//////////////////////////////////////////////////////////// -// -// text edit - -#include -#include // memmove -#include // isspace - -#define STB_TEXTEDIT_CHARTYPE char -#define STB_TEXTEDIT_STRING text_control - -// get the base type -#include "stb_textedit.h" - -// define our editor structure -typedef struct -{ - char *string; - int stringlen; - STB_TexteditState state; -} text_control; - -// define the functions we need -void layout_func(StbTexteditRow *row, STB_TEXTEDIT_STRING *str, int start_i) -{ - int remaining_chars = str->stringlen - start_i; - row->num_chars = remaining_chars > 20 ? 20 : remaining_chars; // should do real word wrap here - row->x0 = 0; - row->x1 = 20; // need to account for actual size of characters - row->baseline_y_delta = 1.25; - row->ymin = -1; - row->ymax = 0; -} - -int delete_chars(STB_TEXTEDIT_STRING *str, int pos, int num) -{ - memmove(&str->string[pos], &str->string[pos+num], str->stringlen - (pos+num)); - str->stringlen -= num; - return 1; // always succeeds -} - -int insert_chars(STB_TEXTEDIT_STRING *str, int pos, STB_TEXTEDIT_CHARTYPE *newtext, int num) -{ - str->string = (char *) realloc(str->string, str->stringlen + num); - memmove(&str->string[pos+num], &str->string[pos], str->stringlen - pos); - memcpy(&str->string[pos], newtext, num); - str->stringlen += num; - return 1; // always succeeds -} - -// define all the #defines needed - -#define KEYDOWN_BIT 0x80000000 - -#define STB_TEXTEDIT_STRINGLEN(tc) ((tc)->stringlen) -#define STB_TEXTEDIT_LAYOUTROW layout_func -#define STB_TEXTEDIT_GETWIDTH(tc,n,i) (1) // quick hack for monospaced -#define STB_TEXTEDIT_KEYTOTEXT(key) (((key) & KEYDOWN_BIT) ? 0 : (key)) -#define STB_TEXTEDIT_GETCHAR(tc,i) ((tc)->string[i]) -#define STB_TEXTEDIT_NEWLINE '\n' -#define STB_TEXTEDIT_IS_SPACE(ch) isspace(ch) -#define STB_TEXTEDIT_DELETECHARS delete_chars -#define STB_TEXTEDIT_INSERTCHARS insert_chars - -#define STB_TEXTEDIT_K_SHIFT 0x40000000 -#define STB_TEXTEDIT_K_CONTROL 0x20000000 -#define STB_TEXTEDIT_K_LEFT (KEYDOWN_BIT | 1) // actually use VK_LEFT, SDLK_LEFT, etc -#define STB_TEXTEDIT_K_RIGHT (KEYDOWN_BIT | 2) // VK_RIGHT -#define STB_TEXTEDIT_K_UP (KEYDOWN_BIT | 3) // VK_UP -#define STB_TEXTEDIT_K_DOWN (KEYDOWN_BIT | 4) // VK_DOWN -#define STB_TEXTEDIT_K_LINESTART (KEYDOWN_BIT | 5) // VK_HOME -#define STB_TEXTEDIT_K_LINEEND (KEYDOWN_BIT | 6) // VK_END -#define STB_TEXTEDIT_K_TEXTSTART (STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_CONTROL) -#define STB_TEXTEDIT_K_TEXTEND (STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_CONTROL) -#define STB_TEXTEDIT_K_DELETE (KEYDOWN_BIT | 7) // VK_DELETE -#define STB_TEXTEDIT_K_BACKSPACE (KEYDOWN_BIT | 8) // VK_BACKSPACE -#define STB_TEXTEDIT_K_UNDO (KEYDOWN_BIT | STB_TEXTEDIT_K_CONTROL | 'z') -#define STB_TEXTEDIT_K_REDO (KEYDOWN_BIT | STB_TEXTEDIT_K_CONTROL | 'y') -#define STB_TEXTEDIT_K_INSERT (KEYDOWN_BIT | 9) // VK_INSERT -#define STB_TEXTEDIT_K_WORDLEFT (STB_TEXTEDIT_K_LEFT | STB_TEXTEDIT_K_CONTROL) -#define STB_TEXTEDIT_K_WORDRIGHT (STB_TEXTEDIT_K_RIGHT | STB_TEXTEDIT_K_CONTROL) -#define STB_TEXTEDIT_K_PGUP (KEYDOWN_BIT | 10) // VK_PGUP -- not implemented -#define STB_TEXTEDIT_K_PGDOWN (KEYDOWN_BIT | 11) // VK_PGDOWN -- not implemented - -#define STB_TEXTEDIT_IMPLEMENTATION -#include "stb_textedit.h" - - diff --git a/third_party/stb/tests/test_dxt.c b/third_party/stb/tests/test_dxt.c deleted file mode 100644 index a1ef29d045..0000000000 --- a/third_party/stb/tests/test_dxt.c +++ /dev/null @@ -1 +0,0 @@ -#include "stb_dxt.h" diff --git a/third_party/stb/tests/test_easyfont.c b/third_party/stb/tests/test_easyfont.c deleted file mode 100644 index 70f284b929..0000000000 --- a/third_party/stb/tests/test_easyfont.c +++ /dev/null @@ -1 +0,0 @@ -#include "stb_easy_font.h" diff --git a/third_party/stb/tests/test_image.c b/third_party/stb/tests/test_image.c deleted file mode 100644 index e23d4a041d..0000000000 --- a/third_party/stb/tests/test_image.c +++ /dev/null @@ -1 +0,0 @@ -#include "stb_image.h" \ No newline at end of file diff --git a/third_party/stb/tests/test_image_write.c b/third_party/stb/tests/test_image_write.c deleted file mode 100644 index cf2302593b..0000000000 --- a/third_party/stb/tests/test_image_write.c +++ /dev/null @@ -1 +0,0 @@ -#include "stb_image_write.h" \ No newline at end of file diff --git a/third_party/stb/tests/test_perlin.c b/third_party/stb/tests/test_perlin.c deleted file mode 100644 index de702c9bcc..0000000000 --- a/third_party/stb/tests/test_perlin.c +++ /dev/null @@ -1 +0,0 @@ -#include "stb_perlin.h" \ No newline at end of file diff --git a/third_party/stb/tests/test_sprintf.c b/third_party/stb/tests/test_sprintf.c deleted file mode 100644 index 078faa80ca..0000000000 --- a/third_party/stb/tests/test_sprintf.c +++ /dev/null @@ -1 +0,0 @@ -#include "stb_sprintf.h" \ No newline at end of file diff --git a/third_party/stb/tests/test_truetype.c b/third_party/stb/tests/test_truetype.c deleted file mode 100644 index 1ac147b778..0000000000 --- a/third_party/stb/tests/test_truetype.c +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef _CRT_SECURE_NO_WARNINGS -// Fixes Compile Errors for Visual Studio 2005 or newer - #define _CRT_SECURE_NO_WARNINGS -#endif - -#include - -// this isn't meant to compile standalone; link with test_c_compilation.c as well -#include "stb_rect_pack.h" -#define STB_TRUETYPE_IMPLEMENTATION -#include "stb_truetype.h" -#include "stb_image_write.h" - -#ifdef TT_TEST - -#include - -unsigned char ttf_buffer[1 << 25]; -unsigned char output[512*100]; - -void debug(void) -{ - stbtt_fontinfo font; - fread(ttf_buffer, 1, 1<<25, fopen("c:/x/lm/LiberationMono-Regular.ttf", "rb")); - stbtt_InitFont(&font, ttf_buffer, 0); - - stbtt_MakeGlyphBitmap(&font, output, 6, 9, 512, 5.172414E-03f, 5.172414E-03f, 54); -} - -#define BITMAP_W 256 -#define BITMAP_H 512 -unsigned char temp_bitmap[BITMAP_H][BITMAP_W]; -stbtt_bakedchar cdata[256*2]; // ASCII 32..126 is 95 glyphs -stbtt_packedchar pdata[256*2]; - -int main(int argc, char **argv) -{ - stbtt_fontinfo font; - unsigned char *bitmap; - int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 34807), s = (argc > 2 ? atoi(argv[2]) : 32); - - //debug(); - - // @TODO: why is minglui.ttc failing? - fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/mingliu.ttc", "rb")); - - //fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/x/DroidSansMono.ttf", "rb")); - { - static stbtt_pack_context pc; - static stbtt_packedchar cd[256]; - static unsigned char atlas[1024*1024]; - - stbtt_PackBegin(&pc, atlas, 1024,1024,1024,1,NULL); - stbtt_PackFontRange(&pc, ttf_buffer, 0, 32.0, 0, 256, cd); - stbtt_PackEnd(&pc); - } - -#if 0 - stbtt_BakeFontBitmap(ttf_buffer,stbtt_GetFontOffsetForIndex(ttf_buffer,0), 40.0, temp_bitmap[0],BITMAP_W,BITMAP_H, 32,96, cdata); // no guarantee this fits! - stbi_write_png("fonttest1.png", BITMAP_W, BITMAP_H, 1, temp_bitmap, 0); - - { - stbtt_pack_context pc; - stbtt_PackBegin(&pc, temp_bitmap[0], BITMAP_W, BITMAP_H, 0, 1, NULL); - stbtt_PackFontRange(&pc, ttf_buffer, 0, 20.0, 32, 95, pdata); - stbtt_PackFontRange(&pc, ttf_buffer, 0, 20.0, 0xa0, 0x100-0xa0, pdata); - stbtt_PackEnd(&pc); - stbi_write_png("fonttest2.png", BITMAP_W, BITMAP_H, 1, temp_bitmap, 0); - } - - { - stbtt_pack_context pc; - stbtt_pack_range pr[2]; - stbtt_PackBegin(&pc, temp_bitmap[0], BITMAP_W, BITMAP_H, 0, 1, NULL); - - pr[0].chardata_for_range = pdata; - pr[0].array_of_unicode_codepoints = NULL; - pr[0].first_unicode_codepoint_in_range = 32; - pr[0].num_chars = 95; - pr[0].font_size = 20.0f; - pr[1].chardata_for_range = pdata+256; - pr[1].array_of_unicode_codepoints = NULL; - pr[1].first_unicode_codepoint_in_range = 0xa0; - pr[1].num_chars = 0x100 - 0xa0; - pr[1].font_size = 20.0f; - - stbtt_PackSetOversampling(&pc, 2, 2); - stbtt_PackFontRanges(&pc, ttf_buffer, 0, pr, 2); - stbtt_PackEnd(&pc); - stbi_write_png("fonttest3.png", BITMAP_W, BITMAP_H, 1, temp_bitmap, 0); - } - return 0; -#endif - - stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0)); - bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, (float)s), c, &w, &h, 0,0); - - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) - putchar(" .:ioVM@"[bitmap[j*w+i]>>5]); - putchar('\n'); - } - return 0; -} -#endif diff --git a/third_party/stb/tests/test_vorbis.c b/third_party/stb/tests/test_vorbis.c deleted file mode 100644 index 341a10269b..0000000000 --- a/third_party/stb/tests/test_vorbis.c +++ /dev/null @@ -1,22 +0,0 @@ -#define STB_IMAGE_STATIC -#define STB_IMAGE_IMPLEMENTATION -#include "stb_image.h" - -#define STB_VORBIS_HEADER_ONLY -#include "stb_vorbis.c" -#include "stb.h" - -extern void stb_vorbis_dumpmem(void); - -#ifdef VORBIS_TEST -int main(int argc, char **argv) -{ - size_t memlen; - unsigned char *mem = stb_fileu("c:/x/sketch008.ogg", &memlen); - int chan, samplerate; - short *output; - int samples = stb_vorbis_decode_memory(mem, memlen, &chan, &samplerate, &output); - stb_filewrite("c:/x/sketch008.raw", output, samples*4); - return 0; -} -#endif diff --git a/third_party/stb/tests/test_voxel.c b/third_party/stb/tests/test_voxel.c deleted file mode 100644 index e177b6f9a2..0000000000 --- a/third_party/stb/tests/test_voxel.c +++ /dev/null @@ -1 +0,0 @@ -#include "stb_voxel_render.h" \ No newline at end of file diff --git a/third_party/stb/tests/textedit_sample.c b/third_party/stb/tests/textedit_sample.c deleted file mode 100644 index 04dc31a887..0000000000 --- a/third_party/stb/tests/textedit_sample.c +++ /dev/null @@ -1,84 +0,0 @@ -// I haven't actually tested this yet, this is just to make sure it compiles - -#include -#include // memmove -#include // isspace - -#define STB_TEXTEDIT_CHARTYPE char -#define STB_TEXTEDIT_STRING text_control - -// get the base type -#include "stb_textedit.h" - -// define our editor structure -typedef struct -{ - char *string; - int stringlen; - STB_TexteditState state; -} text_control; - -// define the functions we need -void layout_func(StbTexteditRow *row, STB_TEXTEDIT_STRING *str, int start_i) -{ - int remaining_chars = str->stringlen - start_i; - row->num_chars = remaining_chars > 20 ? 20 : remaining_chars; // should do real word wrap here - row->x0 = 0; - row->x1 = 20; // need to account for actual size of characters - row->baseline_y_delta = 1.25; - row->ymin = -1; - row->ymax = 0; -} - -int delete_chars(STB_TEXTEDIT_STRING *str, int pos, int num) -{ - memmove(&str->string[pos], &str->string[pos+num], str->stringlen - (pos+num)); - str->stringlen -= num; - return 1; // always succeeds -} - -int insert_chars(STB_TEXTEDIT_STRING *str, int pos, STB_TEXTEDIT_CHARTYPE *newtext, int num) -{ - str->string = realloc(str->string, str->stringlen + num); - memmove(&str->string[pos+num], &str->string[pos], str->stringlen - pos); - memcpy(&str->string[pos], newtext, num); - str->stringlen += num; - return 1; // always succeeds -} - -// define all the #defines needed - -#define KEYDOWN_BIT 0x80000000 - -#define STB_TEXTEDIT_STRINGLEN(tc) ((tc)->stringlen) -#define STB_TEXTEDIT_LAYOUTROW layout_func -#define STB_TEXTEDIT_GETWIDTH(tc,n,i) (1) // quick hack for monospaced -#define STB_TEXTEDIT_KEYTOTEXT(key) (((key) & KEYDOWN_BIT) ? 0 : (key)) -#define STB_TEXTEDIT_GETCHAR(tc,i) ((tc)->string[i]) -#define STB_TEXTEDIT_NEWLINE '\n' -#define STB_TEXTEDIT_IS_SPACE(ch) isspace(ch) -#define STB_TEXTEDIT_DELETECHARS delete_chars -#define STB_TEXTEDIT_INSERTCHARS insert_chars - -#define STB_TEXTEDIT_K_SHIFT 0x40000000 -#define STB_TEXTEDIT_K_CONTROL 0x20000000 -#define STB_TEXTEDIT_K_LEFT (KEYDOWN_BIT | 1) // actually use VK_LEFT, SDLK_LEFT, etc -#define STB_TEXTEDIT_K_RIGHT (KEYDOWN_BIT | 2) // VK_RIGHT -#define STB_TEXTEDIT_K_UP (KEYDOWN_BIT | 3) // VK_UP -#define STB_TEXTEDIT_K_DOWN (KEYDOWN_BIT | 4) // VK_DOWN -#define STB_TEXTEDIT_K_LINESTART (KEYDOWN_BIT | 5) // VK_HOME -#define STB_TEXTEDIT_K_LINEEND (KEYDOWN_BIT | 6) // VK_END -#define STB_TEXTEDIT_K_TEXTSTART (STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_CONTROL) -#define STB_TEXTEDIT_K_TEXTEND (STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_CONTROL) -#define STB_TEXTEDIT_K_DELETE (KEYDOWN_BIT | 7) // VK_DELETE -#define STB_TEXTEDIT_K_BACKSPACE (KEYDOWN_BIT | 8) // VK_BACKSPACE -#define STB_TEXTEDIT_K_UNDO (KEYDOWN_BIT | STB_TEXTEDIT_K_CONTROL | 'z') -#define STB_TEXTEDIT_K_REDO (KEYDOWN_BIT | STB_TEXTEDIT_K_CONTROL | 'y') -#define STB_TEXTEDIT_K_INSERT (KEYDOWN_BIT | 9) // VK_INSERT -#define STB_TEXTEDIT_K_WORDLEFT (STB_TEXTEDIT_K_LEFT | STB_TEXTEDIT_K_CONTROL) -#define STB_TEXTEDIT_K_WORDRIGHT (STB_TEXTEDIT_K_RIGHT | STB_TEXTEDIT_K_CONTROL) -#define STB_TEXTEDIT_K_PGUP (KEYDOWN_BIT | 10) // VK_PGUP -- not implemented -#define STB_TEXTEDIT_K_PGDOWN (KEYDOWN_BIT | 11) // VK_PGDOWN -- not implemented - -#define STB_TEXTEDIT_IMPLEMENTATION -#include "stb_textedit.h" diff --git a/third_party/stb/tests/tilemap_editor_integration_example.c b/third_party/stb/tests/tilemap_editor_integration_example.c deleted file mode 100644 index ea5dee775c..0000000000 --- a/third_party/stb/tests/tilemap_editor_integration_example.c +++ /dev/null @@ -1,193 +0,0 @@ -// This isn't compilable as-is, as it was extracted from a working -// integration-in-a-game and makes reference to symbols from that game. - -#include -#include -#include "game.h" -#include "SDL.h" -#include "stb_tilemap_editor.h" - -extern void editor_draw_tile(int x, int y, unsigned short tile, int mode, float *props); -extern void editor_draw_rect(int x0, int y0, int x1, int y1, unsigned char r, unsigned char g, unsigned char b); - -static int is_platform(short *tiles); -static unsigned int prop_type(int n, short *tiles); -static char *prop_name(int n, short *tiles); -static float prop_range(int n, short *tiles, int is_max); -static int allow_link(short *src, short *dest); - -#define STBTE_MAX_PROPERTIES 8 - -#define STBTE_PROP_TYPE(n, tiledata, p) prop_type(n,tiledata) -#define STBTE_PROP_NAME(n, tiledata, p) prop_name(n,tiledata) -#define STBTE_PROP_MIN(n, tiledata, p) prop_range(n,tiledata,0) -#define STBTE_PROP_MAX(n, tiledata, p) prop_range(n,tiledata,1) -#define STBTE_PROP_FLOAT_SCALE(n,td,p) (0.1) - -#define STBTE_ALLOW_LINK(srctile, srcprop, desttile, destprop) \ - allow_link(srctile, desttile) - -#define STBTE_LINK_COLOR(srctile, srcprop, desttile, destprop) \ - (is_platform(srctile) ? 0xff80ff : 0x808040) - -#define STBTE_DRAW_RECT(x0,y0,x1,y1,c) \ - editor_draw_rect(x0,y0,x1,y1,(c)>>16,((c)>>8)&255,(c)&255) - -#define STBTE_DRAW_TILE(x,y,id,highlight,props) \ - editor_draw_tile(x,y,id,highlight,props) - - - -#define STB_TILEMAP_EDITOR_IMPLEMENTATION -#include "stb_tilemap_editor.h" - -stbte_tilemap *edit_map; - -void editor_key(enum stbte_action act) -{ - stbte_action(edit_map, act); -} - -void editor_process_sdl_event(SDL_Event *e) -{ - switch (e->type) { - case SDL_MOUSEMOTION: - case SDL_MOUSEBUTTONDOWN: - case SDL_MOUSEBUTTONUP: - case SDL_MOUSEWHEEL: - stbte_mouse_sdl(edit_map, e, 1.0f/editor_scale,1.0f/editor_scale,0,0); - break; - - case SDL_KEYDOWN: - if (in_editor) { - switch (e->key.keysym.sym) { - case SDLK_RIGHT: editor_key(STBTE_scroll_right); break; - case SDLK_LEFT : editor_key(STBTE_scroll_left ); break; - case SDLK_UP : editor_key(STBTE_scroll_up ); break; - case SDLK_DOWN : editor_key(STBTE_scroll_down ); break; - } - switch (e->key.keysym.scancode) { - case SDL_SCANCODE_S: editor_key(STBTE_tool_select); break; - case SDL_SCANCODE_B: editor_key(STBTE_tool_brush ); break; - case SDL_SCANCODE_E: editor_key(STBTE_tool_erase ); break; - case SDL_SCANCODE_R: editor_key(STBTE_tool_rectangle ); break; - case SDL_SCANCODE_I: editor_key(STBTE_tool_eyedropper); break; - case SDL_SCANCODE_L: editor_key(STBTE_tool_link); break; - case SDL_SCANCODE_G: editor_key(STBTE_act_toggle_grid); break; - } - if ((e->key.keysym.mod & KMOD_CTRL) && !(e->key.keysym.mod & ~KMOD_CTRL)) { - switch (e->key.keysym.scancode) { - case SDL_SCANCODE_X: editor_key(STBTE_act_cut ); break; - case SDL_SCANCODE_C: editor_key(STBTE_act_copy ); break; - case SDL_SCANCODE_V: editor_key(STBTE_act_paste); break; - case SDL_SCANCODE_Z: editor_key(STBTE_act_undo ); break; - case SDL_SCANCODE_Y: editor_key(STBTE_act_redo ); break; - } - } - } - break; - } -} - -void editor_init(void) -{ - int i; - edit_map = stbte_create_map(20,14, 8, 16,16, 100); - - stbte_set_background_tile(edit_map, T_empty); - - for (i=0; i < T__num_types; ++i) { - if (i != T_reserved1 && i != T_entry && i != T_doorframe) - stbte_define_tile(edit_map, 0+i, 1, "Background"); - } - stbte_define_tile(edit_map, 256+O_player , 8, "Char"); - stbte_define_tile(edit_map, 256+O_robot , 8, "Char"); - for (i=O_lockeddoor; i < O__num_types-2; ++i) - if (i == O_platform || i == O_vplatform) - stbte_define_tile(edit_map, 256+i, 4, "Object"); - else - stbte_define_tile(edit_map, 256+i, 2, "Object"); - - //stbte_set_layername(edit_map, 0, "background"); - //stbte_set_layername(edit_map, 1, "objects"); - //stbte_set_layername(edit_map, 2, "platforms"); - //stbte_set_layername(edit_map, 3, "characters"); -} - -static int is_platform(short *tiles) -{ - // platforms are only on layer #2 - return tiles[2] == 256 + O_platform || tiles[2] == 256 + O_vplatform; -} - -static int is_object(short *tiles) -{ - return (tiles[1] >= 256 || tiles[2] >= 256 || tiles[3] >= 256); -} - -static unsigned int prop_type(int n, short *tiles) -{ - if (is_platform(tiles)) { - static unsigned int platform_types[STBTE_MAX_PROPERTIES] = { - STBTE_PROP_bool, // phantom - STBTE_PROP_int, // x_adjust - STBTE_PROP_int, // y_adjust - STBTE_PROP_float, // width - STBTE_PROP_float, // lspeed - STBTE_PROP_float, // rspeed - STBTE_PROP_bool, // autoreturn - STBTE_PROP_bool, // one-shot - // remainder get 0, means 'no property in this slot' - }; - return platform_types[n]; - } else if (is_object(tiles)) { - if (n == 0) - return STBTE_PROP_bool; - } - return 0; -} - -static char *prop_name(int n, short *tiles) -{ - if (is_platform(tiles)) { - static char *platform_vars[STBTE_MAX_PROPERTIES] = { - "phantom", - "x_adjust", - "y_adjust", - "width", - "lspeed", - "rspeed", - "autoreturn", - "one-shot", - }; - return platform_vars[n]; - } - return "phantom"; -} - -static float prop_range(int n, short *tiles, int is_max) -{ - if (is_platform(tiles)) { - static float ranges[8][2] = { - { 0, 1 }, // phantom-flag, range is ignored - { -15, 15 }, // x_adjust - { -15, 15 }, // y_adjust - { 0, 6 }, // width - { 0, 10 }, // lspeed - { 0, 10 }, // rspeed - { 0, 1 }, // autoreturn, range is ignored - { 0, 1 }, // one-shot, range is ignored - }; - return ranges[n][is_max]; - } - return 0; -} - -static int allow_link(short *src, short *dest) -{ - if (is_platform(src)) - return dest[1] == 256+O_lever; - if (src[1] == 256+O_endpoint) - return is_platform(dest); - return 0; -} diff --git a/third_party/stb/tests/vorbseek/vorbseek.c b/third_party/stb/tests/vorbseek/vorbseek.c deleted file mode 100644 index f3460ad7f6..0000000000 --- a/third_party/stb/tests/vorbseek/vorbseek.c +++ /dev/null @@ -1,125 +0,0 @@ -#include -#include -#include -#include - -#define STB_VORBIS_HEADER_ONLY -#include "stb_vorbis.c" - -#define SAMPLES_TO_TEST 3000 - -int test_count [5] = { 5000, 3000, 2000, 50000, 50000 }; -int test_spacing[5] = { 1, 111, 3337, 7779, 72717 }; - -int try_seeking(stb_vorbis *v, unsigned int pos, short *output, unsigned int num_samples) -{ - int count; - short samples[SAMPLES_TO_TEST*2]; - assert(pos <= num_samples); - - if (!stb_vorbis_seek(v, pos)) { - fprintf(stderr, "Seek to %u returned error from stb_vorbis\n", pos); - return 0; - } - - count = stb_vorbis_get_samples_short_interleaved(v, 2, samples, SAMPLES_TO_TEST*2); - - if (count > (int) (num_samples - pos)) { - fprintf(stderr, "Seek to %u allowed decoding %d samples when only %d should have been valid.\n", - pos, count, (int) (num_samples - pos)); - return 0; - } - - if (count < SAMPLES_TO_TEST && count < (int) (num_samples - pos)) { - fprintf(stderr, "Seek to %u only decoded %d samples of %d attempted when at least %d should have been valid.\n", - pos, count, SAMPLES_TO_TEST, num_samples - pos); - return 0; - } - - if (0 != memcmp(samples, output + pos*2, count*2)) { - int k; - for (k=0; k < SAMPLES_TO_TEST*2; ++k) { - if (samples[k] != output[k]) { - fprintf(stderr, "Seek to %u produced incorrect samples starting at sample %u (short #%d in buffer).\n", - pos, pos + (k/2), k); - break; - } - } - assert(k != SAMPLES_TO_TEST*2); - return 0; - } - - return 1; -} - -int main(int argc, char **argv) -{ - int num_chan, samprate; - int i, j, test, phase; - short *output; - - if (argc == 1) { - fprintf(stderr, "Usage: vorbseek {vorbisfile} [{vorbisfile]*]\n"); - fprintf(stderr, "Tests various seek offsets to make sure they're sample exact.\n"); - return 0; - } - - #if 0 - { - // check that outofmem occurs correctly - stb_vorbis_alloc va; - va.alloc_buffer = malloc(1024*1024); - for (i=0; i < 1024*1024; i += 10) { - int error=0; - stb_vorbis *v; - va.alloc_buffer_length_in_bytes = i; - v = stb_vorbis_open_filename(argv[1], &error, &va); - if (v != NULL) - break; - printf("Error %d at %d\n", error, i); - } - } - #endif - - for (j=1; j < argc; ++j) { - unsigned int successes=0, attempts = 0; - unsigned int num_samples = stb_vorbis_decode_filename(argv[j], &num_chan, &samprate, &output); - - break; - - if (num_samples == 0xffffffff) { - fprintf(stderr, "Error: couldn't open file or not vorbis file: %s\n", argv[j]); - goto fail; - } - - if (num_chan != 2) { - fprintf(stderr, "vorbseek testing only works with files with 2 channels, %s has %d\n", argv[j], num_chan); - goto fail; - } - - for (test=0; test < 5; ++test) { - int error; - stb_vorbis *v = stb_vorbis_open_filename(argv[j], &error, NULL); - if (v == NULL) { - fprintf(stderr, "Couldn't re-open %s for test #%d\n", argv[j], test); - goto fail; - } - for (phase=0; phase < 3; ++phase) { - unsigned int base = phase == 0 ? 0 : phase == 1 ? num_samples - test_count[test]*test_spacing[test] : num_samples/3; - for (i=0; i < test_count[test]; ++i) { - unsigned int pos = base + i*test_spacing[test]; - if (pos > num_samples) // this also catches underflows - continue; - successes += try_seeking(v, pos, output, num_samples); - attempts += 1; - } - } - stb_vorbis_close(v); - } - printf("%d of %d seeks failed in %s (%d samples)\n", attempts-successes, attempts, argv[j], num_samples); - free(output); - } - return 0; - fail: - return 1; -} \ No newline at end of file diff --git a/third_party/stb/tests/vorbseek/vorbseek.dsp b/third_party/stb/tests/vorbseek/vorbseek.dsp deleted file mode 100644 index 5eaf5795ff..0000000000 --- a/third_party/stb/tests/vorbseek/vorbseek.dsp +++ /dev/null @@ -1,96 +0,0 @@ -# Microsoft Developer Studio Project File - Name="vorbseek" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=vorbseek - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "vorbseek.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "vorbseek.mak" CFG="vorbseek - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "vorbseek - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "vorbseek - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "vorbseek - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /Zd /O2 /I "..\.." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 - -!ELSEIF "$(CFG)" == "vorbseek - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "vorbseek - Win32 Release" -# Name "vorbseek - Win32 Debug" -# Begin Source File - -SOURCE=..\..\stb_vorbis.c -# End Source File -# Begin Source File - -SOURCE=.\vorbseek.c -# End Source File -# End Target -# End Project diff --git a/third_party/stb/tnt/README b/third_party/stb/tnt/README index daeaa558f0..84ba79e8fb 100644 --- a/third_party/stb/tnt/README +++ b/third_party/stb/tnt/README @@ -6,4 +6,5 @@ unzip 59e9702.zip mv stb-* stb_new rsync -r stb_new/ stb/ --delete --exclude LICENSE tnt rm -rf 59e9702.zip stb_new +rm -Rf stb/tests git add stb ; git status diff --git a/web/filament-js/extensions.js b/web/filament-js/extensions.js index cb8f3bb717..23b855555b 100644 --- a/web/filament-js/extensions.js +++ b/web/filament-js/extensions.js @@ -409,6 +409,22 @@ Filament.loadClassExtensions = function() { pbd.delete(); } + Filament.Texture.prototype.getWidth = function(engine, level = 0) { + return this._getWidth(engine, level); + } + + Filament.Texture.prototype.getHeight = function(engine, level = 0) { + return this._getHeight(engine, level); + } + + Filament.Texture.prototype.getDepth = function(engine, level = 0) { + return this._getDepth(engine, level); + } + + Filament.Texture.prototype.getLevels = function(engine) { + return this._getLevels(engine); + } + Filament.SurfaceOrientation$Builder.prototype.normals = function(buffer, stride = 0) { buffer = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength); this.norPointer = Filament._malloc(buffer.byteLength); diff --git a/web/filament-js/filament.d.ts b/web/filament-js/filament.d.ts index d138b996a1..2d670049fd 100644 --- a/web/filament-js/filament.d.ts +++ b/web/filament-js/filament.d.ts @@ -120,6 +120,10 @@ export class Texture { public static Builder(): Texture$Builder; public setImage(engine: Engine, level: number, pbd: driver$PixelBufferDescriptor): void; public setImageCube(engine: Engine, level: number, pbd: driver$PixelBufferDescriptor) : void; + public getWidth(engine: Engine, level?: number) : number; + public getHeight(engine: Engine, level?: number) : number; + public getDepth(engine: Engine, level?: number) : number; + public getLevels(engine: Engine) : number; public generateMipmaps(engine: Engine) : void; } @@ -315,8 +319,6 @@ export class RenderableManager { public setGeometryAt(instance: RenderableManager$Instance, primitiveIndex: number, type: RenderableManager$PrimitiveType, vertices: VertexBuffer, indices: IndexBuffer, offset: number, count: number): void; - public setGeometryRangeAt(instance: RenderableManager$Instance, primitiveIndex: number, - type: RenderableManager$PrimitiveType, offset: number, count: number): void; public setBlendOrderAt(instance: RenderableManager$Instance, primitiveIndex: number, order: number): void; public getEnabledAttributesAt(instance: RenderableManager$Instance, @@ -580,6 +582,9 @@ export class gltfio$FilamentAsset { public popRenderable(): Entity; public getMaterialInstances(): Vector; public getResourceUris(): Vector; + public getSkinNames(): Vector; + public attachSkin(skinIndex: number, entity: Entity): void; + public detachSkin(skinIndex: number, entity: Entity): void; public getBoundingBox(): Aabb; public getName(entity: Entity): string; public getExtras(entity: Entity): string; diff --git a/web/filament-js/jsbindings.cpp b/web/filament-js/jsbindings.cpp index 00ea8d0d54..28e041c370 100644 --- a/web/filament-js/jsbindings.cpp +++ b/web/filament-js/jsbindings.cpp @@ -919,6 +919,10 @@ class_("RenderableManager$Builder") (RenderableBuilder* builder, size_t index, uint16_t order), { return &builder->blendOrder(index, order); }) + .BUILDER_FUNCTION("globalBlendOrderEnabled", RenderableBuilder, + (RenderableBuilder* builder, size_t index, bool enabled), { + return &builder->globalBlendOrderEnabled(index, enabled); }) + .BUILDER_FUNCTION("lightChannel", RenderableBuilder, (RenderableBuilder* builder, unsigned int channel, bool enable), { return &builder->lightChannel(channel, enable); }) @@ -971,7 +975,7 @@ class_("RenderableManager") } self->setBones(instance, bones.data(), bones.size(), offset); }), allow_raw_pointers()) - + .function("setMorphWeights", EMBIND_LAMBDA(void, (RenderableManager* self, RenderableManager::Instance instance, emscripten::val weights), { auto nfloats = weights["length"].as(); @@ -996,14 +1000,10 @@ class_("RenderableManager") self->setGeometryAt(instance, primitiveIndex, type, vertices, indices, offset, count); }), allow_raw_pointers()) - .function("setGeometryRangeAt", EMBIND_LAMBDA(void, (RenderableManager* self, - RenderableManager::Instance instance, size_t primitiveIndex, - RenderableManager::PrimitiveType type, size_t offset, size_t count), { - self->setGeometryAt(instance, primitiveIndex, type, offset, count); - }), allow_raw_pointers()) - .function("setBlendOrderAt", &RenderableManager::setBlendOrderAt) + .function("setGlobalBlendOrderEnabledAt", &RenderableManager::setGlobalBlendOrderEnabledAt) + .function("getEnabledAttributesAt", EMBIND_LAMBDA(uint32_t, (RenderableManager* self, RenderableManager::Instance instance, size_t primitiveIndex), { return self->getEnabledAttributesAt(instance, primitiveIndex).getValue(); @@ -1289,6 +1289,22 @@ class_("Texture") uint32_t faceSize = pbd.pbd->size / 6; Texture::FaceOffsets offsets(faceSize); self->setImage(*engine, level, std::move(*pbd.pbd), offsets); + }), allow_raw_pointers()) + .function("_getWidth", EMBIND_LAMBDA(size_t, (Texture* self, + Engine* engine, uint8_t level), { + return self->getWidth(level); + }), allow_raw_pointers()) + .function("_getHeight", EMBIND_LAMBDA(size_t, (Texture* self, + Engine* engine, uint8_t level), { + return self->getHeight(level); + }), allow_raw_pointers()) + .function("_getDepth", EMBIND_LAMBDA(size_t, (Texture* self, + Engine* engine, uint8_t level), { + return self->getDepth(level); + }), allow_raw_pointers()) + .function("_getLevels", EMBIND_LAMBDA(size_t, (Texture* self, + Engine* engine), { + return self->getLevels(); }), allow_raw_pointers()); class_("Texture$Builder") @@ -1787,6 +1803,17 @@ class_("gltfio$FilamentAsset") return retval; }), allow_raw_pointers()) + .function("getSkinNames", EMBIND_LAMBDA(std::vector, (FilamentAsset* self), { + std::vector names(self->getSkinCount()); + for (size_t i = 0; i < names.size(); ++i) { + names[i] = self->getSkinNameAt(i); + } + return names; + }), allow_raw_pointers()) + + .function("attachSkin", &FilamentAsset::attachSkin) + .function("detachSkin", &FilamentAsset::detachSkin) + .function("getBoundingBox", &FilamentAsset::getBoundingBox) .function("getName", EMBIND_LAMBDA(std::string, (FilamentAsset* self, utils::Entity entity), { return std::string(self->getName(entity)); diff --git a/web/filament-js/package.json b/web/filament-js/package.json index e781cb5f3a..f0795a9b37 100644 --- a/web/filament-js/package.json +++ b/web/filament-js/package.json @@ -1,6 +1,6 @@ { "name": "filament", - "version": "1.23.0", + "version": "1.23.1", "description": "Real-time physically based rendering engine", "main": "filament.js", "module": "filament.js",