예제 #1
0
        private void showPixelShaderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SlimDX.Direct3D9.ShaderBytecode shader = null;
            try
            {
                shader = SlimDX.Direct3D9.ShaderBytecode.Compile(this.GetType().Assembly.GetResourceAsString("ModelViewer.pshader.psh"), "ps_main", "ps_3_0", SlimDX.Direct3D9.ShaderFlags.Debug);

                var data = shader.Disassemble(true);

                // Save data to temporary file
                var tempFileName = Path.GetTempFileName();
                using (FileStream fs = File.OpenWrite(tempFileName))
                {
                    data.CopyTo(fs);
                }

                var viewer = new ShaderViewer("pshader.psh", tempFileName);
                viewer.Show();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
                return;
            }
            finally
            {
                if (shader != null)
                {
                    shader.Dispose();
                }
            }
        }
예제 #2
0
 public string Disassemble()
 {
     SlimDX.Direct3D9.ShaderBytecode code = new SlimDX.Direct3D9.ShaderBytecode(RawData);
     SlimDX.DataStream s      = code.Disassemble();
     byte[]            buffer = new byte[s.Length];
     s.Read(buffer, 0, buffer.Length);
     return(ASCIIEncoding.ASCII.GetString(buffer));
 }
예제 #3
0
        private void btnDecompileShader_Click(object sender, EventArgs e)
        {
            var shaderFile = fileNavigator.SelectedNode.Tag as DatDigger.Sections.Shader.FileChunk;

            if (shaderFile == null)
            {
                return;
            }

            using (var shader = new SlimDX.Direct3D9.ShaderBytecode(shaderFile.CompiledShader))
            {
                var data = shader.Disassemble(true);

                // Save data to temporary file
                var tempFileName = Path.GetTempFileName();
                using (FileStream fs = File.OpenWrite(tempFileName))
                {
                    data.CopyTo(fs);
                }

                var viewer = new ShaderViewer(shaderFile.Name, tempFileName);
                viewer.Show();
            }
        }
예제 #4
0
        private void btnDecompileShader_Click(object sender, EventArgs e)
        {
            var shaderFile = fileNavigator.SelectedNode.Tag as DatDigger.Sections.Shader.FileChunk;
            if (shaderFile == null)
            {
                return;
            }

            using (var shader = new SlimDX.Direct3D9.ShaderBytecode(shaderFile.CompiledShader))
            {

                var data = shader.Disassemble(true);

                // Save data to temporary file
                var tempFileName = Path.GetTempFileName();
                using (FileStream fs = File.OpenWrite(tempFileName))
                {
                    data.CopyTo(fs);
                }

                var viewer = new ShaderViewer(shaderFile.Name, tempFileName);
                viewer.Show();
            }
        }