Esempio n. 1
0
        private void ApplyChangesButton_Click(object sender, EventArgs e)
        {
            // Turn the text into the expected encoding.
            IDxcBlobEncoding sourceBlob = EditorForm.CreateBlobForText(this.Library, this.CodeBox.Text);

            sourceBlob = this.Library.GetBlobAstUf8(sourceBlob);
            IDxcBlob bitcodeBlob = sourceBlob;

            List <string> passes = new List <string>();

            passes.Add("hlsl-passes-resume");
            for (int i = PassesListBox.SelectedIndex; i < PassesListBox.Items.Count; ++i)
            {
                passes.Add(((TextSection)PassesListBox.Items[i]).Title);
            }
            string[] options = EditorForm.CreatePassOptions(passes, false, true);
            EditorForm.OptimizeResult opt = EditorForm.RunOptimize(this.Library, options, bitcodeBlob);
            if (!opt.Succeeded)
            {
                MessageBox.Show("Failed to optimize: " + opt.ResultText);
                return;
            }

            OptEditorForm form = new OptEditorForm();

            form.CodeFont        = this.CodeBox.Font;
            form.Library         = this.Library;
            form.HighLevelSource = this.HighLevelSource;
            form.Sections        = TextSection.EnumerateSections(new string[] { "MODULE-PRINT", "Phase:" }, opt.ResultText).ToArray();
            form.StartPosition   = FormStartPosition.CenterParent;
            form.Show(this);
        }
Esempio n. 2
0
        private void ApplyChangesButton_Click(object sender, EventArgs e)
        {
            // Turn the text into a container.
            IDxcBlobEncoding sourceBlob = EditorForm.CreateBlobForText(this.Library, this.CodeBox.Text);

            EditorForm.AssembleResult assembleResult = EditorForm.RunAssembly(this.Library, sourceBlob);
            if (assembleResult.Blob == null)
            {
                MessageBox.Show("Failed to assemble: " + assembleResult.ResultText);
                return;
            }

            // Extract the bitcode portion.
            const uint DxilKind = 0x4c495844; // 'LIXD' - DXIL
            uint       index;
            IDxcContainerReflection reflection = HlslDxcLib.CreateDxcContainerReflection();

            reflection.Load(assembleResult.Blob);
            reflection.FindFirstPartKind(DxilKind, out index);
            IDxcBlob bitcodeBlob = reflection.GetPartContent(index);

            List <string> passes = new List <string>();

            passes.Add("hlsl-passes-resume");
            for (int i = PassesListBox.SelectedIndex; i < PassesListBox.Items.Count; ++i)
            {
                passes.Add(((TextSection)PassesListBox.Items[i]).Title);
            }
            string[] options = EditorForm.CreatePassOptions(passes, false, true);
            EditorForm.OptimizeResult opt = EditorForm.RunOptimize(this.Library, options, bitcodeBlob);
            if (!opt.Succeeded)
            {
                MessageBox.Show("Failed to optimize: " + opt.ResultText);
                return;
            }

            OptEditorForm form = new OptEditorForm();

            form.CodeFont        = this.CodeBox.Font;
            form.Library         = this.Library;
            form.HighLevelSource = this.HighLevelSource;
            form.Sections        = TextSection.EnumerateSections(new string[] { "MODULE-PRINT", "Phase:" }, opt.ResultText).ToArray();
            form.StartPosition   = FormStartPosition.CenterParent;
            form.Show(this);
        }