José Fonseca | 46a2db0 | 2011-04-28 08:48:20 +0100 | [diff] [blame] | 1 | /************************************************************************** |
| 2 | * |
| 3 | * Copyright 2011 Jose Fonseca |
| 4 | * Copyright 2008-2009 VMware, Inc. |
| 5 | * All Rights Reserved. |
| 6 | * |
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | * of this software and associated documentation files (the "Software"), to deal |
| 9 | * in the Software without restriction, including without limitation the rights |
| 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | * copies of the Software, and to permit persons to whom the Software is |
| 12 | * furnished to do so, subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice shall be included in |
| 15 | * all copies or substantial portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 23 | * THE SOFTWARE. |
| 24 | * |
| 25 | **************************************************************************/ |
| 26 | |
José Fonseca | 46a2db0 | 2011-04-28 08:48:20 +0100 | [diff] [blame] | 27 | |
| 28 | #include <stdio.h> |
| 29 | |
José Fonseca | 3b18682 | 2012-11-27 15:25:21 +0000 | [diff] [blame] | 30 | #include "os.hpp" |
| 31 | #include "d3dshader.hpp" |
| 32 | |
José Fonseca | 41a6d89 | 2012-05-13 11:41:08 +0100 | [diff] [blame] | 33 | #include "d3d9shader.hpp" |
José Fonseca | 4d5f12c | 2011-06-04 14:01:11 +0100 | [diff] [blame] | 34 | #include "d3d9imports.hpp" |
José Fonseca | 3dfd457 | 2012-11-03 16:58:34 +0000 | [diff] [blame] | 35 | #include "d3d9size.hpp" |
José Fonseca | 46a2db0 | 2011-04-28 08:48:20 +0100 | [diff] [blame] | 36 | |
| 37 | |
José Fonseca | b4a3d14 | 2011-10-27 07:43:19 +0100 | [diff] [blame] | 38 | void DumpShader(trace::Writer &writer, const DWORD *tokens) |
José Fonseca | 46a2db0 | 2011-04-28 08:48:20 +0100 | [diff] [blame] | 39 | { |
José Fonseca | 3b18682 | 2012-11-27 15:25:21 +0000 | [diff] [blame] | 40 | IDisassemblyBuffer *pDisassembly = NULL; |
| 41 | HRESULT hr = DisassembleShader(tokens, &pDisassembly); |
José Fonseca | 46a2db0 | 2011-04-28 08:48:20 +0100 | [diff] [blame] | 42 | |
José Fonseca | 446b6df | 2012-04-30 23:18:17 +0100 | [diff] [blame] | 43 | if (SUCCEEDED(hr)) { |
José Fonseca | 112a132 | 2012-04-27 17:15:32 +0100 | [diff] [blame] | 44 | writer.beginRepr(); |
José Fonseca | 3b18682 | 2012-11-27 15:25:21 +0000 | [diff] [blame] | 45 | writer.writeString((const char *)pDisassembly->GetBufferPointer(), |
| 46 | pDisassembly->GetBufferSize()); |
| 47 | pDisassembly->Release(); |
José Fonseca | 112a132 | 2012-04-27 17:15:32 +0100 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | writer.writeBlob(tokens, _shaderSize(tokens)); |
| 51 | |
José Fonseca | 446b6df | 2012-04-30 23:18:17 +0100 | [diff] [blame] | 52 | if (SUCCEEDED(hr)) { |
José Fonseca | 112a132 | 2012-04-27 17:15:32 +0100 | [diff] [blame] | 53 | writer.endRepr(); |
| 54 | } |
José Fonseca | 46a2db0 | 2011-04-28 08:48:20 +0100 | [diff] [blame] | 55 | } |