-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir][spirv] Add definition for selected sample operations #129558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
IgWod-IMG
merged 1 commit into
llvm:main
from
imaginationtech:img_sample-implicit-explicit-lod
Mar 24, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
add_subdirectory(IR) | ||
add_subdirectory(Interfaces) | ||
add_subdirectory(Transforms) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_mlir_interface(SPIRVImageInterfaces) |
14 changes: 14 additions & 0 deletions
14
mlir/include/mlir/Dialect/SPIRV/Interfaces/SPIRVImageInterfaces.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//===- SPIRVImageInterfaces.h -----------------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_DIALECT_SPIRV_IMAGE_INTERFACES_H_ | ||
#define MLIR_DIALECT_SPIRV_IMAGE_INTERFACES_H_ | ||
|
||
#include "mlir/Dialect/SPIRV/Interfaces/SPIRVImageInterfaces.h.inc" | ||
|
||
#endif // MLIR_DIALECT_SPIRV_IMAGE_INTERFACES_H_ |
89 changes: 89 additions & 0 deletions
89
mlir/include/mlir/Dialect/SPIRV/Interfaces/SPIRVImageInterfaces.td
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
//===-- SPIRVImageInterfaces.td - MLIR SPIR-V Image Interfaces ------*- tablegen -*------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===------------------------------------------------------------------------------------===// | ||
// | ||
// This file contains interfaces used by image operations. | ||
// | ||
//===------------------------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_DIALECT_SPIRV_IMAGE_INTERFACES | ||
#define MLIR_DIALECT_SPIRV_IMAGE_INTERFACES | ||
|
||
include "mlir/Dialect/SPIRV/IR/SPIRVBase.td" | ||
|
||
// ----- | ||
|
||
def SPIRV_SampleOpInterface : OpInterface<"SamplingOpInterface"> { | ||
let description = [{ | ||
The `SampleOpInterface` defines sampling image operations (`spirv.Image*Sample*`) | ||
and provides interface methods to query operands common across all sampling | ||
instructions. | ||
|
||
Currently only getters for sampled image and coordinate are provided. The | ||
default implementation will work as long as the instruction the interface is | ||
attached to uses standard names for the operands: `$sampled_image` and `$coordinate`. | ||
}]; | ||
let cppNamespace = "::mlir::spirv"; | ||
let methods = [ | ||
InterfaceMethod< | ||
"Get SampledImage of the operation.", | ||
"::mlir::TypedValue<::mlir::Type>", "getSampledImage", (ins), [{ | ||
return $_op.getSampledImage(); | ||
}]>, | ||
InterfaceMethod< | ||
"Get Coordinate of the operation.", | ||
"::mlir::TypedValue<::mlir::Type>", "getCoordinate", (ins), [{ | ||
return $_op.getCoordinate(); | ||
}]> | ||
]; | ||
} | ||
|
||
// ----- | ||
|
||
def SPIRV_ExplicitLodOpInterface : OpInterface<"ExplicitLodOpInterface", [SPIRV_SampleOpInterface]> { | ||
let description = [{ | ||
The `ExplicitLodOpInterface` defines explicit sampling lod operations (`spirv.*ExplicitLod`). Currently | ||
the interface is only used to check whether the instruction is an explicit lod. | ||
}]; | ||
let cppNamespace = "::mlir::spirv"; | ||
} | ||
|
||
// ----- | ||
|
||
def SPIRV_ImplicitLodOpInterface : OpInterface<"ImplicitLodOpInterface", [SPIRV_SampleOpInterface]> { | ||
let description = [{ | ||
The `ImplicitLodOpInterface` defines implicit sampling lod operations (`spirv.*ImplicitLod`). Currently | ||
the interface is only used to check whether the instruction is an implicit lod. | ||
}]; | ||
let cppNamespace = "::mlir::spirv"; | ||
} | ||
|
||
// ----- | ||
|
||
def SPIRV_FetchOpInterface : OpInterface<"FetchOpInterface"> { | ||
let description = [{ | ||
The `FetchOpInterface` defines fetch image operations (`spirv.ImageFetch` and | ||
`spirv.ImageSpareFetch`) and provides interface methods to query operands common | ||
across all fetch instructions. | ||
|
||
Currently only a getter for image is provided. The default implementation | ||
will work as long as the instruction the interface is attached to uses | ||
standard names for the operands: `$image`. | ||
}]; | ||
let cppNamespace = "::mlir::spirv"; | ||
let methods = [ | ||
InterfaceMethod< | ||
"Get Image of the operation.", | ||
"::mlir::TypedValue<::mlir::Type>", "getImage", (ins), [{ | ||
return $_op.getImage(); | ||
}]> | ||
]; | ||
} | ||
|
||
// ----- | ||
|
||
#endif // MLIR_DIALECT_SPIRV_IMAGE_INTERFACES |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
add_subdirectory(IR) | ||
add_subdirectory(Interfaces) | ||
add_subdirectory(Linking) | ||
add_subdirectory(Transforms) | ||
add_subdirectory(Utils) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.