Validate OpImage*Read and OpImage*Write instructions
| 853 | |
| 854 | // Validate OpImage*Read and OpImage*Write instructions |
| 855 | spv_result_t ValidateImageReadWrite(ValidationState_t& _, |
| 856 | const Instruction* inst, |
| 857 | const ImageTypeInfo& info) { |
| 858 | if (info.sampled == 2) { |
| 859 | if (info.dim == spv::Dim::Dim1D && |
| 860 | !_.HasCapability(spv::Capability::Image1D)) { |
| 861 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 862 | << "Capability Image1D is required to access storage image"; |
| 863 | } else if (info.dim == spv::Dim::Rect && |
| 864 | !_.HasCapability(spv::Capability::ImageRect)) { |
| 865 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 866 | << "Capability ImageRect is required to access storage image"; |
| 867 | } else if (info.dim == spv::Dim::Buffer && |
| 868 | !_.HasCapability(spv::Capability::ImageBuffer)) { |
| 869 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 870 | << "Capability ImageBuffer is required to access storage image"; |
| 871 | } else if (info.dim == spv::Dim::Cube && info.arrayed == 1 && |
| 872 | !_.HasCapability(spv::Capability::ImageCubeArray)) { |
| 873 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 874 | << "Capability ImageCubeArray is required to access " |
| 875 | << "storage image"; |
| 876 | } |
| 877 | |
| 878 | if (info.multisampled == 1 && info.arrayed == 1 && info.sampled == 2 && |
| 879 | !_.HasCapability(spv::Capability::ImageMSArray)) { |
| 880 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 881 | << "Capability ImageMSArray is required to access storage " |
| 882 | << "image"; |
| 883 | } |
| 884 | } else if (info.sampled != 0) { |
| 885 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 886 | << "Expected Image 'Sampled' parameter to be 0 or 2"; |
| 887 | } |
| 888 | |
| 889 | return SPV_SUCCESS; |
| 890 | } |
| 891 | |
| 892 | // Returns true if opcode is *ImageSparse*, false otherwise. |
| 893 | bool IsSparse(spv::Op opcode) { |
no test coverage detected