2 * Copyright (C) 2008-2009 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 * Richard Li <RichardZ.Li@amd.com>, <richardradeon@gmail.com>
29 #include "main/glheader.h"
30 #include "main/imports.h"
32 #include "shader/program.h"
35 #include "r600_context.h"
36 #include "r600_emit.h"
38 #include "r700_oglprog.h"
39 #include "r700_fragprog.h"
40 #include "r700_vertprog.h"
43 static struct gl_program
*r700NewProgram(GLcontext
* ctx
,
47 struct gl_program
*pProgram
= NULL
;
49 struct r700_vertex_program
*vp
;
50 struct r700_fragment_program
*fp
;
52 radeon_print(RADEON_SHADER
, RADEON_VERBOSE
,
53 "%s %u, %u\n", __func__
, target
, id
);
57 case GL_VERTEX_STATE_PROGRAM_NV
:
58 case GL_VERTEX_PROGRAM_ARB
:
59 vp
= CALLOC_STRUCT(r700_vertex_program
);
60 pProgram
= _mesa_init_vertex_program(ctx
,
64 vp
->translated
= GL_FALSE
;
65 vp
->loaded
= GL_FALSE
;
70 case GL_FRAGMENT_PROGRAM_NV
:
71 case GL_FRAGMENT_PROGRAM_ARB
:
72 fp
= CALLOC_STRUCT(r700_fragment_program
);
73 pProgram
= _mesa_init_fragment_program(ctx
,
77 fp
->translated
= GL_FALSE
;
78 fp
->loaded
= GL_FALSE
;
84 _mesa_problem(ctx
, "Bad target in r700NewProgram");
90 static void r700DeleteProgram(GLcontext
* ctx
, struct gl_program
*prog
)
92 struct r700_vertex_program
* vp
;
93 struct r700_fragment_program
* fp
;
95 radeon_print(RADEON_SHADER
, RADEON_VERBOSE
,
96 "%s %p\n", __func__
, prog
);
100 case GL_VERTEX_STATE_PROGRAM_NV
:
101 case GL_VERTEX_PROGRAM_ARB
:
102 vp
= (struct r700_vertex_program
*)prog
;
103 /* Release DMA region */
105 r600DeleteShader(ctx
, vp
->shaderbo
);
108 Clean_Up_Assembler(&(vp
->r700AsmCode
));
109 Clean_Up_Shader(&(vp
->r700Shader
));
111 case GL_FRAGMENT_PROGRAM_NV
:
112 case GL_FRAGMENT_PROGRAM_ARB
:
113 fp
= (struct r700_fragment_program
*)prog
;
114 /* Release DMA region */
116 r600DeleteShader(ctx
, fp
->shaderbo
);
119 Clean_Up_Assembler(&(fp
->r700AsmCode
));
120 Clean_Up_Shader(&(fp
->r700Shader
));
123 _mesa_problem(ctx
, "Bad target in r700NewProgram");
126 _mesa_delete_program(ctx
, prog
);
130 r700ProgramStringNotify(GLcontext
* ctx
, GLenum target
, struct gl_program
*prog
)
135 static GLboolean
r700IsProgramNative(GLcontext
* ctx
, GLenum target
, struct gl_program
*prog
)
141 void r700InitShaderFuncs(struct dd_function_table
*functions
)
143 functions
->NewProgram
= r700NewProgram
;
144 functions
->DeleteProgram
= r700DeleteProgram
;
145 functions
->ProgramStringNotify
= r700ProgramStringNotify
;
146 functions
->IsProgramNative
= r700IsProgramNative
;