blob: 6dbe06bd737578aabafb440e6055e7d769bff64d [file] [log] [blame]
José Fonseca46a2db02011-04-28 08:48:20 +01001/**************************************************************************
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é Fonseca46a2db02011-04-28 08:48:20 +010027
28#include <stdio.h>
29
José Fonseca3b186822012-11-27 15:25:21 +000030#include "os.hpp"
31#include "d3dshader.hpp"
32
José Fonseca41a6d892012-05-13 11:41:08 +010033#include "d3d9shader.hpp"
José Fonseca4d5f12c2011-06-04 14:01:11 +010034#include "d3d9imports.hpp"
José Fonseca3dfd4572012-11-03 16:58:34 +000035#include "d3d9size.hpp"
José Fonseca46a2db02011-04-28 08:48:20 +010036
37
José Fonsecab4a3d142011-10-27 07:43:19 +010038void DumpShader(trace::Writer &writer, const DWORD *tokens)
José Fonseca46a2db02011-04-28 08:48:20 +010039{
José Fonseca3b186822012-11-27 15:25:21 +000040 IDisassemblyBuffer *pDisassembly = NULL;
41 HRESULT hr = DisassembleShader(tokens, &pDisassembly);
José Fonseca46a2db02011-04-28 08:48:20 +010042
José Fonseca446b6df2012-04-30 23:18:17 +010043 if (SUCCEEDED(hr)) {
José Fonseca112a1322012-04-27 17:15:32 +010044 writer.beginRepr();
José Fonseca3b186822012-11-27 15:25:21 +000045 writer.writeString((const char *)pDisassembly->GetBufferPointer(),
46 pDisassembly->GetBufferSize());
47 pDisassembly->Release();
José Fonseca112a1322012-04-27 17:15:32 +010048 }
49
50 writer.writeBlob(tokens, _shaderSize(tokens));
51
José Fonseca446b6df2012-04-30 23:18:17 +010052 if (SUCCEEDED(hr)) {
José Fonseca112a1322012-04-27 17:15:32 +010053 writer.endRepr();
54 }
José Fonseca46a2db02011-04-28 08:48:20 +010055}