mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-22 06:45:13 +00:00
entry: return SpirvValue
from declare_interface_global_for_param
.
This commit is contained in:
parent
7cc69e7126
commit
9bada9362d
@ -1,7 +1,7 @@
|
||||
use super::CodegenCx;
|
||||
use crate::abi::ConvSpirvType;
|
||||
use crate::attr::{AggregatedSpirvAttributes, Entry};
|
||||
use crate::builder_spirv::SpirvValue;
|
||||
use crate::builder_spirv::{SpirvValue, SpirvValueExt};
|
||||
use crate::spirv_type::SpirvType;
|
||||
use rspirv::dr::Operand;
|
||||
use rspirv::spirv::{Decoration, ExecutionModel, FunctionControl, StorageClass, Word};
|
||||
@ -145,7 +145,11 @@ impl<'tcx> CodegenCx<'tcx> {
|
||||
.iter()
|
||||
.zip(arg_abis)
|
||||
.zip(hir_params)
|
||||
.flat_map(|((&(var, storage_class), entry_fn_arg), hir_param)| {
|
||||
.flat_map(
|
||||
|((&(global_var, storage_class), entry_fn_arg), hir_param)| {
|
||||
// FIXME(eddyb) use `Builder` and `SpirvValue` here.
|
||||
let var = global_var.def_cx(self);
|
||||
|
||||
let mut dst_len_arg = None;
|
||||
let arg = match entry_fn_arg.layout.ty.kind() {
|
||||
TyKind::Ref(_, ty, _) => {
|
||||
@ -173,7 +177,8 @@ impl<'tcx> CodegenCx<'tcx> {
|
||||
},
|
||||
};
|
||||
std::iter::once(arg).chain(dst_len_arg)
|
||||
})
|
||||
},
|
||||
)
|
||||
.collect();
|
||||
emit.function_call(
|
||||
entry_func_return_type,
|
||||
@ -187,13 +192,16 @@ impl<'tcx> CodegenCx<'tcx> {
|
||||
|
||||
let interface: Vec<_> = if emit.version().unwrap() > (1, 3) {
|
||||
// SPIR-V >= v1.4 includes all OpVariables in the interface.
|
||||
interface_globals.into_iter().map(|(var, _)| var).collect()
|
||||
interface_globals
|
||||
.into_iter()
|
||||
.map(|(var, _)| var.def_cx(self))
|
||||
.collect()
|
||||
} else {
|
||||
// SPIR-V <= v1.3 only includes Input and Output in the interface.
|
||||
interface_globals
|
||||
.into_iter()
|
||||
.filter(|&(_, s)| s == StorageClass::Input || s == StorageClass::Output)
|
||||
.map(|(var, _)| var)
|
||||
.map(|(var, _)| var.def_cx(self))
|
||||
.collect()
|
||||
};
|
||||
emit.entry_point(execution_model, fn_id, name, interface);
|
||||
@ -329,7 +337,7 @@ impl<'tcx> CodegenCx<'tcx> {
|
||||
layout: TyAndLayout<'tcx>,
|
||||
hir_param: &hir::Param<'tcx>,
|
||||
decoration_locations: &mut HashMap<StorageClass, u32>,
|
||||
) -> (Word, StorageClass) {
|
||||
) -> (SpirvValue, StorageClass) {
|
||||
let attrs = AggregatedSpirvAttributes::parse(self, self.tcx.hir().attrs(hir_param.hir_id));
|
||||
|
||||
let (value_ty, storage_class) =
|
||||
@ -412,7 +420,7 @@ impl<'tcx> CodegenCx<'tcx> {
|
||||
self.emit_global()
|
||||
.variable(var_spirv_type, Some(variable), storage_class, None);
|
||||
|
||||
(variable, storage_class)
|
||||
(variable.with_type(var_spirv_type), storage_class)
|
||||
}
|
||||
|
||||
// Kernel mode takes its interface as function parameters(??)
|
||||
|
Loading…
Reference in New Issue
Block a user