public ShaderConfig(IGpuAccessor gpuAccessor, TranslationOptions options) { Stage = ShaderStage.Compute; GpuAccessor = gpuAccessor; Options = options; _usedTextures = new Dictionary <TextureInfo, TextureMeta>(); _usedImages = new Dictionary <TextureInfo, TextureMeta>(); }
private static Block[][] DecodeShader( ulong address, IGpuAccessor gpuAccessor, TranslationOptions options, TranslationCounts counts, out ShaderConfig config) { Block[][] cfg; ulong maxEndAddress = 0; bool hasBindless; if ((options.Flags & TranslationFlags.Compute) != 0) { config = new ShaderConfig(gpuAccessor, options, counts); cfg = Decoder.Decode(gpuAccessor, address, out hasBindless); } else { config = new ShaderConfig(new ShaderHeader(gpuAccessor, address), gpuAccessor, options, counts); cfg = Decoder.Decode(gpuAccessor, address + HeaderSize, out hasBindless); } if (hasBindless) { config.SetUsedFeature(FeatureFlags.Bindless); } for (int funcIndex = 0; funcIndex < cfg.Length; funcIndex++) { for (int blkIndex = 0; blkIndex < cfg[funcIndex].Length; blkIndex++) { Block block = cfg[funcIndex][blkIndex]; if (maxEndAddress < block.EndAddress) { maxEndAddress = block.EndAddress; } if (!hasBindless) { for (int index = 0; index < block.OpCodes.Count; index++) { if (block.OpCodes[index] is OpCodeTextureBase texture) { config.TextureHandlesForCache.Add(texture.HandleOffset); } } } } } config.SizeAdd((int)maxEndAddress + (options.Flags.HasFlag(TranslationFlags.Compute) ? 0 : HeaderSize)); return(cfg); }
public static TranslatorContext CreateContext( ulong address, IGpuAccessor gpuAccessor, TranslationOptions options, TranslationCounts counts = null) { counts ??= new TranslationCounts(); return(DecodeShader(address, gpuAccessor, options, counts)); }
public ShaderConfig(IGpuAccessor gpuAccessor, TranslationOptions options, TranslationCounts counts) { Stage = ShaderStage.Compute; GpuAccessor = gpuAccessor; Options = options; _counts = counts; TextureHandlesForCache = new HashSet <int>(); _usedTextures = new Dictionary <TextureInfo, TextureMeta>(); _usedImages = new Dictionary <TextureInfo, TextureMeta>(); }
public static TranslatorContext CreateContext( ulong address, IGpuAccessor gpuAccessor, TranslationOptions options, TranslationCounts counts = null) { counts ??= new TranslationCounts(); Block[][] cfg = DecodeShader(address, gpuAccessor, options, counts, out ShaderConfig config); return(new TranslatorContext(address, cfg, config)); }
public ShaderConfig(ShaderHeader header, IGpuAccessor gpuAccessor, TranslationOptions options, TranslationCounts counts) : this(gpuAccessor, options, counts) { Stage = header.Stage; GpPassthrough = header.Stage == ShaderStage.Geometry && header.GpPassthrough; OutputTopology = header.OutputTopology; MaxOutputVertices = header.MaxOutputVertexCount; LocalMemorySize = header.ShaderLocalMemoryLowSize + header.ShaderLocalMemoryHighSize; ImapTypes = header.ImapTypes; OmapTargets = header.OmapTargets; OmapSampleMask = header.OmapSampleMask; OmapDepth = header.OmapDepth; }
public ShaderConfig(ShaderHeader header, IGpuAccessor gpuAccessor, TranslationOptions options, TranslationCounts counts) : this(gpuAccessor, options, counts) { Stage = header.Stage; GpPassthrough = header.Stage == ShaderStage.Geometry && header.GpPassthrough; ThreadsPerInputPrimitive = header.ThreadsPerInputPrimitive; OutputTopology = header.OutputTopology; MaxOutputVertices = header.MaxOutputVertexCount; LocalMemorySize = header.ShaderLocalMemoryLowSize + header.ShaderLocalMemoryHighSize; ImapTypes = header.ImapTypes; OmapTargets = header.OmapTargets; OmapSampleMask = header.OmapSampleMask; OmapDepth = header.OmapDepth; TransformFeedbackEnabled = gpuAccessor.QueryTransformFeedbackEnabled(); }
private static TranslatorContext DecodeShader(ulong address, IGpuAccessor gpuAccessor, TranslationOptions options, TranslationCounts counts) { ShaderConfig config; DecodedProgram program; ulong maxEndAddress = 0; if ((options.Flags & TranslationFlags.Compute) != 0) { config = new ShaderConfig(gpuAccessor, options, counts); program = Decoder.Decode(config, address); } else { config = new ShaderConfig(new ShaderHeader(gpuAccessor, address), gpuAccessor, options, counts); program = Decoder.Decode(config, address + HeaderSize); } foreach (DecodedFunction function in program) { foreach (Block block in function.Blocks) { if (maxEndAddress < block.EndAddress) { maxEndAddress = block.EndAddress; } if (!config.UsedFeatures.HasFlag(FeatureFlags.Bindless)) { for (int index = 0; index < block.OpCodes.Count; index++) { InstOp op = block.OpCodes[index]; if (op.Props.HasFlag(InstProps.Tex)) { int tidB = (int)((op.RawOpCode >> 36) & 0x1fff); config.TextureHandlesForCache.Add(tidB); } } } } } config.SizeAdd((int)maxEndAddress + (options.Flags.HasFlag(TranslationFlags.Compute) ? 0 : HeaderSize)); return(new TranslatorContext(address, program, config)); }
public static TranslatorContext CreateContext(ulong address, IGpuAccessor gpuAccessor, TranslationOptions options) { return(DecodeShader(address, gpuAccessor, options)); }